From: Eric Bollengier Date: Mon, 1 Apr 2019 13:07:50 +0000 (+0200) Subject: Fix Windows SD compilation X-Git-Tag: Release-9.6.0~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=300b6400c69cce7b42fb5bffc875719ee50580c6;p=thirdparty%2Fbacula.git Fix Windows SD compilation --- diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 94074fa08..1086695d6 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -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; } - diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index db112ade2..26e58d367 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -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