From: Kern Sibbald Date: Sat, 22 Mar 2008 10:15:13 +0000 (+0000) Subject: Tweak Win32 mount point code X-Git-Tag: Release-2.2.9-b7~47 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=41897ae923f0097bb5e8dd19bba5d48761629847;p=bacula%2Fbacula Tweak Win32 mount point code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6665 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/version.h b/bacula/src/version.h index 5b4a7cab50..1f93477800 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.2.9" -#define BDATE "20 March 2008" -#define LSMDATE "20Mar08" +#define BDATE "22 March 2008" +#define LSMDATE "22Mar08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 14a97cf239..175aaef354 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -592,14 +592,19 @@ statDir(const char *file, struct stat *sb) FILETIME *pftLastWriteTime; FILETIME *pftCreationTime; + /* + * Oh, cool, another exception: Microsoft doesn't let us do + * FindFile operations on a Drive, so simply fake root attibutes. + */ if (file[1] == ':' && file[2] == 0) { - Dmsg1(99, "faking ROOT attrs(%s).\n", file); - sb->st_mode = S_IFDIR; - sb->st_mode |= S_IREAD|S_IEXEC|S_IWRITE; - time(&sb->st_ctime); - time(&sb->st_mtime); - time(&sb->st_atime); - return 0; + time_t now = time(NULL); + Dmsg1(99, "faking ROOT attrs(%s).\n", file); + sb->st_mode = S_IFDIR; + sb->st_mode |= S_IREAD|S_IEXEC|S_IWRITE; + sb->st_ctime = now; + sb->st_mtime = now; + sb->st_atime = now; + return 0; } HANDLE h = INVALID_HANDLE_VALUE; @@ -609,7 +614,7 @@ statDir(const char *file, struct stat *sb) POOLMEM* pwszBuf = get_pool_memory (PM_FNAME); make_win32_path_UTF8_2_wchar(&pwszBuf, file); - h = p_FindFirstFileW((LPCWSTR) pwszBuf, &info_w); + h = p_FindFirstFileW((LPCWSTR)pwszBuf, &info_w); free_pool_memory(pwszBuf); pdwFileAttributes = &info_w.dwFileAttributes; @@ -761,7 +766,7 @@ stat2(const char *file, struct stat *sb) CloseHandle(h); if (attr & FILE_ATTRIBUTE_DIRECTORY) { - return statDir(tmpbuf, sb); + return statDir(file, sb); } return rval; @@ -776,13 +781,6 @@ stat(const char *file, struct stat *sb) memset(sb, 0, sizeof(*sb)); - /* why not allow win 95 to use p_GetFileAttributesExA ? - * this function allows _some_ open files to be stat'ed - * if (g_platform_id == VER_PLATFORM_WIN32_WINDOWS) { - * return stat2(file, sb); - * } - */ - if (p_GetFileAttributesExW) { /* dynamically allocate enough space for UCS2 filename */ POOLMEM* pwszBuf = get_pool_memory (PM_FNAME); @@ -830,7 +828,17 @@ stat(const char *file, struct stat *sb) sb->st_atime = cvt_ftime_to_utime(data.ftLastAccessTime); sb->st_mtime = cvt_ftime_to_utime(data.ftLastWriteTime); sb->st_ctime = cvt_ftime_to_utime(data.ftCreationTime); - if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + + /* + * If we are not at the root, then to distinguish a reparse + * point from a mount point, we must call FindFirstFile() to + * get the WIN32_FIND_DATA, which has the bit that indicates + * that this directory is a mount point -- aren't Win32 APIs + * wonderful? (sarcasm). The code exists in the statDir + * subroutine. + */ + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && + file[1] == ':' && file[2] != 0) { return statDir(file, sb); } return 0;