[PATCH] fs: Allow open with O_CREAT to succeed if existing dir is specified

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

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux