ANDROID: vfs: Add setattr2 for filesystems with per mount permissions
[firefly-linux-kernel-4.4.55.git] / fs / sdcardfs / sdcardfs.h
index f111f898b630f3d042cd2bfcfd7a9599c42e2166..cfda98d257b6ff109d557089139e976c4ca2d894 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;
 };
@@ -321,6 +323,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 +368,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 +427,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);