]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/bls.c
Use rentrant mysql lib, eliminate race in sql_list, Win32 streams, misc see kes-1.31
[bacula/bacula] / bacula / src / stored / bls.c
index 231fae8315d9d752253283f7752e25f5f5e47291..e0c8cfa9293798f22370cc0c5af36519abe505ff 100644 (file)
@@ -5,7 +5,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -39,7 +39,6 @@ static DEVICE *dev;
 static int dump_label = FALSE;
 static int list_blocks = FALSE;
 static int list_jobs = FALSE;
-static int verbose = 0;
 static DEV_RECORD *rec;
 static DEV_BLOCK *block;
 static JCR *jcr;
@@ -58,7 +57,7 @@ static BSR *bsr = NULL;
 static void usage()
 {
    fprintf(stderr,
-"\nVersion: " VERSION " (" DATE ")\n\n"
+"\nVersion: " VERSION " (" BDATE ")\n\n"
 "Usage: bls [-d debug_level] <physical-device-name>\n"
 "       -b <file>       specify a bootstrap file\n"
 "       -c <file>       specify a config file\n"
@@ -67,9 +66,9 @@ static void usage()
 "       -i <file>       include list\n"
 "       -j              list jobs\n"
 "       -k              list blocks\n"
-"       -L              list tape label\n"
 "    (none of above)    list saved files\n"
 "       -v              be verbose\n"
+"       -V              specify Volume names (separated by |)\n"
 "       -?              print this message\n\n");
    exit(1);
 }
@@ -80,6 +79,8 @@ int main (int argc, char *argv[])
    int i, ch;
    FILE *fd;
    char line[1000];
+   char *VolumeName= NULL;
+   char *bsrName = NULL;
 
    working_directory = "/tmp";
    my_name_is(argc, argv, "bls");
@@ -88,11 +89,10 @@ int main (int argc, char *argv[])
    memset(&ff, 0, sizeof(ff));
    init_include_exclude_files(&ff);
 
-   while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLtv?")) != -1) {
+   while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLtvV:?")) != -1) {
       switch (ch) {
          case 'b':
-           bsr = parse_bsr(NULL, optarg);
-//         dump_bsr(bsr);
+           bsrName = optarg;
            break;
 
          case 'c':                    /* specify config file */
@@ -110,7 +110,7 @@ int main (int argc, char *argv[])
 
          case 'e':                    /* exclude list */
             if ((fd = fopen(optarg, "r")) == NULL) {
-               Pmsg2(0, "Could not open exclude file: %s, ERR=%s\n",
+               Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
                  optarg, strerror(errno));
               exit(1);
            }
@@ -152,6 +152,10 @@ int main (int argc, char *argv[])
            verbose++;
            break;
 
+         case 'V':                    /* Volume name */
+           VolumeName = optarg;
+           break;
+
          case '?':
         default:
            usage();
@@ -162,7 +166,7 @@ int main (int argc, char *argv[])
    argv += optind;
 
    if (!argc) {
-      Pmsg0(0, "No archive name specified\n");
+      Pmsg0(0, _("No archive name specified\n"));
       usage();
    }
 
@@ -172,13 +176,15 @@ int main (int argc, char *argv[])
 
    parse_config(configfile);
 
-
    if (ff.included_files_list == NULL) {
       add_fname_to_include_list(&ff, 0, "/");
    }
 
    for (i=0; i < argc; i++) {
-      jcr = setup_jcr("bls", argv[i], bsr);
+      if (bsrName) {
+        bsr = parse_bsr(NULL, bsrName);
+      }
+      jcr = setup_jcr("bls", argv[i], bsr, VolumeName);
       dev = setup_to_access_device(jcr, 1);   /* acquire for read */
       if (!dev) {
         exit(1);
@@ -301,7 +307,6 @@ static void do_ls(char *infname)
       dump_volume_label(dev);
       return;
    }
-
    read_records(jcr, dev, record_cb, mount_next_read_volume);
    printf("%u files found.\n", num_files);
 }
@@ -322,6 +327,8 @@ static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
    /* File Attributes stream */
    if (rec->Stream == STREAM_UNIX_ATTRIBUTES || rec->Stream == STREAM_WIN32_ATTRIBUTES) {
       char *ap, *fp;
+      uint32_t LinkFI;
+
       sscanf(rec->data, "%ld %d", &record_file_index, &type);
       if (record_file_index != rec->FileIndex) {
          Emsg2(M_ERROR_TERM, 0, "Record header file index %ld not equal record index %ld\n",
@@ -340,7 +347,7 @@ static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
       }
       *fp = *ap++;                /* terminate filename & point to attribs */
 
-      decode_stat(ap, &statp);
+      decode_stat(ap, &statp, &LinkFI);
       /* Skip to link name */  
       while (*ap++ != 0)
         ;