ANDROID: sdcardfs: Add gid and mask to private mount data
[firefly-linux-kernel-4.4.55.git] / fs / sdcardfs / sdcardfs.h
index f111f898b630f3d042cd2bfcfd7a9599c42e2166..22ef29857022a2d5f10c602256df57f8f4f55238 100644 (file)
@@ -169,6 +169,8 @@ struct sdcardfs_inode_info {
        userid_t userid;
        uid_t d_uid;
        bool under_android;
+       /* top folder for ownership */
+       struct inode *top;
 
        struct inode vfs_inode;
 };
@@ -191,6 +193,14 @@ struct sdcardfs_mount_options {
        unsigned int reserved_mb;
 };
 
+struct sdcardfs_vfsmount_options {
+       gid_t gid;
+       mode_t mask;
+};
+
+extern int parse_options_remount(struct super_block *sb, char *options, int silent,
+               struct sdcardfs_vfsmount_options *vfsopts);
+
 /* sdcardfs super-block data in memory */
 struct sdcardfs_sb_info {
        struct super_block *sb;
@@ -321,6 +331,35 @@ static inline void sdcardfs_put_reset_##pname(const struct dentry *dent) \
 SDCARDFS_DENT_FUNC(lower_path)
 SDCARDFS_DENT_FUNC(orig_path)
 
+/* 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) {
+               old_top = info->top;
+       }
+       if (top != &info->vfs_inode)
+               igrab(top);
+       info->top = top;
+       iput(old_top);
+}
+
+static inline struct inode *grab_top(struct sdcardfs_inode_info *info)
+{
+       struct inode *top = info->top;
+       if (top) {
+               return igrab(top);
+       } else {
+               return NULL;
+       }
+}
+
+static inline void release_top(struct sdcardfs_inode_info *info)
+{
+       iput(info->top);
+}
+
 static inline int get_gid(struct sdcardfs_inode_info *info) {
        struct sdcardfs_sb_info *sb_info = SDCARDFS_SB(info->vfs_inode.i_sb);
        if (sb_info->options.gid == AID_SDCARD_RW) {
@@ -337,7 +376,7 @@ static inline int get_gid(struct sdcardfs_inode_info *info) {
 static inline int get_mode(struct sdcardfs_inode_info *info) {
        int owner_mode;
        int filtered_mode;
-       struct sdcardfs_sb_info *sb_info = SDCARDFS_SB(info->vfs_inode.i_sb);
+       struct sdcardfs_sb_info * sb_info = SDCARDFS_SB(info->vfs_inode.i_sb);
        int visible_mode = 0775 & ~sb_info->options.mask;
 
        if (info->perm == PERM_PRE_ROOT) {
@@ -396,18 +435,19 @@ extern struct mutex sdcardfs_super_list_lock;
 extern struct list_head sdcardfs_super_list;
 
 /* for packagelist.c */
-extern appid_t get_appid(void *pkgl_id, const char *app_name);
+extern appid_t get_appid(const char *app_name);
 extern int check_caller_access_to_name(struct inode *parent_node, const char* name);
 extern int open_flags_to_access_mode(int open_flags);
 extern int packagelist_init(void);
 extern void packagelist_exit(void);
 
 /* for derived_perm.c */
-extern void setup_derived_state(struct inode *inode, perm_t perm,
-                       userid_t userid, uid_t uid, bool under_android);
+extern void setup_derived_state(struct inode *inode, perm_t perm, userid_t userid,
+                       uid_t uid, bool under_android, struct inode *top);
 extern void get_derived_permission(struct dentry *parent, struct dentry *dentry);
 extern void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, struct dentry *newdentry);
-extern void get_derive_permissions_recursive(struct dentry *parent);
+extern void fixup_top_recursive(struct dentry *parent);
+extern void fixup_perms_recursive(struct dentry *dentry, const char *name, size_t len);
 
 extern void update_derived_permission_lock(struct dentry *dentry);
 extern int need_graft_path(struct dentry *dentry);
@@ -444,7 +484,7 @@ static inline int prepare_dir(const char *path_s, uid_t uid, gid_t gid, mode_t m
                goto out_unlock;
        }
 
-       err = vfs_mkdir(d_inode(parent.dentry), dent, mode);
+       err = vfs_mkdir2(parent.mnt, d_inode(parent.dentry), dent, mode);
        if (err) {
                if (err == -EEXIST)
                        err = 0;
@@ -455,7 +495,7 @@ static inline int prepare_dir(const char *path_s, uid_t uid, gid_t gid, mode_t m
        attrs.ia_gid = make_kgid(&init_user_ns, gid);
        attrs.ia_valid = ATTR_UID | ATTR_GID;
        mutex_lock(&d_inode(dent)->i_mutex);
-       notify_change(dent, &attrs, NULL);
+       notify_change2(parent.mnt, dent, &attrs, NULL);
        mutex_unlock(&d_inode(dent)->i_mutex);
 
 out_dput: