]> git.sur5r.net Git - bacula/bacula/commitdiff
Update doc, default working directory bscan
authorKern Sibbald <kern@sibbald.com>
Sat, 28 Dec 2002 15:28:57 +0000 (15:28 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 28 Dec 2002 15:28:57 +0000 (15:28 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@250 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/bscan.c
bacula/src/stored/butil.c
bacula/src/stored/stored.c
bacula/src/version.h

index bcf9f223fb269ad3380e9c653836ad4853eba892..8f3fe3185a8ea96c752f458a45baf52d27dd1be8 100644 (file)
@@ -54,6 +54,7 @@ static int update_MD5_record(B_DB *db, char *MD5buf, DEV_RECORD *rec);
 
 
 /* Global variables */
+static STORES *me;
 static DEVICE *dev = NULL;
 static B_DB *db;
 static JCR *bjcr;                    /* jcr for bscan */
@@ -79,7 +80,7 @@ static time_t lasttime = 0;
 static char *db_name = "bacula";
 static char *db_user = "bacula";
 static char *db_password = "";
-static char *wd = "/tmp";
+static char *wd = NULL;
 static int verbose = 0;
 static int update_db = 0;
 static int update_vol_info = 0;
@@ -90,6 +91,7 @@ static int ignored_msgs = 0;
 char *configfile;
 
 
+
 static void usage()
 {
    fprintf(stderr, _(
@@ -105,7 +107,7 @@ static void usage()
 "       -r                list records\n"
 "       -s                synchronize or store in database\n"
 "       -v                verbose\n"
-"       -w dir            specify working directory (default /tmp)\n"
+"       -w dir            specify working directory (default from conf file)\n"
 "       -?                print this message\n\n"));
    exit(1);
 }
@@ -113,6 +115,7 @@ static void usage()
 int main (int argc, char *argv[])
 {
    int ch;
+   struct stat stat_buf;
 
    my_name_is(argc, argv, "bscan");
    init_msg(NULL, NULL);
@@ -183,13 +186,38 @@ int main (int argc, char *argv[])
       usage();
    }
 
-   working_directory = wd;
-
    if (configfile == NULL) {
       configfile = bstrdup(CONFIG_FILE);
    }
 
    parse_config(configfile);
+   LockRes();
+   me = (STORES *)GetNextRes(R_STORAGE, NULL);
+   if (!me) {
+      UnlockRes();
+      Emsg1(M_ERROR_TERM, 0, _("No Storage resource defined in %s. Cannot continue.\n"), 
+        configfile);
+   }
+   UnlockRes();
+   /* Check if -w option given, otherwise use resource for working directory */
+   if (wd) { 
+      working_directory = wd;
+   } else if (!me->working_directory) {
+      Emsg1(M_ERROR_TERM, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
+        configfile);
+   } else {
+      working_directory = me->working_directory;
+   }
+
+   /* Check that working directory is good */
+   if (stat(working_directory, &stat_buf) != 0) {
+      Emsg1(M_ERROR_TERM, 0, _("Working Directory: %s not found. Cannot continue.\n"),
+        working_directory);
+   }
+   if (!S_ISDIR(stat_buf.st_mode)) {
+      Emsg1(M_ERROR_TERM, 0, _("Working Directory: %s is not a directory. Cannot continue.\n"),
+        working_directory);
+   }
 
    bjcr = setup_jcr("bscan", argv[0], bsr);
    dev = setup_to_access_device(bjcr, 1);   /* read device */
index 5b114b1f7ceb9904763dc61b7d3d085315f2304e..40389710b58c485b4d9c97c5cadc6529cc8b115b 100644 (file)
@@ -88,14 +88,14 @@ DEVICE *setup_to_access_device(JCR *jcr, int read_access)
    }
 
    if ((device=find_device_res(jcr->dev_name, read_access)) == NULL) {
-      Emsg2(M_FATAL, 0, _("Cannot find device %s in config file %s.\n"), 
+      Jmsg2(jcr, M_FATAL, 0, _("Cannot find device %s in config file %s.\n"), 
           jcr->dev_name, configfile);
       return NULL;
    }
    
    dev = init_dev(NULL, device);
    if (!dev || !open_device(dev)) {
-      Emsg1(M_FATAL, 0, _("Cannot open %s\n"), jcr->dev_name);
+      Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), jcr->dev_name);
       return NULL;
    }
    Dmsg0(90, "Device opened for read.\n");
