X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffindlib%2Ffstype.c;h=059ae048b41f931d64b32c1e59de821b3bf9b660;hb=f8f848fdb5aace95292d905dc60fe0de45521859;hp=6182c6bc96e32126e2ce8cc5bd3eb0da40697168;hpb=96a03380a83d3e0f720b58d70c655661263172c6;p=bacula%2Fbacula diff --git a/bacula/src/findlib/fstype.c b/bacula/src/findlib/fstype.c index 6182c6bc96..059ae048b4 100644 --- a/bacula/src/findlib/fstype.c +++ b/bacula/src/findlib/fstype.c @@ -44,8 +44,8 @@ "HAVE_LINUX_OS\n" \ "HAVE_NETBSD_OS\n" \ "HAVE_OPENBSD_OS\n" \ - "HAVE_SUN_OS\n" -#define bool int + "HAVE_SUN_OS\n" \ + "HAVE_WIN32\n" #define false 0 #define true 1 #define bstrncpy strncpy @@ -252,6 +252,38 @@ bool fstype(const char *fname, char *fs, int fslen) } /* Tru64 */ +#elif defined (HAVE_WIN32) +/* Windows */ + +bool fstype(const char *fname, char *fs, int fslen) +{ + 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(const char *fname, char *fs, int fslen)