X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famtrmidx.c;h=6e20da187e4138c5d304e460feaf6e98aae0bc32;hb=c16b04cb8ba646250049afa94e22e7a800b94e7d;hp=f5be82679e0cee99acbb0f1e1d301e6f624c25d3;hpb=e442edb4d5816c4ad107ad9e71164f845eba70ad;p=debian%2Famanda diff --git a/server-src/amtrmidx.c b/server-src/amtrmidx.c index f5be826..6e20da1 100644 --- a/server-src/amtrmidx.c +++ b/server-src/amtrmidx.c @@ -37,7 +37,6 @@ #include "diskfile.h" #include "tapefile.h" #include "find.h" -#include "version.h" #include "util.h" static int sort_by_name_reversed(const void *a, const void *b); @@ -69,7 +68,7 @@ main( find_result_t *output_find; time_t tmp_time; int amtrmidx_debug = 0; - config_overwrites_t *cfg_ovr = NULL; + config_overrides_t *cfg_ovr = NULL; /* * Configure program for internationalization: @@ -89,14 +88,14 @@ main( signal(SIGPIPE, SIG_IGN); dbopen(DBG_SUBDIR_SERVER); - dbprintf(_("%s: version %s\n"), argv[0], version()); + dbprintf(_("%s: version %s\n"), argv[0], VERSION); - cfg_ovr = extract_commandline_config_overwrites(&argc, &argv); + cfg_ovr = extract_commandline_config_overrides(&argc, &argv); - if (my_argc > 1 && strcmp(my_argv[1], "-t") == 0) { + if (argc > 1 && strcmp(argv[1], "-t") == 0) { amtrmidx_debug = 1; - my_argc--; - my_argv++; + argc--; + argv++; } if (argc < 2) { @@ -104,21 +103,24 @@ main( return 1; } - config_init(CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_FATAL | CONFIG_INIT_USE_CWD, - argv[1]); - apply_config_overwrites(cfg_ovr); - - check_running_as(RUNNING_AS_DUMPUSER); - - dbrename(config_name, DBG_SUBDIR_SERVER); + set_config_overrides(cfg_ovr); + config_init(CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_USE_CWD, argv[1]); conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE)); - if (read_diskfile(conf_diskfile, &diskl) < 0) { - error(_("could not load disklist \"%s\""), conf_diskfile); - /*NOTREACHED*/ - } + read_diskfile(conf_diskfile, &diskl); amfree(conf_diskfile); + if (config_errors(NULL) >= CFGERR_WARNINGS) { + config_print_errors(); + if (config_errors(NULL) >= CFGERR_ERRORS) { + g_critical(_("errors processing config file")); + } + } + + check_running_as(RUNNING_AS_DUMPUSER); + + dbrename(get_config_name(), DBG_SUBDIR_SERVER); + conf_tapelist = config_dir_relative(getconf_str(CNF_TAPELIST)); if(read_tapelist(conf_tapelist)) { error(_("could not load tapelist \"%s\""), conf_tapelist); @@ -146,7 +148,8 @@ main( char *host; char *disk, *qdisk; size_t len_date; - + disk_t *dp; + GSList *matching_dp = NULL; /* get listing of indices, newest first */ host = sanitise_filename(diskp->host->hostname); @@ -158,6 +161,20 @@ main( NULL); qindexdir = quote_string(indexdir); + /* find all dles that use the same indexdir */ + for (dp = diskl.head; dp != NULL; dp = dp->next) { + char *dp_host, *dp_disk; + + dp_host = sanitise_filename(dp->host->hostname); + dp_disk = sanitise_filename(dp->name); + if (strcmp(host, dp_host) == 0 && + strcmp(disk, dp_disk) == 0) { + matching_dp = g_slist_append(matching_dp, dp); + } + amfree(dp_host); + amfree(dp_disk); + } + dbprintf("%s %s -> %s\n", diskp->host->hostname, qdisk, qindexdir); amfree(host); @@ -237,6 +254,8 @@ main( char *datestamp; int level; size_t len_date; + int matching = 0; + GSList *mdp; for(len_date = 0; len_date < SIZEOF("YYYYMMDDHHMMSS")-1; len_date++) { if(! isdigit((int)(names[i][len_date]))) { @@ -246,9 +265,16 @@ main( datestamp = stralloc(names[i]); datestamp[len_date] = '\0'; - level = names[i][len_date+1] - '0'; - if(!dump_exist(output_find, diskp->host->hostname, - diskp->name, datestamp, level)) { + if (sscanf(&names[i][len_date+1], "%d", &level) != 1) + level = 0; + for (mdp = matching_dp; mdp != NULL; mdp = mdp->next) { + dp = mdp->data; + if (dump_exist(output_find, dp->host->hostname, + dp->name, datestamp, level)) { + matching = 1; + } + } + if (!matching) { char *path, *qpath; path = stralloc2(indexdir, names[i]); qpath = quote_string(path);