]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/dird/inc_conf.c
authorEric Bollengier <eric@baculasystems.com>
Fri, 24 Apr 2020 15:54:54 +0000 (17:54 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:17 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Thu Mar 28 17:50:03 2019 +0100

    Fix #4792 about incorrect FileSet { Options {} } not detected (accurate, basejob and verify)

Author: Kern Sibbald <kern@sibbald.com>
Date:   Thu May 8 11:40:18 2014 +0200

    Rework dedup directives

bacula/src/dird/inc_conf.c

index 8c6195335eb1cad36139ea8e11283bf4a3c14c43..d247805ced785a7b8ad5722ed9d1fe3d7aafc159 100644 (file)
@@ -94,6 +94,7 @@ RES_ITEM2 newinc_items[] = {
  */
 RES_ITEM options_items[] = {
    {"Compression",     store_opts,    {0},   0, INC_KW_COMPRESSION,  0},
+   {"Dedup",           store_opts,    {0},   0, INC_KW_DEDUP,        1}, /* default 1=Storage */
    {"Signature",       store_opts,    {0},   0, INC_KW_DIGEST,       0},
    {"OneFs",           store_opts,    {0},   0, INC_KW_ONEFS,        0},
    {"Recurse",         store_opts,    {0},   0, INC_KW_RECURSE,      0},
@@ -140,6 +141,7 @@ RES_ITEM options_items[] = {
  */
 s_kw FS_option_kw[] = {
    {"Compression", INC_KW_COMPRESSION},
+   {"Dedup",       INC_KW_DEDUP},
    {"Signature",   INC_KW_DIGEST},
    {"Encryption",  INC_KW_ENCRYPTION},
    {"Verify",      INC_KW_VERIFY},
@@ -202,6 +204,9 @@ struct s_fs_opt FS_options[] = {
    {"Lzo",      INC_KW_COMPRESSION,  "Zo"},
    {"blowfish", INC_KW_ENCRYPTION,    "B"},   /* ***FIXME*** not implemented */
    {"3des",     INC_KW_ENCRYPTION,    "3"},   /* ***FIXME*** not implemented */
+   {"Storage",  INC_KW_DEDUP,        "d1"},
+   {"BothSides",INC_KW_DEDUP,        "d2"},
+   {"None",     INC_KW_DEDUP,        "d0"},
    {"No",       INC_KW_ONEFS,         "f"},
    {"Yes",      INC_KW_ONEFS,         "0"},
    {"No",       INC_KW_RECURSE,       "h"},
@@ -258,11 +263,42 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
    int i;
    char option[3];
    int lcopts = lc->options;
+   const char *fs_options=NULL;
 
    option[0] = 0;                     /* default option = none */
    option[2] = 0;                     /* terminate options */
    lc->options |= LOPT_STRING;        /* force string */
    lex_get_token(lc, T_STRING);       /* expect at least one option */
+
+   /* Check if the options are correct */
+   switch(keyword) {
+   case INC_KW_VERIFY:
+      fs_options = "ipnugsamcd51:V"; /* From dird/verify.c */
+      break;
+   case INC_KW_BASEJOB:
+   case INC_KW_ACCURATE:
+      fs_options = "ipnugsamMcdA51:JC"; /* From filed/accurate.c accurate_check_file() */
+      break;
+   default:
+      break;
+   }
+
+   if (fs_options) {
+      for (char *p = lc->str; *p ; p++) {
+         if (!strchr(fs_options, *p)) {
+            /* Determine the name of the directive (Verify, BaseJob or Accurate) */
+            const char *directive = NULL;
+            for(int i=0; FS_option_kw[i].name ; i++) {
+               if (FS_option_kw[i].token == keyword) {
+                  directive = FS_option_kw[i].name;
+                  break;
+               }
+            }
+            scan_err3(lc, _("Expected a valid %s option. Got unknown option '%c' from \"%s\""), directive, *p, lc->str);
+         }
+      }
+   }
+
    /*
     * ***FIXME**** ensure these are in permitted set
     */