From e5c4472d1838a0f8c31be5852e782780af9abc3c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 10 May 2003 19:41:29 +0000 Subject: [PATCH] Misc cleanups git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@503 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 11 +++++++++++ bacula/src/dird/ua_label.c | 4 ++-- bacula/src/filed/restore.c | 8 ++++---- bacula/src/findlib/create_file.c | 26 +++++++++++++------------- bacula/src/lib/util.c | 23 ++++++++++++----------- bacula/src/stored/mount.c | 6 ++++-- bacula/src/version.h | 4 ++-- 7 files changed, 48 insertions(+), 34 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 8fcc4af0bd..fb34318d63 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -19,6 +19,17 @@ Testing to do: (painful) For 1.31 release: +- Shell character expansion is failing occassionally. +- One block was orphaned in the SD probably after cancel. +- Test if rewind at end of tape waits for tape to rewind. +- Check if cancel works with FD. +- Error labeling tape from console gets Jmsg error because of no Job. +- Fix the following: + rufus-dir: Max configured use duration exceeded. Marking Volume "MatouBackup" as Used. + rufus-sd: Volume "" previously written, moving to end of data. + rufus-sd: Matou.2003-05-10_10.39.18 Error: I canot write on this volume because: + The number of files mismatch! Volume=1 Catalog=0 + rufus-sd: Matou.2003-05-10_10.39.18 Error: askdir.c:155 NULL Volume name. This shouldn't happen!!! - Properly configure console and gconsole (currently for source not configured for installation). - Fix "access not allowed" for backup of files on WinXP. diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index c424457071..bd6481a91f 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -205,7 +205,7 @@ checkVol: /* Get a new Volume name */ for ( ;; ) { - if (!get_cmd(ua, _("Enter new Volume name: ")) || ua->cmd[0] == '.') { + if (!get_cmd(ua, _("Enter new Volume name: "))) { return 1; } checkName: @@ -234,7 +234,7 @@ checkName: } first = 0; } else { - if (!get_cmd(ua, _("Enter slot (0 for none): ")) || ua->cmd[0] == '.') { + if (!get_cmd(ua, _("Enter slot (0 for none): "))) { return 1; } mr.Slot = atoi(ua->cmd); diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index e3ee694480..b32647b872 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -264,8 +264,9 @@ void do_restore(JCR *jcr) } } - Dmsg1(30, "Outfile=%s\n", ofile); + jcr->num_files_examined++; + Dmsg1(30, "Outfile=%s\n", ofile); extract = FALSE; stat = create_file(jcr, fname, ofile, lname, type, stream, &statp, attribsEx, &bfd, jcr->replace, @@ -294,7 +295,6 @@ void do_restore(JCR *jcr) break; } - jcr->num_files_examined++; /* Data stream */ } else if (stream == STREAM_FILE_DATA || stream == STREAM_SPARSE_DATA) { @@ -429,7 +429,7 @@ extern char *getgroup(gid_t gid); */ static void print_ls_output(JCR *jcr, char *fname, char *lname, int type, struct stat *statp) { - char buf[2000]; + char buf[5000]; char ec1[30]; char *p, *f; int n; @@ -459,6 +459,6 @@ static void print_ls_output(JCR *jcr, char *fname, char *lname, int type, struct } *p++ = '\n'; *p = 0; - Dmsg0(20, buf); + Dmsg1(20, "%s", buf); Jmsg(jcr, M_RESTORED, 0, "%s", buf); } diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 42555260e2..a6d54d6e87 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -137,10 +137,8 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, * execute bit set (i.e. parent_mode), and preserve what already * exists. Normally, this should do nothing. */ - stat = !make_path(jcr, ofile, parent_mode, parent_mode, uid, gid, 1, NULL); - if (stat == 0) { + if (!make_path(jcr, ofile, parent_mode, parent_mode, uid, gid, 1, NULL)) { Dmsg1(0, "Could not make path. %s\n", ofile); - Jmsg1(jcr, M_ERROR, 0, _("Could not make path. %s\n"), ofile); return CF_ERROR; } } @@ -158,7 +156,8 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, } Dmsg1(50, "Create file: %s\n", ofile); if ((bopen(ofd, ofile, mode, S_IRUSR | S_IWUSR)) < 0) { - Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), ofile, berror(ofd)); + Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), + ofile, berror(ofd)); return CF_ERROR; } return CF_EXTRACT; @@ -169,13 +168,15 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, if (S_ISFIFO(statp->st_mode)) { Dmsg1(200, "Restore fifo: %s\n", ofile); if (mkfifo(ofile, statp->st_mode) != 0 && errno != EEXIST) { - Jmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"), ofile, berror(ofd)); + Jmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"), + ofile, strerror(errno)); return CF_ERROR; } } else { Dmsg1(200, "Restore node: %s\n", ofile); if (mknod(ofile, statp->st_mode, statp->st_rdev) != 0 && errno != EEXIST) { - Jmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"), ofile, berror(ofd)); + Jmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"), + ofile, strerror(errno)); return CF_ERROR; } } @@ -190,7 +191,8 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, tid = NULL; } if ((bopen(ofd, ofile, mode, 0)) < 0) { - Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), ofile, berror(ofd)); + Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), + ofile, berror(ofd)); stop_thread_timer(tid); return CF_ERROR; } @@ -204,7 +206,7 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, Dmsg2(130, "FT_LNK should restore: %s -> %s\n", ofile, lname); if (symlink(lname, ofile) != 0 && errno != EEXIST) { Jmsg3(jcr, M_ERROR, 0, _("Could not symlink %s -> %s: ERR=%s\n"), - ofile, lname, berror(ofd)); + ofile, lname, strerror(errno)); return CF_ERROR; } return CF_CREATED; @@ -212,8 +214,8 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname, case FT_LNKSAVED: /* Hard linked, file already saved */ Dmsg2(130, "Hard link %s => %s\n", ofile, lname); if (link(lname, ofile) != 0) { - Jmsg3(jcr, M_ERROR, 0, _("Could not hard link %s ==> %s: ERR=%s\n"), - ofile, lname, berror(ofd)); + Jmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"), + ofile, lname, strerror(errno)); return CF_ERROR; } return CF_CREATED; @@ -222,9 +224,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"), - ofile, berror(ofd)); + if (!make_path(jcr, ofile, new_mode, parent_mode, uid, gid, 0, NULL)) { return CF_ERROR; } return CF_CREATED; diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 6d3e3b6ae9..4b46b247c0 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -436,33 +436,34 @@ int do_shell_expansion(char *name) case 0: /* child */ /* look for shell */ - if ((shellcmd = getenv("SHELL")) == NULL) + if ((shellcmd = getenv("SHELL")) == NULL) { shellcmd = "/bin/sh"; + } close(1); dup(pfd[1]); /* attach pipes to stdin and stdout */ close(2); dup(pfd[1]); for (i = 3; i < 32; i++) /* close everything else */ close(i); strcpy(echout, "echo "); /* form echo command */ - strcat(echout, name); + bstrncat(echout, name, sizeof(echout)); execl(shellcmd, shellcmd, "-c", echout, NULL); /* give to shell */ exit(127); /* shouldn't get here */ default: /* parent */ /* read output from child */ + echout[0] = 0; i = read(pfd[0], echout, sizeof echout); - echout[--i] = 0; /* set end of string */ - /* look for first word or first line. */ - while (--i >= 0) { - if (echout[i] == ' ' || echout[i] == '\n') - echout[i] = 0; /* keep only first one */ + if (i > 0) { + echout[--i] = 0; /* set end of string */ + /* look for first line. */ + while (--i >= 0) { + if (echout[i] == '\n') { + echout[i] = 0; /* keep only first one */ + } + } } - istat = signal(SIGINT, SIG_IGN); - qstat = signal(SIGQUIT, SIG_IGN); /* wait for child to exit */ while ((wpid = wait(&waitstatus)) != pid && wpid != -1) { ; } - signal(SIGINT, istat); - signal(SIGQUIT, qstat); strcpy(name, echout); stat = 1; break; diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 449cc28495..61c31b35ff 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -77,6 +77,9 @@ mount_next_vol: if (!dev_is_tape(dev) || !dev_cap(dev, CAP_ALWAYSOPEN)) { if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) { offline_dev(dev); + } else if (!rewind_dev(dev)) { + Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), + dev_name(dev), strerror_dev(dev)); } close_dev(dev); } @@ -85,8 +88,7 @@ mount_next_vol: if (dev->state & ST_OPENED) { if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) { offline_dev(dev); - } - if (!rewind_dev(dev)) { + } else if (!rewind_dev(dev)) { Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), dev_name(dev), strerror_dev(dev)); } diff --git a/bacula/src/version.h b/bacula/src/version.h index f40a9ce646..e9655e1084 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.31" #define VSTRING "1" -#define BDATE "08 May 2003" -#define LSMDATE "08May03" +#define BDATE "10 May 2003" +#define LSMDATE "10May03" /* Debug flags */ #define DEBUG 1 -- 2.39.5