]> git.sur5r.net Git - bacula/bacula/commitdiff
- Add a second job and a second client to the default
authorKern Sibbald <kern@sibbald.com>
Mon, 14 Mar 2005 19:27:52 +0000 (19:27 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 14 Mar 2005 19:27:52 +0000 (19:27 +0000)
  bacula-dir.conf file.
- Remove old style Include/Excludes.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1887 91ce42f0-d328-0410-95d8-f526ca767f89

14 files changed:
bacula/src/dird/bacula-dir.conf.in
bacula/src/dird/fd_cmds.c
bacula/src/dird/inc_conf.c
bacula/src/dird/protos.h
bacula/src/filed/Makefile.in
bacula/src/filed/job.c
bacula/src/findlib/find.c
bacula/src/findlib/find_one.c
bacula/src/findlib/match.c
bacula/src/findlib/protos.h
bacula/src/stored/bextract.c
bacula/src/stored/bls.c
bacula/src/tools/testfind.c
bacula/src/tools/testls.c

index 83c8ff671134e9f2c647c3ad9378c58e0069fd29..5d22a2fff1bf1a5dfc456671c632bd0a8537fe97 100644 (file)
@@ -46,6 +46,13 @@ Job {
   Write Bootstrap = "@working_dir@/Client1.bsr"
 }
 
+#Job {
+#  Name = "Client2"
+#  Client = @hostname@2-fd
+#  JobDefs = "DefaultJob"
+#  Write Bootstrap = "@working_dir@/Client2.bsr"
+#}
+
 # Backup the catalog database (after the nightly save)
 Job {
   Name = "BackupCatalog"
@@ -61,7 +68,10 @@ Job {
   Priority = 11                   # run after main backup
 }
 
+#
 # Standard Restore template, to be changed by Console program
+#  Only one such job is needed for all Jobs/Clients/Storage ...
+#
 Job {
   Name = "RestoreFiles"
   Type = Restore
@@ -150,6 +160,22 @@ Client {
   AutoPrune = yes                     # Prune expired Jobs/Files
 }
 
+#
+# Second Client (File Services) to backup
+#  You should change Name, Address, and Password before using
+#
+#Client {
+#  Name = @hostname@2-fd                
+#  Address = @hostname@2
+#  FDPort = @fd_port@
+#  Catalog = MyCatalog
+#  Password = "@fd_password@2"         # password for FileDaemon 2
+#  File Retention = 30 days            # 30 days
+#  Job Retention = 6 months            # six months
+#  AutoPrune = yes                     # Prune expired Jobs/Files
+#}
+
+
 # Definiton of file storage device
 Storage {
   Name = File
index c4c9bba8b77aa2cb25c965a14ff90b8efaaef3c7..97dc669ac50c8a4cbf0c02ec52173691b2319b3f 100644 (file)
@@ -36,8 +36,6 @@
 #include "dird.h"
 
 /* Commands sent to File daemon */
-static char inc[]         = "include\n";
-static char exc[]         = "exclude\n";
 static char fileset[]     = "fileset\n"; /* set full fileset */
 static char jobcmd[]      = "JobId=%d Job=%s SDid=%u SDtime=%u Authorization=%s\n";
 /* Note, mtime_only is not used here -- implemented as file option */
@@ -48,7 +46,6 @@ static char runafter[]    = "RunAfterJob %s\n";
 
 /* Responses received from File daemon */
 static char OKinc[]       = "2000 OK include\n";
-static char OKexc[]       = "2000 OK exclude\n";
 static char OKjob[]       = "2000 OK Job";
 static char OKbootstrap[] = "2000 OK bootstrap\n";
 static char OKlevel[]     = "2000 OK level\n";
@@ -212,7 +209,7 @@ static void send_since_time(JCR *jcr)
  * Send level command to FD.
  * Used for backup jobs and estimate command.
  */
-int send_level_command(JCR *jcr)
+bool send_level_command(JCR *jcr)
 {
    BSOCK   *fd = jcr->file_bsock;
    /*
@@ -248,139 +245,6 @@ int send_level_command(JCR *jcr)
    return 1;
 }
 
-
-/*
- * Send either an Included or an Excluded list to FD
- */
-static int send_list(JCR *jcr, int list)
-{
-   FILESET *fileset;
-   BSOCK   *fd;
-   int num;
-
-   fd = jcr->file_bsock;
-   fileset = jcr->fileset;
-
-   if (list == INC_LIST) {
-      num = fileset->num_includes;
-   } else {
-      num = fileset->num_excludes;
-   }
-
-   for (int i=0; i<num; i++) {
-      BPIPE *bpipe;
-      FILE *ffd;
-      char buf[2000];
-      char *p;
-      int optlen, stat;
-      INCEXE *ie;
-
-
-      if (list == INC_LIST) {
-        ie = fileset->include_items[i];
-      } else {
-        ie = fileset->exclude_items[i];
-      }
-      for (int j=0; j<ie->name_list.size(); j++) {
-        p = (char *)ie->name_list.get(j);
-        switch (*p) {
-         case '|':
-           p++;                      /* skip over the | */
-            fd->msg = edit_job_codes(jcr, fd->msg, p, "");
-            bpipe = open_bpipe(fd->msg, 0, "r");
-           if (!bpipe) {
-              berrno be;
-               Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
-                 p, be.strerror());
-              goto bail_out;
-           }
-           /* Copy File options */
-           if (ie->num_opts) {
-              bstrncpy(buf, ie->opts_list[0]->opts, sizeof(buf));
-               bstrncat(buf, " ", sizeof(buf));
-           } else {
-               bstrncpy(buf, "0 ", sizeof(buf));
-           }
-            Dmsg1(500, "Opts=%s\n", buf);
-           optlen = strlen(buf);
-           while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
-               fd->msglen = Mmsg(fd->msg, "%s", buf);
-               Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
-              if (!bnet_send(fd)) {
-                  Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
-                 goto bail_out;
-              }
-           }
-           if ((stat=close_bpipe(bpipe)) != 0) {
-              berrno be;
-               Jmsg(jcr, M_FATAL, 0, _("Error running program %p: ERR=%s\n"),
-                 p, be.strerror(stat));
-              goto bail_out;
-           }
-           break;
-         case '<':
-           p++;                      /* skip over < */
-            if ((ffd = fopen(p, "r")) == NULL) {
-               Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
-                  list==INC_LIST?"included":"excluded", p, strerror(errno));
-              goto bail_out;
-           }
-           /* Copy File options */
-           if (ie->num_opts) {
-              bstrncpy(buf, ie->opts_list[0]->opts, sizeof(buf));
-               bstrncat(buf, " ", sizeof(buf));
-           } else {
-               bstrncpy(buf, "0 ", sizeof(buf));
-           }
-            Dmsg1(500, "Opts=%s\n", buf);
-           optlen = strlen(buf);
-           while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
-               fd->msglen = Mmsg(fd->msg, "%s", buf);
-              if (!bnet_send(fd)) {
-                  Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
-                 goto bail_out;
-              }
-           }
-           fclose(ffd);
-           break;
-         case '\\':
-            p++;                      /* skip over \ */
-           /* Note, fall through wanted */
-        default:
-           if (ie->num_opts) {
-               Dmsg2(500, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts));
-              pm_strcpy(fd->msg, ie->opts_list[0]->opts);
-               pm_strcat(fd->msg, " ");
-           } else {
-               pm_strcpy(fd->msg, "0 ");
-           }
-           fd->msglen = pm_strcat(fd->msg, p);
-            Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
-           if (!bnet_send(fd)) {
-               Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
-              goto bail_out;
-           }
-           break;
-        }
-      }
-   }
-   bnet_sig(fd, BNET_EOD);           /* end of data */
-   if (list == INC_LIST) {
-      if (!response(jcr, fd, OKinc, "Include", DISPLAY_ERROR)) {
-        goto bail_out;
-      }
-   } else if (!response(jcr, fd, OKexc, "Exclude", DISPLAY_ERROR)) {
-       goto bail_out;
-   }
-   return 1;
-
-bail_out:
-   set_jcr_job_status(jcr, JS_ErrorTerminated);
-   return 0;
-
-}
-
-
 /*
  * Send either an Included or an Excluded list to FD
  */
