]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix Windows SD compilation
authorEric Bollengier <eric@baculasystems.com>
Mon, 1 Apr 2019 13:07:50 +0000 (15:07 +0200)
committerRadosław Korzeniewski <radekk@inteos.pl>
Sat, 14 Dec 2019 14:55:28 +0000 (15:55 +0100)
bacula/src/stored/dev.c
bacula/src/stored/stored.c

index 94074fa088044f1fcef867fbc35c5955488926b8..1086695d612601c9ecc103e35dd337c5902e2ee0 100644 (file)
@@ -259,6 +259,36 @@ void DEVICE::set_volcatinfo_from_dcr(DCR *dcr)
    VolCatInfo = dcr->VolCatInfo;
 }
 
+bool DEVICE::sync_data(DCR *dcr)
+{
+   int ret;
+#ifdef HAVE_WIN32
+   return false;
+#endif
+
+   if (!has_cap(CAP_SYNCONCLOSE)) {
+       return true;
+   }
+   if (!is_open()) {
+      Dmsg2(200, "device %s closed vol=%s\n", print_name(),
+            VolHdr.VolumeName);
+      return true;                    /* already closed */
+   }
+
+   while ((ret = fsync(m_fd)) < 0 && errno == EINTR) {
+      bmicrosleep(0, 5000);
+   }
+
+   if (ret < 0) {
+      berrno be;
+      dev_errno = errno;
+      Mmsg(errmsg, _("Error syncing volume \"%s\" on device %s. ERR=%s."),
+           VolHdr.VolumeName, print_name(), be.bstrerror());
+      return false;
+   }
+   return true;
+}
+
 /*
  * Close the device
  *   Can enter with dcr==NULL
@@ -1112,4 +1142,3 @@ bool DEVICE::get_tape_worm(DCR *dcr)
 {
    return false;
 }
-
index db112ade22f56b7878df7aa0cf3fdd323caf23d9..26e58d367ae93d44fe28f7a18fce733e097c0eff 100644 (file)
@@ -641,6 +641,11 @@ void *device_initialization(void *arg)
                dev->print_name());
       }
 
+#ifdef HAVE_WIN32
+      if (device->cap_bits & CAP_SYNCONCLOSE) {
+         device->cap_bits & ~CAP_SYNCONCLOSE; /* Not available on windows */
+      }
+#endif
       /*
        * Note: be careful setting the slot here. If the drive
        *  is shared storage, the contents can change before