From: Andrew Morton <akpm@osdl.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] open: O_DIRECTORY and O_CREAT together should fail
Date: Fri, 23 Sep 2005 12:28:34 -0700 [thread overview]
Message-ID: <20050923122834.659966c4.akpm@osdl.org> (raw)
In-Reply-To: <E1EIonQ-0006Ts-00@dorka.pomaz.szeredi.hu>
Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> Add a check for O_DIRECTORY in the O_CREAT path, and return -EINVAL.
>
> Current behavior is inconsistent with documentation:
> open(..., O_DIRECTORY|O_CREAT) succeeds if file didn't exist, and
> returned descriptor does not refer to a directory.
>
> No other error value quite fits this case:
>
> ENOTDIR - the file doesn't exist, so this is slightly misleading
> ENOENT - yes, but we asked for an O_CREAT so why wasn't it created
>
> But EINVAL - invalid combination of flags, is quite good IMO.
>
We could be a bit screwed here. If there are any apps out there which are
using this combination, we just broke them. Essentially the patch is
assuming that nobody is currently using O_CREAT|O_DIRECTORY, but one day in
the future someone will do that.
>
> Index: linux/fs/namei.c
> ===================================================================
> --- linux.orig/fs/namei.c 2005-09-23 16:35:32.000000000 +0200
> +++ linux/fs/namei.c 2005-09-23 16:36:19.000000000 +0200
> @@ -1441,6 +1441,9 @@ int open_namei(const char * pathname, in
> return error;
> goto ok;
> }
> + /* O_CREAT | O_DIRECTORY should fail */
> + if (flag & O_DIRECTORY)
> + return -EINVAL;
>
> /*
> * Create - we need to know the parent.
next prev parent reply other threads:[~2005-09-23 19:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-23 14:45 Miklos Szeredi
2005-09-23 19:28 ` Andrew Morton [this message]
2005-09-24 5:52 ` Miklos Szeredi
2005-09-24 6:09 ` Al Viro
2005-09-24 6:41 ` Miklos Szeredi
2005-09-24 7:01 ` Al Viro
2005-09-24 7:43 ` Miklos Szeredi
2005-09-24 19:53 ` Kyle Moffett
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=20050923122834.659966c4.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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
all inboxes | Powered by JetHome®