@@ -538,30 +402,26 @@ bail_out:
 /*
  * Send include list to File daemon
  */
-int send_include_list(JCR *jcr)
+bool send_include_list(JCR *jcr)
 {
    BSOCK *fd = jcr->file_bsock;
    if (jcr->fileset->new_include) {
       bnet_fsend(fd, fileset);
       return send_fileset(jcr);
-   } else {
-      bnet_fsend(fd, inc);
    }
-   return send_list(jcr, INC_LIST);
+   return true;
 }
 
 
 /*
  * Send exclude list to File daemon
+ *   Under the new scheme, the Exclude list
+ *   is part of the FileSet sent with the
+ *   "include_list" above.
  */
-int send_exclude_list(JCR *jcr)
+bool send_exclude_list(JCR *jcr)
 {
-   BSOCK *fd = jcr->file_bsock;
-   if (jcr->fileset->new_include) {
-      return 1;
-   }
-   bnet_fsend(fd, exc);
-   return send_list(jcr, EXC_LIST);
+   return true;
 }
 
 
@@ -569,7 +429,7 @@ int send_exclude_list(JCR *jcr)
  * Send bootstrap file if any to the File daemon.
  *  This is used for restore and verify VolumeToCatalog
  */
-int send_bootstrap_file(JCR *jcr)
+bool send_bootstrap_file(JCR *jcr)
 {
    FILE *bs;
    char buf[1000];
index 80f0d2f3bbaeb7379d2bd99c156c1dd30851ea8a..9fa242891717e70959a7d2f7ab54d70e317192af 100644 (file)
@@ -128,8 +128,10 @@ enum {
 };
 
 /*
- * Include keywords -- these are keywords that can appear
- *    in the options lists of an old include ( Include = compression= ...)
+ * This is the list of options that can be stored by store_opts
+ *   Note, now that the old style Include/Exclude code is gone,
+ *   the INC_KW code could be put into the "code" field of the
+ *   options given above.
  */
 static struct s_kw FS_option_kw[] = {
    {"compression", INC_KW_COMPRESSION},
@@ -271,11 +273,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
  */
 void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
 {
-   int token, i;
-   int options = lc->options;
-   int keyword;
-   char inc_opts[100];
-   int inc_opts_len;
+   int token;
 
    /*
     * Decide if we are doing a new Include or an old include. The
@@ -287,113 +285,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
       store_newinc(lc, item, index, pass);
       return;
    }
-
-   /* What follows is scanning for the OLD style Include/Exclude */
-
-   if (token != T_EQUALS) {
-      scan_err1(lc, _("Expecting an equals sign, got: %s\n"), lc->str);
-   }
-   lc->options |= LOPT_NO_IDENT;      /* make spaces significant */
-   memset(&res_incexe, 0, sizeof(INCEXE));
-
-   /* Get include options */
-   inc_opts[0] = 0;
-   while ((token=lex_get_token(lc, T_SKIP_EOL)) != T_BOB) {
-
-      keyword = INC_KW_NONE;
-      for (i=0; FS_option_kw[i].name; i++) {
-        if (strcasecmp(lc->str, FS_option_kw[i].name) == 0) {
-           keyword = FS_option_kw[i].token;
-           break;
-        }
-      }
-      if (keyword == INC_KW_NONE) {
-         scan_err1(lc, _("Expected a FileSet keyword, got: %s"), lc->str);
-      }
-      /* Option keyword should be following by = <option> */
-      if ((token=lex_get_token(lc, T_SKIP_EOL)) != T_EQUALS) {
-         scan_err1(lc, _("expected an = following keyword, got: %s"), lc->str);
-      } else {
-        /* Scan right hand side of option */
-        scan_include_options(lc, keyword, inc_opts, sizeof(inc_opts));
-      }
-      if (token == T_BOB) {
-        break;
-      }
-   }
-
-   if (!inc_opts[0]) {
-      bstrncat(inc_opts, "0", sizeof(inc_opts));   /* set no options */
-   }
-   inc_opts_len = strlen(inc_opts);
-
-   if (pass == 1) {
-      INCEXE *incexe;
-      if (!res_all.res_fs.have_MD5) {
-        MD5Init(&res_all.res_fs.md5c);
-        res_all.res_fs.have_MD5 = TRUE;
-      }
-      setup_current_opts();
-      bstrncpy(res_incexe.current_opts->opts, inc_opts, MAX_FOPTS);
-      Dmsg2(900, "old pass=%d incexe opts=%s\n", pass, res_incexe.current_opts->opts);
-
-      /* Create incexe structure */
-      Dmsg0(900, "Create INCEXE structure\n");
-      incexe = (INCEXE *)malloc(sizeof(INCEXE));
-      memcpy(incexe, &res_incexe, sizeof(INCEXE));
-      memset(&res_incexe, 0, sizeof(INCEXE));
-      if (item->code == 0) { /* include */
-        if (res_all.res_fs.num_includes == 0) {
-           res_all.res_fs.include_items = (INCEXE **)malloc(sizeof(INCEXE *));
-         } else {
-           res_all.res_fs.include_items = (INCEXE **)realloc(res_all.res_fs.include_items,
-                          sizeof(INCEXE *) * (res_all.res_fs.num_includes + 1));
-         }
-         res_all.res_fs.include_items[res_all.res_fs.num_includes++] = incexe;
-          Dmsg1(900, "num_includes=%d\n", res_all.res_fs.num_includes);
-      } else {   /* exclude */
-        if (res_all.res_fs.num_excludes == 0) {
-           res_all.res_fs.exclude_items = (INCEXE **)malloc(sizeof(INCEXE *));
-         } else {
-           res_all.res_fs.exclude_items = (INCEXE **)realloc(res_all.res_fs.exclude_items,
-                          sizeof(INCEXE *) * (res_all.res_fs.num_excludes + 1));
-         }
-         res_all.res_fs.exclude_items[res_all.res_fs.num_excludes++] = incexe;
-          Dmsg1(900, "num_excludes=%d\n", res_all.res_fs.num_excludes);
-      }
-
-      /* Pickup include/exclude names. They are stored in INCEXE
-       *  structures which contains the options and the name.
-       */
-      while ((token = lex_get_token(lc, T_SKIP_EOL)) != T_EOB) {
-        switch (token) {
-        case T_COMMA:
-           continue;
-
-        case T_IDENTIFIER:
-        case T_UNQUOTED_STRING:
-        case T_QUOTED_STRING:
-           if (res_all.res_fs.have_MD5) {
-              MD5Update(&res_all.res_fs.md5c, (unsigned char *)lc->str, lc->str_len);
-           }
-           if (incexe->name_list.size() == 0) {
-              incexe->name_list.init(10, true);
-           }
-           incexe->name_list.append(bstrdup(lc->str));
-            Dmsg1(900, "Add to name_list %s\n", lc->str);
-           break;
-        default:
-            scan_err1(lc, "Expected a filename, got: %s", lc->str);
-        }
-      }
-      /* Note, MD5Final is done in backup.c */
-   } else { /* pass 2 */
-      while (lex_get_token(lc, T_ALL) != T_EOB)
-        {}
-   }
-   scan_to_eol(lc);
-   lc->options = options;
-   set_bit(index, res_all.hdr.item_present);
+   scan_err0(lc, _("Old style Include/Exclude not supported\n"));
 }
 
 
index 66ad717f99ef86b5ccd62da1c599b90e4ff4813c..2af78131f40bb2067f7b4a0e3ab7fdeacd71e92e 100644 (file)
@@ -73,10 +73,10 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp);
 /* fd_cmds.c */
 extern int connect_to_file_daemon(JCR *jcr, int retry_interval,
                                   int max_retry_time, int verbose);
-extern int send_include_list(JCR *jcr);
-extern int send_exclude_list(JCR *jcr);
-extern int send_bootstrap_file(JCR *jcr);
-extern int send_level_command(JCR *jcr);
+extern bool send_include_list(JCR *jcr);
+extern bool send_exclude_list(JCR *jcr);
+extern bool send_bootstrap_file(JCR *jcr);
+extern bool send_level_command(JCR *jcr);
 extern int get_attributes_and_put_in_catalog(JCR *jcr);
 extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId);
 extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname,
