/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2000-2015 Kern Sibbald
- Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2018 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
Public License, v3.0 ("AGPLv3") and some additional permissions and
terms pursuant to its AGPLv3 Section 7.
- This notice must be preserved when any source code is
+ This notice must be preserved when any source code is
conveyed and/or propagated.
Bacula(R) is a registered trademark of Kern Sibbald.
}
}
-/* Compare directly the FS from a fname with a string */
-bool fstype_cmp(FF_PKT *ff_pkt, const char *fsname)
-{
- char buf[256];
- if (fstype(ff_pkt, buf, sizeof(buf))) {
- return (strcmp(buf, fsname) == 0);
- }
- return false;
-}
/*
* These functions should be implemented for each OS
*/
#if defined(HAVE_DARWIN_OS) \
|| defined(HAVE_FREEBSD_OS ) \
+ || defined(HAVE_KFREEBSD_OS ) \
|| defined(HAVE_OPENBSD_OS)
#include <sys/param.h>
/* Tru64 */
#include <sys/stat.h>
#include <sys/mount.h>
+#include <sys/mnttab.h>
bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
{
}
/* Tru64 */
+#elif defined (HAVE_WIN32)
+/* Windows */
+bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
+{
+ char *fname = ff_pkt->fname;
+ DWORD componentlength;
+ DWORD fsflags;
+ CHAR rootpath[4];
+ UINT oldmode;
+ BOOL result;
+
+ /* Copy Drive Letter, colon, and backslash to rootpath */
+ bstrncpy(rootpath, fname, sizeof(rootpath));
+
+ /* We don't want any popups if there isn't any media in the drive */
+ oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);
+ result = GetVolumeInformation(rootpath, NULL, 0, NULL, &componentlength, &fsflags, fs, fslen);
+ SetErrorMode(oldmode);
+
+ if (result) {
+ /* Windows returns NTFS, FAT, etc. Make it lowercase to be consistent with other OSes */
+ lcase(fs);
+ } else {
+ Dmsg2(10, "GetVolumeInformation() failed for \"%s\", Error = %d.\n", rootpath, GetLastError());
+ }
+ return result != 0;
+}
+/* Windows */
+
#else /* No recognised OS */
bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
/* Read mtab entries */
bool read_mtab(mtab_handler_t *mtab_handler, void *user_ctx)
-{
+{
+/* Debian stretch GNU/KFreeBSD has both getmntinfo and getmntent, but
+ only the first seems to work, so we skip over getmntent in this case */
+#ifndef HAVE_KFREEBSD_OS
#ifdef HAVE_GETMNTENT
FILE *mntfp;
struct stat st;
struct mnttab mnt;
P(mutex);
- if ((mntfp = fopen(MNTTAB, "r")) == NULL) {
+ if ((mntfp = bfopen(MNTTAB, "r")) == NULL) {
V(mutex);
return false;
}
#endif
#endif /* HAVE_GETMNTENT */
+#endif /* HAVE_KFREEBSD_OS */
#ifdef HAVE_GETMNTINFO
struct stat st;