mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Linux 4.8 compat: new s_user_ns member of struct super_block
Kernel 4.8 paved the way to enabling mounting a file system inside a non-init user namespace. To facilitate this a s_user_ns member was added holding the userns in which the filesystem's instance was mounted. This enables doing the uid/gid translation relative to this particular username space and not the default init_user_ns. Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: Chunwei Chen <david.chen@osnexus.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4928
This commit is contained in:
committed by
Brian Behlendorf
parent
cf2731e65b
commit
938cfeb0f2
@@ -356,7 +356,11 @@ static inline struct inode *file_inode(const struct file *f)
|
||||
#ifdef HAVE_KUID_HELPERS
|
||||
static inline uid_t zfs_uid_read_impl(struct inode *ip)
|
||||
{
|
||||
#ifdef HAVE_SUPER_USER_NS
|
||||
return (from_kuid(ip->i_sb->s_user_ns, ip->i_uid));
|
||||
#else
|
||||
return (from_kuid(kcred->user_ns, ip->i_uid));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uid_t zfs_uid_read(struct inode *ip)
|
||||
@@ -366,7 +370,11 @@ static inline uid_t zfs_uid_read(struct inode *ip)
|
||||
|
||||
static inline gid_t zfs_gid_read_impl(struct inode *ip)
|
||||
{
|
||||
#ifdef HAVE_SUPER_USER_NS
|
||||
return (from_kgid(ip->i_sb->s_user_ns, ip->i_gid));
|
||||
#else
|
||||
return (from_kgid(kcred->user_ns, ip->i_gid));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline gid_t zfs_gid_read(struct inode *ip)
|
||||
@@ -376,13 +384,22 @@ static inline gid_t zfs_gid_read(struct inode *ip)
|
||||
|
||||
static inline void zfs_uid_write(struct inode *ip, uid_t uid)
|
||||
{
|
||||
#ifdef HAVE_SUPER_USER_NS
|
||||
ip->i_uid = make_kuid(ip->i_sb->s_user_ns, uid);
|
||||
#else
|
||||
ip->i_uid = make_kuid(kcred->user_ns, uid);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void zfs_gid_write(struct inode *ip, gid_t gid)
|
||||
{
|
||||
#ifdef HAVE_SUPER_USER_NS
|
||||
ip->i_gid = make_kgid(ip->i_sb->s_user_ns, gid);
|
||||
#else
|
||||
ip->i_gid = make_kgid(kcred->user_ns, gid);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
static inline uid_t zfs_uid_read(struct inode *ip)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user