index 3b0efbb5b9d1b1a950e728dd4c2494397cf659c6..2ff0648de251e893b5e99e13494733a0b972b232 100755 (executable)
@@ -141,7 +141,7 @@ depend:
        @$(MV) Makefile Makefile.bak
        @$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile
        @$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile
-       @$(CXX) -S -M $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
+       @$(CXX) -S -M $(CPPFLAGS) $(XINC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
        @if test -f Makefile ; then \
            $(RMF) Makefile.bak; \
        else \
index 418c0e1f91756cdf4941828b481ebd593702ce01..56ee2afbe38f5e60713667448e01e4697d88f0b6 100644 (file)
@@ -42,10 +42,8 @@ static int bootstrap_cmd(JCR *jcr);
 static int cancel_cmd(JCR *jcr);
 static int setdebug_cmd(JCR *jcr);
 static int estimate_cmd(JCR *jcr);
-static int exclude_cmd(JCR *jcr);
 static int hello_cmd(JCR *jcr);
 static int job_cmd(JCR *jcr);
-static int include_cmd(JCR *jcr);
 static int fileset_cmd(JCR *jcr);
 static int level_cmd(JCR *jcr);
 static int verify_cmd(JCR *jcr);
@@ -78,9 +76,7 @@ static struct s_cmds cmds[] = {
    {"cancel",       cancel_cmd,    0},
    {"setdebug=",    setdebug_cmd,  0},
    {"estimate",     estimate_cmd,  0},
-   {"exclude",      exclude_cmd,   0},
    {"Hello",        hello_cmd,     1},
-   {"include",      include_cmd,   0},
    {"fileset",      fileset_cmd,   0},
    {"JobId=",       job_cmd,       0},
    {"level = ",     level_cmd,     0},
@@ -113,7 +109,6 @@ static char no_auth[]     = "2998 No Authorization\n";
 static char illegal_cmd[] = "2997 Illegal command for a Director with Monitor directive enabled\n";
 static char OKinc[]       = "2000 OK include\n";
 static char OKest[]       = "2000 OK estimate files=%u bytes=%s\n";
-static char OKexc[]       = "2000 OK exclude\n";
 static char OKlevel[]     = "2000 OK level\n";
 static char OKbackup[]    = "2000 OK backup\n";
 static char OKbootstrap[] = "2000 OK bootstrap\n";
@@ -494,121 +489,6 @@ static bool run_cmd(JCR *jcr, char *cmd, const char *name)
    return true;
 }
 
-
-#define INC_LIST 0
-#define EXC_LIST 1
-
-static void add_fname_to_list(JCR *jcr, char *fname, int list)
-{
-   char *p, *q;
-   BPIPE *bpipe;
-   POOLMEM *fn;
-   FILE *ffd;
-   char buf[1000];
-   int optlen;
-   int stat;
-
-   /* Skip leading options -- currently ignored */
-   for (p=fname; *p && *p != ' '; p++)
-      { }
-   /* Skip spaces, and q points to first space */
-   for (q=NULL; *p && *p == ' '; p++) {
-      if (!q) {
-        q = p;
-      }
-   }
-
-   switch (*p) {
-   case '|':
-      p++;                           /* skip over | */
-      fn = get_pool_memory(PM_FNAME);
-      fn = edit_job_codes(jcr, fn, p, "");
-      bpipe = open_bpipe(fn, 0, "r");
-      free_pool_memory(fn);
-      if (!bpipe) {
-         Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
-           p, strerror(errno));
-        return;
-      }
-      /* Copy File options */
-      if (list == INC_LIST) {
-        *q = 0;                      /* terminate options */
-        bstrncpy(buf, fname, sizeof(buf));
-         bstrncat(buf, " ", sizeof(buf));
-        optlen = strlen(buf);
-      } else {
-        optlen = 0;
-      }
-      while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
-        strip_trailing_junk(buf);
-        if (list == INC_LIST) {
-           add_fname_to_include_list((FF_PKT *)jcr->ff, 1, buf);
-        } else {
-           add_fname_to_exclude_list((FF_PKT *)jcr->ff, buf);
-        }
-      }
-      if ((stat=close_bpipe(bpipe)) != 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
-           p, stat, strerror(errno));
-        return;
-      }
-      break;
-   case '<':
-      p++;                     /* skip over < */
-      if ((ffd = fopen(p, "r")) == NULL) {
-        berrno be;
-         Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
-            list==INC_LIST?"included":"excluded", p, be.strerror());
-        return;
-      }
-      /* Copy File options */
-      if (list == INC_LIST) {
-        *q = 0;                      /* terminate options */
-        bstrncpy(buf, fname, sizeof(buf));
-         bstrncat(buf, " ", sizeof(buf));
-        optlen = strlen(buf);
-      } else {
-        optlen = 0;
-      }
-      while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
-        strip_trailing_junk(buf);
-        if (list == INC_LIST) {
-           add_fname_to_include_list((FF_PKT *)jcr->ff, 1, buf);
-        } else {
-           add_fname_to_exclude_list((FF_PKT *)jcr->ff, buf);
-        }
-      }
-      fclose(ffd);
-      break;
-   default:
-      if (list == INC_LIST) {
-        add_fname_to_include_list((FF_PKT *)jcr->ff, 1, fname);
-      } else {
-        add_fname_to_exclude_list((FF_PKT *)jcr->ff, p);
-      }
-      break;
-   }
-}
-
-/*
- *
- * Get list of files/directories to include from Director
- *
- */
-static int include_cmd(JCR *jcr)
-{
-   BSOCK *dir = jcr->dir_bsock;
-
-   while (bnet_recv(dir) >= 0) {
-      dir->msg[dir->msglen] = 0;
-      strip_trailing_junk(dir->msg);
-      Dmsg1(010, "include file: %s\n", dir->msg);
-      add_fname_to_list(jcr, dir->msg, INC_LIST);
-   }
-
-   return bnet_fsend(dir, OKinc);
-}
-
 static bool init_fileset(JCR *jcr)
 {
    FF_PKT *ff;
@@ -1041,25 +921,6 @@ static int fileset_cmd(JCR *jcr)
 }
 
 
