GNU bug report logs -
#41001
mkdir: cannot create directory ‘test’: File exists
Previous Next
Reported by: Jonny Grant <jg <at> jguk.org>
Date: Fri, 1 May 2020 15:16:01 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
Full log
Message #39 received at 41001 <at> debbugs.gnu.org (full text, mbox):
Hi!
On 03/05/2020 00:13, Paul Eggert wrote:
> On 5/2/20 3:41 PM, Jonny Grant wrote:
>> Is a more accurate strerror considered unreliable?
>>
>> Current:
>> mkdir: cannot create directory ‘test’: File exists
>>
>> Proposed:
>> mkdir: cannot create directory ‘test’: Is a directory
>
> I don't understand this comment. As I understand it you're proposing a change to
> the mkdir command not a change to the strerror library function, and the change
> you're proposing would introduce a race condition to the mkdir command.
As the mkdir error returned to the shell is the same, I don't feel the
difference between the words "File exists" and "Is a directory" on the
terminal can be considered a race condition.
You're right, there will be a race condition where two processes are
both creating and deleting the same files. Any software which is
creating and deleting the same directories in parallel will encounter a
multitude of errors - all bets are off.
> A better fix would be to change the mkdir system call so that it sets errno to
> EISDIR in this situation. This would fix not only the mkdir utility, but also
> lots of other programs; and it wouldn't introduce a race condition. So if you're
> interested in getting the problem fixed, I suggest that you propose such a
> change to the Linux kernel developers.
Yes, if Linux kernel developers would deviate from POSIX. I emailed
linux-ext4 <at> vger.kernel.org the lines of code to change.
I'm not confident it will get in, even harder to get into POSIX I expect.
ext4_match() is what would need to be updated to check if an entry is a
directory
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/fs/ext4/namei.c
Cheers, Jonny
This bug report was last modified 5 years and 12 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.