This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch]: mkdir -p and network drives


At 11:11 AM 5/10/2005 -0400, Christopher Faylor wrote:
>Could we see this as a unified-diff please?

Oops, but in retrospect it's a good thing. I did some more tests.

If c:\dev exists, then mkdir /dev/tty created c:\dev\tty (ditto
for the other /dev/xxx ), but rmdir /dev/tty would not delete 
c:\dev\tty
mkdir /cygdrive created c:\cygwin\cygdrive 

So I restrained mkdir to only act on FH_FS.

Ideally mkdir & rmdir should be part of the various handlers, but
there is no current payoff in doing so as directories can only be
created/deleted on FH_FS 

>On Mon, May 09, 2005 at 08:16:36PM -0400, Pierre A. Humblet wrote:
>>At 06:19 PM 5/9/2005 +0000, Eric Blake wrote:
>>
>>>Second, the sequence chdir("//"), mkdir("machine") creates machine in the 
>>>current directory.
>>
>>Old bug. 
>>chdir("/proc"), mkdir("machine") produces the same result.
>>And mkdir("/proc"), mkdir("/proc/machine") creates c:\proc\machine
>>
>>The fix sets errno to EROFS, which is what rmdir is already doing.
>>Is that OK for coreutils?

Pierre
  
2005-05-11  Pierre Humblet <pierre.humblet@ieee.org>

	* dir.cc (isrofs): New function.
	(mkdir): Check for FH_FS and use isrofs.
	(rmdir): Use isrofs.




Index: dir.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dir.cc,v
retrieving revision 1.84
diff -u -p -r1.84 dir.cc
--- dir.cc      16 Mar 2005 21:20:56 -0000      1.84
+++ dir.cc      11 May 2005 00:38:11 -0000
@@ -216,6 +216,13 @@ closedir (DIR *dir)
   return res;
 }
 
+inline bool 
+isrofs(DWORD devn) 
+{
+  return devn == FH_PROC || devn == FH_REGISTRY 
+    || devn == FH_PROCESS || devn == FH_NETDRIVE;
+}
+
 /* mkdir: POSIX 5.4.1.1 */
 extern "C" int
 mkdir (const char *dir, mode_t mode)
@@ -231,6 +238,14 @@ mkdir (const char *dir, mode_t mode)
       set_errno (real_dir.case_clash ? ECASECLASH : real_dir.error);
       goto done;
     }
+  if (real_dir.get_devn () != FH_FS)
+    {
+      if (isrofs (real_dir.get_devn ()))
+       set_errno (EROFS);
+      else
+       set_errno (EEXIST);
+      goto done;
+    }
 
   nofinalslash (real_dir.get_win32 (), real_dir.get_win32 ());
 
@@ -263,14 +278,12 @@ extern "C" int
 rmdir (const char *dir)
 {
   int res = -1;
-  DWORD devn;
 
   path_conv real_dir (dir, PC_SYM_NOFOLLOW | PC_FULL);
 
   if (real_dir.error)
     set_errno (real_dir.error);
-  else if ((devn = real_dir.get_devn ()) == FH_PROC || devn == FH_REGISTRY
-          || devn == FH_PROCESS)
+  else if (isrofs (real_dir.get_devn ()))
     set_errno (EROFS);
   else if (!real_dir.exists ())
     set_errno (ENOENT);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]