Skip to content

Commit

Permalink
userns: Convert hfsplus to use kuid and kgid where appropriate
Browse files Browse the repository at this point in the history
Signed-off-by: Eric W. Biederman <[email protected]>
  • Loading branch information
ebiederm committed Sep 21, 2012
1 parent 43b5e4c commit 16525e3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions fs/hfsplus/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms)

perms->userflags = HFSPLUS_I(inode)->userflags;
perms->mode = cpu_to_be16(inode->i_mode);
perms->owner = cpu_to_be32(inode->i_uid);
perms->group = cpu_to_be32(inode->i_gid);
perms->owner = cpu_to_be32(i_uid_read(inode));
perms->group = cpu_to_be32(i_gid_read(inode));

if (S_ISREG(inode->i_mode))
perms->dev = cpu_to_be32(inode->i_nlink);
Expand Down
4 changes: 2 additions & 2 deletions fs/hfsplus/hfsplus_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ struct hfsplus_sb_info {
u32 type;

umode_t umask;
uid_t uid;
gid_t gid;
kuid_t uid;
kgid_t gid;

int part, session;
unsigned long flags;
Expand Down
8 changes: 4 additions & 4 deletions fs/hfsplus/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ static void hfsplus_get_perms(struct inode *inode,

mode = be16_to_cpu(perms->mode);

inode->i_uid = be32_to_cpu(perms->owner);
if (!inode->i_uid && !mode)
i_uid_write(inode, be32_to_cpu(perms->owner));
if (!i_uid_read(inode) && !mode)
inode->i_uid = sbi->uid;

inode->i_gid = be32_to_cpu(perms->group);
if (!inode->i_gid && !mode)
i_gid_write(inode, be32_to_cpu(perms->group));
if (!i_gid_read(inode) && !mode)
inode->i_gid = sbi->gid;

if (dir) {
Expand Down
15 changes: 12 additions & 3 deletions fs/hfsplus/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,22 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
printk(KERN_ERR "hfs: uid requires an argument\n");
return 0;
}
sbi->uid = (uid_t)tmp;
sbi->uid = make_kuid(current_user_ns(), (uid_t)tmp);
if (!uid_valid(sbi->uid)) {
printk(KERN_ERR "hfs: invalid uid specified\n");
return 0;
}
break;
case opt_gid:
if (match_int(&args[0], &tmp)) {
printk(KERN_ERR "hfs: gid requires an argument\n");
return 0;
}
sbi->gid = (gid_t)tmp;
sbi->gid = make_kgid(current_user_ns(), (gid_t)tmp);
if (!gid_valid(sbi->gid)) {
printk(KERN_ERR "hfs: invalid gid specified\n");
return 0;
}
break;
case opt_part:
if (match_int(&args[0], &sbi->part)) {
Expand Down Expand Up @@ -215,7 +223,8 @@ int hfsplus_show_options(struct seq_file *seq, struct dentry *root)
if (sbi->type != HFSPLUS_DEF_CR_TYPE)
seq_printf(seq, ",type=%.4s", (char *)&sbi->type);
seq_printf(seq, ",umask=%o,uid=%u,gid=%u", sbi->umask,
sbi->uid, sbi->gid);
from_kuid_munged(&init_user_ns, sbi->uid),
from_kgid_munged(&init_user_ns, sbi->gid));
if (sbi->part >= 0)
seq_printf(seq, ",part=%u", sbi->part);
if (sbi->session >= 0)
Expand Down
1 change: 0 additions & 1 deletion init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,6 @@ config UIDGID_CONVERTED
depends on CODA_FS = n
depends on FUSE_FS = n
depends on GFS2_FS = n
depends on HFSPLUS_FS = n
depends on HPFS_FS = n
depends on ISO9660_FS = n
depends on JFFS2_FS = n
Expand Down

0 comments on commit 16525e3

Please sign in to comment.