Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] make O_EXCL in nd->intent.flags visible in nd->flags

New flag: LOOKUP_EXCL. Set before doing the final step of pathname
resolution on the paths that have LOOKUP_CREATE and O_EXCL.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 3516586a 2c552d81

+9 -8
+1 -1
fs/gfs2/ops_inode.c
··· 69 69 mark_inode_dirty(inode); 70 70 break; 71 71 } else if (PTR_ERR(inode) != -EEXIST || 72 - (nd && (nd->intent.open.flags & O_EXCL))) { 72 + (nd && nd->flags & LOOKUP_EXCL)) { 73 73 gfs2_holder_uninit(ghs); 74 74 return PTR_ERR(inode); 75 75 }
+3 -1
fs/namei.c
··· 1709 1709 dir = nd.path.dentry; 1710 1710 nd.flags &= ~LOOKUP_PARENT; 1711 1711 nd.flags |= LOOKUP_CREATE | LOOKUP_OPEN; 1712 + if (flag & O_EXCL) 1713 + nd.flags |= LOOKUP_EXCL; 1712 1714 mutex_lock(&dir->d_inode->i_mutex); 1713 1715 path.dentry = lookup_hash(&nd); 1714 1716 path.mnt = nd.path.mnt; ··· 1908 1906 if (nd->last_type != LAST_NORM) 1909 1907 goto fail; 1910 1908 nd->flags &= ~LOOKUP_PARENT; 1911 - nd->flags |= LOOKUP_CREATE; 1909 + nd->flags |= LOOKUP_CREATE | LOOKUP_EXCL; 1912 1910 nd->intent.open.flags = O_EXCL; 1913 1911 1914 1912 /*
+2 -4
fs/nfs/dir.c
··· 707 707 { 708 708 if (NFS_PROTO(dir)->version == 2) 709 709 return 0; 710 - if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_CREATE) == 0) 711 - return 0; 712 - return (nd->intent.open.flags & O_EXCL) != 0; 710 + return nd && nfs_lookup_check_intent(nd, LOOKUP_EXCL); 713 711 } 714 712 715 713 /* ··· 1007 1009 1008 1010 /* Let vfs_create() deal with O_EXCL. Instantiate, but don't hash 1009 1011 * the dentry. */ 1010 - if (nd->intent.open.flags & O_EXCL) { 1012 + if (nd->flags & LOOKUP_EXCL) { 1011 1013 d_instantiate(dentry, NULL); 1012 1014 goto out; 1013 1015 }
+3 -2
include/linux/namei.h
··· 51 51 /* 52 52 * Intent data 53 53 */ 54 - #define LOOKUP_OPEN (0x0100) 55 - #define LOOKUP_CREATE (0x0200) 54 + #define LOOKUP_OPEN 0x0100 55 + #define LOOKUP_CREATE 0x0200 56 + #define LOOKUP_EXCL 0x0400 56 57 57 58 extern int user_path_at(int, const char __user *, unsigned, struct path *); 58 59