]> granicus.if.org Git - zfs/commitdiff
Linux 3.8 compat: Support CONFIG_UIDGID_STRICT_TYPE_CHECKS
authorRichard Yao <ryao@gentoo.org>
Sun, 14 Jul 2013 16:59:24 +0000 (12:59 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 9 Aug 2013 22:31:52 +0000 (15:31 -0700)
When CONFIG_UIDGID_STRICT_TYPE_CHECKS is enabled uid_t/git_t are
replaced by kuid_t/kgid_t, which are structures instead of integral
types. This causes any code that uses an integral type to fail to build.
The User Namespace functionality introduced in Linux 3.8 requires
CONFIG_UIDGID_STRICT_TYPE_CHECKS, so we could not build against any
kernel that supported it.

We resolve this by converting between the new kuid_t/kgid_t structures
and the original uid_t/gid_t types.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1589

module/zfs/zfs_ctldir.c
module/zfs/zfs_znode.c
module/zfs/zpl_inode.c

index 168f853f17b0bad559abc6dbb3fffba8d7c75ea2..b35f27d194db5bb24794dc1114b0075077da2ee0 100644 (file)
@@ -200,8 +200,8 @@ zfsctl_inode_alloc(zfs_sb_t *zsb, uint64_t id,
        zp->z_is_stale = B_FALSE;
        ip->i_ino = id;
        ip->i_mode = (S_IFDIR | S_IRUGO | S_IXUGO);
-       ip->i_uid = 0;
-       ip->i_gid = 0;
+       ip->i_uid = SUID_TO_KUID(0);
+       ip->i_gid = SGID_TO_KGID(0);
        ip->i_blkbits = SPA_MINBLOCKSHIFT;
        ip->i_atime = now;
        ip->i_mtime = now;
index 5922d3afa95aad89b835a3c265d206b1556b1a26..aaf17e18f4951969b932acb7989d75b7fc33552d 100644 (file)
@@ -472,8 +472,8 @@ zfs_inode_update(znode_t *zp)
 
        spin_lock(&ip->i_lock);
        ip->i_generation = zp->z_gen;
-       ip->i_uid = zp->z_uid;
-       ip->i_gid = zp->z_gid;
+       ip->i_uid = SUID_TO_KUID(zp->z_uid);
+       ip->i_gid = SGID_TO_KGID(zp->z_gid);
        set_nlink(ip, zp->z_links);
        ip->i_mode = zp->z_mode;
        ip->i_blkbits = SPA_MINBLOCKSHIFT;
index 8c8ec24147816d7fb72d4188096932a1668641a9..ab1fe68237a21e6486c08115b8a00509914a0bc2 100644 (file)
@@ -74,7 +74,7 @@ zpl_vap_init(vattr_t *vap, struct inode *dir, zpl_umode_t mode, cred_t *cr)
        vap->va_uid = crgetfsuid(cr);
 
        if (dir && dir->i_mode & S_ISGID) {
-               vap->va_gid = dir->i_gid;
+               vap->va_gid = KGID_TO_SGID(dir->i_gid);
                if (S_ISDIR(mode))
                        vap->va_mode |= S_ISGID;
        } else {
@@ -235,8 +235,8 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
        vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
        vap->va_mask = ia->ia_valid & ATTR_IATTR_MASK;
        vap->va_mode = ia->ia_mode;
-       vap->va_uid = ia->ia_uid;
-       vap->va_gid = ia->ia_gid;
+       vap->va_uid = KUID_TO_SUID(ia->ia_uid);
+       vap->va_gid = KGID_TO_SGID(ia->ia_gid);
        vap->va_size = ia->ia_size;
        vap->va_atime = ia->ia_atime;
        vap->va_mtime = ia->ia_mtime;