-/*
- * Get list of files to exclude from Director
- *
- */
-static int exclude_cmd(JCR *jcr)
-{
-   BSOCK *dir = jcr->dir_bsock;
-
-   while (bnet_recv(dir) >= 0) {
-      dir->msg[dir->msglen] = 0;
-      strip_trailing_junk(dir->msg);
-      add_fname_to_list(jcr, dir->msg, EXC_LIST);
-      Dmsg1(110, "<dird: exclude file %s\n", dir->msg);
-   }
-
-   return bnet_fsend(dir, OKexc);
-}
-
-
 static int bootstrap_cmd(JCR *jcr)
 {
    BSOCK *dir = jcr->dir_bsock;
index 13bf2c47a4b76fa58c78841ad232acaa1ab1eca1..b94b65481e6285fa84b1fb2973b72779c80d3ca8 100644 (file)
 int32_t name_max;             /* filename max length */
 int32_t path_max;             /* path name max length */
 
-
-/* ****FIXME**** debug until stable */
+#ifdef DEBUG
 #undef bmalloc
 #define bmalloc(x) sm_malloc(__FILE__, __LINE__, x)
+#endif
 static int our_callback(FF_PKT *ff, void *hpkt);
 static bool accept_file(FF_PKT *ff);
 
@@ -63,8 +63,6 @@ FF_PKT *init_find_files()
 
   ff->sys_fname = get_pool_memory(PM_FNAME);
 
-  init_include_exclude_files(ff);          /* init lists */
-
    /* Get system path and filename maximum lengths */
    path_max = pathconf(".", _PC_PATH_MAX);
    if (path_max < 1024) {
@@ -147,20 +145,6 @@ find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void
            }
         }
       }
