if (exists) {
/* Get rid of old copy */
if (unlink(attr->ofname) == -1) {
+ berrno be;
Jmsg(jcr, M_ERROR, 0, _("File %s already exists and could not be replaced. ERR=%s.\n"),
- attr->ofname, strerror(errno));
+ attr->ofname, be.strerror());
/* Continue despite error */
}
}
bclose(bfd);
}
if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
+ berrno be;
+ be.set_errno(bfd->berrno);
Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
- attr->ofname, berror(bfd));
+ attr->ofname, be.strerror());
return CF_ERROR;
}
return CF_EXTRACT;
if (S_ISFIFO(attr->statp.st_mode)) {
Dmsg1(200, "Restore fifo: %s\n", attr->ofname);
if (mkfifo(attr->ofname, attr->statp.st_mode) != 0 && errno != EEXIST) {
+ berrno be;
Jmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"),
- attr->ofname, strerror(errno));
+ attr->ofname, be.strerror());
return CF_ERROR;
}
} else {
Dmsg1(200, "Restore node: %s\n", attr->ofname);
if (mknod(attr->ofname, attr->statp.st_mode, attr->statp.st_rdev) != 0 && errno != EEXIST) {
+ berrno be;
Jmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"),
- attr->ofname, strerror(errno));
+ attr->ofname, be.strerror());
return CF_ERROR;
}
}
Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
}
if ((bopen(bfd, attr->ofname, mode, 0)) < 0) {
+ berrno be;
+ be.set_errno(bfd->berrno);
Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
- attr->ofname, berror(bfd));
+ attr->ofname, be.strerror());
stop_thread_timer(tid);
return CF_ERROR;
}
case FT_LNK:
Dmsg2(130, "FT_LNK should restore: %s -> %s\n", attr->ofname, attr->olname);
if (symlink(attr->olname, attr->ofname) != 0 && errno != EEXIST) {
+ berrno be;
Jmsg3(jcr, M_ERROR, 0, _("Could not symlink %s -> %s: ERR=%s\n"),
- attr->ofname, attr->olname, strerror(errno));
+ attr->ofname, attr->olname, be.strerror());
return CF_ERROR;
}
return CF_CREATED;
case FT_LNKSAVED: /* Hard linked, file already saved */
Dmsg2(130, "Hard link %s => %s\n", attr->ofname, attr->olname);
if (link(attr->olname, attr->ofname) != 0) {
+ berrno be;
Jmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"),
- attr->ofname, attr->olname, strerror(errno));
+ attr->ofname, attr->olname, be.strerror());
return CF_ERROR;
}
return CF_CREATED;
Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
}
if ((bopen(bfd, attr->ofname, O_WRONLY|O_BINARY, 0)) < 0) {
+ berrno be;
+ be.set_errno(bfd->berrno);
Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
- attr->ofname, berror(bfd));
+ attr->ofname, be.strerror());
return CF_ERROR;
}
return CF_EXTRACT;