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
[Message part 1 (text/plain, inline)]
Your message dated Fri, 1 May 2020 10:54:37 -0500
with message-id <3e663b56-7771-20c6-45aa-c709a7ee7296 <at> redhat.com>
and subject line Re: bug#41001: mkdir: cannot create directory ‘test’: File exists
has caused the debbugs.gnu.org bug report #41001,
regarding mkdir: cannot create directory ‘test’: File exists
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
41001: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=41001
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Hello!
Can this error message be clarified? The directory already exists, it is
not a file.
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.
Easy enough to check with stat() and S_ISDIR(sb.st_mode)
Can this be changed? Maybe I can make a patch for it.
Jonny
$ mkdir test
$ mkdir test
mkdir: cannot create directory ‘test’: File exists
$ mkdir --version
mkdir (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie.
$
[Message part 3 (message/rfc822, inline)]
tag 41001 notabug
thanks
On 5/1/20 10:06 AM, Jonny Grant wrote:
> Hello!
>
> Can this error message be clarified? The directory already exists, it is
> not a file.
By one definition, a directory _is_ a file, just with different
semantics (in the same way a block device, character device, symlink,
fifo, or socket can also be a file). It is not a regular file, but "a
file" is any entry stored in a directory, and as subdirectories are
stored in a directory, they count as files.
>
> lib/mkdir-p.c:200 contains this line of code that triggers below:-
>
> error (0, mkdir_errno, _("cannot create directory %s"), quote (dir));
The error message in question is coming from libc's strerror() function;
if you want a different error message for EEXIST, you'll have to
convince glibc to update their error string tables. It is not something
that coreutils directly controls. And while we could indeed output a
custom message instead of using strerror(), that would confuse people
who have grown used to the strerror() message.
>
> As it's easy enough to know that the reason mkdir fails is because
> 'test' a directory that already exists.
>
> Easy enough to check with stat() and S_ISDIR(sb.st_mode)
>
> Can this be changed? Maybe I can make a patch for it.
> Jonny
>
>
>
> $ mkdir test
> $ mkdir test
> mkdir: cannot create directory ‘test’: File exists
If nothing else, you may want to consider using 'mkdir -p test', which
specifically checks if the reason for an EEXIST failure is because the
directory already exists. Once you do that, you don't need to patch
coreutils.
Thus, I'm closing this as not a bug; but feel free to respond further
with any more comments on the topic.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
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.