summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2018-01-18 16:17:16 -0800
committerAmit Pundir <amit.pundir@linaro.org>2018-01-22 13:16:20 +0530
commit6a7d9fbcf9464502248405214cd10842da255fcc (patch)
tree25976d478391960f32ccb3c294608294de7e6ba4 /fs
parent15b3c1dac0c012c7ce0e3e3a3af0ed8e655636fa (diff)
ANDROID: sdcardfs: Move default_normal to superblock
Moving default_normal from mount info to superblock info as it doesn't need to change between mount points. Signed-off-by: Daniel Rosenberg <drosen@google.com> Bug: 72158116 Change-Id: I16c6a0577c601b4f7566269f7e189fcf697afd4e
Diffstat (limited to 'fs')
-rw-r--r--fs/sdcardfs/inode.c7
-rw-r--r--fs/sdcardfs/main.c4
-rw-r--r--fs/sdcardfs/sdcardfs.h10
-rw-r--r--fs/sdcardfs/super.c2
4 files changed, 13 insertions, 10 deletions
diff --git a/fs/sdcardfs/inode.c b/fs/sdcardfs/inode.c
index 85eb8ebb5372..36c36590bcea 100644
--- a/fs/sdcardfs/inode.c
+++ b/fs/sdcardfs/inode.c
@@ -641,7 +641,7 @@ static int sdcardfs_permission(struct vfsmount *mnt, struct inode *inode, int ma
*/
copy_attrs(&tmp, inode);
tmp.i_uid = make_kuid(&init_user_ns, top->d_uid);
- tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, top));
+ tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, inode->i_sb, top));
tmp.i_mode = (inode->i_mode & S_IFMT)
| get_mode(mnt, SDCARDFS_I(inode), top);
data_put(top);
@@ -718,7 +718,7 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
*/
copy_attrs(&tmp, inode);
tmp.i_uid = make_kuid(&init_user_ns, top->d_uid);
- tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, top));
+ tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, dentry->d_sb, top));
tmp.i_mode = (inode->i_mode & S_IFMT)
| get_mode(mnt, SDCARDFS_I(inode), top);
tmp.i_size = i_size_read(inode);
@@ -819,6 +819,7 @@ static int sdcardfs_fillattr(struct vfsmount *mnt,
{
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
struct sdcardfs_inode_data *top = top_data_get(info);
+ struct super_block *sb = inode->i_sb;
if (!top)
return -EINVAL;
@@ -828,7 +829,7 @@ static int sdcardfs_fillattr(struct vfsmount *mnt,
stat->mode = (inode->i_mode & S_IFMT) | get_mode(mnt, info, top);
stat->nlink = inode->i_nlink;
stat->uid = make_kuid(&init_user_ns, top->d_uid);
- stat->gid = make_kgid(&init_user_ns, get_gid(mnt, top));
+ stat->gid = make_kgid(&init_user_ns, get_gid(mnt, sb, top));
stat->rdev = inode->i_rdev;
stat->size = i_size_read(inode);
stat->atime = inode->i_atime;
diff --git a/fs/sdcardfs/main.c b/fs/sdcardfs/main.c
index d5239b21cb8a..ac27bb301c5e 100644
--- a/fs/sdcardfs/main.c
+++ b/fs/sdcardfs/main.c
@@ -70,7 +70,7 @@ static int parse_options(struct super_block *sb, char *options, int silent,
opts->reserved_mb = 0;
/* by default, gid derivation is off */
opts->gid_derivation = false;
- vfsopts->default_normal = false;
+ opts->default_normal = false;
*debug = 0;
@@ -126,7 +126,7 @@ static int parse_options(struct super_block *sb, char *options, int silent,
opts->gid_derivation = true;
break;
case Opt_default_normal:
- vfsopts->default_normal = true;
+ opts->default_normal = true;
break;
/* unknown option */
default:
diff --git a/fs/sdcardfs/sdcardfs.h b/fs/sdcardfs/sdcardfs.h
index f5054a2650f1..c6c49ea182ec 100644
--- a/fs/sdcardfs/sdcardfs.h
+++ b/fs/sdcardfs/sdcardfs.h
@@ -220,13 +220,13 @@ struct sdcardfs_mount_options {
userid_t fs_user_id;
bool multiuser;
bool gid_derivation;
+ bool default_normal;
unsigned int reserved_mb;
};
struct sdcardfs_vfsmount_options {
gid_t gid;
mode_t mask;
- bool default_normal;
};
extern int parse_options_remount(struct super_block *sb, char *options, int silent,
@@ -414,11 +414,13 @@ static inline void set_top(struct sdcardfs_inode_info *info,
}
static inline int get_gid(struct vfsmount *mnt,
+ struct super_block *sb,
struct sdcardfs_inode_data *data)
{
- struct sdcardfs_vfsmount_options *opts = mnt->data;
+ struct sdcardfs_vfsmount_options *vfsopts = mnt->data;
+ struct sdcardfs_sb_info *sbi = SDCARDFS_SB(sb);
- if (opts->gid == AID_SDCARD_RW && !opts->default_normal)
+ if (vfsopts->gid == AID_SDCARD_RW && !sbi->options.default_normal)
/* As an optimization, certain trusted system components only run
* as owner but operate across all users. Since we're now handing
* out the sdcard_rw GID only to trusted apps, we're okay relaxing
@@ -427,7 +429,7 @@ static inline int get_gid(struct vfsmount *mnt,
*/
return AID_SDCARD_RW;
else
- return multiuser_get_uid(data->userid, opts->gid);
+ return multiuser_get_uid(data->userid, vfsopts->gid);
}
static inline int get_mode(struct vfsmount *mnt,
diff --git a/fs/sdcardfs/super.c b/fs/sdcardfs/super.c
index a28b40f5adc8..87d6f836592e 100644
--- a/fs/sdcardfs/super.c
+++ b/fs/sdcardfs/super.c
@@ -304,7 +304,7 @@ static int sdcardfs_show_options(struct vfsmount *mnt, struct seq_file *m,
seq_printf(m, ",userid=%u", opts->fs_user_id);
if (opts->gid_derivation)
seq_puts(m, ",derive_gid");
- if (vfsopts->default_normal)
+ if (opts->default_normal)
seq_puts(m, ",default_normal");
if (opts->reserved_mb != 0)
seq_printf(m, ",reserved=%uMB", opts->reserved_mb);