delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/02/19/06:47:17

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Fri, 19 Feb 2010 12:47:02 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: 1.7.1(0.218/5/3): ls -R bug (Windows XP)
Message-ID: <20100219114702.GZ5683@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <000401cab10d$84b7ce10$8e276a30$@com>
MIME-Version: 1.0
In-Reply-To: <000401cab10d$84b7ce10$8e276a30$@com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

On Feb 19 11:44, Jeff Wilcox wrote:
> In Cygwin 1.7.x if I ls -R the root of a drive which contains only
> directories (i.e. no files at the root level), whatever directory comes
> first is omitted from the listing and the following error is thrown:
> 
> ls: ./<DIR NAME>: not listing already-listed directory

Thanks for the report.  I can reproduce it, even with files in the root
directory.  I'm wondering that this has never been found before.

I see what's going on but not why.

Eric?  Ping?  I need your help.

This only occurs on NTFS drives.  AFAICS, what happens is this:

- ls calls opendir.  This opens the directory with very limited
  permissions, SYNCHRONIZE | FILE_LIST_DIRECTORY.  Note especially
  the lack of FILE_READ_ATTRIBUTES.

- Apparently ls fetches the directory descriptor from the DIR structure
  calling dirfd().  Then it calls fstat(dirfd()).

- Cygwin enters the fhandler_base::fstat_by_handle function and
  the call to NtQueryInformationFile fails with STAUS_ACCESS_DENIED.

- Cygwin tries the alternative call fhandler_base::fstat_by_name
  which succeeds.

- For some unknown reason ls claims
  "ls: ./<DIR NAME>: not listing already-listed directory".

What I did for testing was to change fhandler_disk_file::opendir to open
the directory with FILE_READ_ATTRIBUTES | READ_CONTROL rights.

The change here is that fstat_by_handle now works.  And the end result
is that ls does *not* complain.

However, that's quite puzzeling.  The stat entries are identical.
There's something going on I don't see, and that makes me wary.  I don't
want to change fhandler_disk_file::opendir - even though it's the right
thing to do - unless we are sure about the cause for the above problem.


Corinna

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

--
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

- Raw text -


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