char *label;
int isafile;
GSList *files;
+
+ /* usage_order helps to determine the order in which multiple tapes were
+ * used in a single run; it is set as the tapes are added, as sorted by
+ * dumpfile part number */
+ int usage_order;
} needed_tape_t;
/* local functions */
char *a_ds = a_t? a_t->datestamp : "none";
char *b_ds = b_t? b_t->datestamp : "none";
- return strcmp(a_ds, b_ds);
+ /* if the tape timestamps match, sort them by usage_order, which is derived
+ * from the order the tapes were written in a single run */
+ int r = strcmp(a_ds, b_ds);
+ if (r != 0)
+ return r;
+ return (a_nt->usage_order > b_nt->usage_order)? 1 : -1;
}
/*
find_result_t *curmatch = NULL;
find_result_t *matches = NULL;
tapelist_t *tapes = NULL;
+ int usage_order_counter = 0;
char *conf_tapelist;
/* Load the tape list */
/* Compare all known dumps to our match list, note what we'll need */
matches = dumps_match_dumpspecs(alldumps, dumpspecs, 1);
+
+ /* D = dump_timestamp, newest first
+ * h = hostname
+ * k = diskname
+ * l = level
+ * p = partnum
+ * w = write_timestamp */
sort_find_result("Dhklpw", &matches);
+
for(curmatch = matches; curmatch; curmatch = curmatch->next) {
int havetape = 0;
- g_fprintf(stderr, "Examining %s %s on %s\n", curmatch->hostname, curmatch->diskname, curmatch->label);
/* keep only first dump if only_one */
if (only_one &&
curmatch != matches &&
strcmp(curmatch->diskname, matches->diskname) ||
strcmp(curmatch->timestamp, matches->timestamp) ||
curmatch->level != matches->level)) {
- g_fprintf(stderr, "only_one matched\n");
continue;
}
if(strcmp("OK", curmatch->status)){
curmatch->timestamp, curmatch->hostname,
curmatch->diskname, curmatch->level,
curmatch->status);
- g_fprintf(stderr, "!OK\n");
continue;
}
}
if (!havetape) {
needed_tape_t *newtape = g_new0(needed_tape_t, 1);
+ newtape->usage_order = usage_order_counter++;
newtape->files = g_slist_prepend(newtape->files, curmatch);
newtape->isafile = (curmatch->filenum < 1);
newtape->label = curmatch->label;