This is the mail archive of the cygwin 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: mkdir -p and network drives


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paul Eggert on 5/5/2005 2:09 AM:
> 
> What happens with the file names "//", "//MACHINE", and
> "//MACHINE/Share" in Cygwin?  Don't they appear to be directories,
> albeit directories that you can't alter?  If not, that suggests a bug
> in Cygwin.

By itself, // is currently treated as a synonym for /.  I think that
behavior was chosen because of the number of programs that don't respect
POSIX semantics, but it means that chdir("//") is currently no different
from chdir("/"), other than getcwd(2) knows the spelling difference (the
two directories have the same readdir() contents).  At least cygwin obeys
POSIX in that after chdir("///"), getcwd() returns "/".  //MACHINE
currently generates ENOENT, whether or not there is a server on the
network with that name, and mkdir(2), stat(2), and chdir(2) with an
argument of "//MACHINE" fail.  But //Machine/Share is a valid directory if
it resolves, (if it doesn't resolve, it hangs for several seconds, then
times out with "No such host or network path", ENOSHARE, invented for cygwin).

Yes, I agree that it would be nicer if cygwin knew how to treat // as
distinct from /, such that readdir() on // returned a listing of currently
accessible hosts and acted as a read-only device.  I also agree that it
would be nicer if cygwin knew how to treat //MACHINE as a read-only
directory if //MACHINE is detected on the network, and listed the shares
available from there.  I think that the Windows-provided functions
NetShareEnum and  WNetEnumResource appear to provide what is needed to do
this, but I wouldn't know how to go about patching cygwin to use them.

> That being said, it can't hurt to add the following minor workaround,
> (which would work on Domain OS anyway :-), so I installed it.
> 
> 2005-05-05  Paul Eggert  <eggert@cs.ucla.edu>
> 
> 	* makepath.c (make_path): chdir to "//", not "/", if the file name
> 	starts with exactly two slashes.  This doesn't solve the problem
> 	in general but it's better than nothing.  Problem reported by
> 	Pierre A. Humblet via Eric Blake.

Below is the patch I came up with to fix the issue on cygwin, prior to
your reply.  By the way, the coreutils anon CVS mirror syncronization
appears to be hung again, I haven't seen any of your patches show up on
savannah.gnu.org since April 22nd.  Since it is __CYGWIN__ specific, and
since your minor patch will work if cygwin were patched to treat //MACHINE
as a directory (like Domain OS did), I don't know if you want to fold my
patch into the official repository.

Index: lib/makepath.c
===================================================================
RCS file: /cvsroot/coreutils/coreutils/lib/makepath.c,v
retrieving revision 1.60
diff -u -p -r1.60 makepath.c
- --- lib/makepath.c      30 Jul 2004 20:29:01 -0000      1.60
+++ lib/makepath.c      4 May 2005 13:16:23 -0000
@@ -212,6 +212,36 @@ make_path (const char *argpath,

       slash = dirpath;

+#ifdef __CYGWIN__
+      /* Special case for //server/share prefix.  */
+      if (*dirpath == '/' && dirpath[1] == '/' && dirpath[2]
+         && dirpath[2] != '/')
+       {
+         slash = strchr (&dirpath[2], '/');
+         if (slash == NULL)
+           {
+             error (0, 0, _("%s requires a share name"), quote (dirpath));
+             CLEANUP;
+             return false;
+           }
+         while (*slash == '/')
+           slash++;
+         slash = strchr (slash, '/');
+         if (slash == NULL)
+           {
+             do_chdir = false;
+             slash = strchr (dirpath, '\0');
+           }
+         else if (do_chdir)
+           {
+             *slash = '\0';
+             if (chdir (dirpath) < 0)
+               do_chdir = false;
+             *slash = '/';
+           }
+       }
+#endif /* __CYGWIN__ */
+
       /* Skip over leading slashes.  */
       while (*slash == '/')
        slash++;
- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD4DBQFCehR884KuGfSFAYARAtXJAJURjkAzv/72pxEOE0WklFBQZIf/AJ9sZ/VX
gMBtqxqy/CGzdeOZDn+faw==
=z4qU
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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