Skip to content

Commit 42b7cc1

Browse files
braunerdchinner
authored andcommitted
xfs: port to vfs{g,u}id_t and associated helpers
A while ago we introduced a dedicated vfs{g,u}id_t type in commit 1e5267c ("mnt_idmapping: add vfs{g,u}id_t"). We already switched over a good part of the VFS. Ultimately we will remove all legacy idmapped mount helpers that operate only on k{g,u}id_t in favor of the new type safe helpers that operate on vfs{g,u}id_t. Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent b0463b9 commit 42b7cc1

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

fs/xfs/xfs_inode.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,8 @@ xfs_init_new_inode(
835835
* ID or one of the supplementary group IDs, the S_ISGID bit is cleared
836836
* (and only if the irix_sgid_inherit compatibility variable is set).
837837
*/
838-
if (irix_sgid_inherit &&
839-
(inode->i_mode & S_ISGID) &&
840-
!in_group_p(i_gid_into_mnt(mnt_userns, inode)))
838+
if (irix_sgid_inherit && (inode->i_mode & S_ISGID) &&
839+
!vfsgid_in_group_p(i_gid_into_vfsgid(mnt_userns, inode)))
841840
inode->i_mode &= ~S_ISGID;
842841

843842
ip->i_disk_size = 0;

fs/xfs/xfs_iops.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ xfs_vn_getattr(
558558
struct inode *inode = d_inode(path->dentry);
559559
struct xfs_inode *ip = XFS_I(inode);
560560
struct xfs_mount *mp = ip->i_mount;
561+
vfsuid_t vfsuid = i_uid_into_vfsuid(mnt_userns, inode);
562+
vfsgid_t vfsgid = i_gid_into_vfsgid(mnt_userns, inode);
561563

562564
trace_xfs_getattr(ip);
563565

@@ -568,8 +570,8 @@ xfs_vn_getattr(
568570
stat->dev = inode->i_sb->s_dev;
569571
stat->mode = inode->i_mode;
570572
stat->nlink = inode->i_nlink;
571-
stat->uid = i_uid_into_mnt(mnt_userns, inode);
572-
stat->gid = i_gid_into_mnt(mnt_userns, inode);
573+
stat->uid = vfsuid_into_kuid(vfsuid);
574+
stat->gid = vfsgid_into_kgid(vfsgid);
573575
stat->ino = ip->i_ino;
574576
stat->atime = inode->i_atime;
575577
stat->mtime = inode->i_mtime;

fs/xfs/xfs_itable.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ xfs_bulkstat_one_int(
6666
struct xfs_bulkstat *buf = bc->buf;
6767
xfs_extnum_t nextents;
6868
int error = -EINVAL;
69+
vfsuid_t vfsuid;
70+
vfsgid_t vfsgid;
6971

7072
if (xfs_internal_inum(mp, ino))
7173
goto out_advance;
@@ -81,14 +83,16 @@ xfs_bulkstat_one_int(
8183
ASSERT(ip != NULL);
8284
ASSERT(ip->i_imap.im_blkno != 0);
8385
inode = VFS_I(ip);
86+
vfsuid = i_uid_into_vfsuid(mnt_userns, inode);
87+
vfsgid = i_gid_into_vfsgid(mnt_userns, inode);
8488

8589
/* xfs_iget returns the following without needing
8690
* further change.
8791
*/
8892
buf->bs_projectid = ip->i_projid;
8993
buf->bs_ino = ino;
90-
buf->bs_uid = from_kuid(sb_userns, i_uid_into_mnt(mnt_userns, inode));
91-
buf->bs_gid = from_kgid(sb_userns, i_gid_into_mnt(mnt_userns, inode));
94+
buf->bs_uid = from_kuid(sb_userns, vfsuid_into_kuid(vfsuid));
95+
buf->bs_gid = from_kgid(sb_userns, vfsgid_into_kgid(vfsgid));
9296
buf->bs_size = ip->i_disk_size;
9397

9498
buf->bs_nlink = inode->i_nlink;

0 commit comments

Comments
 (0)