Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <427A147D.2030109@byu.net> Date: Thu, 05 May 2005 06:41:33 -0600 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: Paul Eggert CC: "Pierre A. Humblet" , cygwin AT cygwin DOT com, bug-coreutils AT gnu DOT org Subject: Re: mkdir -p and network drives References: <3 DOT 0 DOT 5 DOT 32 DOT 20050502232204 DOT 00b52180 AT incoming DOT verizon DOT net> <42777719 DOT 8090103 AT byu DOT net> <8764xym6vf DOT fsf AT penguin DOT cs DOT ucla DOT edu> In-Reply-To: <8764xym6vf.fsf@penguin.cs.ucla.edu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes -----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 > > * 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 AT byu DOT 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/