- if (is_bopen(bfd)) {
- Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
- }
- if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
- Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
- attr->ofname, berror(bfd));
- return CF_ERROR;
- }
- return CF_EXTRACT;
-
- case FT_RAW: /* Bacula raw device e.g. /dev/sda1 */
- case FT_FIFO: /* Bacula fifo to save data */
- case FT_SPEC:
- 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) {
- Jmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"),
- attr->ofname, strerror(errno));
- 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) {
- Jmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"),
- attr->ofname, strerror(errno));
- return CF_ERROR;
- }
- }
- if (attr->type == FT_RAW || attr->type == FT_FIFO) {
- btimer_t *tid;
- Dmsg1(200, "FT_RAW|FT_FIFO %s\n", attr->ofname);
- mode = O_WRONLY | O_BINARY;
- /* Timeout open() in 60 seconds */
- if (attr->type == FT_FIFO) {
- tid = start_thread_timer(pthread_self(), 60);
- } else {
- tid = NULL;
- }
- if (is_bopen(bfd)) {
- Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
- }
- if ((bopen(bfd, attr->ofname, mode, 0)) < 0) {
- Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
- attr->ofname, berror(bfd));
- stop_thread_timer(tid);
- return CF_ERROR;
- }
- stop_thread_timer(tid);
- return CF_EXTRACT;
- }
- Dmsg1(200, "FT_SPEC %s\n", attr->ofname);
- return CF_CREATED;
+ if (is_bopen(bfd)) {
+ Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
+ bclose(bfd);
+ }
+
+
+ if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
+ berrno be;
+ be.set_errno(bfd->berrno);
+ Qmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
+ attr->ofname, be.bstrerror());
+ return CF_ERROR;
+ }
+ return CF_EXTRACT;
+
+#ifndef HAVE_WIN32 // none of these exists on MS Windows
+ case FT_RAW: /* Bacula raw device e.g. /dev/sda1 */
+ case FT_FIFO: /* Bacula fifo to save data */
+ case FT_SPEC:
+ if (S_ISFIFO(attr->statp.st_mode)) {
+ Dmsg1(400, "Restore fifo: %s\n", attr->ofname);
+ if (mkfifo(attr->ofname, attr->statp.st_mode) != 0 && errno != EEXIST) {
+ berrno be;
+ Qmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"),
+ attr->ofname, be.bstrerror());
+ return CF_ERROR;
+ }
+ } else if (S_ISSOCK(attr->statp.st_mode)) {
+ Dmsg1(200, "Skipping restore of socket: %s\n", attr->ofname);
+#ifdef S_IFDOOR // Solaris high speed RPC mechanism
+ } else if (S_ISDOOR(attr->statp.st_mode)) {
+ Dmsg1(200, "Skipping restore of door file: %s\n", attr->ofname);
+#endif
+#ifdef S_IFPORT // Solaris event port for handling AIO
+ } else if (S_ISPORT(attr->statp.st_mode)) {
+ Dmsg1(200, "Skipping restore of event port file: %s\n", attr->ofname);
+#endif
+ } else {
+ Dmsg1(400, "Restore node: %s\n", attr->ofname);
+ if (mknod(attr->ofname, attr->statp.st_mode, attr->statp.st_rdev) != 0 && errno != EEXIST) {
+ berrno be;
+ Qmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"),
+ attr->ofname, be.bstrerror());
+ return CF_ERROR;
+ }
+ }
+ /*
+ * Here we are going to attempt to restore to a FIFO, which
+ * means that the FIFO must already exist, AND there must
+ * be some process already attempting to read from the
+ * FIFO, so we open it write-only.
+ */
+ if (attr->type == FT_RAW || attr->type == FT_FIFO) {
+ btimer_t *tid;
+ Dmsg1(400, "FT_RAW|FT_FIFO %s\n", attr->ofname);
+ mode = O_WRONLY | O_BINARY;
+ /* Timeout open() in 60 seconds */
+ if (attr->type == FT_FIFO) {
+ Dmsg0(400, "Set FIFO timer\n");
+ tid = start_thread_timer(jcr, pthread_self(), 60);
+ } else {
+ tid = NULL;
+ }
+ if (is_bopen(bfd)) {
+ Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
+ }
+ Dmsg2(400, "open %s mode=0x%x\n", attr->ofname, mode);
+ if ((bopen(bfd, attr->ofname, mode, 0)) < 0) {
+ berrno be;
+ be.set_errno(bfd->berrno);
+ Qmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
+ attr->ofname, be.bstrerror());
+ Dmsg2(400, "Could not open %s: ERR=%s\n", attr->ofname, be.bstrerror());
+ stop_thread_timer(tid);
+ return CF_ERROR;
+ }
+ stop_thread_timer(tid);
+ return CF_EXTRACT;
+ }
+ Dmsg1(400, "FT_SPEC %s\n", attr->ofname);
+ return CF_CREATED;