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

Configure Feed

Select the types of activity you want to include in your feed.

fs: export may_create() as may_create_dentry()

For many years btrfs as been using a copy of may_create() in
fs/btrfs/ioctl.c:btrfs_may_create(). Everytime may_create() is updated we
need to update the btrfs copy, and this is a maintenance burden. Currently
there are minor differences between both because the btrfs side lacks
updates done in may_create().

Export may_create() so that btrfs can use it and with the less generic
name may_create_dentry().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Link: https://patch.msgid.link/ce5174bca079f4cdcbb8dd145f0924feb1f227cd.1768307858.git.fdmanana@suse.com
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Filipe Manana and committed by
Christian Brauner
26aab3a4 173e9375

+12 -9
+10 -9
fs/namei.c
··· 3657 3657 * 4. We should have write and exec permissions on dir 3658 3658 * 5. We can't do it if dir is immutable (done in permission()) 3659 3659 */ 3660 - static inline int may_create(struct mnt_idmap *idmap, 3661 - struct inode *dir, struct dentry *child) 3660 + int may_create_dentry(struct mnt_idmap *idmap, 3661 + struct inode *dir, struct dentry *child) 3662 3662 { 3663 3663 audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE); 3664 3664 if (child->d_inode) ··· 3670 3670 3671 3671 return inode_permission(idmap, dir, MAY_WRITE | MAY_EXEC); 3672 3672 } 3673 + EXPORT_SYMBOL(may_create_dentry); 3673 3674 3674 3675 // p1 != p2, both are on the same filesystem, ->s_vfs_rename_mutex is held 3675 3676 static struct dentry *lock_two_directories(struct dentry *p1, struct dentry *p2) ··· 4117 4116 struct inode *dir = d_inode(dentry->d_parent); 4118 4117 int error; 4119 4118 4120 - error = may_create(idmap, dir, dentry); 4119 + error = may_create_dentry(idmap, dir, dentry); 4121 4120 if (error) 4122 4121 return error; 4123 4122 ··· 4143 4142 void *arg) 4144 4143 { 4145 4144 struct inode *dir = dentry->d_parent->d_inode; 4146 - int error = may_create(&nop_mnt_idmap, dir, dentry); 4145 + int error = may_create_dentry(&nop_mnt_idmap, dir, dentry); 4147 4146 if (error) 4148 4147 return error; 4149 4148 ··· 4962 4961 struct delegated_inode *delegated_inode) 4963 4962 { 4964 4963 bool is_whiteout = S_ISCHR(mode) && dev == WHITEOUT_DEV; 4965 - int error = may_create(idmap, dir, dentry); 4964 + int error = may_create_dentry(idmap, dir, dentry); 4966 4965 4967 4966 if (error) 4968 4967 return error; ··· 5108 5107 unsigned max_links = dir->i_sb->s_max_links; 5109 5108 struct dentry *de; 5110 5109 5111 - error = may_create(idmap, dir, dentry); 5110 + error = may_create_dentry(idmap, dir, dentry); 5112 5111 if (error) 5113 5112 goto err; 5114 5113 ··· 5498 5497 { 5499 5498 int error; 5500 5499 5501 - error = may_create(idmap, dir, dentry); 5500 + error = may_create_dentry(idmap, dir, dentry); 5502 5501 if (error) 5503 5502 return error; 5504 5503 ··· 5606 5605 if (!inode) 5607 5606 return -ENOENT; 5608 5607 5609 - error = may_create(idmap, dir, new_dentry); 5608 + error = may_create_dentry(idmap, dir, new_dentry); 5610 5609 if (error) 5611 5610 return error; 5612 5611 ··· 5823 5822 return error; 5824 5823 5825 5824 if (!target) { 5826 - error = may_create(rd->mnt_idmap, new_dir, new_dentry); 5825 + error = may_create_dentry(rd->mnt_idmap, new_dir, new_dentry); 5827 5826 } else { 5828 5827 new_is_dir = d_is_dir(new_dentry); 5829 5828
+2
include/linux/fs.h
··· 2659 2659 2660 2660 int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir, 2661 2661 struct dentry *victim, bool isdir); 2662 + int may_create_dentry(struct mnt_idmap *idmap, 2663 + struct inode *dir, struct dentry *child); 2662 2664 2663 2665 static inline bool execute_ok(struct inode *inode) 2664 2666 {