-   } else {
-      struct s_included_file *inc = NULL;
-
-      /* This is the old deprecated way */
-      while (!job_canceled(jcr) && (inc = get_next_included_file(ff, inc))) {
-        /* Copy options for this file */
-        bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts));
-         Dmsg1(100, "find_files: file=%s\n", inc->fname);
-        if (!file_is_excluded(ff, inc->fname)) {
-           if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) {
-              return 0;                  /* error return */
-           }
-        }
-      }
    }
    return 1;
 }
@@ -327,7 +311,6 @@ term_find_files(FF_PKT *ff)
 {
   int hard_links;
 
-  term_include_exclude_files(ff);
   free_pool_memory(ff->sys_fname);
   hard_links = term_find_one(ff);
   free(ff);
index 90709c47eed3056b65d284d89227c8601e9b868f..eff2a1a945ae6a9b73c11dea442846fefd4046f6 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2000-20054 Kern Sibbald
+   Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -163,8 +163,8 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
         if (ff_pkt->flags & FO_KEEPATIME) {
            utime(fname, &restore_times);
         }
-        Jmsg1(jcr, M_ERROR, 0, _("Top level directory \"%s\" has an unlisted fstype\n"), fname);
-        return 1;      /* Just ignore this error - or the whole backup is cancelled */
+         Jmsg1(jcr, M_ERROR, 0, _("Top level directory \"%s\" has an unlisted fstype\n"), fname);
+        return 1;      /* Just ignore this error - or the whole backup is cancelled */
       }
       ff_pkt->volhas_attrlist = volume_has_attrlist(fname);
    }
