- 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
} 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);
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 */
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));
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;
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));
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;
}
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);
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;
/* 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;
/* 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;
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) {
}
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;
}
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 */
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;
}
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;
}
}
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);
/* 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;
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;
}
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;
}
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) {
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;
}
}
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++;
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) {
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
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)) {
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;
if (is_bnet_error(fd)) {
berrno be;
Jmsg2(jcr, M_FATAL, 0, _("bdird<filed: bad attributes from filed n=%d : %s\n"),
- n, be.strerror());
+ n, be.bstrerror());
return false;
}
}
berrno be;
Jmsg2(jcr, M_ERROR, 0, _("acl_to_text error on file \"%s\": ERR=%s\n"),
- jcr->last_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) {
}
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;
}
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;
}
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;
}
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;
}
}
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;
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;
}
/*
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;
}
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;
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;
}
/*
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;
}
/* 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);
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;
}
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;
}
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);
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);
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"));
}
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 */
* 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,
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) {
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; stripped<count && *in; stripped++) {
+ while (*in && !IsPathSeparator(*in)) {
+ in++; /* skip chars */
+ }
+ if (*in) {
+ numsep++; /* count separators seen */
+ in++; /* skip separator */
+ }
+ }
+ /* Copy to end */
+ while (*in) { /* copy to end */
+ if (IsPathSeparator(*in)) {
+ numsep++;
+ }
+ *out++ = *in++;
+ }
+ *out = 0;
+ Dmsg4(500, "stripped=%d count=%d numsep=%d sep>count=%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);
+ }
+}
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;
}
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;
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)) {
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) {
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;
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.
}
} 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
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;
}
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;
}
}
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;
}
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;
}
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;
}
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);
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);
}
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;
}
-/*
- * 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
(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"
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;
}
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 */
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);
}
}
#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
* 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
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);
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;
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;
}
}
}
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 {
}
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);
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;
}
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 */
}
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);
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 {
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 {
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;
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) {
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) {
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);
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 {
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;
}
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;
}
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;
}
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);
}
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 */
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
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);
}
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 */
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; i<len; i++) {
goto read_again;
}
}
- Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, be.strerror(dev->dev_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;
}
}
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"
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;
} 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) {
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));
}
}
} 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;
}
}
berrno be;
Pmsg3(0, _("Read of %d bytes gives stat=%d. ERR=%s\n"),
- len, stat, be.strerror());
+ len, stat, be.bstrerror());
free(buf);
}
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) {
} else {
berrno be;
Pmsg2(-1, _("Could not create state file: %s ERR=%s\n"), buf,
- be.strerror());
+ be.bstrerror());
}
now = time(NULL);
} 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();
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();
}
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)) {
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()) {
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
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");
::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 */
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;
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);
}
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 {
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;
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);
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);
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
}
#endif
Mmsg2(errmsg, _("Rewind error on %s. ERR=%s.\n"),
- print_name(), be.strerror());
+ print_name(), be.bstrerror());
return false;
}
break;
berrno be;
dev_errno = errno;
Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"),
- print_name(), be.strerror());
+ print_name(), be.bstrerror());
return false;
}
}
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
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;
}
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);
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;
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:"));
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
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;
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());
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;
}
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;
}
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 {
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;
}
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);
}
}
Mmsg3(errmsg, _("ioctl MTFSR %d error on %s. ERR=%s.\n"),
- num, print_name(), be.strerror());
+ num, print_name(), be.bstrerror());
}
return stat == 0;
}
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;
}
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;
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);
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;
/* 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
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;
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);
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;
}
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
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);
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 */
}
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 */
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, "
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;
}
}
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;
}
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;
}
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;
}
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) {
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));
}
}
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));
}
}
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));
}
}
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;
}
} 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;
}
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 */
}
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);
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 */
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 */
}
}
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) {
/*
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 */
}
}
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);
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;
}
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:
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;
}
#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 */
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).