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_delete() as may_delete_dentry()

For many years btrfs as been using a copy of may_delete() in
fs/btrfs/ioctl.c:btrfs_may_delete(). Everytime may_delete() 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_delete().

Export may_delete() so that btrfs can use it and with the less generic
name may_delete_dentry(). While at it change the calls in vfs_rmdir() to
pass a boolean literal instead of 1 and 0 as the last argument since the
argument has a bool type.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Link: https://patch.msgid.link/e09128fd53f01b19d0a58f0e7d24739f79f47f6d.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
173e9375 8f0b4cce

+12 -8
+9 -8
fs/namei.c
··· 3604 3604 * 11. We don't allow removal of NFS sillyrenamed files; it's handled by 3605 3605 * nfs_async_unlink(). 3606 3606 */ 3607 - static int may_delete(struct mnt_idmap *idmap, struct inode *dir, 3607 + int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir, 3608 3608 struct dentry *victim, bool isdir) 3609 3609 { 3610 3610 struct inode *inode = d_backing_inode(victim); ··· 3646 3646 return -EBUSY; 3647 3647 return 0; 3648 3648 } 3649 + EXPORT_SYMBOL(may_delete_dentry); 3649 3650 3650 3651 /* Check whether we can create an object with dentry child in directory 3651 3652 * dir. ··· 5210 5209 int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir, 5211 5210 struct dentry *dentry, struct delegated_inode *delegated_inode) 5212 5211 { 5213 - int error = may_delete(idmap, dir, dentry, 1); 5212 + int error = may_delete_dentry(idmap, dir, dentry, true); 5214 5213 5215 5214 if (error) 5216 5215 return error; ··· 5345 5344 struct dentry *dentry, struct delegated_inode *delegated_inode) 5346 5345 { 5347 5346 struct inode *target = dentry->d_inode; 5348 - int error = may_delete(idmap, dir, dentry, 0); 5347 + int error = may_delete_dentry(idmap, dir, dentry, false); 5349 5348 5350 5349 if (error) 5351 5350 return error; ··· 5817 5816 if (source == target) 5818 5817 return 0; 5819 5818 5820 - error = may_delete(rd->mnt_idmap, old_dir, old_dentry, is_dir); 5819 + error = may_delete_dentry(rd->mnt_idmap, old_dir, old_dentry, is_dir); 5821 5820 if (error) 5822 5821 return error; 5823 5822 ··· 5827 5826 new_is_dir = d_is_dir(new_dentry); 5828 5827 5829 5828 if (!(flags & RENAME_EXCHANGE)) 5830 - error = may_delete(rd->mnt_idmap, new_dir, 5831 - new_dentry, is_dir); 5829 + error = may_delete_dentry(rd->mnt_idmap, new_dir, 5830 + new_dentry, is_dir); 5832 5831 else 5833 - error = may_delete(rd->mnt_idmap, new_dir, 5834 - new_dentry, new_is_dir); 5832 + error = may_delete_dentry(rd->mnt_idmap, new_dir, 5833 + new_dentry, new_is_dir); 5835 5834 } 5836 5835 if (error) 5837 5836 return error;
+3
include/linux/fs.h
··· 2657 2657 int __check_sticky(struct mnt_idmap *idmap, struct inode *dir, 2658 2658 struct inode *inode); 2659 2659 2660 + int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir, 2661 + struct dentry *victim, bool isdir); 2662 + 2660 2663 static inline bool execute_ok(struct inode *inode) 2661 2664 { 2662 2665 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);