trailing spaces in 1.7.0

Corinna Vinschen corinna-cygwin@cygwin.com
Sat May 10 19:31:00 GMT 2008


On May 10 21:15, Corinna Vinschen wrote:
> On May 10 20:58, Corinna Vinschen wrote:
> > On May 10 09:14, Eric Blake wrote:
> > > This regression is interfering with the testsuite of a git checkout of 
> > > autoconf, which tries to sanitize special pathnames by first testing if 
> > > trailing spaces in directory names are supported (since in 1.5.25, the 
> > > trailing space is stripped when the directory occurs in isolation, but not 
> > > when used like 'dir /file'; worse, this happened even in managed mounts).  
> > > The problem is probably caused by the fact that 1.7.0 tries to use special 
> > > path names to work around windows limitations:
> > >
> > > $ mkdir 'dir '
> > > $ rm -Rf 'dir '; echo $?
> > > 1
> > > $ ls -dQ d*
> > > "dir "
> > > $ rm -R 'dir '; echo $?
> > > 0
> > > $ ls -dQ d*
> > > ls: cannot access "d*": No such file or directory
> > >
> > > Something in the -f codepath caused rm to exit with failure, but without 
> > > any error message (if nothing else, coreutils should never exit non-zero 
> > > without a message).  I'm still trying to get a debugging build of coreutils 
> > > built under 1.7.0 to further investigate which syscall is causing rm to 
> > > exit, but Corinna is more familiar with the underlying path name 
> > > manipulation that allows the creation of a trailing space in the first 
> > > place.
> > 
> > In theory it should always be possible.  I thought I have removed the
> > code path which handles trailing spaces.  From the top of my head I
> > have no idea what's causing that, sorry.
> 
> I just ran strace on that.
> 
>   $ rmdir 'dir '
> 
> works fine, apparently.  However, when you run the above
> 
>   $ rm -Rf 'dir '
> 
> under strace, there's something strange (I tested this in ~/tmp):
> 
>     0   65415 [main] rm 3700 chdir: dir '/home/corinna/tmp/dir'
> 
> Huh?  Why does rm try to change into 'dir' instead of into 'dir '?
> Naturally this fails because 'dir' doesn't exist:
> 
>     0   65415 [main] rm 3700 symlink_info::check: 0xC0000034 = NtQueryAttributesFile (\??\C:\cygwin\home\corinna\tmp\dir)

I forgot to mention something which might confuse you when debugging.
Trailing dots and spaces are still not left as an excercise for the OS,
even in 1.7.  The reason is that you would be unable to open such files
with Win32 tools.  For that reason, trailing dots and spaces are
transposed to characters in the UNICODE private use area, the same as
special chars like ? or *.  Again, dots and spaces *within* a file name
are left alone, but *trailing* dots and spaces are transposed to the
UNICODE characters 0xf02e and 0xf020.

So, when you debug this, you won't see valid trailing ASCII chars,
but very likely a question mark as replacement char instead.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat



More information about the Cygwin-developers mailing list