update changelog for new upstream release
[debian/amanda] / server-src / amcleanupdisk.c
index a67154cbbf5657db027e1334de3f62e2558b2e15..2ba6fb0d82b8f1181261416d7b6c302fc4b0b1dc 100644 (file)
 #include "conffile.h"
 #include "diskfile.h"
 #include "clock.h"
-#include "version.h"
 #include "holding.h"
 #include "infofile.h"
 #include "server_util.h"
 
 /* Utility funcitons */
 
-/* Call open_diskfile() with the diskfile from the configuration
- */
-static void
-init_diskfile(void)
-{
-    char *conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
-    disklist_t diskq; /* never used, but required by read_diskfile */
-
-    if (read_diskfile(conf_diskfile, &diskq) < 0) {
-       error(_("could not load disklist %s"), conf_diskfile);
-       /*NOTREACHED*/
-    }
-    amfree(conf_diskfile);
-}
-
 /* Call open_infofile() with the infofile from the configuration
  */
 static void
@@ -83,8 +67,8 @@ corrupt_dle(
        hostname, disk);
 
     get_info(hostname, disk, &info);
-    info.command &= ~FORCE_BUMP;
-    info.command |= FORCE_NO_BUMP;
+    CLR(info.command, FORCE_BUMP);
+    SET(info.command, FORCE_NO_BUMP);
     if(put_info(hostname, disk, &info)) {
        dbprintf(_("could not put info record for %s:%s: %s"),
              hostname, disk, strerror(errno));
@@ -98,6 +82,8 @@ main(
 {
     FILE *verbose_output = NULL;
     char *cfg_opt = NULL;
+    char *conf_diskfile;
+    disklist_t diskq;
 
     /*
      * Configure program for internationalization:
@@ -116,7 +102,7 @@ main(
     dbopen(DBG_SUBDIR_SERVER);
 
     if(argc < 2) {
-       error(_("Usage: amcleanupdisk%s <config>"), versionsuffix());
+       error(_("Usage: amcleanupdisk <config>"));
        /*NOTREACHED*/
     }
 
@@ -128,14 +114,25 @@ main(
        cfg_opt = argv[1];
     }
 
-    config_init(CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_FATAL,
+    config_init(CONFIG_INIT_EXPLICIT_NAME,
                cfg_opt);
 
+    conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
+    read_diskfile(conf_diskfile, &diskq);
+    /* diskq also ends up in a global, used by holding_cleanup */
+    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(config_name, DBG_SUBDIR_SERVER);
+    dbrename(get_config_name(), DBG_SUBDIR_SERVER);
 
-    init_diskfile();
     init_infofile();
 
     /* actually perform the cleanup */