From c13ff7139c6b13bfa5492903f07a740cb70d0c9c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 6 May 2007 18:25:15 +0000 Subject: [PATCH] kes Start implementing bstrerror() in place of strerror(). kes First cut at stripping path -- seems to work. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4715 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 1 + bacula/src/dird/backup.c | 2 +- bacula/src/dird/bsr.c | 2 +- bacula/src/dird/fd_cmds.c | 8 +-- bacula/src/dird/inc_conf.c | 2 +- bacula/src/dird/job.c | 6 +- bacula/src/dird/jobq.c | 28 ++++---- bacula/src/dird/msgchan.c | 4 +- bacula/src/dird/ua_restore.c | 2 +- bacula/src/dird/ua_server.c | 2 +- bacula/src/dird/verify.c | 2 +- bacula/src/filed/acl.c | 46 ++++++------- bacula/src/filed/backup.c | 112 ++++++++++++++++++++++++++++---- bacula/src/filed/job.c | 14 ++-- bacula/src/filed/restore.c | 6 +- bacula/src/filed/verify.c | 18 ++--- bacula/src/findlib/find.c | 38 ++++++----- bacula/src/findlib/find.h | 2 + bacula/src/findlib/find_one.c | 49 +++++++++----- bacula/src/stored/acquire.c | 2 +- bacula/src/stored/ansi_label.c | 10 +-- bacula/src/stored/append.c | 2 +- bacula/src/stored/autochanger.c | 14 ++-- bacula/src/stored/bextract.c | 14 ++-- bacula/src/stored/block.c | 16 ++--- bacula/src/stored/btape.c | 28 ++++---- bacula/src/stored/dev.c | 90 ++++++++++++------------- bacula/src/stored/device.c | 6 +- bacula/src/stored/dvd.c | 10 +-- bacula/src/stored/parse_bsr.c | 2 +- bacula/src/stored/reserve.c | 6 +- bacula/src/stored/scan.c | 2 +- bacula/src/stored/spool.c | 20 +++--- bacula/src/stored/stored_conf.c | 2 +- bacula/src/stored/wait.c | 2 +- bacula/src/version.h | 4 +- bacula/technotes-2.1 | 3 + 37 files changed, 348 insertions(+), 229 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index a03728d994..ee54fbe148 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -51,6 +51,7 @@ Professional Needs: - Detect state change of system (verify) Priority: +- When Pool specifies Storage command override does not work. - Please mount volume "xxx" on Storage device ... should also list Pool and MediaType in case user needs to create a new volume. - Implement wait_for_sysop() message display in wait_for_device(), which diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 233074af87..6b062a2727 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -569,7 +569,7 @@ void update_bootstrap_file(JCR *jcr) } else { berrno be; Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n" - "%s: ERR=%s\n"), fname, be.strerror()); + "%s: ERR=%s\n"), fname, be.bstrerror()); set_jcr_job_status(jcr, JS_ErrorTerminated); } free_pool_memory(fname); diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index 4b464bf92f..16d4ee6602 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -245,7 +245,7 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) if (!fd) { berrno be; ua->error_msg(_("Unable to create bootstrap file %s. ERR=%s\n"), - fname.c_str(), be.strerror()); + fname.c_str(), be.bstrerror()); goto bail_out; } /* Write them to file */ diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 0f6ef13500..9d95ce50c2 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -352,7 +352,7 @@ static bool send_fileset(JCR *jcr) if (!bpipe) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), - p, be.strerror()); + p, be.bstrerror()); goto bail_out; } bstrncpy(buf, "F ", sizeof(buf)); @@ -369,7 +369,7 @@ static bool send_fileset(JCR *jcr) if ((stat=close_bpipe(bpipe)) != 0) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. ERR=%s\n"), - p, be.strerror(stat)); + p, be.bstrerror(stat)); goto bail_out; } break; @@ -378,7 +378,7 @@ static bool send_fileset(JCR *jcr) if ((ffd = fopen(p, "rb")) == NULL) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"), - p, be.strerror()); + p, be.bstrerror()); goto bail_out; } bstrncpy(buf, "F ", sizeof(buf)); @@ -473,7 +473,7 @@ bool send_bootstrap_file(JCR *jcr, BSOCK *sock) if (!bs) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), - jcr->RestoreBootstrap, be.strerror()); + jcr->RestoreBootstrap, be.bstrerror()); set_jcr_job_status(jcr, JS_ErrorTerminated); return false; } diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 14260597d5..19651f6f1f 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -276,7 +276,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen); } else if (keyword == INC_KW_STRIPPATH) { /* another special case */ if (!is_an_integer(lc->str)) { - scan_err1(lc, _("Expected a strip path integer, got:%s:"), lc->str); + scan_err1(lc, _("Expected a strip path positive integer, got:%s:"), lc->str); } bstrncat(opts, "P", optlen); /* indicate strip path */ bstrncat(opts, lc->str, optlen); diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index c76a1d7d8c..1edfd23c25 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -59,7 +59,7 @@ void init_job_server(int max_workers) if ((stat = jobq_init(&job_queue, max_workers, job_thread)) != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Could not init job queue: ERR=%s\n"), be.strerror(stat)); + Emsg1(M_ABORT, 0, _("Could not init job queue: ERR=%s\n"), be.bstrerror(stat)); } wd = new_watchdog(); wd->callback = job_monitor_watchdog; @@ -91,7 +91,7 @@ JobId_t run_job(JCR *jcr) /* Queue the job to be run */ if ((stat = jobq_add(&job_queue, jcr)) != 0) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Could not add job queue: ERR=%s\n"), be.strerror(stat)); + Jmsg(jcr, M_FATAL, 0, _("Could not add job queue: ERR=%s\n"), be.bstrerror(stat)); return 0; } return jcr->JobId; @@ -110,7 +110,7 @@ bool setup_job(JCR *jcr) /* Initialize termination condition variable */ if ((errstat = pthread_cond_init(&jcr->term_wait, NULL)) != 0) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.strerror(errstat)); + Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat)); goto bail_out; } jcr->term_wait_inited = true; diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index d811bda771..eb1c05639a 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -72,7 +72,7 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg)) if ((stat = pthread_attr_init(&jq->attr)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_attr_init: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_attr_init: ERR=%s\n"), be.bstrerror(stat)); return stat; } if ((stat = pthread_attr_setdetachstate(&jq->attr, PTHREAD_CREATE_DETACHED)) != 0) { @@ -81,13 +81,13 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg)) } if ((stat = pthread_mutex_init(&jq->mutex, NULL)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_init: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_init: ERR=%s\n"), be.bstrerror(stat)); pthread_attr_destroy(&jq->attr); return stat; } if ((stat = pthread_cond_init(&jq->work, NULL)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_init: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_init: ERR=%s\n"), be.bstrerror(stat)); pthread_mutex_destroy(&jq->mutex); pthread_attr_destroy(&jq->attr); return stat; @@ -120,7 +120,7 @@ int jobq_destroy(jobq_t *jq) } if ((stat = pthread_mutex_lock(&jq->mutex)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.bstrerror(stat)); return stat; } jq->valid = 0; /* prevent any more operations */ @@ -133,7 +133,7 @@ int jobq_destroy(jobq_t *jq) if (jq->idle_workers) { if ((stat = pthread_cond_broadcast(&jq->work)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_broadcast: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_broadcast: ERR=%s\n"), be.bstrerror(stat)); pthread_mutex_unlock(&jq->mutex); return stat; } @@ -141,7 +141,7 @@ int jobq_destroy(jobq_t *jq) while (jq->num_workers > 0) { if ((stat = pthread_cond_wait(&jq->work, &jq->mutex)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_wait: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_wait: ERR=%s\n"), be.bstrerror(stat)); pthread_mutex_unlock(&jq->mutex); return stat; } @@ -149,7 +149,7 @@ int jobq_destroy(jobq_t *jq) } if ((stat = pthread_mutex_unlock(&jq->mutex)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_unlock: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_unlock: ERR=%s\n"), be.bstrerror(stat)); return stat; } stat = pthread_mutex_destroy(&jq->mutex); @@ -225,7 +225,7 @@ int jobq_add(jobq_t *jq, JCR *jcr) /* Initialize termination condition variable */ if ((stat = pthread_cond_init(&jcr->term_wait, NULL)) != 0) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.strerror(stat)); + Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(stat)); return stat; } jcr->term_wait_inited = true; @@ -247,14 +247,14 @@ int jobq_add(jobq_t *jq, JCR *jcr) stat = pthread_create(&id, &jq->attr, sched_wait, (void *)sched_pkt); if (stat != 0) { /* thread not created */ berrno be; - Jmsg1(jcr, M_ERROR, 0, _("pthread_thread_create: ERR=%s\n"), be.strerror(stat)); + Jmsg1(jcr, M_ERROR, 0, _("pthread_thread_create: ERR=%s\n"), be.bstrerror(stat)); } return stat; } if ((stat = pthread_mutex_lock(&jq->mutex)) != 0) { berrno be; - Jmsg1(jcr, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.strerror(stat)); + Jmsg1(jcr, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.bstrerror(stat)); free_jcr(jcr); /* release jcr */ return stat; } @@ -319,7 +319,7 @@ int jobq_remove(jobq_t *jq, JCR *jcr) if ((stat = pthread_mutex_lock(&jq->mutex)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.bstrerror(stat)); return stat; } @@ -365,7 +365,7 @@ static int start_server(jobq_t *jq) Dmsg0(2300, "Signal worker to wake up\n"); if ((stat = pthread_cond_broadcast(&jq->work)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_signal: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_signal: ERR=%s\n"), be.bstrerror(stat)); return stat; } } else if (jq->num_workers < jq->max_workers) { @@ -374,7 +374,7 @@ static int start_server(jobq_t *jq) set_thread_concurrency(jq->max_workers + 1); if ((stat = pthread_create(&id, &jq->attr, jobq_server, (void *)jq)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_create: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_create: ERR=%s\n"), be.bstrerror(stat)); return stat; } } @@ -400,7 +400,7 @@ void *jobq_server(void *arg) Dmsg0(2300, "Start jobq_server\n"); if ((stat = pthread_mutex_lock(&jq->mutex)) != 0) { berrno be; - Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.strerror(stat)); + Jmsg1(NULL, M_ERROR, 0, _("pthread_mutex_lock: ERR=%s\n"), be.bstrerror(stat)); return NULL; } jq->num_workers++; diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index c03460aea5..cfacd1fbf5 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -322,7 +322,7 @@ bool start_storage_daemon_message_thread(JCR *jcr) Dmsg0(100, "Start SD msg_thread.\n"); if ((status=pthread_create(&thid, NULL, msg_thread, (void *)jcr)) != 0) { berrno be; - Jmsg1(jcr, M_ABORT, 0, _("Cannot create message thread: %s\n"), be.strerror(status)); + Jmsg1(jcr, M_ABORT, 0, _("Cannot create message thread: %s\n"), be.bstrerror(status)); } /* Wait for thread to start */ while (jcr->SD_msg_chan == 0) { @@ -470,7 +470,7 @@ void init_device_resources() Dmsg0(100, "Start Device thread.\n"); if ((status=pthread_create(&thid, NULL, device_thread, NULL)) != 0) { berrno be; - Jmsg1(NULL, M_ABORT, 0, _("Cannot create message thread: %s\n"), be.strerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Cannot create message thread: %s\n"), be.bstrerror(status)); } } #endif diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index e39db95151..9915136b65 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -813,7 +813,7 @@ static void insert_one_file_or_dir(UAContext *ua, RESTORE_CTX *rx, char *date, b if ((ffd = fopen(p, "rb")) == NULL) { berrno be; ua->error_msg(_("Cannot open file %s: ERR=%s\n"), - p, be.strerror()); + p, be.bstrerror()); break; } while (fgets(file, sizeof(file), ffd)) { diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index 5d50184b1a..bc9c54e9ef 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -69,7 +69,7 @@ void start_UA_server(dlist *addrs) if ((status=pthread_create(&thid, NULL, connect_thread, (void *)myaddrs)) != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Cannot create UA thread: %s\n"), be.strerror(status)); + Emsg1(M_ABORT, 0, _("Cannot create UA thread: %s\n"), be.bstrerror(status)); } started = TRUE; return; diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 8f6b84a776..ddce0354ca 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -721,7 +721,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) if (is_bnet_error(fd)) { berrno be; Jmsg2(jcr, M_FATAL, 0, _("bdirdlast_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl_to_text error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); acl_free(acl); #ifndef HAVE_OSF1_OS /* BACL_ENOTSUP not defined for OSF1 */ } else if (errno == BACL_ENOTSUP) { @@ -212,7 +212,7 @@ int bacl_set(JCR *jcr, int acltype) } berrno be; Jmsg2(jcr, M_ERROR, 0, _("acl_delete_def_file error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); return -1; } @@ -220,9 +220,9 @@ int bacl_set(JCR *jcr, int acltype) if (acl == NULL) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("acl_from_text error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl_from_text error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); return -1; } @@ -234,9 +234,9 @@ int bacl_set(JCR *jcr, int acltype) if (acl_valid(acl) != 0) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("ac_valid error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl_valid error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); acl_free(acl); return -1; } @@ -249,9 +249,9 @@ int bacl_set(JCR *jcr, int acltype) if (acl_set_file(jcr->last_fname, ostype, acl) != 0 && jcr->last_type != FT_LNK) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("acl_set_file error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl_set_file error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); acl_free(acl); return -1; } @@ -283,9 +283,9 @@ int bacl_get(JCR *jcr, int acltype) } berrno be; Jmsg2(jcr, M_ERROR, 0, _("acltostr error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acltostr error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); return -1; } return -1; @@ -300,17 +300,17 @@ int bacl_set(JCR *jcr, int acltype) if (n <= 0) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("strtoacl error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "strtoacl error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); return -1; } if (strtoacl(jcr->acl_text, n, NACLENTRIES, acls, ACL_FILEOWNER, ACL_FILEGROUP) != n) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("strtoacl error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "strtoacl error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); return -1; } /* @@ -320,9 +320,9 @@ int bacl_set(JCR *jcr, int acltype) if (setacl(jcr->last_fname, n, acls) != 0 && jcr->last_type != FT_LNK) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("setacl error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "setacl error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); return -1; } return 0; @@ -356,9 +356,9 @@ int bacl_get(JCR *jcr, int acltype) } berrno be; Jmsg2(jcr, M_ERROR, 0, _("acltotext error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acltotext error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); } free(acls); return -1; @@ -373,9 +373,9 @@ int bacl_set(JCR *jcr, int acltype) if (!acls) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("aclfromtext error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "aclfromtext error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); return -1; } /* @@ -385,9 +385,9 @@ int bacl_set(JCR *jcr, int acltype) if (acl(jcr->last_fname, SETACL, n, acls) == -1 && jcr->last_type != FT_LNK) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("acl(SETACL) error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl(SETACL) error acl=%s file=%s ERR=%s\n", - jcr->acl_text, jcr->last_fname, be.strerror()); + jcr->acl_text, jcr->last_fname, be.bstrerror()); actuallyfree(acls); return -1; } diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 4a38ef4867..ca770df552 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -40,6 +40,8 @@ /* Forward referenced functions */ static int save_file(FF_PKT *ff_pkt, void *pkt, bool top_level); +static void strip_path(FF_PKT *ff_pkt); +static void unstrip_path(FF_PKT *ff_pkt); static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, DIGEST *signature_digest); static bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream); static bool read_and_send_acl(JCR *jcr, int acltype, int stream); @@ -290,21 +292,21 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) case FT_NOACCESS: { berrno be; Jmsg(jcr, M_NOTSAVED, 0, _(" Could not access %s: ERR=%s\n"), ff_pkt->fname, - be.strerror(ff_pkt->ff_errno)); + be.bstrerror(ff_pkt->ff_errno)); jcr->Errors++; return 1; } case FT_NOFOLLOW: { berrno be; - Jmsg(jcr, M_NOTSAVED, 0, _(" Could not follow link %s: ERR=%s\n"), ff_pkt->fname, - be.strerror(ff_pkt->ff_errno)); + Jmsg(jcr, M_NOTSAVED, 0, _(" Could not follow link %s: ERR=%s\n"), + ff_pkt->fname, be.bstrerror(ff_pkt->ff_errno)); jcr->Errors++; return 1; } case FT_NOSTAT: { berrno be; Jmsg(jcr, M_NOTSAVED, 0, _(" Could not stat %s: ERR=%s\n"), ff_pkt->fname, - be.strerror(ff_pkt->ff_errno)); + be.bstrerror(ff_pkt->ff_errno)); jcr->Errors++; return 1; } @@ -317,13 +319,14 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) return 1; case FT_NOOPEN: { berrno be; - Jmsg(jcr, M_NOTSAVED, 0, _(" Could not open directory %s: ERR=%s\n"), ff_pkt->fname, - be.strerror(ff_pkt->ff_errno)); + Jmsg(jcr, M_NOTSAVED, 0, _(" Could not open directory %s: ERR=%s\n"), + ff_pkt->fname, be.bstrerror(ff_pkt->ff_errno)); jcr->Errors++; return 1; } default: - Jmsg(jcr, M_NOTSAVED, 0, _(" Unknown file type %d; not saved: %s\n"), ff_pkt->type, ff_pkt->fname); + Jmsg(jcr, M_NOTSAVED, 0, _(" Unknown file type %d; not saved: %s\n"), + ff_pkt->type, ff_pkt->fname); jcr->Errors++; return 1; } @@ -450,7 +453,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) ff_pkt->ff_errno = errno; berrno be; Jmsg(jcr, M_NOTSAVED, 0, _(" Cannot open %s: ERR=%s.\n"), ff_pkt->fname, - be.strerror()); + be.bstrerror()); jcr->Errors++; if (tid) { stop_thread_timer(tid); @@ -486,8 +489,8 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) if (!bopen_rsrc(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { ff_pkt->ff_errno = errno; berrno be; - Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), ff_pkt->fname, - be.strerror()); + Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), + ff_pkt->fname, be.bstrerror()); jcr->Errors++; if (is_bopen(&ff_pkt->bfd)) { bclose(&ff_pkt->bfd); @@ -896,7 +899,7 @@ int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, if (sd->msglen < 0) { /* error */ berrno be; Jmsg(jcr, M_ERROR, 0, _("Read error on file %s. ERR=%s\n"), - ff_pkt->fname, be.strerror(ff_pkt->bfd.berrno)); + ff_pkt->fname, be.bstrerror(ff_pkt->bfd.berrno)); if (jcr->Errors++ > 1000) { /* insanity check */ Jmsg(jcr, M_FATAL, 0, _("Too many errors.\n")); } @@ -1016,6 +1019,7 @@ static bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_strea return true; #endif + Dmsg1(300, "encode_and_send_attrs fname=%s\n", ff_pkt->fname); /* Find what data stream we will use, then encode the attributes */ if ((data_stream = select_data_stream(ff_pkt)) == STREAM_NONE) { /* This should not happen */ @@ -1058,6 +1062,7 @@ static bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_strea * For a directory, link is the same as fname, but with trailing * slash. For a linked file, link is the link. */ + strip_path(ff_pkt); if (ff_pkt->type == FT_LNK || ff_pkt->type == FT_LNKSAVED) { Dmsg2(300, "Link %s to %s\n", ff_pkt->fname, ff_pkt->link); stat = bnet_fsend(sd, "%ld %d %s%c%s%c%s%c%s%c", jcr->JobFiles, @@ -1071,6 +1076,7 @@ static bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_strea stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0); } + unstrip_path(ff_pkt); Dmsg2(300, ">stored: attr len=%d: %s\n", sd->msglen, sd->msg); if (!stat) { @@ -1081,3 +1087,87 @@ static bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_strea bnet_sig(sd, BNET_EOD); /* indicate end of attributes data */ return true; } + +/* + * Do in place strip of path + */ +static bool do_strip(int count, char *in) +{ + char *out = in; + int stripped; + int numsep = 0; + + /* Copy to first path separator -- Win32 might have c: ... */ + while (*in && !IsPathSeparator(*in)) { + *out++ = *in++; + } + *out++ = *in++; + numsep++; /* one separator seen */ + for (stripped=0; strippedcount=%d\n", + stripped, count, numsep, numsep>count); + return stripped==count && numsep>count; +} + +/* + * If requested strip leading components of the path + */ +static void strip_path(FF_PKT *ff_pkt) +{ + if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) { + Dmsg1(200, "No strip for %s\n", ff_pkt->fname); + return; + } + if (!ff_pkt->fname_save) { + ff_pkt->fname_save = get_pool_memory(PM_FNAME); + ff_pkt->link_save = get_pool_memory(PM_FNAME); + } + pm_strcpy(ff_pkt->fname_save, ff_pkt->fname); + + /* + * Strip path. If it doesn't succeed put it back. If + * it does, and there is a different link string, + * attempt to strip the link. If it fails, but them + * both back. + * I.e. if either stripping fails don't strip anything. + */ + if (do_strip(ff_pkt->strip_path, ff_pkt->fname)) { + if (ff_pkt->fname != ff_pkt->link) { + pm_strcpy(ff_pkt->link_save, ff_pkt->link); + if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { + strcpy(ff_pkt->link, ff_pkt->link_save); + strcpy(ff_pkt->fname, ff_pkt->fname_save); + } + } + } else { + strcpy(ff_pkt->fname, ff_pkt->fname_save); + } + Dmsg2(200, "fname=%s stripped=%s\n", ff_pkt->fname_save, ff_pkt->fname); +} + +static void unstrip_path(FF_PKT *ff_pkt) +{ + if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) { + return; + } + strcpy(ff_pkt->fname, ff_pkt->fname_save); + if (ff_pkt->fname != ff_pkt->link) { + strcpy(ff_pkt->link, ff_pkt->link_save); + } +} diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 5d41d55a30..10eb7fb32e 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -628,7 +628,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese if (!bpipe) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), - p, be.strerror()); + p, be.bstrerror()); free_pool_memory(fn); return; } @@ -640,7 +640,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese if ((stat=close_bpipe(bpipe)) != 0) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. stat=%d: ERR=%s\n"), - p, be.code(stat), be.strerror(stat)); + p, be.code(stat), be.bstrerror(stat)); return; } break; @@ -650,7 +650,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese if ((ffd = fopen(p, "rb")) == NULL) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), - p, be.strerror()); + p, be.bstrerror()); return; } while (fgets(buf, sizeof(buf), ffd)) { @@ -1012,6 +1012,7 @@ static void set_options(findFOPTS *fo, const char *opts) break; case 'P': /* strip path */ /* Get integer */ + p++; /* skip P */ for (j=0; *p && *p != ':'; p++) { strip[j] = *p; if (j < (int)sizeof(strip) - 1) { @@ -1021,6 +1022,7 @@ static void set_options(findFOPTS *fo, const char *opts) strip[j] = 0; fo->strip_path = atoi(strip); fo->flags |= FO_STRIPPATH; + Dmsg2(100, "strip=%s strip_path=%d\n", strip, fo->strip_path); break; case 'w': fo->flags |= FO_IF_NEWER; @@ -1109,7 +1111,7 @@ static int bootstrap_cmd(JCR *jcr) if (!bs) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"), - jcr->RestoreBootstrap, be.strerror()); + jcr->RestoreBootstrap, be.bstrerror()); /* * Suck up what he is sending to us so that he will then * read our error message. @@ -1406,7 +1408,7 @@ static int backup_cmd(JCR *jcr) } } else { berrno be; - Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.strerror()); + Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.bstrerror()); } } #endif @@ -1810,7 +1812,7 @@ static int send_bootstrap_file(JCR *jcr) if (!bs) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), - jcr->RestoreBootstrap, be.strerror()); + jcr->RestoreBootstrap, be.bstrerror()); set_jcr_job_status(jcr, JS_ErrorTerminated); goto bail_out; } diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 8a81fe6c4d..6f5cf607c7 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -884,7 +884,7 @@ bool sparse_data(JCR *jcr, BFILE *bfd, uint64_t *addr, char **data, uint32_t *le berrno be; Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), edit_uint64(*addr, ec1), jcr->last_fname, - be.strerror(bfd->berrno)); + be.bstrerror(bfd->berrno)); return false; } } @@ -939,13 +939,13 @@ bool store_data(JCR *jcr, BFILE *bfd, char *data, const int32_t length, bool win if (!processWin32BackupAPIBlock(bfd, data, length)) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("Write error in Win32 Block Decomposition on %s: %s\n"), - jcr->last_fname, be.strerror(bfd->berrno)); + jcr->last_fname, be.bstrerror(bfd->berrno)); return false; } } else if (bwrite(bfd, data, length) != (ssize_t)length) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), - jcr->last_fname, be.strerror(bfd->berrno)); + jcr->last_fname, be.bstrerror(bfd->berrno)); return false; } diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index 126ef80fed..711d4427e5 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -119,21 +119,21 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt, bool top_level) case FT_NOACCESS: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 1, _(" Could not access %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); + Jmsg(jcr, M_NOTSAVED, 1, _(" Could not access %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror()); jcr->Errors++; return 1; } case FT_NOFOLLOW: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 1, _(" Could not follow link %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); + Jmsg(jcr, M_NOTSAVED, 1, _(" Could not follow link %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror()); jcr->Errors++; return 1; } case FT_NOSTAT: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 1, _(" Could not stat %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); + Jmsg(jcr, M_NOTSAVED, 1, _(" Could not stat %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror()); jcr->Errors++; return 1; } @@ -154,7 +154,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt, bool top_level) case FT_NOOPEN: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 1, _(" Could not open directory %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); + Jmsg(jcr, M_NOTSAVED, 1, _(" Could not open directory %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror()); jcr->Errors++; return 1; } @@ -295,9 +295,9 @@ int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest) ff_pkt->ff_errno = errno; berrno be; be.set_errno(bfd.berrno); - Dmsg2(100, "Cannot open %s: ERR=%s\n", ff_pkt->fname, be.strerror()); + Dmsg2(100, "Cannot open %s: ERR=%s\n", ff_pkt->fname, be.bstrerror()); Jmsg(jcr, M_ERROR, 1, _(" Cannot open %s: ERR=%s.\n"), - ff_pkt->fname, be.strerror()); + ff_pkt->fname, be.bstrerror()); return 1; } read_digest(&bfd, digest, jcr); @@ -311,7 +311,7 @@ int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest) ff_pkt->ff_errno = errno; berrno be; Jmsg(jcr, M_ERROR, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), - ff_pkt->fname, be.strerror()); + ff_pkt->fname, be.bstrerror()); if (is_bopen(&ff_pkt->bfd)) { bclose(&ff_pkt->bfd); } @@ -347,9 +347,9 @@ int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr) if (n < 0) { berrno be; be.set_errno(bfd->berrno); - Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->last_fname, be.strerror()); + Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->last_fname, be.bstrerror()); Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"), - jcr->last_fname, be.strerror()); + jcr->last_fname, be.bstrerror()); jcr->Errors++; return -1; } diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index a90bd9c23f..e77b4d2094 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -1,14 +1,3 @@ -/* - * Main routine for finding files on a file system. - * The heart of the work to find the files on the - * system is done in find_one.c. Here we have the - * higher level control as well as the matching - * routines for the new syntax Options resource. - * - * Kern E. Sibbald, MM - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution @@ -36,6 +25,17 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Main routine for finding files on a file system. + * The heart of the work to find the files on the + * system is done in find_one.c. Here we have the + * higher level control as well as the matching + * routines for the new syntax Options resource. + * + * Kern E. Sibbald, MM + * + * Version $Id$ + */ #include "bacula.h" @@ -411,10 +411,16 @@ static int our_callback(FF_PKT *ff, void *hpkt, bool top_level) int term_find_files(FF_PKT *ff) { - int hard_links; + int hard_links; - free_pool_memory(ff->sys_fname); - hard_links = term_find_one(ff); - free(ff); - return hard_links; + free_pool_memory(ff->sys_fname); + if (ff->fname_save) { + free_pool_memory(ff->fname_save); + } + if (ff->link_save) { + free_pool_memory(ff->link_save); + } + hard_links = term_find_one(ff); + free(ff); + return hard_links; } diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 6172182f37..6fc90fed0f 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -197,6 +197,8 @@ struct FF_PKT { char *fname; /* full filename */ char *link; /* link if file linked */ POOLMEM *sys_fname; /* system filename */ + POOLMEM *fname_save; /* save when stripping path */ + POOLMEM *link_save; /* save when stripping path */ struct stat statp; /* stat packet */ int32_t FileIndex; /* FileIndex of this file */ int32_t LinkFI; /* FileIndex of main hard linked file */ diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 84792fa0ea..47b877b820 100644 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -84,11 +84,42 @@ static inline int LINKHASH(const struct stat &info) return hash & LINK_HASHTABLE_MASK; } +/* + * Create a new directory Find File packet, but copy + * some of the essential info from the current packet. + * However, be careful to zero out the rest of the + * packet. + */ +static FF_PKT *new_dir_ff_pkt(FF_PKT *ff_pkt) +{ + FF_PKT *dir_ff_pkt = (FF_PKT *)bmalloc(sizeof(FF_PKT)); + memcpy(dir_ff_pkt, ff_pkt, sizeof(FF_PKT)); + dir_ff_pkt->fname = bstrdup(ff_pkt->fname); + dir_ff_pkt->link = bstrdup(ff_pkt->link); + dir_ff_pkt->sys_fname = get_pool_memory(PM_FNAME); + dir_ff_pkt->included_files_list = NULL; + dir_ff_pkt->excluded_files_list = NULL; + dir_ff_pkt->excluded_paths_list = NULL; + dir_ff_pkt->linkhash = NULL; + dir_ff_pkt->fname_save = NULL; + dir_ff_pkt->link_save = NULL; + return dir_ff_pkt; +} + +/* + * Free the temp directory ff_pkt + */ static void free_dir_ff_pkt(FF_PKT *dir_ff_pkt) { free(dir_ff_pkt->fname); free(dir_ff_pkt->link); free_pool_memory(dir_ff_pkt->sys_fname); + if (dir_ff_pkt->fname_save) { + free_pool_memory(dir_ff_pkt->fname_save); + } + if (dir_ff_pkt->link_save) { + free_pool_memory(dir_ff_pkt->link_save); + } free(dir_ff_pkt); } @@ -332,14 +363,6 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, } #endif -/* ***FIXME*** implement this */ -#if xxxxxxx - /* See if we are trying to dump the archive. */ - if (ar_dev && ff_pkt->statp.st_dev == ar_dev && ff_pkt->statp.st_ino == ar_ino) { - ff_pkt->type = FT_ISARCH; - return handle_file(ff_pkt, pkt, top_level); - } -#endif ff_pkt->LinkFI = 0; /* * Handle hard linked files @@ -515,15 +538,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, * be reset after all the files have been restored. */ Dmsg1(300, "Create temp ff packet for dir: %s\n", ff_pkt->fname); - FF_PKT *dir_ff_pkt = (FF_PKT *)bmalloc(sizeof(FF_PKT)); - memcpy(dir_ff_pkt, ff_pkt, sizeof(FF_PKT)); - dir_ff_pkt->fname = bstrdup(ff_pkt->fname); - dir_ff_pkt->link = bstrdup(ff_pkt->link); - dir_ff_pkt->sys_fname = get_pool_memory(PM_FNAME); - dir_ff_pkt->included_files_list = NULL; - dir_ff_pkt->excluded_files_list = NULL; - dir_ff_pkt->excluded_paths_list = NULL; - dir_ff_pkt->linkhash = NULL; + FF_PKT *dir_ff_pkt = new_dir_ff_pkt(ff_pkt); /* * Do not descend into subdirectories (recurse) if the diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 8a312307a3..c83149328e 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -548,7 +548,7 @@ bool release_device(DCR *dcr) if (status != 0) { berrno be; Jmsg(jcr, M_ALERT, 0, _("3997 Bad alert command: %s: ERR=%s.\n"), - alert, be.strerror(status)); + alert, be.bstrerror(status)); } Dmsg1(400, "alert status=%d\n", status); diff --git a/bacula/src/stored/ansi_label.c b/bacula/src/stored/ansi_label.c index 76005940a0..e688f5fd20 100644 --- a/bacula/src/stored/ansi_label.c +++ b/bacula/src/stored/ansi_label.c @@ -92,9 +92,9 @@ int read_ansi_ibm_label(DCR *dcr) if (stat < 0) { berrno be; dev->clrerror(-1); - Dmsg1(100, "Read device got: ERR=%s\n", be.strerror()); + Dmsg1(100, "Read device got: ERR=%s\n", be.bstrerror()); Mmsg2(jcr->errmsg, _("Read error on device %s in ANSI label. ERR=%s\n"), - dev->dev_name, be.strerror()); + dev->dev_name, be.bstrerror()); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); dev->VolCatInfo.VolCatErrors++; return VOL_IO_ERROR; @@ -313,7 +313,7 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) if (stat != sizeof(label)) { berrno be; Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI VOL1 label. ERR=%s\n"), - be.strerror()); + be.bstrerror()); return false; } } @@ -351,7 +351,7 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) } if (dev->dev_errno != ENOSPC) { Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label. ERR=%s\n"), - be.strerror()); + be.bstrerror()); return false; } } else { @@ -380,7 +380,7 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) } if (dev->dev_errno != ENOSPC) { Jmsg1(jcr, M_FATAL, 0, _("Could not write ANSI HDR1 label. ERR=%s\n"), - be.strerror()); + be.bstrerror()); return false; } dev->weof(1); diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 78c8524369..a137788ce2 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -119,7 +119,7 @@ bool do_append_data(JCR *jcr) if (!bnet_fsend(fd_sock, OK_data)) { berrno be; Jmsg1(jcr, M_FATAL, 0, _("Network send error to FD. ERR=%s\n"), - be.strerror(fd_sock->b_errno)); + be.bstrerror(fd_sock->b_errno)); ok = false; } diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 6a2309c67d..ea79fcc778 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -197,10 +197,10 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir) berrno be; be.set_errno(status); Dmsg3(100, "load slot %d, drive %d, bad stats=%s.\n", slot, drive, - be.strerror()); + be.bstrerror()); Jmsg(jcr, M_FATAL, 0, _("3992 Bad autochanger \"load slot %d, drive %d\": " "ERR=%s.\nResults=%s\n"), - slot, drive, be.strerror(), results.c_str()); + slot, drive, be.bstrerror(), results.c_str()); rtn_stat = -1; /* hard error */ dev->Slot = -1; /* mark unknown */ } @@ -280,7 +280,7 @@ int get_autochanger_loaded_slot(DCR *dcr) berrno be; be.set_errno(status); Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded? drive %d\" command: " - "ERR=%s.\nResults=%s\n"), drive, be.strerror(), results.c_str()); + "ERR=%s.\nResults=%s\n"), drive, be.bstrerror(), results.c_str()); loaded = -1; /* force unload */ } unlock_changer(dcr); @@ -354,7 +354,7 @@ bool unload_autochanger(DCR *dcr, int loaded) be.set_errno(stat); Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": " "ERR=%s\nResults=%s\n"), - loaded, dev->drive_index, be.strerror(), results.c_str()); + loaded, dev->drive_index, be.bstrerror(), results.c_str()); ok = false; dev->Slot = -1; /* unknown */ } else { @@ -451,10 +451,10 @@ static bool unload_other_drive(DCR *dcr, int slot) berrno be; be.set_errno(stat); Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"), - slot, dev->drive_index, be.strerror()); + slot, dev->drive_index, be.bstrerror()); Dmsg3(100, "Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n", - slot, dev->drive_index, be.strerror()); + slot, dev->drive_index, be.bstrerror()); ok = false; dev->Slot = -1; /* unknown */ } else { @@ -540,7 +540,7 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd) if (stat != 0) { berrno be; be.set_errno(stat); - bnet_fsend(dir, _("Autochanger error: ERR=%s\n"), be.strerror()); + bnet_fsend(dir, _("Autochanger error: ERR=%s\n"), be.bstrerror()); } bnet_sig(dir, BNET_EOD); ok = true; diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 051be3d1ab..d53dc45569 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -135,7 +135,7 @@ int main (int argc, char *argv[]) if ((fd = fopen(optarg, "rb")) == NULL) { berrno be; Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"), - optarg, be.strerror()); + optarg, be.bstrerror()); exit(1); } while (fgets(line, sizeof(line), fd) != NULL) { @@ -150,7 +150,7 @@ int main (int argc, char *argv[]) if ((fd = fopen(optarg, "rb")) == NULL) { berrno be; Pmsg2(0, _("Could not open include file: %s, ERR=%s\n"), - optarg, be.strerror()); + optarg, be.bstrerror()); exit(1); } while (fgets(line, sizeof(line), fd) != NULL) { @@ -237,7 +237,7 @@ static void do_extract(char *devname) if (stat(where, &statp) < 0) { berrno be; Emsg2(M_ERROR_TERM, 0, _("Cannot stat %s. It must exist. ERR=%s\n"), - where, be.strerror()); + where, be.bstrerror()); } if (!S_ISDIR(statp.st_mode)) { Emsg1(M_ERROR_TERM, 0, _("%s must be a directory.\n"), where); @@ -358,7 +358,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) if (blseek(&bfd, (boffset_t)fileAddr, SEEK_SET) < 0) { berrno be; Emsg2(M_ERROR_TERM, 0, _("Seek error on %s: %s\n"), - attr->ofname, be.strerror()); + attr->ofname, be.bstrerror()); } } } else { @@ -370,7 +370,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) { berrno be; Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), - attr->ofname, be.strerror()); + attr->ofname, be.bstrerror()); } fileAddr += wsize; } @@ -398,7 +398,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) if (blseek(&bfd, (boffset_t)fileAddr, SEEK_SET) < 0) { berrno be; Emsg3(M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), - edit_uint64(fileAddr, ec1), attr->ofname, be.strerror()); + edit_uint64(fileAddr, ec1), attr->ofname, be.bstrerror()); extract = false; return true; } @@ -420,7 +420,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) berrno be; Pmsg0(0, _("===Write error===\n")); Emsg2(M_ERROR, 0, _("Write error on %s: %s\n"), - attr->ofname, be.strerror()); + attr->ofname, be.bstrerror()); extract = false; return true; } diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index a2dd5a01cb..db36345cf3 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -533,7 +533,7 @@ bool write_block_to_dev(DCR *dcr) if (retry > 0 && stat == -1 && errno == EBUSY) { berrno be; Dmsg4(100, "===== write retry=%d stat=%d errno=%d: ERR=%s\n", - retry, stat, errno, be.strerror()); + retry, stat, errno, be.bstrerror()); bmicrosleep(5, 0); /* pause a bit if busy or lots of errors */ dev->clrerror(-1); } @@ -563,7 +563,7 @@ bool write_block_to_dev(DCR *dcr) if (dev->dev_errno != ENOSPC) { dev->VolCatInfo.VolCatErrors++; Jmsg4(jcr, M_ERROR, 0, _("Write error at %u:%u on device %s. ERR=%s.\n"), - dev->file, dev->block_num, dev->print_name(), be.strerror()); + dev->file, dev->block_num, dev->print_name(), be.bstrerror()); } } else { dev->dev_errno = ENOSPC; /* out of space */ @@ -646,20 +646,20 @@ static void reread_last_block(DCR *dcr) berrno be; ok = false; Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), - be.strerror(dev->dev_errno)); + be.bstrerror(dev->dev_errno)); } if (ok && dev->has_cap(CAP_TWOEOF) && !dev->bsf(1)) { berrno be; ok = false; Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), - be.strerror(dev->dev_errno)); + be.bstrerror(dev->dev_errno)); } /* Backspace over record */ if (ok && !dev->bsr(1)) { berrno be; ok = false; Jmsg(jcr, M_ERROR, 0, _("Backspace record at EOT failed. ERR=%s\n"), - be.strerror(dev->dev_errno)); + be.bstrerror(dev->dev_errno)); /* * On FreeBSD systems, if the user got here, it is likely that his/her * tape drive is "frozen". The correct thing to do is a @@ -971,7 +971,7 @@ reread: if ((retry > 0 && stat == -1 && errno == EBUSY)) { berrno be; Dmsg4(100, "===== read retry=%d stat=%d errno=%d: ERR=%s\n", - retry, stat, errno, be.strerror()); + retry, stat, errno, be.bstrerror()); bmicrosleep(10, 0); /* pause a bit if busy or lots of errors */ dev->clrerror(-1); } @@ -981,10 +981,10 @@ reread: if (stat < 0) { berrno be; dev->clrerror(-1); - Dmsg1(200, "Read device got: ERR=%s\n", be.strerror()); + Dmsg1(200, "Read device got: ERR=%s\n", be.bstrerror()); block->read_len = 0; Mmsg5(dev->errmsg, _("Read error on fd=%d at file:blk %u:%u on device %s. ERR=%s.\n"), - dev->fd(), dev->file, dev->block_num, dev->print_name(), be.strerror()); + dev->fd(), dev->file, dev->block_num, dev->print_name(), be.bstrerror()); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); if (dev->at_eof()) { /* EOF just seen? */ dev->set_eot(); /* yes, error => EOT */ diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 4f4560475d..6637b947b7 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -749,13 +749,13 @@ static int re_read_block_test() Pmsg0(0, _("Backspace record OK.\n")); if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) { berrno be; - Pmsg1(0, _("Read block failed! ERR=%s\n"), be.strerror(dev->dev_errno)); + Pmsg1(0, _("Read block failed! ERR=%s\n"), be.bstrerror(dev->dev_errno)); goto bail_out; } memset(rec->data, 0, rec->data_len); if (!read_record_from_block(dcr, block, rec)) { berrno be; - Pmsg1(0, _("Read block failed! ERR=%s\n"), be.strerror(dev->dev_errno)); + Pmsg1(0, _("Read block failed! ERR=%s\n"), be.bstrerror(dev->dev_errno)); goto bail_out; } for (int i=0; idev_errno)); + Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, be.bstrerror(dev->dev_errno)); goto bail_out; } memset(rec->data, 0, rec->data_len); if (!read_record_from_block(dcr, block, rec)) { berrno be; - Pmsg2(0, _("Read record failed. Block %d! ERR=%s\n"), i, be.strerror(dev->dev_errno)); + Pmsg2(0, _("Read record failed. Block %d! ERR=%s\n"), i, be.bstrerror(dev->dev_errno)); goto bail_out; } p = (int *)rec->data; @@ -1017,7 +1017,7 @@ read_again: } } Pmsg4(0, _("Read block %d failed! file=%d blk=%d. ERR=%s\n\n"), - recno, file, blk, be.strerror(dev->dev_errno)); + recno, file, blk, be.bstrerror(dev->dev_errno)); Pmsg0(0, _("This may be because the tape drive block size is not\n" " set to variable blocking as normally used by Bacula.\n" " Please see the Tape Testing chapter in the manual and \n" @@ -1034,7 +1034,7 @@ read_again: memset(rec->data, 0, rec->data_len); if (!read_record_from_block(dcr, block, rec)) { berrno be; - Pmsg1(0, _("Read record failed! ERR=%s\n"), be.strerror(dev->dev_errno)); + Pmsg1(0, _("Read record failed! ERR=%s\n"), be.bstrerror(dev->dev_errno)); goto bail_out; } p = (int *)rec->data; @@ -1168,7 +1168,7 @@ try_again: } else { berrno be; Pmsg1(-1, _("3991 Bad autochanger command: %s\n"), changer); - Pmsg2(-1, _("3991 result=\"%s\": ERR=%s\n"), results, be.strerror(status)); + Pmsg2(-1, _("3991 result=\"%s\": ERR=%s\n"), results, be.bstrerror(status)); goto bail_out; } if (loaded) { @@ -1190,7 +1190,7 @@ try_again: if (status != 0) { berrno be; Pmsg1(-1, _("3992 Bad autochanger command: %s\n"), changer); - Pmsg2(-1, _("3992 result=\"%s\": ERR=%s\n"), results, be.strerror(status)); + Pmsg2(-1, _("3992 result=\"%s\": ERR=%s\n"), results, be.bstrerror(status)); } } @@ -1213,7 +1213,7 @@ try_again: } else { berrno be; Pmsg1(-1, _("3993 Bad autochanger command: %s\n"), changer); - Pmsg2(-1, _("3993 result=\"%s\": ERR=%s\n"), results, be.strerror(status)); + Pmsg2(-1, _("3993 result=\"%s\": ERR=%s\n"), results, be.bstrerror(status)); goto bail_out; } @@ -1602,7 +1602,7 @@ static void rrcmd() } berrno be; Pmsg3(0, _("Read of %d bytes gives stat=%d. ERR=%s\n"), - len, stat, be.strerror()); + len, stat, be.bstrerror()); free(buf); } @@ -1635,7 +1635,7 @@ static void scancmd() berrno be; dev->clrerror(-1); Mmsg2(dev->errmsg, _("read error on %s. ERR=%s.\n"), - dev->dev_name, be.strerror()); + dev->dev_name, be.bstrerror()); Pmsg2(0, _("Bad status from read %d. ERR=%s\n"), stat, dev->bstrerror()); if (blocks > 0) { if (blocks==1) { @@ -2047,7 +2047,7 @@ static void fillcmd() } else { berrno be; Pmsg2(-1, _("Could not create state file: %s ERR=%s\n"), buf, - be.strerror()); + be.bstrerror()); } now = time(NULL); @@ -2104,7 +2104,7 @@ static void unfillcmd() } else { berrno be; Pmsg2(-1, _("\nCould not find the state file: %s ERR=%s\n" - "You must redo the fill command.\n"), buf, be.strerror()); + "You must redo the fill command.\n"), buf, be.bstrerror()); return; } do_unfill(); @@ -2518,7 +2518,7 @@ static void rawfill_cmd() printf("\n"); berrno be; printf(_("Write failed at block %u. stat=%d ERR=%s\n"), block_num, stat, - be.strerror(my_errno)); + be.bstrerror(my_errno)); weofcmd(); } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 143eaab021..34e7d225fe 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -123,7 +123,7 @@ init_dev(JCR *jcr, DEVRES *device) if (stat(device->device_name, &statp) < 0) { berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to stat device %s: ERR=%s\n"), - device->device_name, be.strerror()); + device->device_name, be.bstrerror()); return NULL; } if (S_ISDIR(statp.st_mode)) { @@ -193,7 +193,7 @@ init_dev(JCR *jcr, DEVRES *device) berrno be; dev->dev_errno = errno; Jmsg2(jcr, M_ERROR_TERM, 0, _("Unable to stat mount point %s: ERR=%s\n"), - device->mount_point, be.strerror()); + device->mount_point, be.bstrerror()); } } if (dev->is_dvd()) { @@ -221,32 +221,32 @@ init_dev(JCR *jcr, DEVRES *device) if ((errstat = pthread_mutex_init(&dev->m_mutex, NULL)) != 0) { berrno be; dev->dev_errno = errstat; - Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.strerror(errstat)); + Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = pthread_cond_init(&dev->wait, NULL)) != 0) { berrno be; dev->dev_errno = errstat; - Mmsg1(dev->errmsg, _("Unable to init cond variable: ERR=%s\n"), be.strerror(errstat)); + Mmsg1(dev->errmsg, _("Unable to init cond variable: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = pthread_cond_init(&dev->wait_next_vol, NULL)) != 0) { berrno be; dev->dev_errno = errstat; - Mmsg1(dev->errmsg, _("Unable to init cond variable: ERR=%s\n"), be.strerror(errstat)); + Mmsg1(dev->errmsg, _("Unable to init cond variable: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } if ((errstat = pthread_mutex_init(&dev->spool_mutex, NULL)) != 0) { berrno be; dev->dev_errno = errstat; - Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.strerror(errstat)); + Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } #ifdef xxx if ((errstat = rwl_init(&dev->lock)) != 0) { berrno be; dev->dev_errno = errstat; - Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.strerror(errstat)); + Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } #endif @@ -379,7 +379,7 @@ void DEVICE::open_tape_device(DCR *dcr, int omode) berrno be; dev_errno = errno; Dmsg5(050, "Open error on %s omode=%d mode=%x errno=%d: ERR=%s\n", - print_name(), omode, mode, errno, be.strerror()); + print_name(), omode, mode, errno, be.bstrerror()); } else { /* Tape open, now rewind it */ Dmsg0(050, "Rewind after open\n"); @@ -392,7 +392,7 @@ void DEVICE::open_tape_device(DCR *dcr, int omode) ::close(m_fd); clear_opened(); Dmsg2(100, "Rewind error on %s close: ERR=%s\n", print_name(), - be.strerror(dev_errno)); + be.bstrerror(dev_errno)); /* If we get busy, device is probably rewinding, try again */ if (dev_errno != EBUSY) { break; /* error -- no medium */ @@ -405,7 +405,7 @@ void DEVICE::open_tape_device(DCR *dcr, int omode) berrno be; dev_errno = errno; Dmsg5(050, "Open error on %s omode=%d mode=%x errno=%d: ERR=%s\n", - print_name(), omode, mode, errno, be.strerror()); + print_name(), omode, mode, errno, be.bstrerror()); break; } dev_errno = 0; @@ -425,7 +425,7 @@ void DEVICE::open_tape_device(DCR *dcr, int omode) if (!is_open()) { berrno be; Mmsg2(errmsg, _("Unable to open device %s: ERR=%s\n"), - print_name(), be.strerror(dev_errno)); + print_name(), be.bstrerror(dev_errno)); Dmsg1(100, "%s", errmsg); } @@ -483,7 +483,7 @@ void DEVICE::open_file_device(DCR *dcr, int omode) berrno be; dev_errno = errno; Mmsg2(errmsg, _("Could not open: %s, ERR=%s\n"), archive_name.c_str(), - be.strerror()); + be.bstrerror()); Dmsg1(29, "open failed: %s", errmsg); Emsg0(M_FATAL, 0, errmsg); } else { @@ -597,7 +597,7 @@ void DEVICE::open_dvd_device(DCR *dcr, int omode) if (stat(part1_name.c_str(), &statp) < 0) { berrno be; Mmsg(errmsg, _("Unable to stat DVD part 1 file %s: ERR=%s\n"), - part1_name.c_str(), be.strerror()); + part1_name.c_str(), be.bstrerror()); Emsg0(M_FATAL, 0, errmsg); clear_opened(); return; @@ -651,7 +651,7 @@ void DEVICE::open_dvd_device(DCR *dcr, int omode) if ((m_fd = ::open(archive_name.c_str(), mode, 0640)) < 0) { berrno be; Mmsg2(errmsg, _("Could not open: %s, ERR=%s\n"), archive_name.c_str(), - be.strerror()); + be.bstrerror()); // Should this be set if we try the create/open below dev_errno = EIO; /* Interpreted as no device present by acquire.c:acquire_device_for_read(). */ Dmsg1(29, "open failed: %s", errmsg); @@ -681,7 +681,7 @@ void DEVICE::open_dvd_device(DCR *dcr, int omode) berrno be; dev_errno = errno; Mmsg2(errmsg, _("Could not fstat: %s, ERR=%s\n"), archive_name.c_str(), - be.strerror()); + be.bstrerror()); Dmsg1(29, "open failed: %s", errmsg); /* Use system close() */ ::close(m_fd); @@ -732,7 +732,7 @@ bool DEVICE::rewind(DCR *dcr) berrno be; clrerror(MTREW); if (i == max_rewind_wait) { - Dmsg1(200, "Rewind error, %s. retrying ...\n", be.strerror()); + Dmsg1(200, "Rewind error, %s. retrying ...\n", be.bstrerror()); } /* * This is a gross hack, because if the user has the @@ -764,7 +764,7 @@ bool DEVICE::rewind(DCR *dcr) } #endif Mmsg2(errmsg, _("Rewind error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } break; @@ -774,7 +774,7 @@ bool DEVICE::rewind(DCR *dcr) berrno be; dev_errno = errno; Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } } @@ -890,7 +890,7 @@ bool DEVICE::eod(DCR *dcr) dev_errno = errno; berrno be; Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } #ifdef MTEOM @@ -923,10 +923,10 @@ bool DEVICE::eod(DCR *dcr) if (tape_ioctl(m_fd, MTIOCTOP, (char *)&mt_com) < 0) { berrno be; clrerror(mt_com.mt_op); - Dmsg1(50, "ioctl error: %s\n", be.strerror()); + Dmsg1(50, "ioctl error: %s\n", be.bstrerror()); update_pos(dcr); Mmsg2(errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } @@ -935,7 +935,7 @@ bool DEVICE::eod(DCR *dcr) berrno be; clrerror(-1); Mmsg2(errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } Dmsg1(100, "EOD file=%d\n", os_file); @@ -1025,9 +1025,9 @@ bool DEVICE::update_pos(DCR *dcr) if (pos < 0) { berrno be; dev_errno = errno; - Pmsg1(000, _("Seek error: ERR=%s\n"), be.strerror()); + Pmsg1(000, _("Seek error: ERR=%s\n"), be.bstrerror()); Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); ok = false; } else { file_addr = pos; @@ -1068,7 +1068,7 @@ uint32_t status_dev(DEVICE *dev) berrno be; dev->dev_errno = errno; Mmsg2(dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"), - dev->print_name(), be.strerror()); + dev->print_name(), be.bstrerror()); return 0; } Pmsg0(-20, _(" Device status:")); @@ -1182,7 +1182,7 @@ bool load_dev(DEVICE *dev) berrno be; dev->dev_errno = ENOTTY; /* function not available */ Mmsg2(dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"), - dev->print_name(), be.strerror()); + dev->print_name(), be.bstrerror()); return false; #else @@ -1195,7 +1195,7 @@ bool load_dev(DEVICE *dev) berrno be; dev->dev_errno = errno; Mmsg2(dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"), - dev->print_name(), be.strerror()); + dev->print_name(), be.bstrerror()); return false; } return true; @@ -1226,7 +1226,7 @@ bool DEVICE::offline() berrno be; dev_errno = errno; Mmsg2(errmsg, _("ioctl MTOFFL error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } Dmsg1(100, "Offlined device %s\n", print_name()); @@ -1303,7 +1303,7 @@ bool DEVICE::fsf(int num) Dmsg0(200, "Set ST_EOT\n"); clrerror(MTFSF); Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); Dmsg1(200, "%s", errmsg); return false; } @@ -1347,9 +1347,9 @@ bool DEVICE::fsf(int num) set_eot(); clrerror(-1); Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev_errno, - be.strerror()); + be.bstrerror()); Mmsg2(errmsg, _("read error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); Dmsg1(100, "%s", errmsg); break; } @@ -1378,7 +1378,7 @@ bool DEVICE::fsf(int num) Dmsg0(100, "Set ST_EOT\n"); clrerror(MTFSF); Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); Dmsg0(100, "Got < 0 for MTFSF\n"); Dmsg1(100, "%s", errmsg); } else { @@ -1450,7 +1450,7 @@ bool DEVICE::bsf(int num) berrno be; clrerror(MTBSF); Mmsg2(errmsg, _("ioctl MTBSF error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); } return stat == 0; } @@ -1493,7 +1493,7 @@ bool DEVICE::fsr(int num) berrno be; struct mtget mt_stat; clrerror(MTFSR); - Dmsg1(100, "FSF fail: ERR=%s\n", be.strerror()); + Dmsg1(100, "FSF fail: ERR=%s\n", be.bstrerror()); if (dev_get_os_pos(this, &mt_stat)) { Dmsg4(100, "Adjust from %d:%d to %d:%d\n", file, block_num, mt_stat.mt_fileno, mt_stat.mt_blkno); @@ -1507,7 +1507,7 @@ bool DEVICE::fsr(int num) } } Mmsg3(errmsg, _("ioctl MTFSR %d error on %s. ERR=%s.\n"), - num, print_name(), be.strerror()); + num, print_name(), be.bstrerror()); } return stat == 0; } @@ -1549,7 +1549,7 @@ bool DEVICE::bsr(int num) berrno be; clrerror(MTBSR); Mmsg2(errmsg, _("ioctl MTBSR error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); } return stat == 0; } @@ -1596,7 +1596,7 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock) berrno be; dev_errno = errno; Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } file = rfile; @@ -1639,7 +1639,7 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock) berrno be; dev_errno = errno; Dmsg2(30, "Failed to find requested block on %s: ERR=%s", - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } Dmsg2(300, "moving forward wanted_blk=%d at_blk=%d\n", rblock, block_num); @@ -1692,7 +1692,7 @@ bool DEVICE::weof(int num) clrerror(MTWEOF); if (stat == -1) { Mmsg2(errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); } } return stat == 0; @@ -1825,7 +1825,7 @@ void DEVICE::clrerror(int func) /* Read and clear SCSI error status */ union mterrstat mt_errstat; Dmsg2(200, "Doing MTIOCERRSTAT errno=%d ERR=%s\n", dev_errno, - be.strerror(dev_errno)); + be.bstrerror(dev_errno)); tape_ioctl(m_fd, MTIOCERRSTAT, (char *)&mt_errstat); } #endif @@ -1956,7 +1956,7 @@ bool DEVICE::truncate(DCR *dcr) /* We need the DCR for DVD-writing */ if (ftruncate(m_fd, 0) != 0) { berrno be; Mmsg2(errmsg, _("Unable to truncate device %s. ERR=%s\n"), - print_name(), be.strerror()); + print_name(), be.bstrerror()); return false; } return true; @@ -2053,9 +2053,9 @@ bool DEVICE::do_mount(int mount, int dotimeout) if (status != 0) { berrno be; Dmsg5(40, "Device %s cannot be %smounted. stat=%d result=%s ERR=%s\n", print_name(), - (mount ? "" : "un"), status, results, be.strerror(status)); + (mount ? "" : "un"), status, results, be.bstrerror(status)); Mmsg(errmsg, _("Device %s cannot be %smounted. ERR=%s\n"), - print_name(), (mount ? "" : "un"), be.strerror(status)); + print_name(), (mount ? "" : "un"), be.bstrerror(status)); } else { Dmsg4(40, "Device %s cannot be %smounted. stat=%d ERR=%s\n", print_name(), (mount ? "" : "un"), status, results); @@ -2080,7 +2080,7 @@ bool DEVICE::do_mount(int mount, int dotimeout) berrno be; dev_errno = errno; Dmsg3(29, "do_mount: failed to open dir %s (dev=%s), ERR=%s\n", - device->mount_point, print_name(), be.strerror()); + device->mount_point, print_name(), be.bstrerror()); goto get_out; } @@ -2468,7 +2468,7 @@ void set_os_device_parameters(DCR *dcr) berrno be; dev->dev_errno = errno; /* save errno */ Mmsg2(dev->errmsg, _("Unable to set eotmodel on device %s: ERR=%s\n"), - dev->print_name(), be.strerror(dev->dev_errno)); + dev->print_name(), be.bstrerror(dev->dev_errno)); Jmsg(dcr->jcr, M_FATAL, 0, dev->errmsg); } #endif diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index b654f28cd5..5ac20e7a68 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -145,7 +145,7 @@ bool fixup_device_block_write_error(DCR *dcr) if (!write_block_to_dev(dcr)) { berrno be; Pmsg1(0, _("write_block_to_device Volume label failed. ERR=%s"), - be.strerror(dev->dev_errno)); + be.bstrerror(dev->dev_errno)); free_block(label_blk); dcr->block = block; unblock_device(dev); @@ -181,7 +181,7 @@ bool fixup_device_block_write_error(DCR *dcr) if (!write_block_to_dev(dcr)) { berrno be; Pmsg1(0, _("write_block_to_device overflow block failed. ERR=%s"), - be.strerror(dev->dev_errno)); + be.bstrerror(dev->dev_errno)); unblock_device(dev); return false; /* device locked */ } @@ -414,7 +414,7 @@ void DEVICE::r_dlock() berrno be; this->dunlock(); Emsg1(M_ABORT, 0, _("pthread_cond_wait failure. ERR=%s\n"), - be.strerror(stat)); + be.bstrerror(stat)); } } this->num_waiting--; /* no longer waiting */ diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index a739e320a1..3413850bf8 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -144,7 +144,7 @@ bool DEVICE::update_freespace() free_space_errno = EPIPE; clear_freespace_ok(); /* no valid freespace */ Mmsg2(errmsg, _("Cannot run free space command. Results=%s ERR=%s\n"), - results, be.strerror(status)); + results, be.bstrerror(status)); if (--timeout > 0) { Dmsg4(40, "Cannot get free space on device %s. free_space=%s, " @@ -376,7 +376,7 @@ int dvd_open_next_part(DCR *dcr) dev->set_part_spooled(false); dev->dev_errno = errno; Mmsg2(dev->errmsg, _("open_next_part can't unlink existing part %s, ERR=%s\n"), - archive_name.c_str(), be.strerror()); + archive_name.c_str(), be.bstrerror()); return -1; } } @@ -720,7 +720,7 @@ bool check_can_write_on_non_blank_dvd(DCR *dcr) berrno be; dev->dev_errno = errno; Dmsg3(29, "check_can_write_on_non_blank_dvd: failed to open dir %s (dev=%s), ERR=%s\n", - dev->device->mount_point, dev->print_name(), be.strerror()); + dev->device->mount_point, dev->print_name(), be.bstrerror()); return false; } @@ -747,7 +747,7 @@ bool check_can_write_on_non_blank_dvd(DCR *dcr) berrno be; dev->dev_errno = errno; Dmsg2(29, "check_can_write_on_non_blank_dvd: cannot stat file (file=%s), ERR=%s\n", - filename.c_str(), be.strerror()); + filename.c_str(), be.bstrerror()); ok = false; break; } @@ -796,7 +796,7 @@ int find_num_dvd_parts(DCR *dcr) berrno be; dev->dev_errno = errno; Dmsg3(29, "find_num_dvd_parts: failed to open dir %s (dev=%s), ERR=%s\n", - dev->device->mount_point, dev->print_name(), be.strerror()); + dev->device->mount_point, dev->print_name(), be.bstrerror()); goto get_out; } diff --git a/bacula/src/stored/parse_bsr.c b/bacula/src/stored/parse_bsr.c index 31cc8930f8..9bd28ebc71 100644 --- a/bacula/src/stored/parse_bsr.c +++ b/bacula/src/stored/parse_bsr.c @@ -142,7 +142,7 @@ BSR *parse_bsr(JCR *jcr, char *fname) if ((lc = lex_open_file(lc, fname, s_err)) == NULL) { berrno be; Emsg2(M_ERROR_TERM, 0, _("Cannot open bootstrap file %s: %s\n"), - fname, be.strerror()); + fname, be.bstrerror()); } lc->caller_ctx = (void *)jcr; while ((token=lex_get_token(lc, T_ALL)) != T_EOF) { diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 0e5e810a20..7511c54576 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -86,7 +86,7 @@ void init_reservations_lock() if ((errstat=rwl_init(&reservation_lock)) != 0) { berrno be; Emsg1(M_ABORT, 0, _("Unable to initialize reservation lock. ERR=%s\n"), - be.strerror(errstat)); + be.bstrerror(errstat)); } } @@ -106,7 +106,7 @@ void _lock_reservations() if ((errstat=rwl_writelock(&reservation_lock)) != 0) { berrno be; Emsg2(M_ABORT, 0, "rwl_writelock failure. stat=%d: ERR=%s\n", - errstat, be.strerror(errstat)); + errstat, be.bstrerror(errstat)); } } @@ -117,7 +117,7 @@ void _unlock_reservations() if ((errstat=rwl_writeunlock(&reservation_lock)) != 0) { berrno be; Emsg2(M_ABORT, 0, "rwl_writeunlock failure. stat=%d: ERR=%s\n", - errstat, be.strerror(errstat)); + errstat, be.bstrerror(errstat)); } } diff --git a/bacula/src/stored/scan.c b/bacula/src/stored/scan.c index 137cc91670..655ee2924c 100644 --- a/bacula/src/stored/scan.c +++ b/bacula/src/stored/scan.c @@ -75,7 +75,7 @@ bool DEVICE::scan_dir_for_volume(DCR *dcr) berrno be; dev_errno = errno; Dmsg3(29, "scan_dir_for_vol: failed to open dir %s (dev=%s), ERR=%s\n", - mount_point, print_name(), be.strerror()); + mount_point, print_name(), be.bstrerror()); goto get_out; } diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index c38104c868..7e9d57e9cf 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -168,7 +168,7 @@ static bool open_data_spool_file(DCR *dcr) } else { berrno be; Jmsg(dcr->jcr, M_FATAL, 0, _("Open data spool file %s failed: ERR=%s\n"), name, - be.strerror()); + be.bstrerror()); free_pool_memory(name); return false; } @@ -306,7 +306,7 @@ static bool despool_data(DCR *dcr, bool commit) if (ftruncate(rdcr->spool_fd, 0) != 0) { berrno be; Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"), - be.strerror()); + be.bstrerror()); /* Note, try continuing despite ftruncate problem */ } @@ -361,7 +361,7 @@ static int read_block_from_spool_file(DCR *dcr) if (stat == -1) { berrno be; Jmsg(dcr->jcr, M_FATAL, 0, _("Spool header read error. ERR=%s\n"), - be.strerror()); + be.bstrerror()); } else { Pmsg2(000, _("Spool read error. Wanted %u bytes, got %d\n"), rlen, stat); Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %d\n"), rlen, stat); @@ -476,7 +476,7 @@ static bool write_spool_header(DCR *dcr) if (stat == -1) { berrno be; Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing header to spool file. ERR=%s\n"), - be.strerror()); + be.bstrerror()); } if (stat != (ssize_t)sizeof(hdr)) { /* If we wrote something, truncate it, then despool */ @@ -489,7 +489,7 @@ static bool write_spool_header(DCR *dcr) if (ftruncate(dcr->spool_fd, pos - stat) != 0) { berrno be; Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"), - be.strerror()); + be.bstrerror()); /* Note, try continuing despite ftruncate problem */ } } @@ -516,7 +516,7 @@ static bool write_spool_data(DCR *dcr) if (stat == -1) { berrno be; Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing data to spool file. ERR=%s\n"), - be.strerror()); + be.bstrerror()); } if (stat != (ssize_t)block->binbuf) { /* @@ -531,7 +531,7 @@ static bool write_spool_data(DCR *dcr) if (ftruncate(dcr->spool_fd, pos - stat - sizeof(spool_hdr)) != 0) { berrno be; Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"), - be.strerror()); + be.bstrerror()); /* Note, try continuing despite ftruncate problem */ } } @@ -602,14 +602,14 @@ bool commit_attribute_spool(JCR *jcr) if (fseeko(jcr->dir_bsock->spool_fd, 0, SEEK_END) != 0) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"), - be.strerror()); + be.bstrerror()); goto bail_out; } size = ftello(jcr->dir_bsock->spool_fd); if (size < 0) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"), - be.strerror()); + be.bstrerror()); goto bail_out; } P(mutex); @@ -646,7 +646,7 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs) if (!bs->spool_fd) { berrno be; Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name, - be.strerror()); + be.bstrerror()); free_pool_memory(name); return false; } diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index bae09e0b2d..1f1cded7b4 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -609,7 +609,7 @@ void save_resource(int type, RES_ITEM *items, int pass) if ((errstat = pthread_mutex_init(&res->res_changer.changer_mutex, NULL)) != 0) { berrno be; Jmsg1(NULL, M_ERROR_TERM, 0, _("Unable to init mutex: ERR=%s\n"), - be.strerror(errstat)); + be.bstrerror(errstat)); } break; default: diff --git a/bacula/src/stored/wait.c b/bacula/src/stored/wait.c index fe634e4507..d35aab71ce 100644 --- a/bacula/src/stored/wait.c +++ b/bacula/src/stored/wait.c @@ -124,7 +124,7 @@ int wait_for_sysop(DCR *dcr) if (stat == EINVAL) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("pthread timedwait error. ERR=%s\n"), be.strerror(stat)); + Jmsg1(jcr, M_FATAL, 0, _("pthread timedwait error. ERR=%s\n"), be.bstrerror(stat)); stat = W_ERROR; /* error */ break; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 67a2ebe9e6..42d26fb24c 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.8" -#define BDATE "04 May 2007" -#define LSMDATE "04May07" +#define BDATE "06 May 2007" +#define LSMDATE "06May07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index ea05a91526..567acd443c 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,9 @@ Technical notes on version 2.1 General: +06May07 +kes Start implementing bstrerror() in place of strerror(). +kes First cut at stripping path -- seems to work. 04May07 kes Prevent door and port files from being restored (mostly Solaris stuff). -- 2.39.2