From 606b4af5b49e8cde8ce01dffe8aa348f60aa4b95 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 7 May 2003 09:18:00 +0000 Subject: [PATCH] Include RunBefore/After output in job report git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@495 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/Makefile.in | 8 ++++---- bacula/src/dird/backup.c | 4 ---- bacula/src/dird/job.c | 27 ++++++++++++++++++++------- bacula/src/filed/restore.c | 4 ++-- bacula/src/findlib/attribs.c | 10 +++++----- bacula/src/findlib/create_file.c | 6 +++--- bacula/src/findlib/makepath.c | 20 ++++++++++---------- bacula/src/version.h | 4 ++-- 8 files changed, 46 insertions(+), 37 deletions(-) diff --git a/bacula/src/dird/Makefile.in b/bacula/src/dird/Makefile.in index 5ec19ed3e2..30208e19ca 100644 --- a/bacula/src/dird/Makefile.in +++ b/bacula/src/dird/Makefile.in @@ -22,8 +22,8 @@ first_rule: all dummy: # -SVRSRCS = dird.c authenticate.c autoprune.c \ - backup.c \ +SVRSRCS = dird.c admin.c authenticate.c \ + autoprune.c backup.c \ catreq.c dird_conf.c \ fd_cmds.c getmsg.c inc_conf.c job.c \ mountreq.c msgchan.c newvol.c \ @@ -35,8 +35,8 @@ SVRSRCS = dird.c authenticate.c autoprune.c \ ua_purge.c ua_restore.c ua_run.c \ ua_select.c ua_server.c \ ua_status.c verify.c -SVROBJS = dird.o authenticate.o autoprune.o \ - backup.o \ +SVROBJS = dird.o admin.o authenticate.o \ + autoprune.o backup.o \ catreq.o dird_conf.o \ fd_cmds.o getmsg.o inc_conf.o job.o \ mountreq.o msgchan.o newvol.o \ diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 358bb96506..872b94c106 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -4,9 +4,6 @@ * * Kern Sibbald, March MM * - * This routine is called as a thread. It may not yet be totally - * thread reentrant!!! - * * Basic tasks done here: * Open DB and create records for this job. * Open Message Channel with Storage daemon to tell him a job will be starting. @@ -485,6 +482,5 @@ Termination: %s\n\n"), sd_term_msg, term_msg); - Dmsg0(100, "Leave backup_cleanup()\n"); } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 5da55395ea..f9d258db50 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -46,9 +46,9 @@ void run_job(JCR *jcr); extern void term_scheduler(); extern void term_ua_server(); extern int do_backup(JCR *jcr); +extern int do_admin(JCR *jcr); extern int do_restore(JCR *jcr); extern int do_verify(JCR *jcr); -extern void backup_cleanup(void); #ifdef USE_SEMAPHORE static semlock_t job_lock; @@ -195,9 +195,15 @@ static void *job_thread(void *arg) if (jcr->job->RunBeforeJob) { POOLMEM *before = get_pool_memory(PM_FNAME); int status; + BPIPE *bpipe; + char line[MAXSTRING]; before = edit_run_codes(jcr, before, jcr->job->RunBeforeJob); - status = run_program(before, 0, NULL); + bpipe = open_bpipe(before, 0, "r"); + while (fgets(line, sizeof(line), bpipe->rfd)) { + Jmsg(jcr, M_INFO, 0, _("RunBefore: %s"), line); + } + status = close_bpipe(bpipe); if (status != 0) { Jmsg(jcr, M_FATAL, 0, _("RunBeforeJob returned non-zero status=%d\n"), status); @@ -228,9 +234,10 @@ static void *job_thread(void *arg) } break; case JT_ADMIN: - /* No actual job */ - do_autoprune(jcr); - set_jcr_job_status(jcr, JS_Terminated); + do_admin(jcr); + if (jcr->JobStatus == JS_Terminated) { + do_autoprune(jcr); + } break; default: Pmsg1(0, "Unimplemented job type: %d\n", jcr->JobType); @@ -239,9 +246,15 @@ static void *job_thread(void *arg) if (jcr->job->RunAfterJob) { POOLMEM *after = get_pool_memory(PM_FNAME); int status; - + BPIPE *bpipe; + char line[MAXSTRING]; + after = edit_run_codes(jcr, after, jcr->job->RunAfterJob); - status = run_program(after, 0, NULL); + bpipe = open_bpipe(after, 0, "r"); + while (fgets(line, sizeof(line), bpipe->rfd)) { + Jmsg(jcr, M_INFO, 0, _("RunAfter: %s"), line); + } + status = close_bpipe(bpipe); if (status != 0) { Jmsg(jcr, M_FATAL, 0, _("RunAfterJob returned non-zero status=%d\n"), status); diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 1df512a849..e3ee694480 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -369,7 +369,7 @@ void do_restore(JCR *jcr) Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total); if ((uLong)bwrite(&bfd, jcr->compress_buf, compress_len) != compress_len) { Dmsg0(0, "===Write error===\n"); - Jmsg2(jcr, M_ERROR, 0, "Write error on %s: %s\n", ofile, berror(&bfd)); + Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), ofile, berror(&bfd)); goto bail_out; } total += compress_len; @@ -378,7 +378,7 @@ void do_restore(JCR *jcr) } #else if (extract) { - Jmsg(jcr, M_ERROR, 0, "GZIP data stream found, but GZIP not configured!\n"); + Jmsg(jcr, M_ERROR, 0, _("GZIP data stream found, but GZIP not configured!\n")); goto bail_out; } #endif diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index 3a39b02dac..449841b5ce 100755 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -217,18 +217,18 @@ int set_attributes(void *jcr, char *fname, char *ofile, char *lname, if (type == FT_LNK) { /* Change owner of link, not of real file */ if (lchown(ofile, statp->st_uid, statp->st_gid) < 0) { - Jmsg2(jcr, M_WARNING, 0, "Unable to set file owner %s: ERR=%s\n", + Jmsg2(jcr, M_WARNING, 0, _("Unable to set file owner %s: ERR=%s\n"), ofile, strerror(errno)); stat = 0; } } else { if (chown(ofile, statp->st_uid, statp->st_gid) < 0) { - Jmsg2(jcr, M_WARNING, 0, "Unable to set file owner %s: ERR=%s\n", + Jmsg2(jcr, M_WARNING, 0, _("Unable to set file owner %s: ERR=%s\n"), ofile, strerror(errno)); stat = 0; } if (chmod(ofile, statp->st_mode) < 0) { - Jmsg2(jcr, M_WARNING, 0, "Unable to set file modes %s: ERR=%s\n", + Jmsg2(jcr, M_WARNING, 0, _("Unable to set file modes %s: ERR=%s\n"), ofile, strerror(errno)); stat = 0; } @@ -236,7 +236,7 @@ int set_attributes(void *jcr, char *fname, char *ofile, char *lname, /* FreeBSD user flags */ #ifdef HAVE_CHFLAGS if (chflags(ofile, statp->st_flags) < 0) { - Jmsg2(jcr, M_WARNING, 0, "Unable to set file flags %s: ERR=%s\n", + Jmsg2(jcr, M_WARNING, 0, _("Unable to set file flags %s: ERR=%s\n"), ofile, strerror(errno)); stat = 0; } @@ -245,7 +245,7 @@ int set_attributes(void *jcr, char *fname, char *ofile, char *lname, * Reset file times. */ if (utime(ofile, &ut) < 0) { - Jmsg2(jcr, M_ERROR, 0, "Unable to set file times %s: ERR=%s\n", + Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"), ofile, strerror(errno)); stat = 0; } diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 319cabac2d..42555260e2 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -223,7 +223,7 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, case FT_DIR: Dmsg2(300, "Make dir mode=%o dir=%s\n", new_mode, ofile); if (make_path(jcr, ofile, new_mode, parent_mode, uid, gid, 0, NULL) != 0) { - Jmsg2(jcr, M_ERROR, 0, _("Could not make directory %s: ERR=%s.\n"), + Jmsg2(jcr, M_ERROR, 0, _("Could not make directory %s: ERR=%s\n"), ofile, berror(ofd)); return CF_ERROR; } @@ -239,7 +239,7 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, case FT_NORECURSE: case FT_NOFSCHG: case FT_NOOPEN: - Jmsg2(jcr, M_ERROR, 0, _("Original file %s not saved. Stat=%d\n"), fname, type); + Jmsg2(jcr, M_ERROR, 0, _("Original file %s not saved: type=%d\n"), fname, type); default: Jmsg2(jcr, M_ERROR, 0, _("Unknown file type %d; not restored: %s\n"), type, fname); } @@ -249,7 +249,7 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, /* * Returns: > 0 index into path where last path char is. * 0 no path - * -1 filename is zero + * -1 filename is zero length */ static int separate_path_and_file(void *jcr, char *fname, char *ofile) { diff --git a/bacula/src/findlib/makepath.c b/bacula/src/findlib/makepath.c index 827b240723..74324fc108 100644 --- a/bacula/src/findlib/makepath.c +++ b/bacula/src/findlib/makepath.c @@ -112,11 +112,11 @@ make_dir(void *jcr, const char *dir, const char *dirpath, mode_t mode, int *crea would fail with EEXIST. */ if (stat(dir, &stats)) { - Jmsg(jcr, M_ERROR, 0, "Cannot create directory %s: %s\n", + Jmsg(jcr, M_ERROR, 0, _("Cannot create directory %s: ERR=%s\n"), dirpath, strerror(save_errno)); fail = 1; } else if (!S_ISDIR(stats.st_mode)) { - Jmsg(jcr, M_ERROR, 0, "%s exists but is not a directory\n", quote(dirpath)); + Jmsg(jcr, M_ERROR, 0, _("%s exists but is not a directory\n"), quote(dirpath)); fail = 1; } else { /* DIR (aka DIRPATH) already exists and is a directory. */ @@ -253,7 +253,7 @@ make_path( #endif ) { /* Note, if we are restoring as NON-root, this may not be fatal */ - Jmsg(jcr, M_WARNING, 0, "Cannot change owner and/or group of %s: %s\n", + Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"), quote(dirpath), strerror(errno)); } Dmsg0(300, "Chown done.\n"); @@ -273,7 +273,7 @@ make_path( creating an entry in that directory. This avoids making stat and mkdir process O(n^2) file name components. */ if (cwd.do_chdir && chdir(basename_dir) < 0) { - Jmsg(jcr, M_ERROR, 0, "Cannot chdir to directory, %s: %s\n", + Jmsg(jcr, M_ERROR, 0, _("Cannot chdir to directory, %s: ERR=%s\n"), quote(dirpath), strerror(errno)); umask(oldmask); cleanup(&cwd); @@ -312,7 +312,7 @@ make_path( #endif ) { - Jmsg(jcr, M_WARNING, 0, "Cannot change owner and/or group of %s: %s\n", + Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"), quote(dirpath), strerror(errno)); } } @@ -326,7 +326,7 @@ make_path( Dmsg1(300, "Final chmod mode=%o\n", mode); } if ((mode & ~S_IRWXUGO) && chmod(basename_dir, mode)) { - Jmsg(jcr, M_WARNING, 0, "Cannot change permissions of %s: %s\n", + Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"), quote(dirpath), strerror(errno)); } @@ -341,7 +341,7 @@ make_path( *(p->dirname_end) = '\0'; Dmsg2(300, "Reset parent mode=%o dir=%s\n", parent_mode, dirpath); if (chmod(dirpath, parent_mode)) { - Jmsg(jcr, M_WARNING, 0, "Cannot change permissions of %s: %s\n", + Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"), quote (dirpath), strerror(errno)); } } @@ -351,7 +351,7 @@ make_path( const char *dirpath = argpath; if (!S_ISDIR(stats.st_mode)) { - Jmsg(jcr, M_ERROR, 0, "%s exists but is not a directory\n", quote(dirpath)); + Jmsg(jcr, M_ERROR, 0, _("%s exists but is not a directory\n"), quote(dirpath)); return 1; } @@ -369,11 +369,11 @@ make_path( && errno != EPERM #endif ) { - Jmsg(jcr, M_WARNING, 0, "Cannot change owner and/or group of %s: %s\n", + Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"), quote(dirpath), strerror(errno)); } if (chmod(dirpath, mode)) { - Jmsg(jcr, M_WARNING, 0, "Cannot change permissions of %s: %s\n", + Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"), quote(dirpath), strerror(errno)); } Dmsg2(300, "pathexists chmod mode=%o dir=%s\n", mode, dirpath); diff --git a/bacula/src/version.h b/bacula/src/version.h index b29dda4170..caf7ec56fe 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.31" #define VSTRING "1" -#define BDATE "06 May 2003" -#define LSMDATE "06May03" +#define BDATE "07 May 2003" +#define LSMDATE "07May03" /* Debug flags */ #define DEBUG 1 -- 2.39.5