index b83653f8f98db1a4131ca85661b0ab3d9c8aa48c..0fd29bfd2dcbd51009a49dc3179d0bc07e8f761e 100644 (file)
@@ -4,13 +4,14 @@
  *
  *  Note, this file is used for the old style include and
  *   excludes, so is deprecated. The new style code is
- *   found in find.c
+ *   found in find.c.  
+ *  This code is still used for lists in testls and bextract.
  *
  *   Kern E. Sibbald, December MMI
  *
  */
 /*
-   Copyright (C) 2001-2004 Kern Sibbald
+   Copyright (C) 2001-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -53,13 +54,28 @@ static const int fnmode = 0;
 
 extern const int win32_client;
 
-/*
- * Initialize structures for filename matching
- */
-void init_include_exclude_files(FF_PKT *ff)
+int
+match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void *his_pkt)
 {
+   ff->callback = callback;
+
+   struct s_included_file *inc = NULL;
+
+   /* This is the old deprecated way */
+   while (!job_canceled(jcr) && (inc = get_next_included_file(ff, inc))) {
+      /* Copy options for this file */
+      bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts));
+      Dmsg1(100, "find_files: file=%s\n", inc->fname);
+      if (!file_is_excluded(ff, inc->fname)) {
+        if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) {
+           return 0;                  /* error return */
+        }
+      }
+   }
+   return 1;
 }
 
+
 /*
  * Done doing filename matching, release all
  *  resources used.
index 16867ba6a3c51a191e3d9b3a9cabcf1d6e6fc3e6..13288582469f22724f4366c39ba93acc55ab3a8c 100644 (file)
 
  */
 /* from attribs.c */
-void   encode_stat       (char *buf, FF_PKT *ff_pkt, int data_stream);
-int    decode_stat       (char *buf, struct stat *statp, int32_t *LinkFI);
-int32_t decode_LinkFI    (char *buf, struct stat *statp);
-int    encode_attribsEx  (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt);
-bool   set_attributes    (JCR *jcr, ATTR *attr, BFILE *ofd);
-int    select_data_stream(FF_PKT *ff_pkt);
+void    encode_stat       (char *buf, FF_PKT *ff_pkt, int data_stream);
+int     decode_stat       (char *buf, struct stat *statp, int32_t *LinkFI);
+int32_t decode_LinkFI     (char *buf, struct stat *statp);
+int     encode_attribsEx  (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt);
+bool    set_attributes    (JCR *jcr, ATTR *attr, BFILE *ofd);
+int     select_data_stream(FF_PKT *ff_pkt);
 
 /* from create_file.c */
-int    create_file      (JCR *jcr, ATTR *attr, BFILE *ofd, int replace);
+int    create_file       (JCR *jcr, ATTR *attr, BFILE *ofd, int replace);
 
 /* From find.c */
 FF_PKT *init_find_files();
 void  set_find_options(FF_PKT *ff, int incremental, time_t mtime);
 int   find_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt), void *pkt);
+int   match_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt), void *pkt);
 int   term_find_files(FF_PKT *ff);
 
 /* From match.c */
@@ -47,11 +48,11 @@ void  add_fname_to_exclude_list(FF_PKT *ff, const char *fname);
 int   file_is_excluded(FF_PKT *ff, const char *file);
 int   file_is_included(FF_PKT *ff, const char *file);
 struct s_included_file *get_next_included_file(FF_PKT *ff,
-                          struct s_included_file *inc);
+                           struct s_included_file *inc);
 
 /* From find_one.c */
 int   find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt),
-              void *pkt, char *p, dev_t parent_device, int top_level);
+               void *pkt, char *p, dev_t parent_device, int top_level);
 int   term_find_one(FF_PKT *ff);
 
 
@@ -61,8 +62,8 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors);
 
 /* from makepath.c */
 int make_path(JCR *jcr, const char *argpath, int mode,
-          int parent_mode, uid_t owner, gid_t group,
-          int preserve_existing, char *verbose_fmt_string);
+           int parent_mode, uid_t owner, gid_t group,
+           int preserve_existing, char *verbose_fmt_string);
 
 /* from fstype.c */
 bool fstype(const char *fname, char *fs, int fslen);
index 145fca6c3c169fc249c3ddd8bc9f8a01159dd685..2577094a7b6d02e4c2eb021b308d06f331d2d4a4 100644 (file)
@@ -44,8 +44,7 @@ static DEVICE *dev = NULL;
 static DCR *dcr;
 static BFILE bfd;
 static JCR *jcr;
-static FF_PKT my_ff;
-static FF_PKT *ff = &my_ff;
+static FF_PKT *ff;
 static BSR *bsr = NULL;
 static bool extract = false;
 static int non_support_data = 0;
