aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/inode.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-01-31 06:40:12 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-12 06:19:25 -0500
commitab871b903e9095772c219b512d9eae96c4663a5d (patch)
treea09142df515aa7c0acbe2045d7d093e8f912ac50 /fs/ceph/inode.c
parent05cb11c17e892f0e131b6c2ba25d63221aafbd11 (diff)
ceph: Translate inode uid and gid attributes to/from kuids and kgids.
- In fill_inode() transate uids and gids in the initial user namespace into kuids and kgids stored in inode->i_uid and inode->i_gid. - In ceph_setattr() if they have changed convert inode->i_uid and inode->i_gid into initial user namespace uids and gids for transmission. Cc: Sage Weil <sage@inktank.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r--fs/ceph/inode.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 2971eaa65cdc..40e0787022e9 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -612,8 +612,8 @@ static int fill_inode(struct inode *inode,
612 612
613 if ((issued & CEPH_CAP_AUTH_EXCL) == 0) { 613 if ((issued & CEPH_CAP_AUTH_EXCL) == 0) {
614 inode->i_mode = le32_to_cpu(info->mode); 614 inode->i_mode = le32_to_cpu(info->mode);
615 inode->i_uid = le32_to_cpu(info->uid); 615 inode->i_uid = make_kuid(&init_user_ns, le32_to_cpu(info->uid));
616 inode->i_gid = le32_to_cpu(info->gid); 616 inode->i_gid = make_kgid(&init_user_ns, le32_to_cpu(info->gid));
617 dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode, 617 dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode,
618 inode->i_uid, inode->i_gid); 618 inode->i_uid, inode->i_gid);
619 } 619 }
@@ -1570,8 +1570,9 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
1570 inode->i_uid = attr->ia_uid; 1570 inode->i_uid = attr->ia_uid;
1571 dirtied |= CEPH_CAP_AUTH_EXCL; 1571 dirtied |= CEPH_CAP_AUTH_EXCL;
1572 } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || 1572 } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 ||
1573 attr->ia_uid != inode->i_uid) { 1573 !uid_eq(attr->ia_uid, inode->i_uid)) {
1574 req->r_args.setattr.uid = cpu_to_le32(attr->ia_uid); 1574 req->r_args.setattr.uid = cpu_to_le32(
1575 from_kuid(&init_user_ns, attr->ia_uid));
1575 mask |= CEPH_SETATTR_UID; 1576 mask |= CEPH_SETATTR_UID;
1576 release |= CEPH_CAP_AUTH_SHARED; 1577 release |= CEPH_CAP_AUTH_SHARED;
1577 } 1578 }
@@ -1583,8 +1584,9 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
1583 inode->i_gid = attr->ia_gid; 1584 inode->i_gid = attr->ia_gid;
1584 dirtied |= CEPH_CAP_AUTH_EXCL; 1585 dirtied |= CEPH_CAP_AUTH_EXCL;
1585 } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || 1586 } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 ||
1586 attr->ia_gid != inode->i_gid) { 1587 !gid_eq(attr->ia_gid, inode->i_gid)) {
1587 req->r_args.setattr.gid = cpu_to_le32(attr->ia_gid); 1588 req->r_args.setattr.gid = cpu_to_le32(
1589 from_kgid(&init_user_ns, attr->ia_gid));
1588 mask |= CEPH_SETATTR_GID; 1590 mask |= CEPH_SETATTR_GID;
1589 release |= CEPH_CAP_AUTH_SHARED; 1591 release |= CEPH_CAP_AUTH_SHARED;
1590 } 1592 }