vfs: pass S_IFDIR mode to vfs_prepare_mode()
Subsystems (30)
v2 cover vfs: pass S_IFDIR mode to vfs_prepare_mode()
There is a comment in vfs_prepare_mode() that says:
Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving S_IFDIR from the vfs before we enforce a non-zero type.
It is useful to do this clean-up ahead of O_CREAT|O_DIRECTORY. Specifically, in lookup_open() we need to replace the vfs_prepare_mode() with something that also handles dirs. I don't really want to push the odd
mode = vfs_prepare_mode(idmap, dir, mode, S_IRWXUGO | S_ISVTX, 0);
further into that code, and neither do I want this to be different from the regular vfs_mkdir() path. We can then also match on S_IFMT in may_o_create(), instead of passing a bool to signal whether we are creating a dir (and assuming 0 means a dir is really ugly).
It is a bit challenging to verify that passing S_IFDIR is safe, as there are many filesystems. Claude Opus 4.8 was used to generate the context for each mkdir implementation from which it can be judged whether passing S_IFDIR is OK. The result was then verified by hand by looking at how the mode argument is used in each case. To check whether all mkdir implementations are covered, 'rg "\.mkdir" ' was used and checked against the list of uses Claude found.
It is safe to do this clean-up except that three filesystems (fuse, cifs, and coda) forward the mkdir @mode unchanged to something outside the kernel. Mask S_IFDIR back out in coda_mkdir(), fuse_mkdir() and cifs_mkdir() so that what is sent outside the kernel is unchanged. Their maintainers can drop the mask once they have confirmed it is safe. For the other filesystems redundant S_IFDIR OR'ing is dropped.
Jori Koolstra (31):
vfs: pass S_IFDIR mode to vfs_prepare_mode()
9p: drop redundant S_IFDIR from mkdir
affs: drop redundant S_IFDIR from mkdir
afs: drop redundant S_IFDIR from mkdir
autofs: drop redundant S_IFDIR from mkdir
btrfs: drop redundant S_IFDIR from mkdir
ceph: drop redundant S_IFDIR from mkdir
ext2: drop redundant S_IFDIR from mkdir
ext4: drop redundant S_IFDIR from mkdir
f2fs: drop redundant S_IFDIR from mkdir
gfs2: drop redundant S_IFDIR from mkdir
hfs: drop redundant S_IFDIR from mkdir
hfsplus: drop redundant S_IFDIR from mkdir
hpfs: drop redundant S_IFDIR from mkdir
hugetlbfs: drop redundant S_IFDIR from mkdir
jffs2: drop redundant S_IFDIR from mkdir
jfs: drop redundant S_IFDIR from mkdir
minix: drop redundant S_IFDIR from mkdir
nilfs2: drop redundant S_IFDIR from mkdir
ntfs3: drop redundant S_IFDIR from mkdir
ocfs2: drop redundant S_IFDIR from mkdir
ocfs2: dlmfs: drop redundant S_IFDIR from mkdir
omfs: drop redundant S_IFDIR from mkdir
orangefs: drop redundant S_IFDIR from mkdir
ramfs: drop redundant S_IFDIR from mkdir
udf: drop redundant S_IFDIR from mkdir
ufs: drop redundant S_IFDIR from mkdir
nfs: drop redundant S_IFDIR from mkdir
ubifs: drop redundant S_IFDIR from mkdir
xfs: drop redundant S_IFDIR from mkdir
ntfs: drop redundant S_IFDIR from mkdir
fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 1 - fs/affs/namei.c | 2 +- fs/afs/dir.c | 2 +- fs/autofs/root.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 1 - fs/coda/dir.c | 7 ++++++- fs/ext2/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/f2fs/namei.c | 2 +- fs/fuse/dir.c | 8 ++++++++ fs/gfs2/inode.c | 2 +- fs/hfs/dir.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hpfs/namei.c | 4 ++-- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 2 -- fs/jfs/namei.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 7 +------ fs/nfs/dir.c | 2 +- fs/nilfs2/namei.c | 2 +- fs/ntfs/namei.c | 2 +- fs/ntfs3/namei.c | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 2 +- fs/ocfs2/namei.c | 2 +- fs/omfs/dir.c | 2 +- fs/orangefs/namei.c | 2 +- fs/ramfs/inode.c | 2 +- fs/smb/client/inode.c | 7 +++++++ fs/ubifs/dir.c | 2 +- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 35 files changed, 51 insertions(+), 40 deletions(-)
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
Signature · 1 line
2.54.0
PATCH v2 1/31 vfs: pass S_IFDIR mode to vfs_prepare_mode()
There is a comment in vfs_prepare_mode() that says:
Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving S_IFDIR from the vfs before we enforce a non-zero type.
It is safe to do this clean-up except that three filesystems (fuse, cifs, and coda) forward the mkdir @mode unchanged to something outside the kernel. Mask S_IFDIR back out in coda_mkdir(), fuse_mkdir() and cifs_mkdir() so that what is sent outside the kernel is unchanged. Their maintainers can drop the mask once they have confirmed it is safe.
--- fs/coda/dir.c | 7 ++++++- fs/fuse/dir.c | 8 ++++++++ fs/namei.c | 7 +------ fs/smb/client/inode.c | 7 +++++++ 4 files changed, 22 insertions(+), 7 deletions(-)
fs/coda/dir.c +6 -1
@@ -179,7 +179,12 @@ static struct dentry *coda_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (is_root_inode (dir) &&coda_iscontrol (name, len))return ERR_PTR (-EPERM ); - attrs.va_mode = mode; +/* +* vfs_mkdir() now passes S_IFDIR in @mode, but @mode is forwarded +* verbatim to userspace, which has only ever been given the permission +* bits. Strip the type bit until venus is known to cope with it. +*/ + attrs.va_mode = mode & ~S_IFDIR ; error =venus_mkdir (dir->i_sb,coda_i2f (dir), name, len, &newfid, &attrs);if (error)
fs/fuse/dir.c +8 -0
@@ -1117,6 +1117,14 @@ static struct dentry *fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!fm->fc->dont_mask) mode &= ~current_umask (); +/* +* vfs_mkdir() now passes S_IFDIR in @mode, but @mode is forwarded +* verbatim to the userspace server which has only ever been given the +* permission bits. Strip the type bit until the protocol is known to +* cope with it. +*/ + mode &= ~S_IFDIR ; +memset (&inarg,0 ,sizeof (inarg)); inarg.mode = mode; inarg.umask =current_umask ();
fs/namei.c +1 -6
@@ -4140,11 +4140,6 @@ EXPORT_SYMBOL(end_renaming);* after setgid stripping allows the same ordering for both non-POSIX ACL and * POSIX ACL supporting filesystems. * -* Note that it's currently valid for @type to be 0 if a directory is created. -* Filesystems raise that flag individually and we need to check whether each -* filesystem can deal with receiving S_IFDIR from the vfs before we enforce a -* non-zero type. -* * Returns: mode to be passed to the filesystem */ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
@@ -5256,7 +5251,7 @@ struct dentry *vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!dir->i_op->mkdir) goto err; - mode =vfs_prepare_mode (idmap, dir, mode,S_IRWXUGO |S_ISVTX ,0 ); + mode =vfs_prepare_mode (idmap, dir, mode,S_IRWXUGO |S_ISVTX ,S_IFDIR ); error =security_inode_mkdir (dir, dentry, mode);if (error) goto err;
fs/smb/client/inode.c +7 -0
@@ -2282,6 +2282,13 @@ struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,const char *full_path;void *page; +/* +* vfs_mkdir() now passes S_IFDIR in @mode, but @mode is forwarded +* verbatim to the server and in the past only contained permission +* bits. Strip the type bit until SMB is verified to deal with it. +*/ + mode &= ~S_IFDIR ; +cifs_dbg (FYI ,"In cifs_mkdir, mode = %04ho inode = 0x%p\n" , mode, inode);
Signature · 1 line
2.54.0
Quoted 7 lines · Jori Koolstra
There is a comment in
vfs_prepare_mode()that says:Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving
S_IFDIRfrom the vfs before we enforce a non-zero type.
Quoted 8 lines
It is safe to do this clean-up except that three filesystems (fuse, cifs, and coda) forward the mkdir @mode unchanged to something outside the kernel. Mask
S_IFDIRback out incoda_mkdir(),fuse_mkdir()andcifs_mkdir()so that what is sent outside the kernel is unchanged. Their maintainers can drop the mask once they have confirmed it is safe.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 90 lines
--- fs/coda/dir.c | 7 ++++++- fs/fuse/dir.c | 8 ++++++++ fs/namei.c | 7 +------ fs/smb/client/inode.c | 7 +++++++ 4 files changed, 22 insertions(+), 7 deletions(-)fs/coda/dir.c +6
-1@@ -179,7 +179,12 @@ static struct dentry *coda_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (is_root_inode (dir) &&coda_iscontrol (name, len))return ERR_PTR (-EPERM ); - attrs.va_mode = mode; +/* +* vfs_mkdir() now passes S_IFDIR in @mode, but @mode is forwarded +* verbatim to userspace, which has only ever been given the permission +* bits. Strip the type bit until venus is known to cope with it. +*/ + attrs.va_mode = mode & ~S_IFDIR ; error =venus_mkdir (dir->i_sb,coda_i2f (dir), name, len, &newfid, &attrs);if (error)fs/fuse/dir.c +8
-0@@ -1117,6 +1117,14 @@ static struct dentry *fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!fm->fc->dont_mask) mode &= ~current_umask (); +/* +* vfs_mkdir() now passes S_IFDIR in @mode, but @mode is forwarded +* verbatim to the userspace server which has only ever been given the +* permission bits. Strip the type bit until the protocol is known to +* cope with it. +*/ + mode &= ~S_IFDIR ; +memset (&inarg,0 ,sizeof (inarg)); inarg.mode = mode; inarg.umask =current_umask ();fs/namei.c +1
-6@@ -4140,11 +4140,6 @@ EXPORT_SYMBOL(end_renaming);* after setgid stripping allows the same ordering for both non-POSIX ACL and * POSIX ACL supporting filesystems. * -* Note that it's currently valid for @type to be 0 if a directory is created. -* Filesystems raise that flag individually and we need to check whether each -* filesystem can deal with receiving S_IFDIR from the vfs before we enforce a -* non-zero type. -* * Returns: mode to be passed to the filesystem */ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,@@ -5256,7 +5251,7 @@ struct dentry *vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!dir->i_op->mkdir) goto err; - mode =vfs_prepare_mode (idmap, dir, mode,S_IRWXUGO |S_ISVTX ,0 ); + mode =vfs_prepare_mode (idmap, dir, mode,S_IRWXUGO |S_ISVTX ,S_IFDIR ); error =security_inode_mkdir (dir, dentry, mode);if (error) goto err;fs/smb/client/inode.c +7
-0@@ -2282,6 +2282,13 @@ struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,const char *full_path;void *page; +/* +* vfs_mkdir() now passes S_IFDIR in @mode, but @mode is forwarded +* verbatim to the server and in the past only contained permission +* bits. Strip the type bit until SMB is verified to deal with it. +*/ + mode &= ~S_IFDIR ; +cifs_dbg (FYI ,"In cifs_mkdir, mode = %04ho inode = 0x%p\n" , mode, inode);Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 2/31 9p: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in v9fs_vfs_mkdir() is redundant. Drop it.
--- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
fs/9p/vfs_inode.c +1 -1
@@ -689,7 +689,7 @@ static struct dentry *v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,p9_debug (P9_DEBUG_VFS ,"name %pd\n" , dentry); v9ses =v9fs_inode2v9ses (dir); - perm =unixmode2p9mode (v9ses, mode |S_IFDIR ); + perm =unixmode2p9mode (v9ses, mode); fid =v9fs_create (v9ses, dir, dentry,NULL , perm,P9_OREAD );if (IS_ERR (fid))return ERR_CAST (fid);
fs/9p/vfs_inode_dotl.c +0 -1
@@ -362,7 +362,6 @@ static struct dentry *v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap,p9_debug (P9_DEBUG_VFS ,"name %pd\n" , dentry); v9ses =v9fs_inode2v9ses (dir); - omode |=S_IFDIR ;if (dir->i_mode &S_ISGID ) omode |=S_ISGID ;
Signature · 1 line
2.54.0
PATCH v2 3/31 affs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in affs_mkdir() is redundant. Drop it.
--- fs/affs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/affs/namei.c +1 -1
@@ -287,7 +287,7 @@ affs_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!inode)return ERR_PTR (-ENOSPC ); - inode->i_mode =S_IFDIR | mode; + inode->i_mode = mode;affs_mode_to_prot (inode); inode->i_op = &affs_dir_inode_operations;
Signature · 1 line
2.54.0
PATCH v2 4/31 afs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in afs_mkdir() is redundant. Drop it.
--- fs/afs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/dir.c +1 -1
@@ -1323,7 +1323,7 @@ static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, op->file[0 ].modification = true; op->file[0 ].update_ctime = true; op->dentry = dentry; - op->create.mode =S_IFDIR | mode; + op->create.mode = mode; op->create.reason = afs_edit_dir_for_mkdir; op->mtime =current_time (dir); op->ops = &afs_mkdir_operation;
Signature · 1 line
2.54.0
PATCH v2 5/31 autofs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in autofs_dir_mkdir() is redundant. Drop it.
--- fs/autofs/root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/autofs/root.c +1 -1
@@ -741,7 +741,7 @@ static struct dentry *autofs_dir_mkdir(struct mnt_idmap *idmap,autofs_del_active (dentry); - inode =autofs_get_inode (dir->i_sb,S_IFDIR | mode); + inode =autofs_get_inode (dir->i_sb, mode);if (!inode)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.54.0
PATCH v2 6/31 btrfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in btrfs_mkdir() is redundant. Drop it.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -6936,7 +6936,7 @@ static struct dentry *btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, inode =new_inode (dir->i_sb);if (!inode)return ERR_PTR (-ENOMEM ); -inode_init_owner (idmap, inode, dir,S_IFDIR | mode); +inode_init_owner (idmap, inode, dir, mode); inode->i_op = &btrfs_dir_inode_operations; inode->i_fop = &btrfs_dir_file_operations;return ERR_PTR (btrfs_create_common (dir, dentry, inode));
Signature · 1 line
2.54.0
PATCH v2 7/31 ceph: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ceph_mkdir() is redundant. Drop it.
--- fs/ceph/dir.c | 1 - 1 file changed, 1 deletion(-)
fs/ceph/dir.c +0 -1
@@ -1142,7 +1142,6 @@ static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, goto out; } - mode |=S_IFDIR ; req->r_new_inode =ceph_new_inode (dir, dentry, &mode, &as_ctx);if (IS_ERR (req->r_new_inode)) { ret =ERR_CAST (req->r_new_inode);
Signature · 1 line
2.54.0
PATCH v2 8/31 ext2: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ext2_mkdir() is redundant. Drop it.
--- fs/ext2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext2/namei.c +1 -1
@@ -236,7 +236,7 @@ static struct dentry *ext2_mkdir(struct mnt_idmap * idmap,inode_inc_link_count (dir); - inode =ext2_new_inode (dir,S_IFDIR | mode, &dentry->d_name); + inode =ext2_new_inode (dir, mode, &dentry->d_name); err =PTR_ERR (inode);if (IS_ERR (inode)) goto out_dir;
Signature · 1 line
2.54.0
Re: [PATCH v2 08/31] ext2: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again inext2_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/ext2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ext2/namei.c +1
-1@@ -236,7 +236,7 @@ static struct dentry *ext2_mkdir(struct mnt_idmap * idmap,inode_inc_link_count (dir); - inode =ext2_new_inode (dir,S_IFDIR | mode, &dentry->d_name); + inode =ext2_new_inode (dir, mode, &dentry->d_name); err =PTR_ERR (inode);if (IS_ERR (inode)) goto out_dir;Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 9/31 ext4: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ext4_mkdir() is redundant. Drop it.
--- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/namei.c +1 -1
@@ -3009,7 +3009,7 @@ static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, credits = (EXT4_DATA_TRANS_BLOCKS (dir->i_sb) +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 ); retry: - inode =ext4_new_inode_start_handle (idmap, dir,S_IFDIR | mode, + inode =ext4_new_inode_start_handle (idmap, dir, mode, &dentry->d_name,0 ,NULL ,EXT4_HT_DIR , credits); handle =ext4_journal_current_handle ();
Signature · 1 line
2.54.0
Re: [PATCH v2 09/31] ext4: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again inext4_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ext4/namei.c +1
-1@@ -3009,7 +3009,7 @@ static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, credits = (EXT4_DATA_TRANS_BLOCKS (dir->i_sb) +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 ); retry: - inode =ext4_new_inode_start_handle (idmap, dir,S_IFDIR | mode, + inode =ext4_new_inode_start_handle (idmap, dir, mode, &dentry->d_name,0 ,NULL ,EXT4_HT_DIR , credits); handle =ext4_journal_current_handle ();Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 10/31 f2fs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in f2fs_mkdir() is redundant. Drop it.
--- fs/f2fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/namei.c +1 -1
@@ -742,7 +742,7 @@ static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (err)return ERR_PTR (err); - inode =f2fs_new_inode (idmap, dir,S_IFDIR | mode,NULL ); + inode =f2fs_new_inode (idmap, dir, mode,NULL );if (IS_ERR (inode))return ERR_CAST (inode);
Signature · 1 line
2.54.0
PATCH v2 11/31 gfs2: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in gfs2_mkdir() is redundant. Drop it.
--- fs/gfs2/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/inode.c +1 -1
@@ -1351,7 +1351,7 @@ static struct dentry *gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir, {unsigned dsize =gfs2_max_stuffed_size (GFS2_I (dir)); -return ERR_PTR (gfs2_create_inode (dir, dentry,NULL ,S_IFDIR | mode,0 ,NULL , dsize,0 )); +return ERR_PTR (gfs2_create_inode (dir, dentry,NULL , mode,0 ,NULL , dsize,0 )); }/**
Signature · 1 line
2.54.0
PATCH v2 12/31 hfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in hfs_mkdir() is redundant. Drop it.
--- fs/hfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hfs/dir.c +1 -1
@@ -219,7 +219,7 @@ static struct dentry *hfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,struct inode *inode;int res; - inode =hfs_new_inode (dir, &dentry->d_name,S_IFDIR | mode); + inode =hfs_new_inode (dir, &dentry->d_name, mode);if (IS_ERR (inode))return ERR_CAST (inode);
Signature · 1 line
2.54.0
PATCH v2 13/31 hfsplus: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in hfsplus_mkdir() is redundant. Drop it.
--- fs/hfsplus/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hfsplus/dir.c +1 -1
@@ -570,7 +570,7 @@ static int hfsplus_create(struct mnt_idmap *idmap, struct inode *dir,static struct dentry *hfsplus_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode) { -return ERR_PTR (hfsplus_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFDIR ,0 )); +return ERR_PTR (hfsplus_mknod (&nop_mnt_idmap, dir, dentry, mode,0 )); } static int hfsplus_rename(struct mnt_idmap *idmap,
Signature · 1 line
2.54.0
PATCH v2 14/31 hpfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in hpfs_mkdir() is redundant. Drop it.
--- fs/hpfs/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/hpfs/namei.c +2 -2
@@ -105,10 +105,10 @@ static struct dentry *hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!uid_eq (result->i_uid,current_fsuid ()) || !gid_eq (result->i_gid,current_fsgid ()) || - result->i_mode != (mode |S_IFDIR )) { + result->i_mode != mode) { result->i_uid =current_fsuid (); result->i_gid =current_fsgid (); - result->i_mode = mode |S_IFDIR ; + result->i_mode = mode;hpfs_write_inode_nolock (result); }hpfs_update_directory_times (dir);
Signature · 1 line
2.54.0
PATCH v2 15/31 hugetlbfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in hugetlbfs_mkdir() is redundant. Drop it.
--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hugetlbfs/inode.c +1 -1
@@ -971,7 +971,7 @@ static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dir struct dentry *dentry, umode_t mode) { int retval = hugetlbfs_mknod(idmap, dir, dentry, - mode |S_IFDIR ,0 ); + mode,0 );if (!retval)inc_nlink (dir);return ERR_PTR (retval);
Signature · 1 line
2.54.0
PATCH v2 16/31 jffs2: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in jffs2_mkdir() is redundant. Drop it.
--- fs/jffs2/dir.c | 2 -- 1 file changed, 2 deletions(-)
fs/jffs2/dir.c +0 -2
@@ -462,8 +462,6 @@ static struct dentry *jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,uint32_t alloclen;int ret; - mode |=S_IFDIR ; - ri =jffs2_alloc_raw_inode ();if (!ri)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.54.0
PATCH v2 17/31 jfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in jfs_mkdir() is redundant. Drop it.
--- fs/jfs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/namei.c +1 -1
@@ -223,7 +223,7 @@ static struct dentry *jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,* block there while holding dtree page, so we allocate the inode & * begin the transaction before we search the directory. */ - ip =ialloc (dip,S_IFDIR | mode); + ip =ialloc (dip, mode);if (IS_ERR (ip)) { rc =PTR_ERR (ip); goto out2;
Signature · 1 line
2.54.0
PATCH v2 18/31 minix: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in minix_mkdir() is redundant. Drop it.
--- fs/minix/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/minix/namei.c +1 -1
@@ -110,7 +110,7 @@ static struct dentry *minix_mkdir(struct mnt_idmap *idmap, struct inode *dir,struct inode * inode;int err; - inode =minix_new_inode (dir,S_IFDIR | mode); + inode =minix_new_inode (dir, mode);if (IS_ERR (inode))return ERR_CAST (inode);
Signature · 1 line
2.54.0
Re: [PATCH v2 18/31] minix: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again inminix_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/minix/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/minix/namei.c +1
-1@@ -110,7 +110,7 @@ static struct dentry *minix_mkdir(struct mnt_idmap *idmap, struct inode *dir,struct inode * inode;int err; - inode =minix_new_inode (dir,S_IFDIR | mode); + inode =minix_new_inode (dir, mode);if (IS_ERR (inode))return ERR_CAST (inode);Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 19/31 nilfs2: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in nilfs_mkdir() is redundant. Drop it.
--- fs/nilfs2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/namei.c +1 -1
@@ -231,7 +231,7 @@ static struct dentry *nilfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,inc_nlink (dir); - inode =nilfs_new_inode (dir,S_IFDIR | mode); + inode =nilfs_new_inode (dir, mode); err =PTR_ERR (inode);if (IS_ERR (inode)) goto out_dir;
Signature · 1 line
2.54.0
PATCH v2 20/31 ntfs3: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ntfs_mkdir() is redundant. Drop it.
--- fs/ntfs3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/namei.c +1 -1
@@ -213,7 +213,7 @@ static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode) {return ERR_PTR (ntfs_create_inode (idmap, dir, dentry,NULL , -S_IFDIR | mode,0 ,NULL ,0 ,NULL )); + mode,0 ,NULL ,0 ,NULL )); }/*
Signature · 1 line
2.54.0
PATCH v2 21/31 ocfs2: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ocfs2_mkdir() is redundant. Drop it.
--- fs/ocfs2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/namei.c +1 -1
@@ -657,7 +657,7 @@ static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap,trace_ocfs2_mkdir (dir, dentry, dentry->d_name.len, dentry->d_name.name,OCFS2_I (dir)->ip_blkno, mode); - ret =ocfs2_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFDIR ,0 ); + ret =ocfs2_mknod (&nop_mnt_idmap, dir, dentry, mode,0 );if (ret)mlog_errno (ret);
Signature · 1 line
2.54.0
Re: [PATCH v2 21/31] ocfs2: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again inocfs2_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/ocfs2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ocfs2/namei.c +1
-1@@ -657,7 +657,7 @@ static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap,trace_ocfs2_mkdir (dir, dentry, dentry->d_name.len, dentry->d_name.name,OCFS2_I (dir)->ip_blkno, mode); - ret =ocfs2_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFDIR ,0 ); + ret =ocfs2_mknod (&nop_mnt_idmap, dir, dentry, mode,0 );if (ret)mlog_errno (ret);Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 22/31 ocfs2: dlmfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in dlmfs_mkdir() is redundant. Drop it.
--- fs/ocfs2/dlmfs/dlmfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/dlmfs/dlmfs.c +1 -1
@@ -422,7 +422,7 @@ static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap, goto bail; } - inode =dlmfs_get_inode (dir, dentry, mode |S_IFDIR ); + inode =dlmfs_get_inode (dir, dentry, mode);if (!inode) { status = -ENOMEM ;mlog_errno (status);
Signature · 1 line
2.54.0
Re: [PATCH v2 22/31] ocfs2: dlmfs: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again indlmfs_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/ocfs2/dlmfs/dlmfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ocfs2/dlmfs/dlmfs.c +1
-1@@ -422,7 +422,7 @@ static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap, goto bail; } - inode =dlmfs_get_inode (dir, dentry, mode |S_IFDIR ); + inode =dlmfs_get_inode (dir, dentry, mode);if (!inode) { status = -ENOMEM ;mlog_errno (status);Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 23/31 omfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in omfs_mkdir() is redundant. Drop it.
--- fs/omfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/omfs/dir.c +1 -1
@@ -282,7 +282,7 @@ static int omfs_add_node(struct inode *dir, struct dentry *dentry, umode_t mode)static struct dentry *omfs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode) { -return ERR_PTR (omfs_add_node (dir, dentry, mode |S_IFDIR )); +return ERR_PTR (omfs_add_node (dir, dentry, mode)); } static int omfs_create(struct mnt_idmap *idmap, struct inode *dir,
Signature · 1 line
2.54.0
PATCH v2 24/31 orangefs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in orangefs_mkdir() is redundant. Drop it.
--- fs/orangefs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/orangefs/namei.c +1 -1
@@ -333,7 +333,7 @@ static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir, ref = new_op->downcall.resp.mkdir.refn; - inode =orangefs_new_inode (dir->i_sb, dir,S_IFDIR | mode,0 , &ref); + inode =orangefs_new_inode (dir->i_sb, dir, mode,0 , &ref);if (IS_ERR (inode)) {gossip_err ("*** Failed to allocate orangefs dir inode\n" ); ret =PTR_ERR (inode);
Signature · 1 line
2.54.0
PATCH v2 25/31 ramfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ramfs_mkdir() is redundant. Drop it.
--- fs/ramfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ramfs/inode.c +1 -1
@@ -121,7 +121,7 @@ ramfs_mknod(struct mnt_idmap *idmap, struct inode *dir,static struct dentry *ramfs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode) { -int retval =ramfs_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFDIR ,0 ); +int retval =ramfs_mknod (&nop_mnt_idmap, dir, dentry, mode,0 );if (!retval)inc_nlink (dir);return ERR_PTR (retval);
Signature · 1 line
2.54.0
Re: [PATCH v2 25/31] ramfs: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again inramfs_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/ramfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ramfs/inode.c +1
-1@@ -121,7 +121,7 @@ ramfs_mknod(struct mnt_idmap *idmap, struct inode *dir,static struct dentry *ramfs_mkdir (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode) { -int retval =ramfs_mknod (&nop_mnt_idmap, dir, dentry, mode |S_IFDIR ,0 ); +int retval =ramfs_mknod (&nop_mnt_idmap, dir, dentry, mode,0 );if (!retval)inc_nlink (dir);return ERR_PTR (retval);Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 26/31 udf: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in udf_mkdir() is redundant. Drop it.
--- fs/udf/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/udf/namei.c +1 -1
@@ -428,7 +428,7 @@ static struct dentry *udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,struct udf_inode_info *dinfo =UDF_I (dir);struct udf_inode_info *iinfo; - inode =udf_new_inode (dir,S_IFDIR | mode); + inode =udf_new_inode (dir, mode);if (IS_ERR (inode))return ERR_CAST (inode);
Signature · 1 line
2.54.0
Re: [PATCH v2 26/31] udf: drop redundant S_IFDIR from mkdir
Quoted 6 lines · Jori Koolstra
vfs_mkdir()now sets theS_IFDIRtype bit in the mode it passes to ->mkdir(), so OR-ingS_IFDIRinto the mode again inudf_mkdir()is redundant. Drop it.Assisted-by Claude Opus 4.8 (1M context)Signed-off-by Jori Koolstra <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 20 lines
--- fs/udf/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/udf/namei.c +1
-1@@ -428,7 +428,7 @@ static struct dentry *udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,struct udf_inode_info *dinfo =UDF_I (dir);struct udf_inode_info *iinfo; - inode =udf_new_inode (dir,S_IFDIR | mode); + inode =udf_new_inode (dir, mode);if (IS_ERR (inode))return ERR_CAST (inode);Signature · 1 line
2.54.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 27/31 ufs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ufs_mkdir() is redundant. Drop it.
--- fs/ufs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ufs/namei.c +1 -1
@@ -174,7 +174,7 @@ static struct dentry *ufs_mkdir(struct mnt_idmap * idmap, struct inode * dir,inode_inc_link_count (dir); - inode =ufs_new_inode (dir,S_IFDIR |mode); + inode =ufs_new_inode (dir, mode); err =PTR_ERR (inode);if (IS_ERR (inode)) goto out_dir;
Signature · 1 line
2.54.0
PATCH v2 28/31 nfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in nfs_mkdir() is redundant. Drop it.
--- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/dir.c +1 -1
@@ -2474,7 +2474,7 @@ struct dentry *nfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, dir->i_sb->s_id, dir->i_ino, dentry); attr.ia_valid =ATTR_MODE ; - attr.ia_mode = mode |S_IFDIR ; + attr.ia_mode = mode;trace_nfs_mkdir_enter (dir, dentry); ret =NFS_PROTO (dir)->mkdir (dir, dentry, &attr);
Signature · 1 line
2.54.0
PATCH v2 29/31 ubifs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ubifs_mkdir() is redundant. Drop it.
--- fs/ubifs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/dir.c +1 -1
@@ -1031,7 +1031,7 @@ static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir, sz_change =CALC_DENT_SIZE (fname_len (&nm)); - inode =ubifs_new_inode (c, dir,S_IFDIR | mode, false); + inode =ubifs_new_inode (c, dir, mode, false);if (IS_ERR (inode)) { err =PTR_ERR (inode); goto out_fname;
Signature · 1 line
2.54.0
PATCH v2 30/31 xfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in xfs_vn_mkdir() is redundant. Drop it.
--- fs/xfs/xfs_iops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_iops.c +1 -1
@@ -306,7 +306,7 @@ xfs_vn_mkdir(struct dentry *dentry, umode_t mode) { -return ERR_PTR (xfs_generic_create (idmap, dir, dentry, mode |S_IFDIR ,0 ,NULL )); + return ERR_PTR(xfs_generic_create(idmap, dir, dentry, mode, 0, NULL)); } STATIC struct dentry *
Signature · 1 line
2.54.0
PATCH v2 31/31 ntfs: drop redundant S_IFDIR from mkdir
In reply to Jori Koolstravfs_mkdir() now sets the S_IFDIR type bit in the mode it passes to ->mkdir(), so OR-ing S_IFDIR into the mode again in ntfs_mkdir() is redundant. Drop it.
--- fs/ntfs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs/namei.c +1 -1
@@ -1082,7 +1082,7 @@ static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,if (!(vol->vol_flags &VOLUME_IS_DIRTY ))ntfs_set_volume_flags (vol,VOLUME_IS_DIRTY ); - ni =__ntfs_create (idmap, dir, uname, uname_len,S_IFDIR | mode,0 ,NULL ,0 ); + ni =__ntfs_create (idmap, dir, uname, uname_len, mode,0 ,NULL ,0 );kmem_cache_free (ntfs_name_cache, uname);if (IS_ERR (ni)) { err =PTR_ERR (ni);
Signature · 1 line
2.54.0
Quoted 27 lines · Jori Koolstra
There is a comment in
vfs_prepare_mode()that says:Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving
S_IFDIRfrom the vfs before we enforce a non-zero type.It is useful to do this clean-up ahead of O_CREAT|O_DIRECTORY. Specifically, in
lookup_open()we need to replace thevfs_prepare_mode()with something that also handles dirs. I don't really want to push the oddmode = vfs_prepare_mode(idmap, dir, mode, S_IRWXUGO | S_ISVTX, 0);further into that code, and neither do I want this to be different from the regular
vfs_mkdir()path. We can then also match onS_IFMTinmay_o_create(), instead of passing a bool to signal whether we are creating a dir (and assuming 0 means a dir is really ugly).It is a bit challenging to verify that passing
S_IFDIRis safe, as there are many filesystems. Claude Opus 4.8 was used to generate the context for each mkdir implementation from which it can be judged whether passingS_IFDIRis OK. The result was then verified by hand by looking at how the mode argument is used in each case. To check whether all mkdir implementations are covered, 'rg "\.mkdir" ' was used and checked against the list of uses Claude found.
Quoted 6 lines
It is safe to do this clean-up except that three filesystems (fuse, cifs, and coda) forward the mkdir @mode unchanged to something outside the kernel. Mask
S_IFDIRback out incoda_mkdir(),fuse_mkdir()andcifs_mkdir()so that what is sent outside the kernel is unchanged. Their maintainers can drop the mask once they have confirmed it is safe. For the other filesystems redundantS_IFDIROR'ing is dropped.
This all looks good to me - thanks.
NeilBrown
Quoted 77 lines
Jori Koolstra (31):
vfs: passS_IFDIRmode tovfs_prepare_mode()
9p: drop redundantS_IFDIRfrom mkdir
affs: drop redundantS_IFDIRfrom mkdir
afs: drop redundantS_IFDIRfrom mkdir
autofs: drop redundantS_IFDIRfrom mkdir
btrfs: drop redundantS_IFDIRfrom mkdir
ceph: drop redundantS_IFDIRfrom mkdir
ext2: drop redundantS_IFDIRfrom mkdir
ext4: drop redundantS_IFDIRfrom mkdir
f2fs: drop redundantS_IFDIRfrom mkdir
gfs2: drop redundantS_IFDIRfrom mkdir
hfs: drop redundantS_IFDIRfrom mkdir
hfsplus: drop redundantS_IFDIRfrom mkdir
hpfs: drop redundantS_IFDIRfrom mkdir
hugetlbfs: drop redundantS_IFDIRfrom mkdir
jffs2: drop redundantS_IFDIRfrom mkdir
jfs: drop redundantS_IFDIRfrom mkdir
minix: drop redundantS_IFDIRfrom mkdir
nilfs2: drop redundantS_IFDIRfrom mkdir
ntfs3: drop redundantS_IFDIRfrom mkdir
ocfs2: drop redundantS_IFDIRfrom mkdir
ocfs2: dlmfs: drop redundantS_IFDIRfrom mkdir
omfs: drop redundantS_IFDIRfrom mkdir
orangefs: drop redundantS_IFDIRfrom mkdir
ramfs: drop redundantS_IFDIRfrom mkdir
udf: drop redundantS_IFDIRfrom mkdir
ufs: drop redundantS_IFDIRfrom mkdir
nfs: drop redundantS_IFDIRfrom mkdir
ubifs: drop redundantS_IFDIRfrom mkdir
xfs: drop redundantS_IFDIRfrom mkdir
ntfs: drop redundantS_IFDIRfrom mkdirfs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 1 - fs/affs/namei.c | 2 +- fs/afs/dir.c | 2 +- fs/autofs/root.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 1 - fs/coda/dir.c | 7 ++++++- fs/ext2/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/f2fs/namei.c | 2 +- fs/fuse/dir.c | 8 ++++++++ fs/gfs2/inode.c | 2 +- fs/hfs/dir.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hpfs/namei.c | 4 ++-- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 2 -- fs/jfs/namei.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 7 +------ fs/nfs/dir.c | 2 +- fs/nilfs2/namei.c | 2 +- fs/ntfs/namei.c | 2 +- fs/ntfs3/namei.c | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 2 +- fs/ocfs2/namei.c | 2 +- fs/omfs/dir.c | 2 +- fs/orangefs/namei.c | 2 +- fs/ramfs/inode.c | 2 +- fs/smb/client/inode.c | 7 +++++++ fs/ubifs/dir.c | 2 +- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 35 files changed, 51 insertions(+), 40 deletions(-)base-commit:
dc59e4fea9d83f03bad6bddf3fa2e52491777482Signature · 1 line
2.54.0
Quoted 39 lines
Op 01-07-2026 00:37 CEST schreef NeilBrown <[email protected]>:
Quoted 27 lines · Jori Koolstra
There is a comment in
vfs_prepare_mode()that says:Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving
S_IFDIRfrom the vfs before we enforce a non-zero type.It is useful to do this clean-up ahead of O_CREAT|O_DIRECTORY. Specifically, in
lookup_open()we need to replace thevfs_prepare_mode()with something that also handles dirs. I don't really want to push the oddmode = vfs_prepare_mode(idmap, dir, mode, S_IRWXUGO | S_ISVTX, 0);further into that code, and neither do I want this to be different from the regular
vfs_mkdir()path. We can then also match onS_IFMTinmay_o_create(), instead of passing a bool to signal whether we are creating a dir (and assuming 0 means a dir is really ugly).It is a bit challenging to verify that passing
S_IFDIRis safe, as there are many filesystems. Claude Opus 4.8 was used to generate the context for each mkdir implementation from which it can be judged whether passingS_IFDIRis OK. The result was then verified by hand by looking at how the mode argument is used in each case. To check whether all mkdir implementations are covered, 'rg "\.mkdir" ' was used and checked against the list of uses Claude found.Quoted 6 lines
It is safe to do this clean-up except that three filesystems (fuse, cifs, and coda) forward the mkdir @mode unchanged to something outside the kernel. Mask
S_IFDIRback out incoda_mkdir(),fuse_mkdir()andcifs_mkdir()so that what is sent outside the kernel is unchanged. Their maintainers can drop the mask once they have confirmed it is safe. For the other filesystems redundantS_IFDIROR'ing is dropped.
Quoted 6 lines
This all looks good to me - thanks.
Reviewed-by NeilBrown <[email protected]>NeilBrown
Thanks for the review, Neil.
By the way, if possible, would be great if we can get the excl flag removed (as you mentioned) before the next merge window. Then the O_CREAT|O_DIRECTORY stuff can use that clean-up as well (along with this) and maybe we can get it all into 7.3.
Is it OK if I just go ahead and do that? But it is your observation, so feel free to do it yourself whenever you have time, of course :)
Quoted 10 lines · Jori Koolstra
vfs: pass
S_IFDIRmode tovfs_prepare_mode()There is a comment in
vfs_prepare_mode()that says:Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving
S_IFDIRfrom the vfs before we enforce a non-zero type.[...]
People are of course free to annotate their patches with Assisted-by tags to point out that they are using an LLM. But I'm refusing to do free in-kernel advertising for specific companies. So I've changed all tags to read:
which is good enough for all purposes. Nobody cares what specific sed or coccinelle version or whatever else was used.
---
Applied to the vfs-7.3.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.3.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.3.misc
[01/31] vfs: pass S_IFDIR mode to vfs_prepare_mode()
https://git.kernel.org/vfs/vfs/c/efdfa808046b [02/31] 9p: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/cdece9964e85 [03/31] affs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/a8b708c9854f [04/31] afs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/f5522bef1e46 [05/31] autofs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/31468de07502 [06/31] btrfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/119ace91c0b6 [07/31] ceph: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2a3471957fb2 [08/31] ext2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/59d70c116933 [09/31] ext4: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/583b53b0b470 [10/31] f2fs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/9822629e4207 [11/31] gfs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/cda6023f474b [12/31] hfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/c9c0d511a820 [13/31] hfsplus: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/698ce0b15c50 [14/31] hpfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/e3ec849de731 [15/31] hugetlbfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/d6c1e7d1ddfe [16/31] jffs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2b8c9ca36328 [17/31] jfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/f6ad401d7f0c [18/31] minix: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/3b4857471b66 [19/31] nilfs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2183594ad607 [20/31] ntfs3: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/fc70a07e2702 [21/31] ocfs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/b12ec01ea00f [22/31] ocfs2: dlmfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/840de92490a2 [23/31] omfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2f2983204488 [24/31] orangefs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/7643456f3468 [25/31] ramfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/86f91a68fb25 [26/31] udf: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/d36d77de05c1 [27/31] ufs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/6449e995b4b2 [28/31] nfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/0266eafe7e34 [29/31] ubifs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/9fc38090ccbc [30/31] xfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/57162848e543 [31/31] ntfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/bec2272283f9
Quoted 21 lines
Op 01-07-2026 12:51 CEST schreef Christian Brauner <[email protected]>:
Quoted 10 lines · Jori Koolstra
vfs: pass
S_IFDIRmode tovfs_prepare_mode()There is a comment in
vfs_prepare_mode()that says:Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving
S_IFDIRfrom the vfs before we enforce a non-zero type.[...]
People are of course free to annotate their patches with Assisted-by tags to point out that they are using an LLM. But I'm refusing to do free in-kernel advertising for specific companies. So I've changed all tags to read:
Quoted 5 lines
Assisted-by LLMwhich is good enough for all purposes. Nobody cares what specific sed or coccinelle version or whatever else was used.
Oh, I actually much prefer that. Thanks for changing it. I was just following
https://docs.kernel.org/process/coding-assistants.html. Maybe that should be updated...?
Quoted 79 lines
---
Applied to the vfs-7.3.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.3.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.3.misc[01/31] vfs: pass
S_IFDIRmode tovfs_prepare_mode()https://git.kernel.org/vfs/vfs/c/efdfa808046b [02/31] 9p: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/cdece9964e85 [03/31] affs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/a8b708c9854f [04/31] afs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/f5522bef1e46 [05/31] autofs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/31468de07502 [06/31] btrfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/119ace91c0b6 [07/31] ceph: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2a3471957fb2 [08/31] ext2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/59d70c116933 [09/31] ext4: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/583b53b0b470 [10/31] f2fs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/9822629e4207 [11/31] gfs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/cda6023f474b [12/31] hfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/c9c0d511a820 [13/31] hfsplus: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/698ce0b15c50 [14/31] hpfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/e3ec849de731 [15/31] hugetlbfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/d6c1e7d1ddfe [16/31] jffs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2b8c9ca36328 [17/31] jfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/f6ad401d7f0c [18/31] minix: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/3b4857471b66 [19/31] nilfs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2183594ad607 [20/31] ntfs3: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/fc70a07e2702 [21/31] ocfs2: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/b12ec01ea00f [22/31] ocfs2: dlmfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/840de92490a2 [23/31] omfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/2f2983204488 [24/31] orangefs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/7643456f3468 [25/31] ramfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/86f91a68fb25 [26/31] udf: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/d36d77de05c1 [27/31] ufs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/6449e995b4b2 [28/31] nfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/0266eafe7e34 [29/31] ubifs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/9fc38090ccbc [30/31] xfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/57162848e543 [31/31] ntfs: drop redundant S_IFDIR from mkdir https://git.kernel.org/vfs/vfs/c/bec2272283f9
Christian Brauner
maintainerQuoted 23 lines · Jori Koolstra
Quoted 23 lines
Op 01-07-2026 12:51 CEST schreef Christian Brauner <[email protected]>:
Quoted 10 lines · Jori Koolstra
vfs: pass
S_IFDIRmode tovfs_prepare_mode()There is a comment in
vfs_prepare_mode()that says:Note that it's currently valid for @type to be 0 if a directory is created. Filesystems raise that flag individually and we need to check whether each filesystem can deal with receiving
S_IFDIRfrom the vfs before we enforce a non-zero type.[...]
People are of course free to annotate their patches with Assisted-by tags to point out that they are using an LLM. But I'm refusing to do free in-kernel advertising for specific companies. So I've changed all tags to read:
Assisted-by LLM
Quoted 7 lines
Quoted 3 lines
which is good enough for all purposes. Nobody cares what specific sed or coccinelle version or whatever else was used.
Oh, I actually much prefer that. Thanks for changing it. I was just following
https://docs.kernel.org/process/coding-assistants.html. Maybe that should be updated...?
I have no appetite for reviving this endless discussion...