]> git.sur5r.net Git - bacula/bacula/commitdiff
Implement | and < in File daemon
authorKern Sibbald <kern@sibbald.com>
Sat, 6 Sep 2003 20:23:28 +0000 (20:23 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 6 Sep 2003 20:23:28 +0000 (20:23 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@689 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/filed/job.c

index afdbafed186cf083c53c68d90fed37352110cca1..19907ae21a9c74d4dd86ed481692cb260becb42c 100644 (file)
@@ -32,12 +32,10 @@ For 1.32:
   scan 1; scan 1-5; scan 1,2,4 ...  to update the catalog 
 - Allow a slot or range of slots on the label barcodes command.
   when the magazine is changed.
-- Implement ClientRunBeforeJob and ClientRunAfterJob.
 - Figure out what is interrupting sql command in console.
 - Don't print "Warning: Wrong Volume mounted ..." if mounting second
   volume.
 - Implement List Volume Job=xxx  or List scheduled volumes or Status Director 
-- Make | and < work on FD side.
 - Take a careful look a the Basic recycling algorithm.  When Bacula
   chooses, the order should be:
    - Look for Append
@@ -888,3 +886,6 @@ Done: (see kernsdone for more)
 - Use repositioning at the beginning of the tape.                   
 - Do full check the command line args in update (e.g. VolStatus ...).
 - Specify list of files to restore
+- Implement ClientRunBeforeJob and ClientRunAfterJob.
+- Make | and < work on FD side.
+
index dd7c4856dfdd1080bb45b6517464e1d6ae249514..e79f6142bde2ba7147177c446da2af736a9a2830 100644 (file)
@@ -416,17 +416,91 @@ static int run_cmd(JCR *jcr, char *cmd, char *name)
 
 static void add_fname_to_list(JCR *jcr, char *fname, int list)
 {
-   char *p;  
-   if (list == INC_LIST) {
-      add_fname_to_include_list((FF_PKT *)jcr->ff, 1, fname);
-   } else {
-      /* Skip leading options -- currently ignored */
-      for (p=fname; *p && *p != ' '; p++)
-        { }
-      /* Skip spaces */
-      for ( ; *p && *p == ' '; p++)
-        { }
-      add_fname_to_exclude_list((FF_PKT *)jcr->ff, p);
+   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 '|':
+      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 */
+        strcpy(buf, fname);
+         strcat(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) {
+         Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
+            list==INC_LIST?"included":"excluded", p, strerror(errno));
+        return;
+      }
+      /* Copy File options */
+      if (list == INC_LIST) {
+        *q = 0;                      /* terminate options */
+        strcpy(buf, fname);
+         strcat(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;
    }
 }