From 8c02f468c32a202ca3ad81e7544fb36085c7c456 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 7 Aug 2006 09:17:25 +0000 Subject: [PATCH] kes Fix bug #462 incorrect error message printed when client script called from File= was not found. kes Fix bug #558 (waiting for feedback) where Bacula needs too much time to do a rewind on Solaris when no tape is in the drive (Solaris does not have the detailed errno found on Linux). Added Solaris specific code. Note, this may apply to other OSes as well. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3264 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 1 + bacula/src/filed/job.c | 11 +++++++---- bacula/src/lib/berrno.c | 6 +++--- bacula/src/lib/berrno.h | 7 ++++++- bacula/src/lib/bpipe.c | 10 +++++----- bacula/src/lib/runscript.c | 6 +++--- bacula/src/stored/dev.c | 10 ++++++++-- bacula/src/version.h | 6 +++--- bacula/technotes-1.39 | 7 +++++++ 9 files changed, 43 insertions(+), 21 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index be2860a656..2603a3b290 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -31,6 +31,7 @@ Document: Priority: For 1.39: +- Add manpages to the list of directories for make install. - If a job terminates, the DIR connection can close before the Volume info is updated, leaving the File count wrong. - Look at why SIGPIPE during connection can cause seg fault in diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index fb9e3b6bed..6d5fad97ce 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -591,19 +591,22 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese 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) { + berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), - p, strerror(errno)); + p, be.strerror()); + free_pool_memory(fn); return; } + free_pool_memory(fn); while (fgets(buf, sizeof(buf), bpipe->rfd)) { strip_trailing_junk(buf); fileset->incexe->name_list.append(bstrdup(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)); + berrno be; + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. stat=%d: ERR=%s\n"), + p, be.code(stat), be.strerror(stat)); return; } break; diff --git a/bacula/src/lib/berrno.c b/bacula/src/lib/berrno.c index 76641fd49b..2a7109f953 100644 --- a/bacula/src/lib/berrno.c +++ b/bacula/src/lib/berrno.c @@ -12,7 +12,7 @@ * */ /* - Copyright (C) 2004-2005 Kern Sibbald + Copyright (C) 2004-2006 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -56,7 +56,7 @@ const char *berrno::strerror() return _("Unknown error during program execvp"); } } else { - Mmsg(&buf_, _("Child exited with code %d"), stat); + Mmsg(buf_, _("Child exited with code %d"), stat); return buf_; } /* If we drop out here, berrno_ is set to an execvp errno */ @@ -64,7 +64,7 @@ const char *berrno::strerror() } if (berrno_ & b_errno_signal) { stat = (berrno_ & ~b_errno_signal); /* remove bit */ - Mmsg(&buf_, _("Child died from signal %d: %s"), stat, get_signal_name(stat)); + Mmsg(buf_, _("Child died from signal %d: %s"), stat, get_signal_name(stat)); return buf_; } #endif diff --git a/bacula/src/lib/berrno.h b/bacula/src/lib/berrno.h index adeeab0cb7..46a6a3a304 100644 --- a/bacula/src/lib/berrno.h +++ b/bacula/src/lib/berrno.h @@ -5,7 +5,7 @@ * */ /* - Copyright (C) 2004-2005 Kern Sibbald + Copyright (C) 2004-2006 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -19,6 +19,9 @@ */ +/* + * Extra bits set to interpret errno value differently from errno + */ #ifdef HAVE_WIN32 #define b_errno_win32 (1<<29) /* user reserved bit */ #endif @@ -48,6 +51,8 @@ public: const char *strerror(); const char *strerror(int errnum); void set_errno(int errnum); + int code() { return berrno_ & ~(b_errno_exit|b_errno_signal); } + int code(int stat) { return stat & ~(b_errno_exit|b_errno_signal); } }; /* Constructor */ diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index d0fa3aaa79..3f142bb8cb 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -80,8 +80,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode) if (mode_write && pipe(writep) == -1) { save_errno = errno; free(bpipe); - errno = save_errno; free_pool_memory(tprog); + errno = save_errno; return NULL; } if (mode_read && pipe(readp) == -1) { @@ -91,8 +91,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode) close(writep[1]); } free(bpipe); - errno = save_errno; free_pool_memory(tprog); + errno = save_errno; return NULL; } /* Start worker process */ @@ -108,8 +108,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode) close(readp[1]); } free(bpipe); - errno = save_errno; free_pool_memory(tprog); + errno = save_errno; return NULL; case 0: /* child */ @@ -237,7 +237,7 @@ int close_bpipe(BPIPE *bpipe) #ifndef HAVE_WIN32 stat = WTERMSIG(chldstatus); #else -#warning "WTERMSIG undefined in Win32 !!!" + stat = 1; /* fake child status */ #endif Dmsg1(800, "Child died from signal %d\n", stat); stat |= b_errno_signal; /* exit signal returned */ @@ -247,7 +247,7 @@ int close_bpipe(BPIPE *bpipe) stop_child_timer(bpipe->timer_id); } free(bpipe); - Dmsg1(800, "returning stat = %d\n", stat); + Dmsg2(800, "returning stat=%d,%d\n", stat & ~(b_errno_exit|b_errno_signal), stat); return stat; } diff --git a/bacula/src/lib/runscript.c b/bacula/src/lib/runscript.c index aeb99c4e8e..13b6d74e95 100644 --- a/bacula/src/lib/runscript.c +++ b/bacula/src/lib/runscript.c @@ -203,7 +203,7 @@ int RUNSCRIPT::run(JCR *jcr, const char *name) free_pool_memory(ecmd); if (bpipe == NULL) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("%s could not execute. ERR=%s\n"), name, + Jmsg(jcr, M_FATAL, 0, _("Runscript: %s could not execute. ERR=%s\n"), name, be.strerror()); return false; } @@ -217,8 +217,8 @@ int RUNSCRIPT::run(JCR *jcr, const char *name) status = close_bpipe(bpipe); if (status != 0) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("%s returned non-zero status=%d. ERR=%s\n"), name, - status, be.strerror(status)); + Jmsg(jcr, M_FATAL, 0, _("Runscript: %s returned non-zero status=%d. ERR=%s\n"), name, + be.code(status), be.strerror(status)); return false; } return true; diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 0643ff3b4e..f394db043d 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -684,11 +684,18 @@ bool DEVICE::rewind(DCR *dcr) first = false; continue; } +#ifdef HAVE_SUN_OS + if (dev_errno == EIO) { + Mmsg1(errmsg, _("No tape loaded or drive offline on %s.\n"), print_name()); + return false; + } +#else if (dev_errno == EIO && i > 0) { Dmsg0(200, "Sleeping 5 seconds.\n"); bmicrosleep(5, 0); continue; } +#endif Mmsg2(errmsg, _("Rewind error on %s. ERR=%s.\n"), print_name(), be.strerror()); return false; @@ -1617,8 +1624,7 @@ void DEVICE::clrerror(int func) if (errno == ENOTTY || errno == ENOSYS) { /* Function not implemented */ switch (func) { case -1: - Emsg0(M_ABORT, 0, _("Got ENOTTY on read/write!\n")); - break; + break; /* ignore message printed later */ case MTWEOF: msg = "WTWEOF"; capabilities &= ~CAP_EOF; /* turn off feature */ diff --git a/bacula/src/version.h b/bacula/src/version.h index f636ca7472..1acb70209a 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "1.39.18" -#define BDATE "04 August 2006" -#define LSMDATE "04Aug06" +#define VERSION "1.39.19" +#define BDATE "07 August 2006" +#define LSMDATE "07Aug06" #define BYEAR "2006" /* year for copyright messages in progs */ /* Debug flags */ diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 960f7335d6..7d4021b3c9 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,13 @@ Technical notes on version 1.39 General: +07Aug06 +kes Fix bug #462 incorrect error message printed when client script called + from File= was not found. +kes Fix bug #558 (waiting for feedback) where Bacula needs too much time to + do a rewind on Solaris when no tape is in the drive (Solaris does not + have the detailed errno found on Linux). Added Solaris specific code. + Note, this may apply to other OSes as well. 06Aug06 kes Defined BUILDING_CATS in src/cats/cats.h so that *nix builds. dsb Updated rpm spec for 1.39 - updatedb 9 to 10, add new man pages, -- 2.39.5