@@ -97,8 +96,7 @@ int main (int argc, char *argv[])
    my_name_is(argc, argv, "bextract");
    init_msg(NULL, NULL);             /* setup message handler */
 
-   memset(ff, 0, sizeof(FF_PKT));
-   init_include_exclude_files(ff);
+   ff = init_find_files();
    binit(&bfd);
 
    while ((ch = getopt(argc, argv, "b:c:d:e:i:pvV:?")) != -1) {
@@ -202,6 +200,8 @@ int main (int argc, char *argv[])
       Pmsg1(000, "%d Win32 data or Win32 gzip data stream records. Ignored.\n",
         win32_data_msg);
    }
+   term_include_exclude_files(ff);
+   term_find_files(ff);
    return 0;
 }
 
index 167958a3422266c9e51d0a00f865fd91c63067d3..4bc1931b5859670483fd9367513db43614ea215a 100644 (file)
@@ -58,7 +58,7 @@ char *configfile;
 bool forge_on = false;
 
 
-static FF_PKT ff;
+static FF_PKT *ff;
 
 static BSR *bsr = NULL;
 
@@ -98,8 +98,7 @@ int main (int argc, char *argv[])
    my_name_is(argc, argv, "bls");
    init_msg(NULL, NULL);             /* initialize message handler */
 
