linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonny Grant <jg@jguk.org>
To: "Theodore Y. Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: /fs/ext4/namei.c ext4_find_dest_de()
Date: Tue, 5 May 2020 19:07:23 +0100	[thread overview]
Message-ID: <f1d8d13f-1605-a19c-e75c-1ecdb8c42fcf@jguk.org> (raw)
In-Reply-To: <20200504195255.GC404484@mit.edu>



On 04/05/2020 20:52, Theodore Y. Ts'o wrote:
> On Mon, May 04, 2020 at 08:38:33AM +0100, Jonny Grant wrote:
>>>> I noticed that mkdir() returns EEXIST if a directory already exists.
>>>> strerror(EEXIST) text is "File exists"
>>>>
>>>> Can ext4_find_dest_de() be amended to return EISDIR if a directory already
>>>> exists? This will make the error message clearer.
>>>
>>> No; this will confuse potentially a large number of existing programs.
>>> Also, the current behavior is required by POSIx and the Single Unix
>>> Specification standards.
>>>
>>> 	https://pubs.opengroup.org/onlinepubs/009695399/
>>>
>> Is it likely POSIX would introduce this change? It's a shame we're still
>> constrained by old standards (SVr4, BSD), but it's fine if they can be
>> updated.
> 
> No, because it has the potential to break existing Unix/Linux/Posix-compliant
> programs.  There may very well be C programs doing the following....
> 
> 	   if (mkdir(filename) < 0) {
> 	   	if (errno != EEXIST) {
> 			perror(filename);
> 			exit(1);
> 		}
> 	}
> 
> For example, there may very well be implementations of "mkdir -p" that
> do precisely this.
> 
> If we change the error returned by the mkdir system call as you
> propose, it would break these innocent, unsuspecting programs.  That's
> not something which will be allowed, because it falls into the
> category of a Bad Thing.

Thank you for your reply.

What's an appropriate solution to this problem?

To achieve the desired output. when a directory exists.

$ mkdir test
$ mkdir: cannot create directory ‘test’: Is a directory

Cheers, Jonny

  reply	other threads:[~2020-05-05 18:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 13:00 /fs/ext4/namei.c ext4_find_dest_de() Jonny Grant
2020-05-04  1:51 ` Theodore Y. Ts'o
2020-05-04  7:38   ` Jonny Grant
2020-05-04 19:52     ` Theodore Y. Ts'o
2020-05-05 18:07       ` Jonny Grant [this message]
2020-05-05 18:50         ` Andreas Dilger
2020-05-07 11:25           ` Jonny Grant
2020-05-27 21:25   ` Jonny Grant
2020-05-28  1:12     ` Theodore Y. Ts'o
2020-06-08  1:39       ` Jonny Grant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1d8d13f-1605-a19c-e75c-1ecdb8c42fcf@jguk.org \
    --to=jg@jguk.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).