From: Kern Sibbald Date: Sat, 6 Sep 2003 20:23:28 +0000 (+0000) Subject: Implement | and < in File daemon X-Git-Tag: Release-1.32~30 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f061f2184a59f5204b1738de3053d85862379161;p=bacula%2Fbacula Implement | and < in File daemon git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@689 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index afdbafed18..19907ae21a 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -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. + diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index dd7c4856df..e79f6142bd 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -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; } }