Patch to enable proper handling of Win32 //?/GLOBALROOT/device paths

d3@mutable.net d3@mutable.net
Fri Oct 6 22:32:00 GMT 2006


This patch is to enable Win32 device paths in the form of:

//?/GLOBALROOT/Device/Harddisk0/Partition1/
//?/GLOBALROOT/Device/Harddiskvolume1/
//?/GLOBALROOT/Device/HarddiskVolumeShadowCopy1/

Etc... 

This patch to cygwin enables tools like rsync to access Win32 volume
shadow copies that can be created with Win32 tools like vshadow.exe so
that you can access open files, SQL, and Exchange databases.

A note about the change in fhandle_disk_file.cc: The patch enforces
Win32 style paths (i.e. backslashes) because the NT kernal functions do
not like mixed paths when accessing \\?\GLOBALROOT. They will only
accept backslashes.

Here is a rsync test I have been successfully using with this patch
applied:

rsync -av --modify-window=2
//?/globalroot/device/harddiskvolume1/testfiles/ server::test/testfiles/


2006-10-06 David Jade <d3@mutable.net>

ChangeLog for winsup/cygwin:

	* path.cc (path_conv::get_nt_native_path): update to properly
detect
	\\?\GLOBALROOT device paths

	(mount_info::conv_to_win32_path): updated	comment to
reflect
	\\?\GLOBALROOT changes

	* fhandler_disk_file.cc (path_conv::ndisk_links): updated to use
	backslashes to make NT kernel functions work for \\?\GLOBALROOT
device
	paths

	


Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.414
diff -u -p -r1.414 path.cc
--- path.cc     2 Aug 2006 15:11:48 -0000       1.414
+++ path.cc     6 Oct 2006 21:05:56 -0000
@@ -526,13 +526,13 @@ path_conv::get_nt_native_path (UNICODE_S
     }
   else if (path[1] != '\\')            /* \Device\... */
     str2uni_cat (upath, path);
-  else if (path[2] != '.'
+  else if ((path[2] != '.' && path[2] != '?') /* not for \\.\ or \\?\
GLOBALROOT devices */
           || path[3] != '\\')          /* \\server\share\... */
     {
       str2uni_cat (upath, "\\??\\UNC\\");
       str2uni_cat (upath, path + 2);
     }
-  else                                 /* \\.\device */
+  else                                 /* \\?\\ or \\.\ devices */
     {
       str2uni_cat (upath, "\\??\\");
       str2uni_cat (upath, path + 4);
@@ -1661,7 +1661,7 @@ mount_info::conv_to_win32_path (const ch
     }

   MALLOC_CHECK;
-  /* If the path is on a network drive, bypass the mount table.
+  /* If the path is on a network drive or a \\?\ GLOBALROOT device,
bypass the mount table.
      If it's // or //MACHINE, use the netdrive device. */
   if (src_path[1] == '/')
     {



Index: fhandler_disk_file.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.190
diff -u -p -r1.190 fhandler_disk_file.cc
--- fhandler_disk_file.cc       20 Aug 2006 12:31:07 -0000      1.190
+++ fhandler_disk_file.cc       6 Oct 2006 21:05:54 -0000
@@ -143,12 +143,12 @@ path_conv::ndisk_links (DWORD nNumberOfL
   __DIR_mounts *dir = new __DIR_mounts (normalized_path);
   if (nNumberOfLinks <= 1)
     {
-      s = "/*";
+      s = "\\*";       /*  must be backslash because \\?\GLOBALROOT
doesn't like mixed slashes */
       count = 0;
     }
   else
     {
-      s = "/..";
+      s = "\\..";      /* must be backslash because \\?\GLOBALROOT
doesn't like mixed slashes */
       count = nNumberOfLinks;
     }



David Jade



More information about the Cygwin-patches mailing list