ANDROID: sdcardfs: Fix formatting

This fixes various spacing and bracket related issues
pointed out by checkpatch.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35331000
Change-Id: I6e248833a7a04e3899f3ae9462d765cfcaa70c96
This commit is contained in:
Daniel Rosenberg 2017-03-16 17:42:58 -07:00 committed by Amit Pundir
parent 1a14972611
commit 4704f29d6a
9 changed files with 184 additions and 144 deletions

View file

@ -46,7 +46,8 @@ static int sdcardfs_d_revalidate(struct dentry *dentry, unsigned int flags)
spin_unlock(&dentry->d_lock);
/* check uninitialized obb_dentry and
* whether the base obbpath has been changed or not */
* whether the base obbpath has been changed or not
*/
if (is_obbpath_invalid(dentry)) {
d_drop(dentry);
return 0;
@ -106,12 +107,10 @@ static int sdcardfs_d_revalidate(struct dentry *dentry, unsigned int flags)
static void sdcardfs_d_release(struct dentry *dentry)
{
/* release and reset the lower paths */
if(has_graft_path(dentry)) {
if (has_graft_path(dentry))
sdcardfs_put_reset_orig_path(dentry);
}
sdcardfs_put_reset_lower_path(dentry);
free_dentry_private_data(dentry);
return;
}
static int sdcardfs_hash_ci(const struct dentry *dentry,
@ -167,14 +166,16 @@ static int sdcardfs_cmp_ci(const struct dentry *dentry,
return 1;
}
static void sdcardfs_canonical_path(const struct path *path, struct path *actual_path) {
static void sdcardfs_canonical_path(const struct path *path,
struct path *actual_path)
{
sdcardfs_get_real_lower(path->dentry, actual_path);
}
const struct dentry_operations sdcardfs_ci_dops = {
.d_revalidate = sdcardfs_d_revalidate,
.d_release = sdcardfs_d_release,
.d_hash = sdcardfs_hash_ci,
.d_hash = sdcardfs_hash_ci,
.d_compare = sdcardfs_cmp_ci,
.d_canonical_path = sdcardfs_canonical_path,
};

View file

@ -37,7 +37,8 @@ static void inherit_derived_state(struct inode *parent, struct inode *child)
/* helper function for derived state */
void setup_derived_state(struct inode *inode, perm_t perm, userid_t userid,
uid_t uid, bool under_android, struct inode *top)
uid_t uid, bool under_android,
struct inode *top)
{
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
@ -50,11 +51,14 @@ void setup_derived_state(struct inode *inode, perm_t perm, userid_t userid,
set_top(info, top);
}
/* While renaming, there is a point where we want the path from dentry, but the name from newdentry */
void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, const struct qstr *name)
/* While renaming, there is a point where we want the path from dentry,
* but the name from newdentry
*/
void get_derived_permission_new(struct dentry *parent, struct dentry *dentry,
const struct qstr *name)
{
struct sdcardfs_inode_info *info = SDCARDFS_I(d_inode(dentry));
struct sdcardfs_inode_info *parent_info= SDCARDFS_I(d_inode(parent));
struct sdcardfs_inode_info *parent_info = SDCARDFS_I(d_inode(parent));
appid_t appid;
struct qstr q_Android = QSTR_LITERAL("Android");
struct qstr q_data = QSTR_LITERAL("data");
@ -118,9 +122,8 @@ void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, co
case PERM_ANDROID_MEDIA:
info->perm = PERM_ANDROID_PACKAGE;
appid = get_appid(name->name);
if (appid != 0 && !is_excluded(name->name, parent_info->userid)) {
if (appid != 0 && !is_excluded(name->name, parent_info->userid))
info->d_uid = multiuser_get_uid(parent_info->userid, appid);
}
set_top(info, &info->vfs_inode);
break;
case PERM_ANDROID_PACKAGE:
@ -257,7 +260,8 @@ static int descendant_may_need_fixup(struct sdcardfs_inode_info *info, struct li
return 0;
}
static int needs_fixup(perm_t perm) {
static int needs_fixup(perm_t perm)
{
if (perm == PERM_ANDROID_DATA || perm == PERM_ANDROID_OBB
|| perm == PERM_ANDROID_MEDIA)
return 1;
@ -295,9 +299,9 @@ static void __fixup_perms_recursive(struct dentry *dentry, struct limit_search *
}
spin_unlock(&child->d_lock);
}
} else if (descendant_may_need_fixup(info, limit)) {
} else if (descendant_may_need_fixup(info, limit)) {
list_for_each_entry(child, &dentry->d_subdirs, d_child) {
__fixup_perms_recursive(child, limit, depth + 1);
__fixup_perms_recursive(child, limit, depth + 1);
}
}
spin_unlock(&dentry->d_lock);
@ -313,7 +317,7 @@ inline void update_derived_permission_lock(struct dentry *dentry)
{
struct dentry *parent;
if(!dentry || !d_inode(dentry)) {
if (!dentry || !d_inode(dentry)) {
printk(KERN_ERR "sdcardfs: %s: invalid dentry\n", __func__);
return;
}
@ -321,11 +325,11 @@ inline void update_derived_permission_lock(struct dentry *dentry)
* 1. need to check whether the dentry is updated or not
* 2. remove the root dentry update
*/
if(IS_ROOT(dentry)) {
if (IS_ROOT(dentry)) {
//setup_default_pre_root_state(d_inode(dentry));
} else {
parent = dget_parent(dentry);
if(parent) {
if (parent) {
get_derived_permission(parent, dentry);
dput(parent);
}
@ -337,15 +341,15 @@ int need_graft_path(struct dentry *dentry)
{
int ret = 0;
struct dentry *parent = dget_parent(dentry);
struct sdcardfs_inode_info *parent_info= SDCARDFS_I(d_inode(parent));
struct sdcardfs_inode_info *parent_info = SDCARDFS_I(d_inode(parent));
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
struct qstr obb = QSTR_LITERAL("obb");
if(parent_info->perm == PERM_ANDROID &&
if (parent_info->perm == PERM_ANDROID &&
qstr_case_eq(&dentry->d_name, &obb)) {
/* /Android/obb is the base obbpath of DERIVED_UNIFIED */
if(!(sbi->options.multiuser == false
if (!(sbi->options.multiuser == false
&& parent_info->userid == 0)) {
ret = 1;
}
@ -365,17 +369,18 @@ int is_obbpath_invalid(struct dentry *dent)
/* check the base obbpath has been changed.
* this routine can check an uninitialized obb dentry as well.
* regarding the uninitialized obb, refer to the sdcardfs_mkdir() */
* regarding the uninitialized obb, refer to the sdcardfs_mkdir()
*/
spin_lock(&di->lock);
if(di->orig_path.dentry) {
if(!di->lower_path.dentry) {
if (di->orig_path.dentry) {
if (!di->lower_path.dentry) {
ret = 1;
} else {
path_get(&di->lower_path);
//lower_parent = lock_parent(lower_path->dentry);
path_buf = kmalloc(PATH_MAX, GFP_ATOMIC);
if(!path_buf) {
if (!path_buf) {
ret = 1;
printk(KERN_ERR "sdcardfs: fail to allocate path_buf in %s.\n", __func__);
} else {
@ -402,13 +407,13 @@ int is_base_obbpath(struct dentry *dentry)
{
int ret = 0;
struct dentry *parent = dget_parent(dentry);
struct sdcardfs_inode_info *parent_info= SDCARDFS_I(d_inode(parent));
struct sdcardfs_inode_info *parent_info = SDCARDFS_I(d_inode(parent));
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
struct qstr q_obb = QSTR_LITERAL("obb");
spin_lock(&SDCARDFS_D(dentry)->lock);
if (sbi->options.multiuser) {
if(parent_info->perm == PERM_PRE_ROOT &&
if (parent_info->perm == PERM_PRE_ROOT &&
qstr_case_eq(&dentry->d_name, &q_obb)) {
ret = 1;
}
@ -423,7 +428,8 @@ int is_base_obbpath(struct dentry *dentry)
/* The lower_path will be stored to the dentry's orig_path
* and the base obbpath will be copyed to the lower_path variable.
* if an error returned, there's no change in the lower_path
* returns: -ERRNO if error (0: no error) */
* returns: -ERRNO if error (0: no error)
*/
int setup_obb_dentry(struct dentry *dentry, struct path *lower_path)
{
int err = 0;
@ -438,7 +444,7 @@ int setup_obb_dentry(struct dentry *dentry, struct path *lower_path)
err = kern_path(sbi->obbpath_s,
LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &obbpath);
if(!err) {
if (!err) {
/* the obbpath base has been found */
pathcpy(lower_path, &obbpath);
} else {
@ -446,7 +452,8 @@ int setup_obb_dentry(struct dentry *dentry, struct path *lower_path)
* setup the lower_path with its orig_path.
* but, the current implementation just returns an error
* because the sdcard daemon also regards this case as
* a lookup fail. */
* a lookup fail.
*/
printk(KERN_INFO "sdcardfs: the sbi->obbpath is not available\n");
}
return err;

View file

@ -248,9 +248,8 @@ static int sdcardfs_open(struct inode *inode, struct file *file)
if (err)
kfree(SDCARDFS_F(file));
else {
else
sdcardfs_copy_and_fix_attrs(inode, sdcardfs_lower_inode(inode));
}
out_revert_cred:
REVERT_CRED(saved_cred);

View file

@ -240,13 +240,14 @@ static int sdcardfs_symlink(struct inode *dir, struct dentry *dentry,
}
#endif
static int touch(char *abs_path, mode_t mode) {
static int touch(char *abs_path, mode_t mode)
{
struct file *filp = filp_open(abs_path, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, mode);
if (IS_ERR(filp)) {
if (PTR_ERR(filp) == -EEXIST) {
return 0;
}
else {
} else {
printk(KERN_ERR "sdcardfs: failed to open(%s): %ld\n",
abs_path, PTR_ERR(filp));
return PTR_ERR(filp);
@ -315,19 +316,21 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
}
/* if it is a local obb dentry, setup it with the base obbpath */
if(need_graft_path(dentry)) {
if (need_graft_path(dentry)) {
err = setup_obb_dentry(dentry, &lower_path);
if(err) {
if (err) {
/* if the sbi->obbpath is not available, the lower_path won't be
* changed by setup_obb_dentry() but the lower path is saved to
* its orig_path. this dentry will be revalidated later.
* but now, the lower_path should be NULL */
* but now, the lower_path should be NULL
*/
sdcardfs_put_reset_lower_path(dentry);
/* the newly created lower path which saved to its orig_path or
* the lower_path is the base obbpath.
* therefore, an additional path_get is required */
* therefore, an additional path_get is required
*/
path_get(&lower_path);
} else
make_nomedia_in_obb = 1;
@ -391,7 +394,8 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
/* sdcardfs_get_real_lower(): in case of remove an user's obb dentry
* the dentry on the original path should be deleted. */
* the dentry on the original path should be deleted.
*/
sdcardfs_get_real_lower(dentry, &lower_path);
lower_dentry = lower_path.dentry;
@ -663,6 +667,7 @@ static int sdcardfs_permission(struct vfsmount *mnt, struct inode *inode, int ma
* we check it with AID_MEDIA_RW permission
*/
struct inode *lower_inode;
OVERRIDE_CRED(SDCARDFS_SB(inode->sb));
lower_inode = sdcardfs_lower_inode(inode);
@ -733,7 +738,8 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
/* prepare our own lower struct iattr (with the lower file) */
memcpy(&lower_ia, ia, sizeof(lower_ia));
/* Allow touch updating timestamps. A previous permission check ensures
* we have write access. Changes to mode, owner, and group are ignored*/
* we have write access. Changes to mode, owner, and group are ignored
*/
ia->ia_valid |= ATTR_FORCE;
err = setattr_prepare(&tmp_d, ia);
@ -819,10 +825,12 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
return err;
}
static int sdcardfs_fillattr(struct vfsmount *mnt, struct inode *inode, struct kstat *stat)
static int sdcardfs_fillattr(struct vfsmount *mnt,
struct inode *inode, struct kstat *stat)
{
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
struct inode *top = grab_top(info);
if (!top)
return -EINVAL;

View file

@ -73,6 +73,7 @@ static int sdcardfs_inode_test(struct inode *inode, void *candidate_data/*void *
{
struct inode *current_lower_inode = sdcardfs_lower_inode(inode);
userid_t current_userid = SDCARDFS_I(inode)->userid;
if (current_lower_inode == ((struct inode_data *)candidate_data)->lower_inode &&
current_userid == ((struct inode_data *)candidate_data)->id)
return 1; /* found a match */
@ -102,7 +103,7 @@ struct inode *sdcardfs_iget(struct super_block *sb, struct inode *lower_inode, u
* instead.
*/
lower_inode->i_ino, /* hashval */
sdcardfs_inode_test, /* inode comparison function */
sdcardfs_inode_test, /* inode comparison function */
sdcardfs_inode_set, /* inode init function */
&data); /* data passed to test+set fxns */
if (!inode) {
@ -213,8 +214,8 @@ struct sdcardfs_name_data {
bool found;
};
static int sdcardfs_name_match(struct dir_context *ctx, const char *name, int namelen,
loff_t offset, u64 ino, unsigned int d_type)
static int sdcardfs_name_match(struct dir_context *ctx, const char *name,
int namelen, loff_t offset, u64 ino, unsigned int d_type)
{
struct sdcardfs_name_data *buf = container_of(ctx, struct sdcardfs_name_data, ctx);
struct qstr candidate = QSTR_INIT(name, namelen);
@ -303,23 +304,26 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
if (!err) {
/* check if the dentry is an obb dentry
* if true, the lower_inode must be replaced with
* the inode of the graft path */
* the inode of the graft path
*/
if(need_graft_path(dentry)) {
if (need_graft_path(dentry)) {
/* setup_obb_dentry()
* The lower_path will be stored to the dentry's orig_path
* The lower_path will be stored to the dentry's orig_path
* and the base obbpath will be copyed to the lower_path variable.
* if an error returned, there's no change in the lower_path
* returns: -ERRNO if error (0: no error) */
* returns: -ERRNO if error (0: no error)
*/
err = setup_obb_dentry(dentry, &lower_path);
if(err) {
if (err) {
/* if the sbi->obbpath is not available, we can optionally
* setup the lower_path with its orig_path.
* but, the current implementation just returns an error
* because the sdcard daemon also regards this case as
* a lookup fail. */
* a lookup fail.
*/
printk(KERN_INFO "sdcardfs: base obbpath is not available\n");
sdcardfs_put_reset_orig_path(dentry);
goto out;
@ -374,9 +378,9 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
/*
* On success:
* fills dentry object appropriate values and returns NULL.
* fills dentry object appropriate values and returns NULL.
* On fail (== error)
* returns error ptr
* returns error ptr
*
* @dir : Parent inode.
* @dentry : Target dentry to lookup. we should set each of fields.
@ -396,7 +400,7 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
if (!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
ret = ERR_PTR(-EACCES);
goto out_err;
}
}
/* save current_cred and override it */
OVERRIDE_CRED_PTR(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
@ -412,9 +416,7 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
ret = __sdcardfs_lookup(dentry, flags, &lower_parent_path, SDCARDFS_I(dir)->userid);
if (IS_ERR(ret))
{
goto out;
}
if (ret)
dentry = ret;
if (d_inode(dentry)) {

View file

@ -72,6 +72,7 @@ static int parse_options(struct super_block *sb, char *options, int silent,
while ((p = strsep(&options, ",")) != NULL) {
int token;
if (!*p)
continue;
@ -148,6 +149,7 @@ int parse_options_remount(struct super_block *sb, char *options, int silent,
while ((p = strsep(&options, ",")) != NULL) {
int token;
if (!*p)
continue;
@ -223,8 +225,8 @@ static struct dentry *sdcardfs_d_alloc_root(struct super_block *sb)
#endif
DEFINE_MUTEX(sdcardfs_super_list_lock);
LIST_HEAD(sdcardfs_super_list);
EXPORT_SYMBOL_GPL(sdcardfs_super_list_lock);
LIST_HEAD(sdcardfs_super_list);
EXPORT_SYMBOL_GPL(sdcardfs_super_list);
/*
@ -328,14 +330,15 @@ static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
/* setup permission policy */
sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
mutex_lock(&sdcardfs_super_list_lock);
if(sb_info->options.multiuser) {
setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT, sb_info->options.fs_user_id, AID_ROOT, false, d_inode(sb->s_root));
if (sb_info->options.multiuser) {
setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
sb_info->options.fs_user_id, AID_ROOT,
false, d_inode(sb->s_root));
snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
/*err = prepare_dir(sb_info->obbpath_s,
sb_info->options.fs_low_uid,
sb_info->options.fs_low_gid, 00755);*/
} else {
setup_derived_state(d_inode(sb->s_root), PERM_ROOT, sb_info->options.fs_user_id, AID_ROOT, false, d_inode(sb->s_root));
setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
sb_info->options.fs_user_id, AID_ROOT,
false, d_inode(sb->s_root));
snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
}
fixup_tmp_permissions(d_inode(sb->s_root));
@ -368,8 +371,10 @@ static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
/* A feature which supports mount_nodev() with options */
static struct dentry *mount_nodev_with_options(struct vfsmount *mnt,
struct file_system_type *fs_type, int flags, const char *dev_name, void *data,
int (*fill_super)(struct vfsmount *, struct super_block *, const char *, void *, int))
struct file_system_type *fs_type, int flags,
const char *dev_name, void *data,
int (*fill_super)(struct vfsmount *, struct super_block *,
const char *, void *, int))
{
int error;
@ -401,19 +406,22 @@ static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
raw_data, sdcardfs_read_super);
}
static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type, int flags,
const char *dev_name, void *raw_data)
static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
int flags, const char *dev_name, void *raw_data)
{
WARN(1, "sdcardfs does not support mount. Use mount2.\n");
return ERR_PTR(-EINVAL);
}
void *sdcardfs_alloc_mnt_data(void) {
void *sdcardfs_alloc_mnt_data(void)
{
return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
}
void sdcardfs_kill_sb(struct super_block *sb) {
void sdcardfs_kill_sb(struct super_block *sb)
{
struct sdcardfs_sb_info *sbi;
if (sb->s_magic == SDCARDFS_SUPER_MAGIC) {
sbi = SDCARDFS_SB(sb);
mutex_lock(&sdcardfs_super_list_lock);

View file

@ -90,6 +90,7 @@ static appid_t __get_appid(const struct qstr *key)
appid_t get_appid(const char *key)
{
struct qstr q;
qstr_init(&q, key);
return __get_appid(&q);
}
@ -115,6 +116,7 @@ static appid_t __get_ext_gid(const struct qstr *key)
appid_t get_ext_gid(const char *key)
{
struct qstr q;
qstr_init(&q, key);
return __get_ext_gid(&q);
}
@ -145,7 +147,8 @@ appid_t is_excluded(const char *key, userid_t user)
/* Kernel has already enforced everything we returned through
* derive_permissions_locked(), so this is used to lock down access
* even further, such as enforcing that apps hold sdcard_rw. */
* even further, such as enforcing that apps hold sdcard_rw.
*/
int check_caller_access_to_name(struct inode *parent_node, const struct qstr *name)
{
struct qstr q_autorun = QSTR_LITERAL("autorun.inf");
@ -162,26 +165,26 @@ int check_caller_access_to_name(struct inode *parent_node, const struct qstr *na
}
/* Root always has access; access for any other UIDs should always
* be controlled through packages.list. */
if (from_kuid(&init_user_ns, current_fsuid()) == 0) {
* be controlled through packages.list.
*/
if (from_kuid(&init_user_ns, current_fsuid()) == 0)
return 1;
}
/* No extra permissions to enforce */
return 1;
}
/* This function is used when file opening. The open flags must be
* checked before calling check_caller_access_to_name() */
int open_flags_to_access_mode(int open_flags) {
if((open_flags & O_ACCMODE) == O_RDONLY) {
* checked before calling check_caller_access_to_name()
*/
int open_flags_to_access_mode(int open_flags)
{
if ((open_flags & O_ACCMODE) == O_RDONLY)
return 0; /* R_OK */
} else if ((open_flags & O_ACCMODE) == O_WRONLY) {
if ((open_flags & O_ACCMODE) == O_WRONLY)
return 1; /* W_OK */
} else {
/* Probably O_RDRW, but treat as default to be safe */
/* Probably O_RDRW, but treat as default to be safe */
return 1; /* R_OK | W_OK */
}
}
static struct hashtable_entry *alloc_hashtable_entry(const struct qstr *key,
@ -373,7 +376,6 @@ static void remove_packagelist_entry(const struct qstr *key)
remove_packagelist_entry_locked(key);
fixup_all_perms_name(key);
mutex_unlock(&sdcardfs_super_list_lock);
return;
}
static void remove_ext_gid_entry_locked(const struct qstr *key, gid_t group)
@ -396,7 +398,6 @@ static void remove_ext_gid_entry(const struct qstr *key, gid_t group)
mutex_lock(&sdcardfs_super_list_lock);
remove_ext_gid_entry_locked(key, group);
mutex_unlock(&sdcardfs_super_list_lock);
return;
}
static void remove_userid_all_entry_locked(userid_t userid)
@ -424,7 +425,6 @@ static void remove_userid_all_entry(userid_t userid)
remove_userid_all_entry_locked(userid);
fixup_all_perms_userid(userid);
mutex_unlock(&sdcardfs_super_list_lock);
return;
}
static void remove_userid_exclude_entry_locked(const struct qstr *key, userid_t userid)
@ -449,7 +449,6 @@ static void remove_userid_exclude_entry(const struct qstr *key, userid_t userid)
remove_userid_exclude_entry_locked(key, userid);
fixup_all_perms_name_userid(key, userid);
mutex_unlock(&sdcardfs_super_list_lock);
return;
}
static void packagelist_destroy(void)
@ -458,6 +457,7 @@ static void packagelist_destroy(void)
struct hlist_node *h_t;
HLIST_HEAD(free_list);
int i;
mutex_lock(&sdcardfs_super_list_lock);
hash_for_each_rcu(package_to_appid, i, hash_cur, hlist) {
hash_del_rcu(&hash_cur->hlist);
@ -605,7 +605,7 @@ static struct configfs_attribute *package_details_attrs[] = {
};
static struct configfs_item_operations package_details_item_ops = {
.release = package_details_release,
.release = package_details_release,
};
static struct config_item_type package_appid_type = {
@ -661,6 +661,7 @@ static struct config_item *extension_details_make_item(struct config_group *grou
struct extension_details *extension_details = kzalloc(sizeof(struct extension_details), GFP_KERNEL);
const char *tmp;
int ret;
if (!extension_details)
return ERR_PTR(-ENOMEM);
@ -715,6 +716,7 @@ static struct config_group *extensions_make_group(struct config_group *group, co
static void extensions_drop_group(struct config_group *group, struct config_item *item)
{
struct extensions_value *value = to_extensions_value(item);
printk(KERN_INFO "sdcardfs: No longer mapping any files to gid %d\n", value->num);
kfree(value);
}
@ -880,7 +882,7 @@ int packagelist_init(void)
}
configfs_sdcardfs_init();
return 0;
return 0;
}
void packagelist_exit(void)

View file

@ -87,11 +87,11 @@
} while (0)
/* OVERRIDE_CRED() and REVERT_CRED()
* OVERRID_CRED()
* backup original task->cred
* and modifies task->cred->fsuid/fsgid to specified value.
* OVERRIDE_CRED()
* backup original task->cred
* and modifies task->cred->fsuid/fsgid to specified value.
* REVERT_CRED()
* restore original task->cred->fsuid/fsgid.
* restore original task->cred->fsuid/fsgid.
* These two macro should be used in pair, and OVERRIDE_CRED() should be
* placed at the beginning of a function, right after variable declaration.
*/
@ -120,27 +120,29 @@
/* Android 5.0 support */
/* Permission mode for a specific node. Controls how file permissions
* are derived for children nodes. */
* are derived for children nodes.
*/
typedef enum {
/* Nothing special; this node should just inherit from its parent. */
PERM_INHERIT,
/* This node is one level above a normal root; used for legacy layouts
* which use the first level to represent user_id. */
PERM_PRE_ROOT,
/* This node is "/" */
PERM_ROOT,
/* This node is "/Android" */
PERM_ANDROID,
/* This node is "/Android/data" */
PERM_ANDROID_DATA,
/* This node is "/Android/obb" */
PERM_ANDROID_OBB,
/* This node is "/Android/media" */
PERM_ANDROID_MEDIA,
/* This node is "/Android/[data|media|obb]/[package]" */
PERM_ANDROID_PACKAGE,
/* This node is "/Android/[data|media|obb]/[package]/cache" */
PERM_ANDROID_PACKAGE_CACHE,
/* Nothing special; this node should just inherit from its parent. */
PERM_INHERIT,
/* This node is one level above a normal root; used for legacy layouts
* which use the first level to represent user_id.
*/
PERM_PRE_ROOT,
/* This node is "/" */
PERM_ROOT,
/* This node is "/Android" */
PERM_ANDROID,
/* This node is "/Android/data" */
PERM_ANDROID_DATA,
/* This node is "/Android/obb" */
PERM_ANDROID_OBB,
/* This node is "/Android/media" */
PERM_ANDROID_MEDIA,
/* This node is "/Android/[data|media|obb]/[package]" */
PERM_ANDROID_PACKAGE,
/* This node is "/Android/[data|media|obb]/[package]/cache" */
PERM_ANDROID_PACKAGE_CACHE,
} perm_t;
struct sdcardfs_sb_info;
@ -150,7 +152,7 @@ struct sdcardfs_inode_info;
/* Do not directly use this function. Use OVERRIDE_CRED() instead. */
const struct cred *override_fsids(struct sdcardfs_sb_info *sbi, struct sdcardfs_inode_info *info);
/* Do not directly use this function, use REVERT_CRED() instead. */
void revert_fsids(const struct cred * old_cred);
void revert_fsids(const struct cred *old_cred);
/* operations vectors defined in specific files */
extern const struct file_operations sdcardfs_main_fops;
@ -227,7 +229,8 @@ struct sdcardfs_sb_info {
struct super_block *sb;
struct super_block *lower_sb;
/* derived perm policy : some of options have been added
* to sdcardfs_mount_options (Android 4.4 support) */
* to sdcardfs_mount_options (Android 4.4 support)
*/
struct sdcardfs_mount_options options;
spinlock_t lock; /* protects obbpath */
char *obbpath_s;
@ -338,7 +341,7 @@ static inline void sdcardfs_put_reset_##pname(const struct dentry *dent) \
{ \
struct path pname; \
spin_lock(&SDCARDFS_D(dent)->lock); \
if(SDCARDFS_D(dent)->pname.dentry) { \
if (SDCARDFS_D(dent)->pname.dentry) { \
pathcpy(&pname, &SDCARDFS_D(dent)->pname); \
SDCARDFS_D(dent)->pname.dentry = NULL; \
SDCARDFS_D(dent)->pname.mnt = NULL; \
@ -354,17 +357,17 @@ SDCARDFS_DENT_FUNC(orig_path)
static inline bool sbinfo_has_sdcard_magic(struct sdcardfs_sb_info *sbinfo)
{
return sbinfo && sbinfo->sb && sbinfo->sb->s_magic == SDCARDFS_SUPER_MAGIC;
return sbinfo && sbinfo->sb && sbinfo->sb->s_magic == SDCARDFS_SUPER_MAGIC;
}
/* grab a refererence if we aren't linking to ourself */
static inline void set_top(struct sdcardfs_inode_info *info, struct inode *top)
{
struct inode *old_top = NULL;
BUG_ON(IS_ERR_OR_NULL(top));
if (info->top && info->top != &info->vfs_inode) {
if (info->top && info->top != &info->vfs_inode)
old_top = info->top;
}
if (top != &info->vfs_inode)
igrab(top);
info->top = top;
@ -374,11 +377,11 @@ static inline void set_top(struct sdcardfs_inode_info *info, struct inode *top)
static inline struct inode *grab_top(struct sdcardfs_inode_info *info)
{
struct inode *top = info->top;
if (top) {
if (top)
return igrab(top);
} else {
else
return NULL;
}
}
static inline void release_top(struct sdcardfs_inode_info *info)
@ -386,21 +389,24 @@ static inline void release_top(struct sdcardfs_inode_info *info)
iput(info->top);
}
static inline int get_gid(struct vfsmount *mnt, struct sdcardfs_inode_info *info) {
static inline int get_gid(struct vfsmount *mnt, struct sdcardfs_inode_info *info)
{
struct sdcardfs_vfsmount_options *opts = mnt->data;
if (opts->gid == AID_SDCARD_RW) {
if (opts->gid == AID_SDCARD_RW)
/* 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
* the user boundary enforcement for the default view. The UIDs
* assigned to app directories are still multiuser aware. */
* assigned to app directories are still multiuser aware.
*/
return AID_SDCARD_RW;
} else {
else
return multiuser_get_uid(info->userid, opts->gid);
}
}
static inline int get_mode(struct vfsmount *mnt, struct sdcardfs_inode_info *info) {
static inline int get_mode(struct vfsmount *mnt, struct sdcardfs_inode_info *info)
{
int owner_mode;
int filtered_mode;
struct sdcardfs_vfsmount_options *opts = mnt->data;
@ -409,17 +415,18 @@ static inline int get_mode(struct vfsmount *mnt, struct sdcardfs_inode_info *inf
if (info->perm == PERM_PRE_ROOT) {
/* Top of multi-user view should always be visible to ensure
* secondary users can traverse inside. */
* secondary users can traverse inside.
*/
visible_mode = 0711;
} else if (info->under_android) {
/* Block "other" access to Android directories, since only apps
* belonging to a specific user should be in there; we still
* leave +x open for the default view. */
if (opts->gid == AID_SDCARD_RW) {
* leave +x open for the default view.
*/
if (opts->gid == AID_SDCARD_RW)
visible_mode = visible_mode & ~0006;
} else {
else
visible_mode = visible_mode & ~0007;
}
}
owner_mode = info->lower_inode->i_mode & 0700;
filtered_mode = visible_mode & (owner_mode | (owner_mode >> 3) | (owner_mode >> 6));
@ -444,7 +451,7 @@ static inline void sdcardfs_get_real_lower(const struct dentry *dent,
/* in case of a local obb dentry
* the orig_path should be returned
*/
if(has_graft_path(dent))
if (has_graft_path(dent))
sdcardfs_get_orig_path(dent, real_lower);
else
sdcardfs_get_lower_path(dent, real_lower);
@ -453,7 +460,7 @@ static inline void sdcardfs_get_real_lower(const struct dentry *dent,
static inline void sdcardfs_put_real_lower(const struct dentry *dent,
struct path *real_lower)
{
if(has_graft_path(dent))
if (has_graft_path(dent))
sdcardfs_put_orig_path(dent, real_lower);
else
sdcardfs_put_lower_path(dent, real_lower);
@ -497,6 +504,7 @@ extern int setup_obb_dentry(struct dentry *dentry, struct path *lower_path);
static inline struct dentry *lock_parent(struct dentry *dentry)
{
struct dentry *dir = dget_parent(dentry);
inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
return dir;
}

View file

@ -36,7 +36,7 @@ static void sdcardfs_put_super(struct super_block *sb)
if (!spd)
return;
if(spd->obbpath_s) {
if (spd->obbpath_s) {
kfree(spd->obbpath_s);
path_put(&spd->obbpath);
}
@ -125,29 +125,33 @@ static int sdcardfs_remount_fs2(struct vfsmount *mnt, struct super_block *sb,
* SILENT, but anything else left over is an error.
*/
if ((*flags & ~(MS_RDONLY | MS_MANDLOCK | MS_SILENT | MS_REMOUNT)) != 0) {
printk(KERN_ERR
"sdcardfs: remount flags 0x%x unsupported\n", *flags);
pr_err("sdcardfs: remount flags 0x%x unsupported\n", *flags);
err = -EINVAL;
}
printk(KERN_INFO "Remount options were %s for vfsmnt %p.\n", options, mnt);
pr_info("Remount options were %s for vfsmnt %p.\n", options, mnt);
err = parse_options_remount(sb, options, *flags & ~MS_SILENT, mnt->data);
return err;
}
static void* sdcardfs_clone_mnt_data(void *data) {
struct sdcardfs_vfsmount_options* opt = kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
struct sdcardfs_vfsmount_options* old = data;
if(!opt) return NULL;
static void *sdcardfs_clone_mnt_data(void *data)
{
struct sdcardfs_vfsmount_options *opt = kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
struct sdcardfs_vfsmount_options *old = data;
if (!opt)
return NULL;
opt->gid = old->gid;
opt->mask = old->mask;
return opt;
}
static void sdcardfs_copy_mnt_data(void *data, void *newdata) {
struct sdcardfs_vfsmount_options* old = data;
struct sdcardfs_vfsmount_options* new = newdata;
static void sdcardfs_copy_mnt_data(void *data, void *newdata)
{
struct sdcardfs_vfsmount_options *old = data;
struct sdcardfs_vfsmount_options *new = newdata;
old->gid = new->gid;
old->mask = new->mask;
}
@ -235,7 +239,8 @@ static void sdcardfs_umount_begin(struct super_block *sb)
lower_sb->s_op->umount_begin(lower_sb);
}
static int sdcardfs_show_options(struct vfsmount *mnt, struct seq_file *m, struct dentry *root)
static int sdcardfs_show_options(struct vfsmount *mnt, struct seq_file *m,
struct dentry *root)
{
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(root->d_sb);
struct sdcardfs_mount_options *opts = &sbi->options;