]> git.sur5r.net Git - bacula/bacula/commitdiff
Tweak Win32 mount point code
authorKern Sibbald <kern@sibbald.com>
Sat, 22 Mar 2008 10:15:13 +0000 (10:15 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 22 Mar 2008 10:15:13 +0000 (10:15 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6665 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/version.h
bacula/src/win32/compat/compat.cpp

index 5b4a7cab50c732f457382696f73e098938f875d1..1f93477800d2d547b8afe99d65ad2134e7ddecaa 100644 (file)
@@ -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 */
index 14a97cf239b30cd333ccb505f87ba0973ecb792d..175aaef3541b7d2836edb6f71e1de8a8479a32c2 100644 (file)
@@ -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;