bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#41001: mkdir: cannot create directory ‘test’: File exists


From: Jonny Grant
Subject: bug#41001: mkdir: cannot create directory ‘test’: File exists
Date: Thu, 7 May 2020 12:29:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]