- filename = stralloc(holding_file);
- while(filename != NULL && filename[0] != '\0') {
- if((fd = open(filename,O_RDONLY)) == -1) {
- fprintf(stderr,"unlink_holding_files: open of %s failed: %s\n",filename,strerror(errno));
- amfree(filename);
- return 0;
- }
- if ((buflen = fullread(fd, buffer, sizeof(buffer))) > 0) {
- parse_file_header(buffer, &file, buflen);
- }
- close(fd);
- unlink(filename);
- if(buflen > 0) {
- filename = newstralloc(filename, file.cont_filename);
- }
- else {
- amfree(filename);
+ if (is_cruft) {
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("Invalid holding file '%s'\n"), element);
+ return 0;
+ }
+
+
+ stat = holding_file_get_dumpfile(fqpath, &file);
+
+ if (!stat) {
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("Could not read read header from '%s'\n"), element);
+ return 0;
+ }
+
+ if (file.type != F_DUMPFILE && file.type != F_CONT_DUMPFILE) {
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("File '%s' is not a dump file\n"), element);
+ return 0;
+ }
+
+ if(file.dumplevel < 0 || file.dumplevel > 9) {
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("File '%s' has invalid level %d\n"), element, file.dumplevel);
+ return 0;
+ }
+
+ dp = lookup_disk(file.name, file.disk);
+
+ if (dp == NULL) {
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("File '%s' is for '%s:%s', which is not in the disklist\n"),
+ element, file.name, file.disk);
+ return 0;
+ }
+
+ if ((l = strlen(element)) >= 7 && strncmp(&fqpath[l-4],".tmp",4) == 0) {
+ char *destname;
+
+ /* generate a name without '.tmp' */
+ destname = stralloc(fqpath);
+ destname[strlen(destname) - 4] = '\0';
+
+ /* OK, it passes muster -- rename it to salvage some data,
+ * and mark the DLE as corrupted */
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("Processing partial holding file '%s'\n"), element);
+
+ if(rename_tmp_holding(destname, 0)) {
+ if (data->corrupt_dle)
+ data->corrupt_dle(dp->host->hostname, dp->name);
+ } else {
+ dbprintf(_("rename_tmp_holding(%s) failed\n"), destname);
+ if (data->verbose_output)
+ g_fprintf(data->verbose_output,
+ _("Rename of '%s' to '%s' failed.\n"), element, destname);