From 137f3636336f7057cbf709341a773afaea5a2eeb Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 21 Jul 2004 15:39:19 +0000 Subject: [PATCH] Rescue updates + misc git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1484 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 18 +++++------ bacula/src/dird/Makefile.in | 21 ++++++------- bacula/src/filed/filed.c | 2 +- bacula/src/filed/filed.h | 2 +- bacula/src/filed/heartbeat.c | 16 ++++++++-- bacula/src/filed/job.c | 2 +- bacula/src/findlib/attribs.c | 58 ++++++++++++++++++++---------------- bacula/src/findlib/protos.h | 22 +++++++------- bacula/src/stored/append.c | 6 ++-- bacula/src/stored/block.c | 3 +- bacula/src/stored/btape.c | 4 +++ bacula/src/stored/fd_cmds.c | 4 +-- bacula/src/version.h | 4 +-- 13 files changed, 91 insertions(+), 71 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 2f7c3ee53c..95d2455709 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -2,21 +2,12 @@ 14 July 2004 1.35 Items to do: -- Fix GROUP BYs in all SQL. -- Add new DCR calling sequences everywhere in SD. - This will permit simultaneous use of multiple - devices by a single job. -- Make btape release the drive during the "test" append. - Do tape alerts -- see tapealert.txt - Revisit and revise Disaster Recovery (fix SCSI and RAID disk detection) - Document a get out of jail procedure if everything breaks if you lost/broke the Catalog -- do the same for "I know my file is there how do I get it back?". -- Make FD run on Win95 if possible: - The error I when I installed 1.34.2 clients: - The BACULA-FD file is - linked to missing export KERNEL32.DLL:GetFileAttributesExA. - Add better error codes to run_program (10000+) - When passwords do not match, print message that points the user to the doc. @@ -26,7 +17,9 @@ - Look at adding Client run command that will use the port opened by the client. - Fix find_device in stored/dircmd.c:462 -- Make entering multiple Storage names in Dir illegal. +- Add new DCR calling sequences everywhere in SD. + This will permit simultaneous use of multiple + devices by a single job. Documentation to do: (any release a little bit at a time) - Document query file format. @@ -1101,3 +1094,8 @@ Block Position: 0 - Look at Win32 inc problem when new directory added files not saved??? - Require resource names to be unique. - Make sure that all errors from libacl are printed. +- Make FD run on Win95 if possible (not really possible). +- Fix GROUP BYs in all SQL (done by Dan -- thanks) +- Make entering multiple Storage names in Dir illegal. +- Make btape release the drive during the "test" append. + diff --git a/bacula/src/dird/Makefile.in b/bacula/src/dird/Makefile.in index b12a0a51cf..005c756198 100644 --- a/bacula/src/dird/Makefile.in +++ b/bacula/src/dird/Makefile.in @@ -96,16 +96,17 @@ devclean: realclean install: all $(INSTALL_PROGRAM) bacula-dir $(DESTDIR)$(sbindir)/bacula-dir @srcconf=bacula-dir.conf; \ - if test -f ${DESTDIR}${sysconfdir}/$$srcconf; then \ - destconf=$$srcconf.new; \ - echo " ==> Found existing $$srcconf, installing new conf file as $$destconf"; \ - else \ - destconf=$$srcconf; \ - fi; \ - echo "${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf"; \ - ${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf - if test -f ${DESTDIR}${scriptdir}/query.sql; then \ - $(MV) -f ${DESTDIR}${scriptdir}/query.sql ${DESTDIR}${scriptdir}/query.sql.save; \ + if test -f ${DESTDIR}${sysconfdir}/$$srcconf; then \ + destconf=$$srcconf.new; \ + echo " ==> Found existing $$srcconf, installing new conf file as $$destconf"; \ + else \ + destconf=$$srcconf; \ + fi; \ + echo "${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf"; \ + ${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf + @if test -f ${DESTDIR}${scriptdir}/query.sql; then \ + echo " ==> Saving existing query.sql to query.sql.old"; \ + $(MV) -f ${DESTDIR}${scriptdir}/query.sql ${DESTDIR}${scriptdir}/query.sql.old; \ fi ${INSTALL_DATA} query.sql ${DESTDIR}${scriptdir}/query.sql @if test -f static-bacula-dir; then \ diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index 40bb9152c6..3d8e788d22 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -42,6 +42,7 @@ void terminate_filed(int sig); CLIENT *me; /* my resource */ char OK_msg[] = "2000 OK\n"; char TERM_msg[] = "2999 Terminate\n"; +bool no_signals = false; #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) const int win32_client = 1; @@ -91,7 +92,6 @@ static void usage() int main (int argc, char *argv[]) { int ch; - bool no_signals = false; bool test_config = false; DIRRES *director; char *uid = NULL; diff --git a/bacula/src/filed/filed.h b/bacula/src/filed/filed.h index a4a90910c2..99c3045e7c 100644 --- a/bacula/src/filed/filed.h +++ b/bacula/src/filed/filed.h @@ -6,7 +6,7 @@ * Version $Id$ */ /* - Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + Copyright (C) 2000-2004 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/bacula/src/filed/heartbeat.c b/bacula/src/filed/heartbeat.c index 83f090adb9..81a0e39f2e 100644 --- a/bacula/src/filed/heartbeat.c +++ b/bacula/src/filed/heartbeat.c @@ -43,7 +43,7 @@ extern "C" void *sd_heartbeat_thread(void *arg); extern "C" void *dir_heartbeat_thread(void *arg); - +extern bool no_signals; /* * Listen on the SD socket for heartbeat signals. @@ -94,14 +94,24 @@ extern "C" void *sd_heartbeat_thread(void *arg) /* Startup the heartbeat thread -- see above */ void start_heartbeat_monitor(JCR *jcr) { - jcr->hb_bsock = NULL; - pthread_create(&jcr->heartbeat_id, NULL, sd_heartbeat_thread, (void *)jcr); + /* + * If no signals are set, do not start the heartbeat because + * it gives a constant stream of TIMEOUT_SIGNAL signals that + * make debugging impossible. + */ + if (!no_signals) { + jcr->hb_bsock = NULL; + pthread_create(&jcr->heartbeat_id, NULL, sd_heartbeat_thread, (void *)jcr); + } } /* Terminate the heartbeat thread. Used for both SD and DIR */ void stop_heartbeat_monitor(JCR *jcr) { int cnt = 0; + if (no_signals) { + return; + } /* Wait max 10 secs for heartbeat thread to start */ while (jcr->hb_bsock == NULL && cnt++ < 200) { bmicrosleep(0, 50); /* avoid race */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 09ea212958..591a1d6ac2 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1112,7 +1112,6 @@ static int storage_cmd(JCR *jcr) /* Try to connect for 1 hour at 10 second intervals */ sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"), jcr->stored_addr, NULL, stored_port, 1); - Dmsg0(110, "Connection OK to SD.\n"); if (sd == NULL) { Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"), jcr->stored_addr, stored_port); @@ -1120,6 +1119,7 @@ static int storage_cmd(JCR *jcr) jcr->stored_addr, stored_port); return 0; } + Dmsg0(110, "Connection OK to SD.\n"); jcr->store_bsock = sd; diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index 0c6e6cb840..492e5b8024 100755 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -34,7 +34,7 @@ #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) /* Forward referenced subroutines */ -static int set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd); +static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd); void unix_name_to_win32(POOLMEM **win32_name, char *name); void win_error(JCR *jcr, char *prefix, POOLMEM *ofile); HANDLE bget_handle(BFILE *bfd); @@ -284,14 +284,14 @@ int32_t decode_LinkFI(char *buf, struct stat *statp) * fname is the original filename * ofile is the output filename (may be in a different directory) * - * Returns: 1 on success - * 0 on failure + * Returns: true on success + * false on failure */ -int set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) +bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) { struct utimbuf ut; mode_t old_mask; - int stat = 1; + bool ok = true; #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) if (attr->stream == STREAM_UNIX_ATTRIBUTES_EX && @@ -300,7 +300,7 @@ int set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) bclose(ofd); } pm_strcpy(&attr->ofname, "*none*"); - return 1; + return true; } if (attr->data_stream == STREAM_WIN32_DATA || attr->data_stream == STREAM_WIN32_GZIP_DATA) { @@ -308,7 +308,7 @@ int set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) bclose(ofd); } pm_strcpy(&attr->ofname, "*none*"); - return 1; + return true; } @@ -337,40 +337,46 @@ int set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) if (lchown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0) { Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"), attr->ofname, strerror(errno)); - stat = 0; + ok = false; } } else { if (chown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0) { Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"), attr->ofname, strerror(errno)); - stat = 0; + ok = false; } if (chmod(attr->ofname, attr->statp.st_mode) < 0) { Jmsg2(jcr, M_ERROR, 0, _("Unable to set file modes %s: ERR=%s\n"), attr->ofname, strerror(errno)); - stat = 0; + ok = false; } - /* FreeBSD user flags */ -#ifdef HAVE_CHFLAGS - if (chflags(attr->ofname, attr->statp.st_flags) < 0) { - Jmsg2(jcr, M_ERROR, 0, _("Unable to set file flags %s: ERR=%s\n"), - attr->ofname, strerror(errno)); - stat = 0; - } -#endif /* * Reset file times. */ if (utime(attr->ofname, &ut) < 0) { Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"), attr->ofname, strerror(errno)); - stat = 0; + ok = false; + } +#ifdef HAVE_CHFLAGS + /* + * FreeBSD user flags + * + * Note, this should really be done before the utime() above, + * but if the immutable bit is set, it will make the utimes() + * fail. + */ + if (chflags(attr->ofname, attr->statp.st_flags) < 0) { + Jmsg2(jcr, M_ERROR, 0, _("Unable to set file flags %s: ERR=%s\n"), + attr->ofname, strerror(errno)); + ok = false; } +#endif } pm_strcpy(&attr->ofname, "*none*"); umask(old_mask); - return stat; + return ok; } @@ -467,10 +473,10 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt) * fname is the original filename * ofile is the output filename (may be in a different directory) * - * Returns: 1 on success - * 0 on failure + * Returns: true on success + * false on failure */ -static int set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) +static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) { char *p = attr->attrEx; int64_t val; @@ -479,7 +485,7 @@ static int set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) POOLMEM *win32_ofile; if (!p_GetFileAttributesEx) { - return 0; + return false; } if (!p || !*p) { /* we should have attributes */ @@ -487,7 +493,7 @@ static int set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) if (is_bopen(ofd)) { bclose(ofd); } - return 0; + return false; } else { Dmsg2(100, "Attribs %s = %s\n", attr->ofname, attr->attrEx); } @@ -547,7 +553,7 @@ static int set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) } } free_pool_memory(win32_ofile); - return 1; + return true; } void win_error(JCR *jcr, char *prefix, POOLMEM *win32_ofile) diff --git a/bacula/src/findlib/protos.h b/bacula/src/findlib/protos.h index 135c304d46..58566d9cfd 100644 --- a/bacula/src/findlib/protos.h +++ b/bacula/src/findlib/protos.h @@ -23,15 +23,15 @@ */ /* from attribs.c */ -void encode_stat (char *buf, FF_PKT *ff_pkt, int data_stream); -int decode_stat (char *buf, struct stat *statp, int32_t *LinkFI); -int32_t decode_LinkFI (char *buf, struct stat *statp); -int encode_attribsEx (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt); -int set_attributes (JCR *jcr, ATTR *attr, BFILE *ofd); -int select_data_stream(FF_PKT *ff_pkt); +void encode_stat (char *buf, FF_PKT *ff_pkt, int data_stream); +int decode_stat (char *buf, struct stat *statp, int32_t *LinkFI); +int32_t decode_LinkFI (char *buf, struct stat *statp); +int encode_attribsEx (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt); +bool set_attributes (JCR *jcr, ATTR *attr, BFILE *ofd); +int select_data_stream(FF_PKT *ff_pkt); /* from create_file.c */ -int create_file (JCR *jcr, ATTR *attr, BFILE *ofd, int replace); +int create_file (JCR *jcr, ATTR *attr, BFILE *ofd, int replace); /* From find.c */ FF_PKT *init_find_files(); @@ -47,11 +47,11 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname); int file_is_excluded(FF_PKT *ff, const char *file); int file_is_included(FF_PKT *ff, const char *file); struct s_included_file *get_next_included_file(FF_PKT *ff, - struct s_included_file *inc); + struct s_included_file *inc); /* From find_one.c */ int find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt), - void *pkt, char *p, dev_t parent_device, int top_level); + void *pkt, char *p, dev_t parent_device, int top_level); int term_find_one(FF_PKT *ff); @@ -61,7 +61,7 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors); /* from makepath.c */ int make_path(JCR *jcr, const char *argpath, int mode, - int parent_mode, uid_t owner, gid_t group, - int preserve_existing, char *verbose_fmt_string); + int parent_mode, uid_t owner, gid_t group, + int preserve_existing, char *verbose_fmt_string); /* from bfile.c -- see bfile.h */ diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 2a8df378ff..cff97bf8d3 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -37,7 +37,7 @@ static char OK_data[] = "3000 OK data\n"; * Append Data sent from File daemon * */ -int do_append_data(JCR *jcr) +bool do_append_data(JCR *jcr) { int32_t n; int32_t file_index, stream, last_file_index; @@ -56,7 +56,7 @@ int do_append_data(JCR *jcr) if (!bnet_set_buffer_size(ds, jcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_ErrorTerminated); Jmsg(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n")); - return 0; + return false; } /* @@ -67,7 +67,7 @@ int do_append_data(JCR *jcr) Dmsg0(100, "just before acquire_device\n"); if (!(dcr=acquire_device_for_append(jcr))) { set_jcr_job_status(jcr, JS_ErrorTerminated); - return 0; + return false; } dev = dcr->dev; block = dcr->block; diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 0c8f24d440..8e5725adeb 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -566,7 +566,8 @@ bool write_block_to_dev(DCR *dcr, DEV_BLOCK *block) dev->file, dev->block_num, dev->dev_name, strerror(dev->dev_errno)); } else { dev->dev_errno = ENOSPC; /* out of space */ - Jmsg(jcr, M_INFO, 0, _("End of medium at %u:%u on device %s. Write of %u bytes got %d.\n"), + Jmsg(jcr, M_INFO, 0, _("End of Volume \"%s\" at %u:%u on device %s. Write of %u bytes got %d.\n"), + dev->VolCatInfo.VolCatName, dev->file, dev->block_num, dev->dev_name, wlen, stat); } diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index ee168b41e5..674307dbb3 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1002,6 +1002,10 @@ static int append_test() if (dev_cap(dev, CAP_TWOEOF)) { weofcmd(); } + force_close_dev(dev); /* release device */ + if (!open_the_device()) { + return -1; + } rewindcmd(); Pmsg0(0, _("Now moving to end of medium.\n")); eodcmd(); diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index 17e94d8bf5..99ab03a030 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -40,8 +40,8 @@ extern STORES *me; static char ferrmsg[] = "3900 Invalid command\n"; /* Imported functions */ -extern int do_append_data(JCR *jcr); -extern int do_read_data(JCR *jcr); +extern bool do_append_data(JCR *jcr); +extern bool do_read_data(JCR *jcr); /* Forward referenced functions */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 2c8ff5b773..274d86b094 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.35.1" -#define BDATE "18 July 2004" -#define LSMDATE "18Jul04" +#define BDATE "21 July 2004" +#define LSMDATE "21Jul04" /* Debug flags */ #undef DEBUG -- 2.39.5