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
View this message in rfc822 format
Hi Eric
On 05/05/2020 20:58, Eric Blake wrote:
> On 5/5/20 1:36 PM, Jonny Grant wrote:
>
>>>
>>> Okay. That's confusing. The only value in hand being EEXIST then
>>> that is the error to be reported. If this were repeated many times
>>> then sometimes we would catch it as an actual directory.
>>>
>>> lstat("foodir1", 0x7ffcafc12800) = -1 ENOENT (No such file
>>> or directory)
>>> mkdir("foodir1", 0777) = -1 EEXIST (File exists)
>>> lstat("foodir1", {st_mode=S_IFDIR|0775, st_size=40, ...}) = 0
>>>
>>> In that case the proposal is to report it as EISDIR.
>
>>
>> yes, I only asked Linux kernel ext4 team, as it is one place to ask
>> the question, and judge the response. They also don't want to make any
>> change. We're stuck with all these old interfaces. Unless someone
>> wants to come up with mkdir2() and get it into POSIX.
>
> We already have mkdirat() specified by POSIX. It would be easier to add
> a new O_ flag that tells mkdirat() to give a different errno failure
> than to add a completely new interface. But emulating that new flag on
> older kernels that don't natively support it will be back at the same
> non-atomic racy situation we are in now.
Sounds good.
Would that O_ flag work on the 'mode' ? in which case could be mkdir() too.
>>
>> Maybe a simple localised string is better in your mkdir tool?
>> After-all the man page and POSIX gives the exact meaning of EEXIST in
>> this context?
>>
>> "pathname already exists"
>
> If you can convince glibc to change the contents of their
> strerror(EEXIST) along those lines, then go for it. But they would
> probably tell you that the GNU Coding Standards frown on using
> "pathname" instead of "filename" (per GCS, "path" should be reserved for
> colon-separated lists such as $PATH - which is a different definition
> than POSIX has where "path" is merely a concatenation of "filenames"
> using '/', so it's a tough sell.
"name already exists" might work, or "Directory or file already exists".
Although it's almost certainly impossible, they also won't want to
change it for strerror(EEXIST)
This comment is based on something Andreas Dilger suggested on the ext4
list:
How about updating mkdir tool with this?
if (EEXIST == errno)
{
errmsg = _("name already exists");
}
>> The output is only incorrect because it defaults to system localised
>> strerror(EEXIST)
>>
>> So with this change, it would be:
>>
>> mkdir: cannot create directory ‘test’: pathname already exists
>
> Giving different output than strerror() will confuse users; it's better
> to make the change in glibc for ALL clients of strerror(EEXIST) rather
> than just this one client.
I doubt glibc would ever agree to change strerror(EEXIST). I imagine it
all gets beaurocratic, and they might require POSIX make the update to
the spec first?
Cheers, Jonny
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.