X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=restore-src%2Famfetchdump.c;h=e0764d79d22b6b162a3e0cd131b15dfc5f811b9e;hb=f86ca883daf8a5123c8cac43bfd76d514c5b1c82;hp=927149da4e94b6f93adbfcbb88784147926a6f32;hpb=afaa71b3866b46b082b6c895772e15b36d8865fe;p=debian%2Famanda diff --git a/restore-src/amfetchdump.c b/restore-src/amfetchdump.c index 927149d..e0764d7 100644 --- a/restore-src/amfetchdump.c +++ b/restore-src/amfetchdump.c @@ -51,6 +51,11 @@ typedef struct needed_tapes_s { 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 */ @@ -102,7 +107,12 @@ sort_needed_tapes_by_write_timestamp( 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; } /* @@ -123,6 +133,7 @@ list_needed_tapes( 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 */ @@ -142,11 +153,18 @@ list_needed_tapes( /* 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 && @@ -154,7 +172,6 @@ list_needed_tapes( 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)){ @@ -162,7 +179,6 @@ list_needed_tapes( curmatch->timestamp, curmatch->hostname, curmatch->diskname, curmatch->level, curmatch->status); - g_fprintf(stderr, "!OK\n"); continue; } @@ -194,6 +210,7 @@ list_needed_tapes( } 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;