public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: Eric Blake <eblake@redhat.com>
Cc: cygwin@cygwin.com
Subject: Re: Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...
Date: Wed, 28 Aug 2019 14:22:00 -0000	[thread overview]
Message-ID: <20190828141556.GM11632@calimero.vinschen.de> (raw)
In-Reply-To: <421ac447-b249-da21-1ca5-228041cfc884@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1882 bytes --]

On Aug 28 08:36, Eric Blake wrote:
> On 8/28/19 7:59 AM, Corinna Vinschen wrote:
> 
> >>>>> mkdir(2) has some special code from 2009 which drops trailing
> >>>>> {back}slashes to perform a bordercase in mkdir Linux-compatible.
> >>>>> This code snippet doesn't exist in rmdir(2).
> 
> Dropping trailing slashes to be Linux-compatible is okay.  Dropping
> trailing backslashes is risky, though, if it makes us forget that the
> user was asking for a DOS path (even though DOS paths are not always
> going to work as expected).
> 
> 
> > 
> > Eric, any insight?  As usual our comments from way back when are lacking
> > in terms of what exact problem this code is trying to fix/workaround.
> 
> If I recall, we had cases where 'mkdir a/' and 'mkdir a' did not behave
> identically, even though POSIX says they should; compounded by the fact
> that Windows treats trailing slash differently when performing native
> mkdir on a drive than it does on a subdirectory of a drive.
> 
> It may be as simple as changing the isdirsep() from the identified
> commit to instead check only for '/' (and ignore '\').

As simple as that?

diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index b757851d5c7f..747b1582af50 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -314,13 +314,13 @@ mkdir (const char *dir, mode_t mode)
 	  set_errno (ENOENT);
 	  __leave;
 	}
-      if (isdirsep (dir[strlen (dir) - 1]))
+      if (dir[strlen (dir) - 1] == '/')
 	{
 	  /* This converts // to /, but since both give EEXIST, we're okay.  */
 	  char *buf;
 	  char *p = stpcpy (buf = tp.c_get (), dir) - 1;
 	  dir = buf;
-	  while (p > dir && isdirsep (*p))
+	  while (p > dir && *p == '/')
 	    *p-- = '\0';
 	}
       if (!(fh = build_fh_name (dir, PC_SYM_NOFOLLOW)))


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-08-28 14:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 15:25 Houder
2019-08-27 16:28 ` Corinna Vinschen
2019-08-27 17:01   ` Houder
2019-08-27 17:32     ` Vince Rice
2019-08-27 17:50       ` Corinna Vinschen
2019-08-28  7:16       ` Houder
2019-08-28  9:22         ` john doe
2019-08-28 11:47           ` Houder
2019-08-28 13:22         ` Corinna Vinschen
2019-08-28 14:16           ` Eric Blake
2019-08-28 14:22             ` Corinna Vinschen [this message]
2019-08-28 15:18               ` Corinna Vinschen
2019-08-29 15:19                 ` Houder
2019-08-30  8:20                   ` Corinna Vinschen
2019-08-30 12:42                   ` Houder
2019-09-01 17:38                     ` Houder
2019-09-02  8:15                       ` Corinna Vinschen
2019-09-03  8:40                         ` Houder
2019-09-03  6:50                       ` Andrey Repin
2019-09-19 19:51                       ` Ken Brown
2019-09-20  9:11                         ` Houder
2019-09-20 18:20                           ` Houder
2019-09-21 16:07                             ` Ken Brown
2019-09-22  7:34                               ` Houder
2019-09-22 14:12                                 ` Ken Brown
2019-09-07  3:47                 ` L A Walsh
2019-08-27 19:48   ` Achim Gratz
2019-08-27 20:58     ` Brian Inglis
2019-08-28  7:16       ` Corinna Vinschen
2019-08-27 22:21     ` Achim Gratz
2019-08-28 13:36 ` Eric Blake
2019-08-28 22:57   ` Houder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190828141556.GM11632@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    --cc=eblake@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).