-   memset(&ff, 0, sizeof(ff));
-   init_include_exclude_files(&ff);
+   ff = init_find_files();
 
    while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLpvV:?")) != -1) {
       switch (ch) {
@@ -129,7 +128,7 @@ int main (int argc, char *argv[])
         while (fgets(line, sizeof(line), fd) != NULL) {
            strip_trailing_junk(line);
             Dmsg1(100, "add_exclude %s\n", line);
-           add_fname_to_exclude_list(&ff, line);
+           add_fname_to_exclude_list(ff, line);
         }
         fclose(fd);
         break;
@@ -143,7 +142,7 @@ int main (int argc, char *argv[])
         while (fgets(line, sizeof(line), fd) != NULL) {
            strip_trailing_junk(line);
             Dmsg1(100, "add_include %s\n", line);
-           add_fname_to_include_list(&ff, 0, line);
+           add_fname_to_include_list(ff, 0, line);
         }
         fclose(fd);
         break;
@@ -193,8 +192,8 @@ int main (int argc, char *argv[])
 
    parse_config(configfile);
 
-   if (ff.included_files_list == NULL) {
-      add_fname_to_include_list(&ff, 0, "/");
+   if (ff->included_files_list == NULL) {
+      add_fname_to_include_list(ff, 0, "/");
    }
 
    for (i=0; i < argc; i++) {
@@ -236,6 +235,8 @@ int main (int argc, char *argv[])
    if (bsr) {
       free_bsr(bsr);
    }
+   term_include_exclude_files(ff);
+   term_find_files(ff);
    return 0;
 }
 
@@ -370,7 +371,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
       build_attr_output_fnames(jcr, attr);
 
-      if (file_is_included(&ff, attr->fname) && !file_is_excluded(&ff, attr->fname)) {
+      if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
         if (verbose) {
             Pmsg5(-1, "FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d\n",
                  rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
index e72fb045ab2a3dd64493fb63612dc5e7acb33dde..fe0ffda701db06b111c85f41d316d73a9896b04c 100644 (file)
@@ -82,26 +82,26 @@ main (int argc, char *const *argv)
 
    while ((ch = getopt(argc, argv, "ad:e:i:?")) != -1) {
       switch (ch) {
-        case 'a':                    /* print extended attributes *debug* */
+         case 'a':                    /* print extended attributes *debug* */
            attrs = 1;
            break;
 
-        case 'd':                    /* set debug level */
+         case 'd':                    /* set debug level */
            debug_level = atoi(optarg);
            if (debug_level <= 0) {
               debug_level = 1;
            }
            break;
 
-        case 'e':                    /* exclude patterns */
+         case 'e':                    /* exclude patterns */
            exc = optarg;
            break;
 
-        case 'i':                    /* include patterns */
+         case 'i':                    /* include patterns */
            inc = optarg;
            break;
 
-        case '?':
+         case '?':
         default:
            usage();
 
@@ -117,7 +117,7 @@ main (int argc, char *const *argv)
       add_fname_to_include_list(ff, 0, "/"); /* default to / */
    } else {
       for (i=0; i < argc; i++) {
-        if (strcmp(argv[i], "-") == 0) {
+         if (strcmp(argv[i], "-") == 0) {
             while (fgets(name, sizeof(name)-1, stdin)) {
                strip_trailing_junk(name);
                add_fname_to_include_list(ff, 0, name);
@@ -130,7 +130,7 @@ main (int argc, char *const *argv)
    if (inc) {
       fd = fopen(inc, "r");
       if (!fd) {
-        printf("Could not open include file: %s\n", inc);
+         printf("Could not open include file: %s\n", inc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -143,7 +143,7 @@ main (int argc, char *const *argv)
    if (exc) {
       fd = fopen(exc, "r");
       if (!fd) {
-        printf("Could not open exclude file: %s\n", exc);
+         printf("Could not open exclude file: %s\n", exc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -152,7 +152,8 @@ main (int argc, char *const *argv)
       }
       fclose(fd);
    }
-   find_files(jcr, ff, print_file, NULL);
+   match_files(jcr, ff, print_file, NULL);
+   term_include_exclude_files(ff);
    hard_links = term_find_files(ff);
 
    printf(_(""
@@ -177,32 +178,32 @@ static int print_file(FF_PKT *ff, void *pkt)
    switch (ff->type) {
    case FT_LNKSAVED:
       if (debug_level == 1) {
-        printf("%s\n", ff->fname);
+         printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-        printf("Lnka: %s -> %s\n", ff->fname, ff->link);
+         printf("Lnka: %s -> %s\n", ff->fname, ff->link);
       }
       break;
    case FT_REGE:
       if (debug_level == 1) {
-        printf("%s\n", ff->fname);
+         printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-        printf("Empty: %s\n", ff->fname);
+         printf("Empty: %s\n", ff->fname);
       }
       count_files(ff);
       break;
    case FT_REG:
       if (debug_level == 1) {
-        printf("%s\n", ff->fname);
+         printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-        printf("Reg: %s\n", ff->fname);
+         printf("Reg: %s\n", ff->fname);
       }
       count_files(ff);
       break;
    case FT_LNK:
       if (debug_level == 1) {
-        printf("%s\n", ff->fname);
+         printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-        printf("Lnk: %s -> %s\n", ff->fname, ff->link);
+         printf("Lnk: %s -> %s\n", ff->fname, ff->link);
       }
       count_files(ff);
       break;
@@ -213,24 +214,24 @@ static int print_file(FF_PKT *ff, void *pkt)
    case FT_INVALIDFS:
    case FT_DIREND:
       if (debug_level) {
-        char errmsg[100] = "";
+         char errmsg[100] = "";
         if (ff->type == FT_NORECURSE) {
-           bstrncpy(errmsg, "\t[will not descend: recursion turned off]", sizeof(errmsg));
+            bstrncpy(errmsg, "\t[will not descend: recursion turned off]", sizeof(errmsg));
         } else if (ff->type == FT_NOFSCHG) {
-           bstrncpy(errmsg, "\t[will not descend: file system change not allowed]", sizeof(errmsg));
+            bstrncpy(errmsg, "\t[will not descend: file system change not allowed]", sizeof(errmsg));
         } else if (ff->type == FT_INVALIDFS) {
-           bstrncpy(errmsg, "\t[will not descend: disallowed file system]", sizeof(errmsg));
+            bstrncpy(errmsg, "\t[will not descend: disallowed file system]", sizeof(errmsg));
         }
-        printf("%s%s%s\n", (debug_level > 1 ? "Dir: " : ""), ff->fname, errmsg);
+         printf("%s%s%s\n", (debug_level > 1 ? "Dir: " : ""), ff->fname, errmsg);
       }
       ff->type = FT_DIREND;
       count_files(ff);
       break;
    case FT_SPEC:
       if (debug_level == 1) {
-        printf("%s\n", ff->fname);
+         printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-        printf("Spec: %s\n", ff->fname);
+         printf("Spec: %s\n", ff->fname);
       }
       count_files(ff);
       break;
@@ -260,7 +261,7 @@ static int print_file(FF_PKT *ff, void *pkt)
       char attr[200];
       encode_attribsEx(NULL, attr, ff);
       if (*attr != 0) {
-        printf("AttrEx=%s\n", attr);
+         printf("AttrEx=%s\n", attr);
       }
 //    set_attribsEx(NULL, ff->fname, NULL, NULL, ff->type, attr);
    }
index f10ee60b4e970b2e654fd48d8b9293caab5a7a15..c1122bc677ff8c7d7ac9c6810b581765518a98fd 100755 (executable)
@@ -112,7 +112,7 @@ main (int argc, char *const *argv)
       add_fname_to_include_list(ff, 0, "/"); /* default to / */
    } else {
       for (i=0; i < argc; i++) {
-        if (strcmp(argv[i], "-") == 0) {
+         if (strcmp(argv[i], "-") == 0) {
             while (fgets(name, sizeof(name)-1, stdin)) {
                strip_trailing_junk(name);
                add_fname_to_include_list(ff, 0, name);
@@ -125,7 +125,7 @@ main (int argc, char *const *argv)
    if (inc) {
       fd = fopen(inc, "r");
       if (!fd) {
-        printf("Could not open include file: %s\n", inc);
+         printf("Could not open include file: %s\n", inc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -138,7 +138,7 @@ main (int argc, char *const *argv)
    if (exc) {
       fd = fopen(exc, "r");
       if (!fd) {
-        printf("Could not open exclude file: %s\n", exc);
+         printf("Could not open exclude file: %s\n", exc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -147,7 +147,8 @@ main (int argc, char *const *argv)
       }
       fclose(fd);
    }
-   find_files(jcr, ff, print_file, NULL);
+   match_files(jcr, ff, print_file, NULL);
+   term_include_exclude_files(ff);
    hard_links = term_find_files(ff);
 
    free_jcr(jcr);