]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/stored/bls.c
authorAlain Spineux <alain@baculasystems.com>
Tue, 12 May 2020 16:40:28 +0000 (18:40 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:18 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Dec 16 17:31:23 2016 +0100

    Enhance bls -D/-F help message

bacula/src/stored/bls.c

index 1f228f583af291d22ed24b9e59f8255b851dea80..8a97008fae4f4c8e440967c7db8297b79a7d3202 100644 (file)
  *  Dumb program to do an "ls" of a Bacula 1.0 mortal file.
  *
  *  Kern Sibbald, MM
+ *
  */
 
 #include "bacula.h"
 #include "stored.h"
+#include "dedupstored.h"
 #include "findlib/find.h"
 #include "lib/cmd_parser.h"
 
@@ -49,6 +51,9 @@ static uint32_t num_files = 0;
 static ATTR *attr;
 static CONFIG *config;
 
+static bool filter = false;                  /* any filter set ? */
+static bool dedup = false;                   /* decode dedup reference */
+
 void *start_heap;
 #define CONFIG_FILE "bacula-sd.conf"
 char *configfile = NULL;
@@ -59,6 +64,11 @@ static FF_PKT *ff;
 
 static BSR *bsr = NULL;
 
+#ifdef COMMUNITY
+bool dedup_parse_filter(char *fltr) { return false; }
+void dedup_filter_record(int verbose, DCR *dcr, DEV_RECORD *rec, char *dedup_msg, int len) {}
+#endif
+
 static void usage()
 {
    fprintf(stderr, _(
@@ -79,7 +89,9 @@ PROG_COPYRIGHT
 "     -V                 specify Volume names (separated by |)\n"
 "     -E                 Check records to detect errors\n"
 "     -v                 be verbose\n"
-"     -?                 print this message\n\n"), 2000, "", VERSION, BDATE);
+"     -D                 Display dedup reference (to use with -v)\n"
+"     -F <key=value,>    Filter regarding some key, value (to use with -D)\n"
+"     -?                 print this message\n\n"), 2000, BDEMO, VERSION, BDATE);
    exit(1);
 }
 
@@ -200,6 +212,18 @@ int main (int argc, char *argv[])
          VolumeName = optarg;
          break;
 
+      case 'D':
+         dedup = true;
+         break;
+
+      case 'F':
+         filter = true;
+         if (!dedup_parse_filter(optarg)) {
+            Pmsg1(0, _("Error parsing filter: %s\n"), optarg);
+            exit(1);
+         }
+         break;
+
       case '?':
       default:
          usage();
@@ -283,7 +307,6 @@ static void do_close(JCR *jcr)
    dev->term(NULL);
 }
 
-
 /* List just block information */
 static void do_blocks(char *infname)
 {
@@ -384,17 +407,19 @@ static void do_ls(char *infname)
    printf("%u files found.\n", num_files);
 }
 
-
 /*
  * Called here for each record from read_records()
  */
 static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 {
+   char dedup_msg[200];
    if (verbose && rec->FileIndex < 0) {
       dump_label_record(dcr->dev, rec, verbose, false);
       return true;
    }
 
+   dedup_filter_record(verbose, dcr, rec, dedup_msg, sizeof(dedup_msg));
+
    /* File Attributes stream */
    if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES ||
        rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) {
@@ -413,8 +438,8 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
       if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
          if (verbose) {
-            Pmsg5(000, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d\n"),
-                  rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
+            Pmsg6(000, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d %s\n"),
+                  rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len, dedup_msg);
          }
          print_ls_output(jcr, attr);
          num_files++;