All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arthur Williams <taaparthur@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, Arthur Williams <taaparthur@gmail.com>
Subject: [PATCH] fs: Allow open with O_CREAT to succeed if existing dir is specified
Date: Sat, 19 Jun 2021 06:01:48 -0500	[thread overview]
Message-ID: <20210619110148.30412-1-taaparthur@gmail.com> (raw)

Make opening a file with the O_CREAT flag a no-op if the specified file
exists even if it exists as a directory. Allows userspace commands, like
flock, to open a file and create it if it doesn't exist instead of
having to parse errno.

Signed-off-by: Arthur Williams <taaparthur@gmail.com>
---
 fs/namei.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 79b0ff9b151e..58d06709541c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3334,8 +3334,6 @@ static int do_open(struct nameidata *nd,
 	if (open_flag & O_CREAT) {
 		if ((open_flag & O_EXCL) && !(file->f_mode & FMODE_CREATED))
 			return -EEXIST;
-		if (d_is_dir(nd->path.dentry))
-			return -EISDIR;
 		error = may_create_in_sticky(mnt_userns, nd,
 					     d_backing_inode(nd->path.dentry));
 		if (unlikely(error))
-- 
2.31.1


             reply	other threads:[~2021-06-19 11:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19 11:01 Arthur Williams [this message]
2021-06-19 12:42 ` [PATCH] fs: Allow open with O_CREAT to succeed if existing dir is specified Al Viro
2021-06-19 14:27   ` Matthew Wilcox
     [not found]   ` <CAJ6D+Z96OWwZMzickLP3PtUnsJhSfZqTnLrmk4-t5iNUid=N=Q@mail.gmail.com>
2021-06-19 15:09     ` Al Viro
2021-07-01  2:19 ` [fs] 87f196bed3: xfstests.generic.157.fail kernel test robot
2021-07-01  2:19   ` kernel test robot
2021-07-01  9:48   ` David Sterba
2021-07-01  9:48     ` David Sterba

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=20210619110148.30412-1-taaparthur@gmail.com \
    --to=taaparthur@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.