public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...
Date: Sat, 21 Sep 2019 16:07:00 -0000	[thread overview]
Message-ID: <8b163d0f-680f-e4ea-098c-703d0fac87fd@cornell.edu> (raw)
In-Reply-To: <3eca1ecf200f0075efd154544c2fd5b4@smtp-cloud7.xs4all.net>

On 9/20/2019 5:11 AM, Houder wrote:
> As I said already, the snippet should NOT be executed in general. Perhaps
> it is another left-over from old times that should have been deleted.

You're absolutely right.  Prior to commit b0717aae0, the code looked like this:

       if (strncmp (path, "\\\\.\\", 4))
	{
	  /* Windows ignores trailing dots and spaces in the last path
	     component, and ignores exactly one trailing dot in inner
	     path components. */
	  char *tail = NULL;
           [...]
	  if (!tail || tail == path)
	    /* nothing */;
	  else if (tail[-1] != '\\')
	    {
	      *tail = '\0';
	      strip_tail = true;
	    }
	  else
	    {
	      error = ENOENT;
	      return;
	    }
	}

Note the use of a *local* tail variable.  It's a pointer into path, as you can 
see by looking at the part I omitted.

In commit b0717aae0, Corinna intended to disable this code, but she 
inadvertently disabled only part of it.  Here's the relevant part of that commit:

@@ -1170,6 +1225,7 @@ out:
      {
        if (strncmp (path, "\\\\.\\", 4))
         {
+#if 0
           /* Windows ignores trailing dots and spaces in the last path
              component, and ignores exactly one trailing dot in inner
              path components. */
@@ -1190,7 +1246,7 @@ out:
                   tail = NULL;
                 }
             }
-
+#endif
           if (!tail || tail == path)
             /* nothing */;
           else if (tail[-1] != '\\')

In particular, the declaration of the local tail variable is in the disabled 
code, so the cruft at the end is referring to the other tail, which points into 
path_copy.

[A later commit removed the disabled code.]

I'll fix this and then look at your patches to mkdir and rmdir.  It would be 
very helpful if you would write these as a patch series with cover letter, using 
git format-patch, and send them to the cygwin-patches list.

Ken

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

  reply	other threads:[~2019-09-21 15:42 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
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 [this message]
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=8b163d0f-680f-e4ea-098c-703d0fac87fd@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.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).