From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 923 invoked by alias); 28 Aug 2019 14:16:10 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 908 invoked by uid 89); 28 Aug 2019 14:16:10 -0000 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 Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (217.72.192.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2019 14:16:00 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mzz2e-1iNH0V2YMA-00x4RE for ; Wed, 28 Aug 2019 16:15:57 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id EF179A804B1; Wed, 28 Aug 2019 16:15:56 +0200 (CEST) Date: Wed, 28 Aug 2019 14:22:00 -0000 From: Corinna Vinschen To: Eric Blake Cc: cygwin@cygwin.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@cygwin.com Mail-Followup-To: Eric Blake , cygwin@cygwin.com References: <20190827152549.GY11632@calimero.vinschen.de> <3E262D05-F393-453A-9E43-B248DDE50812@solidrocksystems.com> <20190828125939.GL11632@calimero.vinschen.de> <421ac447-b249-da21-1ca5-228041cfc884@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nPR02K0w4EXagsIO" Content-Disposition: inline In-Reply-To: <421ac447-b249-da21-1ca5-228041cfc884@redhat.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-SW-Source: 2019-08/txt/msg00369.txt.bz2 --nPR02K0w4EXagsIO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1861 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" Content-length: 833 -----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--