-
-void
-check_holdingdisk(
- char * diskdir,
- char * datestamp)
-{
- DIR *workdir;
- struct dirent *entry;
- char *dirname = NULL;
- char *tmpname = NULL;
- char *destname = NULL;
- char *hostname = NULL;
- char *diskname = NULL;
- disk_t *dp;
- filetype_t filetype;
- info_t info;
- int level;
- size_t dl, l;
-
- dirname = vstralloc(diskdir, "/", datestamp, NULL);
- dl = strlen(dirname);
-
- if((workdir = opendir(dirname)) == NULL) {
- amfree(dirname);
- return;
- }
-
- while((entry = readdir(workdir)) != NULL) {
- if(is_dot_or_dotdot(entry->d_name)) {
- continue;
- }
-
- if((l = strlen(entry->d_name)) < 7 ) {
- continue;
- }
-
- if(strncmp(&entry->d_name[l-4],".tmp",4) != 0) {
- continue;
- }
-
- tmpname = newvstralloc(tmpname,
- dirname, "/", entry->d_name,
- NULL);
-
- destname = newstralloc(destname, tmpname);
- destname[dl + 1 + l - 4] = '\0';
-
- amfree(hostname);
- amfree(diskname);
- filetype = get_amanda_names(tmpname, &hostname, &diskname, &level);
- amfree(tmpname);
- if(filetype != F_DUMPFILE) {
- continue;
- }
-
- dp = lookup_disk(hostname, diskname);
-
- if (dp == NULL) {
- continue;
- }
-
- if(level < 0 || level > 9) {
- continue;
- }
-
- if(rename_tmp_holding(destname, 0)) {
- get_info(dp->host->hostname, dp->name, &info);
- info.command &= ~FORCE_BUMP;
- info.command |= FORCE_NO_BUMP;
- if(put_info(dp->host->hostname, dp->name, &info)) {
- error("could not put info record for %s:%s: %s",
- dp->host->hostname, dp->name, strerror(errno));
- /*NOTREACHED*/
- }
- } else {
- fprintf(stderr,"rename_tmp_holding(%s) failed\n", destname);
- }
- }
- closedir(workdir);
-
- /* try to zap the potentially empty working dir */
- /* ignore any errors -- it either works or it doesn't */
- (void) rmdir(dirname);
-
- amfree(diskname);
- amfree(hostname);
- amfree(destname);
- amfree(dirname);
-}
-
-
-void
-check_disks(void)
-{
- holdingdisk_t *hdisk;
- sle_t *dir;
-
- for(dir = holding_list->first; dir !=NULL; dir = dir->next) {
- for(hdisk = getconf_holdingdisks(); hdisk != NULL; hdisk = hdisk->next)
- check_holdingdisk(holdingdisk_get_diskdir(hdisk), dir->name);
- }
-}