@@ -106,7 +106,6 @@ DEVICE *setup_to_access_device(JCR *jcr, int read_access)
 
    if (read_access) {
       if (!acquire_device_for_read(jcr, dev, block)) {
-        Emsg0(M_ERROR, 0, dev->errmsg);
         free_block(block);
         return NULL;
       }
index ebe8cf2419cd6708d0762719d2ec2cc485bab67d..35d50f4a8ab35f248fc357a6753f24334ab7e0de 100644 (file)
@@ -226,7 +226,7 @@ static void check_config()
    me = (STORES *)GetNextRes(R_STORAGE, NULL);
    if (!me) {
       UnlockRes();
-      Emsg1(M_ABORT, 0, _("No Storage resource defined in %s. Cannot continue.\n"),
+      Emsg1(M_ERROR_TERM, 0, _("No Storage resource defined in %s. Cannot continue.\n"),
         configfile);
    }
 
@@ -234,23 +234,23 @@ static void check_config()
 
    if (GetNextRes(R_STORAGE, (RES *)me) != NULL) {
       UnlockRes();
-      Emsg1(M_ABORT, 0, _("Only one Storage resource permitted in %s\n"), 
+      Emsg1(M_ERROR_TERM, 0, _("Only one Storage resource permitted in %s\n"), 
         configfile);
    }
    if (GetNextRes(R_DIRECTOR, NULL) == NULL) {
       UnlockRes();
-      Emsg1(M_ABORT, 0, _("No Director resource defined in %s. Cannot continue.\n"),
+      Emsg1(M_ERROR_TERM, 0, _("No Director resource defined in %s. Cannot continue.\n"),
         configfile);
    }
    if (GetNextRes(R_DEVICE, NULL) == NULL){
       UnlockRes();
-      Emsg1(M_ABORT, 0, _("No Device resource defined in %s. Cannot continue.\n"),
+      Emsg1(M_ERROR_TERM, 0, _("No Device resource defined in %s. Cannot continue.\n"),
           configfile);
    }
    if (!me->messages) {
       me->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
       if (!me->messages) {
-         Emsg1(M_ABORT, 0, _("No Messages resource defined in %s. Cannot continue.\n"),
+         Emsg1(M_ERROR_TERM, 0, _("No Messages resource defined in %s. Cannot continue.\n"),
            configfile);
       }
    }
@@ -260,15 +260,15 @@ static void check_config()
    UnlockRes();
 
    if (!me->working_directory) {
-      Emsg1(M_ABORT, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
+      Emsg1(M_ERROR_TERM, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
         configfile);
    }
    if (stat(me->working_directory, &stat_buf) != 0) {
-      Emsg1(M_ABORT, 0, _("Working Directory: %s not found. Cannot continue.\n"),
+      Emsg1(M_ERROR_TERM, 0, _("Working Directory: %s not found. Cannot continue.\n"),
         me->working_directory);
    }
    if (!S_ISDIR(stat_buf.st_mode)) {
-      Emsg1(M_ABORT, 0, _("Working Directory: %s is not a directory. Cannot continue.\n"),
+      Emsg1(M_ERROR_TERM, 0, _("Working Directory: %s is not a directory. Cannot continue.\n"),
         me->working_directory);
    }
    working_directory = me->working_directory;
index 95dbcaf5d10fbb4e878125ca9badf2e374fbe928..fe6ffcf8237cea645a91720facb2028ff550588d 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.28"
 #define VSTRING "1"
-#define DATE    "25 December 2002"
-#define LSMDATE "25Dec02"
+#define DATE    "28 December 2002"
+#define LSMDATE "28Dec02"
 
 /* Debug flags */
 #define DEBUG 1