delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/08/28/10:17:00

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:cc:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=Y+J3L/wHoywULSx5p1z0ai1K7Ip7G9d1tP/7Ku7AWgUtA5FnLprc0
5zxQv06zoFeI5XjJFP8eVHkVlTQGP4qpAp/0wknsyEfVqNrxtUvSvQoMUge3v255
MHJDR/OTvCuM+rA4NgYfM4hZC+kyjpqw3N6Bb99ebDVRHJ8BO2VwA4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:cc:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=1PdaIbEh/jQibHNauHw+MsUzkQY=; b=PtIAimgG+3KuNNtHefa3JxokJQWV
UeVIwiQprheiPs+AYTDISP20VaBxlerKcTQAmSYAILSZUXeZl53uIV0W/oqA4oJ+
c5ndrZfyvpy45Qmig0OviQjuESSB7DnWI6MywrvRBfahNyXiVMUDgNS1YPlInzBh
qV+oO33nvazEK0g=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-114.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=our
X-HELO: mout.kundenserver.de
Date: Wed, 28 Aug 2019 16:15:56 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: Eric Blake <eblake AT redhat DOT com>
Cc: cygwin AT cygwin DOT com
Subject: Re: Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...
Message-ID: <20190828141556.GM11632@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: Eric Blake <eblake AT redhat DOT com>, cygwin AT cygwin DOT com
References: <bc3df101ab93c20b86c3ab7fa7d3ea4f AT xs4all DOT nl> <20190827152549 DOT GY11632 AT calimero DOT vinschen DOT de> <a47cc167b725c08e6f1c914166fabcaf AT smtp-cloud8 DOT xs4all DOT net> <3E262D05-F393-453A-9E43-B248DDE50812 AT solidrocksystems DOT com> <b97e4dbe952154efc68412540514ae81 AT smtp-cloud8 DOT xs4all DOT net> <20190828125939 DOT GL11632 AT calimero DOT vinschen DOT de> <421ac447-b249-da21-1ca5-228041cfc884 AT redhat DOT com>
MIME-Version: 1.0
In-Reply-To: <421ac447-b249-da21-1ca5-228041cfc884@redhat.com>
User-Agent: Mutt/1.11.3 (2019-02-01)

--nPR02K0w4EXagsIO
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Aug 28 08:36, Eric Blake wrote:
> On 8/28/19 7:59 AM, Corinna Vinschen wrote:
>=20
> >>>>> 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).
>=20
> 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).
>=20
>=20
> >=20
> > 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.
>=20
> 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.
>=20
> 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] =3D=3D '/')
 	{
 	  /* This converts // to /, but since both give EEXIST, we're okay.  */
 	  char *buf;
 	  char *p =3D stpcpy (buf =3D tp.c_get (), dir) - 1;
 	  dir =3D buf;
-	  while (p > dir && isdirsep (*p))
+	  while (p > dir && *p =3D=3D '/')
 	    *p-- =3D '\0';
 	}
       if (!(fh =3D build_fh_name (dir, PC_SYM_NOFOLLOW)))


Thanks,
Corinna

--=20
Corinna Vinschen
Cygwin Maintainer

--nPR02K0w4EXagsIO
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl1mjJwACgkQ9TYGna5E
T6B9tg/7Btw8Wd42tE5bb+TXrhexWfnqvJ961ZAAaH5bej2DVrIXVO+jIyJz+7oM
HZZid/DRZ0nihX/2cShXGmHUhZMhUXcP0HKRmx5bIc7jWNWyiVeenENxH3eHNO2L
jxaaPP+TZ+kW897xzPXXhDtjy384WVwn76sjAAqTTGCCuYw812q3Yn+roE9tdWYD
QcFZ+C3V31qx9kDqEdZKiLnpp/zNmE2OlTtE0A2F6QqNx9uWtAZwxCSWSBphiSTK
AroCK3jPOr6b41ma+0q85s+VBZsPmtXVlNsolN8Fk5yNrhmFXyAdjzgVAidW3t+V
4mxNHmCOrO9xY9tdfm9aBI0uSRirP5ZHIRNg5kw/pXfpyHAqQi3KAtEw+Ea+sypT
5IpmEVXuoUs1oZaUgPb2toOwYdjLxEABHHIKMPJqK3wVbLyHhVhfsCvhhd1zoq1t
+hNW1wSUuZFu1eQbOB7ye0ISpc8YBqeVvIvl4p8R4UJfAt6S5e5WIyhjZkzUmGxk
HuhM0qe0SwBtvWv/YYdNNZxNpgTjhcHSmHgj7hANgEzD+flyEl1hOhtmJEZP/ClF
xZu7fmgt4PgfvsaTRKZJL01E+VhDPwQ0HMd19fwp6Jo+nKfO3veWuYCNrGNd+BuZ
+JjGaElSwDg4pNF7gg2ij4Y8nNBQJvSkWX4osyDgLImewMbUtmY=
=b60q
-----END PGP SIGNATURE-----

--nPR02K0w4EXagsIO--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019