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 #54 received at 41001 <at> debbugs.gnu.org (full text, mbox):
taehwan jeoung wrote:
> Can this error message be clarified? The directory already exists, it is
> not a file.
That is incorrect. Directories are files. FIFOs are files. Device
nodes are files. Symlinks are files. Network sockets are files.
They are all files. Therefore it is not incorrect to say that a file
already exists. Directories are files.
We have all agreed that if a better error message were provided then
that would be an improvement. We agree with you. We would do it if
it were within the power of mkdir(1) to do it. But it isn't.
Therefore we can't.
> lib/mkdir-p.c:200 contains this line of code that triggers below:-
>
> error (0, mkdir_errno, _("cannot create directory %s"), quote (dir));
>
> As it's easy enough to know that the reason mkdir fails is because
> 'test' a directory that already exists.
That is also incorrect. Since that information is not provided at the
time of the action it can only be inferred by implication later. But
at the time of the failure return it cannot be known unless the kernel
provides that information. Later in time things might have changed.
> Easy enough to check with stat() and S_ISDIR(sb.st_mode)
Incorrect. Checking *later* with stat() does not provide the reason
that the earlier mkdir(2) failed. It provides a guess of something
that might be the reason. Maybe. Or it maybe not. Things may have
changed later in time and the guess made later might not be the
correct reason. Reporting that as if it were would be a worse bug.
That checking later in time after the mkdir has failed is what
introduces the race condition that we have been talking about. Please
do not ignore that critically important point.
> Can this be changed? Maybe I can make a patch for it.
Sigh. Ignoring the reasons why this is a bad idea are not helpful.
Bob
This bug report was last modified 5 years and 11 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.