[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ls: issue error message on removed directory
From: |
Colin Watson |
Subject: |
Re: [PATCH] ls: issue error message on removed directory |
Date: |
Wed, 12 Feb 2020 11:20:04 +0000 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Wed, Feb 12, 2020 at 10:54:43AM +0000, Pádraig Brady wrote:
> Sorry I sent the following to the list only.
> Please cc address@hidden on any responses...
>
> On 11/02/2020 10:45, Colin Watson wrote:
> > If the current directory has been removed, then "ls" confusingly
> > produced no output and no error message, indistinguishable from the case
> > of running on an empty directory. It makes more sense to report ENOENT
> > in this case.
>
> I don't think this is a general solution as the opendir() spec states:
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html
> "The directory entries for dot and dot-dot are optional".
> I've also seen reference to FUSE file systems that don't provide those
> entries.
Ah. Fair point; that is unfortunate.
I do think this is a confusing problem and worth trying to solve,
though. The only other idea I have is, if there are no entries in the
directory, to fstat the directory fd and see if st_nlink == 0; if so,
issue a warning message, perhaps more like "directory may have been
removed" than "no such file or directory". There are probably still
FUSE-like situations where that goes wrong, but IIRC naïve FUSE
implementations tend to set st_nlink to 1 rather than 0.
Might something like that be acceptable?
--
Colin Watson [address@hidden]