f2fs: Use in_group_or_capable() helper

Use the in_group_or_capable() helper function to simplify the code.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Link: https://lore.kernel.org/r/20240620032335.147136-2-youling.tang@linux.dev
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Youling Tang 2024-06-20 11:23:34 +08:00 committed by Christian Brauner
parent 9b6a14f08b
commit 8444ee22ad
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
2 changed files with 2 additions and 5 deletions

View File

@ -219,8 +219,7 @@ static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
return error; return error;
if (error == 0) if (error == 0)
*acl = NULL; *acl = NULL;
if (!vfsgid_in_group_p(i_gid_into_vfsgid(idmap, inode)) && if (!in_group_or_capable(idmap, inode, i_gid_into_vfsgid(idmap, inode)))
!capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID))
mode &= ~S_ISGID; mode &= ~S_ISGID;
*mode_p = mode; *mode_p = mode;
return 0; return 0;

View File

@ -923,10 +923,8 @@ static void __setattr_copy(struct mnt_idmap *idmap,
inode_set_ctime_to_ts(inode, attr->ia_ctime); inode_set_ctime_to_ts(inode, attr->ia_ctime);
if (ia_valid & ATTR_MODE) { if (ia_valid & ATTR_MODE) {
umode_t mode = attr->ia_mode; umode_t mode = attr->ia_mode;
vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
if (!vfsgid_in_group_p(vfsgid) && if (!in_group_or_capable(idmap, inode, i_gid_into_vfsgid(idmap, inode)))
!capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID))
mode &= ~S_ISGID; mode &= ~S_ISGID;
set_acl_inode(inode, mode); set_acl_inode(inode, mode);
} }