From: Kern Sibbald Date: Sun, 28 Dec 2003 14:32:58 +0000 (+0000) Subject: Fix conio.c on FreeBSD + fix string concat on FreeBSD X-Git-Tag: Release-1.34.0~201 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2e55358dd94ecb3e22181ace337412aafd776c61;p=bacula%2Fbacula Fix conio.c on FreeBSD + fix string concat on FreeBSD git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@961 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 08a8c16028..ab9da4c99f 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,5 +1,27 @@ 2003-12-xxx Version 1.33 xxNov03 +28Dec03 +- Find commonset of c_iflags that work with FreeBSD tcsetattr on terminals. +- Remove comments from string concatenation -- doesn't work on FreeBSD + compiler. +- Moderately improve bpipe_close() errors. Must rethink status return. +- Eliminate some Emsgs in favor of Jmsgs. +27Dec03 +- Add optional Pool keyword on restore command line. If specified, the pool + used will be restricted to the specified pool. +- "Finish" implementation of JobDefs. +- Fix directory for chmod of cats scripts. +26Dec03 +- Implement foreach_res() #define and start replacing old code. +- Work some more on jobdefs -- more to be done. +- Implement bstrftime_nc() bstrftime with no century. +- Fix static console problem in gnome2 and gnome directories reported by Alan + Brown. +- Add code to test for valid Resource Names. Permitted characters are now + alpha, numeric, colon, period, minus, underscore, space. +- Turnoff some unused code in timers.c +- Start adding code to dev.c to prevent infinite loops if fast forward space + file (MTFSF) is configured on but not properly supported by OS. 24Nov03 - Sort FileSet selection list by CreateTime. - Add "lsmark", and "estimate" to tree routines. diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index 2f6d416573..729c67e3d3 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -1,7 +1,7 @@ Release Notes for Bacula 1.33 - Bacula code: Total files = 281 Total lines = 83,612 (*.h *.c *.in) + Bacula code: Total files = 281 Total lines = 83,815 (*.h *.c *.in) Most Significant Changes since 1.32d - Implement "update slots scan" that reads the volume label(s). @@ -24,6 +24,7 @@ Most Significant Changes since 1.32d tape block, so the tape is not recognized. Other Changes since 1.32d +- Implement conio.c to use in console program -- mini-readline. - Enhance "fill" command of btape -- simpler output. Use -v to cause last block to be dumped after write and after re-read. - Added an autochanger test to the btape "test" command. It is diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index 0bc02354a2..0e50af0334 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -9,6 +9,7 @@ #else #include #include +#include #include #include #include @@ -780,7 +781,7 @@ static void add_esc_smap(char *str, int func) return; } if (tcgetattr(0, &old_term_params) != 0) { - printf(_("conio: Cannot tcgetattr()\n")); + printf("conio: Cannot tcgetattr()\n"); exit(1); } old_term_params_set = true; @@ -789,8 +790,7 @@ static void add_esc_smap(char *str, int func) t.c_cc[VTIME] = 0; t.c_iflag &= ~(BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | ICRNL | IXON | IXOFF | INLCR | IGNCR); - t.c_iflag |= IGNBRK | ISIG; -// t.c_oflag &= ~(OPOST); /* no output processing */ + t.c_iflag |= IGNBRK; t.c_oflag |= ONLCR; t.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL | ICANON | NOFLSH | TOSTOP); @@ -799,13 +799,13 @@ static void add_esc_smap(char *str, int func) printf("Cannot tcsetattr()\n"); } -// signal(SIGQUIT, SIG_IGN); -// signal(SIGHUP, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGHUP, SIG_IGN); // signal(SIGSTOP, SIG_IGN); signal(SIGINT, sigintcatcher); -// signal(SIGWINCH, SIG_IGN); -// signal(SIGQUIT, SIG_IGN); -// signal(SIGCHLD, SIG_IGN); + signal(SIGWINCH, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGCHLD, SIG_IGN); // signal(SIGTSTP, SIG_IGN); if (!termtype) { @@ -894,10 +894,7 @@ static void add_esc_smap(char *str, int func) static int /*FCN*/t_gnc() { - int ch; - - while ((ch=t_getch()) == 0) ; /* get next input character */ - return(ch); + return t_getch(); } @@ -1028,4 +1025,3 @@ static void asdell() { t_send(t_dl); } - diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index 048be2c526..d02a0b44dd 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -231,7 +231,7 @@ char *uar_last_full = "AND JobMedia.MediaId=Media.MediaId " "AND Job.FileSetId=FileSet.FileSetId " "AND FileSet.FileSet='%s' " - "%s" /* dynamically added PoolId selection */ + "%s" "ORDER BY Job.JobTDate DESC LIMIT 1"; char *uar_full = @@ -254,7 +254,7 @@ char *uar_inc_dec = "AND JobMedia.MediaId=Media.MediaId " "AND Job.Level IN ('I', 'D') AND JobStatus='T' " "AND Job.FileSetId=FileSet.FileSetId " - "%s" /* dynamically added PoolId selection */ + "%s" "AND FileSet.FileSet='%s' "; char *uar_list_temp = diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 13485befa1..69039eda49 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -540,7 +540,7 @@ static uint32_t *bget_host_ip(JCR *jcr, char *host) } else { P(ip_mutex); if ((hp = gethostbyname(host)) == NULL) { - Jmsg2(jcr, M_ERROR, 0, "gethostbyname() for %s failed: ERR=%s\n", + Jmsg2(jcr, M_ERROR, 0, "gethostbyname() for host \"%s\" failed: ERR=%s\n", host, gethost_strerror()); V(ip_mutex); return NULL; diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index 1501e18d2c..b5bb3fa0bc 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -132,7 +132,12 @@ int close_wpipe(BPIPE *bpipe) return stat; } -/* Close both pipes and free resources */ +/* + * Close both pipes and free resources + * + * Returns: 0 on success + * errno on failure + */ int close_bpipe(BPIPE *bpipe) { int chldstatus = 0; @@ -176,8 +181,7 @@ int close_bpipe(BPIPE *bpipe) bmicrosleep(1, 0); /* wait one second */ remaining_wait--; } else { - stat = 1; /* set error status */ - errno = ETIME; /* set timed out */ + stat = ETIME; /* set error status */ wpid = -1; break; /* don't wait any longer */ } @@ -185,14 +189,14 @@ int close_bpipe(BPIPE *bpipe) if (wpid > 0) { if (WIFEXITED(chldstatus)) { /* process exit()ed */ stat = WEXITSTATUS(chldstatus); - Dmsg1(200, "status =%d\n", stat); + if (stat != 0) { + stat = ECHILD; + } + Dmsg1(200, "status =%d\n", stat); } else if (WIFSIGNALED(chldstatus)) { /* process died */ - stat = 1; + stat = ECHILD; Dmsg0(200, "Signaled\n"); } - if (stat != 0) { - errno = ECHILD; /* set child errno */ - } } if (bpipe->timer_id) { stop_child_timer(bpipe->timer_id); @@ -211,7 +215,7 @@ int close_bpipe(BPIPE *bpipe) * Contrary to my normal calling conventions, this program * * Returns: 0 on success - * non-zero on error + * non-zero on error == errno */ int run_program(char *prog, int wait, POOLMEM *results) { @@ -222,7 +226,7 @@ int run_program(char *prog, int wait, POOLMEM *results) mode = (char *)(results != NULL ? "r" : ""); bpipe = open_bpipe(prog, wait, mode); if (!bpipe) { - return 0; + return ENOENT; } if (results) { mp_chr(results)[0] = 0; diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index ba4fce000f..43367c9f30 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -477,8 +477,9 @@ void close_msg(JCR *jcr) stat = close_bpipe(bpipe); if (stat != 0 && msgs != daemon_msgs) { Dmsg1(150, "Calling emsg. CMD=%s\n", cmd); - Jmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error. stat=%d\n" - "CMD=%s\n"), stat, cmd); + Jmsg3(jcr, M_ERROR, 0, _("Mail program terminated in error. stat=%d\n" + "CMD=%s\n" + "ERR=%s\n"), stat, cmd, strerror(stat)); } free_memory(line); rem_temp_file: @@ -636,8 +637,9 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) /* Messages to the operator go one at a time */ stat = close_bpipe(bpipe); if (stat != 0) { - Emsg1(M_ERROR, 0, _("Operator mail program terminated in error.\nCMD=%s\n"), - mcmd); + Jmsg2(jcr, M_ERROR, 0, _("Operator mail program terminated in error.\n" + "CMD=%s\n" + "ERR=%s\n"), mcmd, strerror(stat)); } } free_pool_memory(mcmd); @@ -651,7 +653,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) d->fd = fopen(mp_chr(name), "w+"); if (!d->fd) { d->fd = stdout; - Emsg2(M_ERROR, 0, "fopen %s failed: ERR=%s\n", name, strerror(errno)); + Jmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", name, strerror(errno)); d->fd = NULL; free_pool_memory(name); break; @@ -670,7 +672,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) d->fd = fopen(d->where, "w+"); if (!d->fd) { d->fd = stdout; - Emsg2(M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, strerror(errno)); + Jmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, strerror(errno)); d->fd = NULL; break; } @@ -683,7 +685,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) d->fd = fopen(d->where, "a"); if (!d->fd) { d->fd = stdout; - Emsg2(M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, strerror(errno)); + Jmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, strerror(errno)); d->fd = NULL; break; } @@ -744,7 +746,7 @@ d_msg(char *file, int line, int level, char *fmt,...) bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); trace_fd = fopen(buf, "a+"); if (!trace_fd) { - Emsg2(M_ABORT, 0, _("Cannot open %s: ERR=%s\n"), + Emsg2(M_ABORT, 0, _("Cannot open trace file \"%s\": ERR=%s\n"), buf, strerror(errno)); } } @@ -830,7 +832,7 @@ t_msg(char *file, int line, int level, char *fmt,...) bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); trace_fd = fopen(buf, "a+"); if (!trace_fd) { - Emsg2(M_ABORT, 0, _("Cannot open %s: ERR=%s\n"), + Emsg2(M_ABORT, 0, _("Cannot open trace file \"%s\": ERR=%s\n"), buf, strerror(errno)); } } diff --git a/bacula/src/version.h b/bacula/src/version.h index 85b7b71757..07c1431581 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.33" #define VSTRING "1" -#define BDATE "26 Dec 2003" -#define LSMDATE "26Dec03" +#define BDATE "28 Dec 2003" +#define LSMDATE "28Dec03" /* Debug flags */ #undef DEBUG