ANDROID: sdcardfs: User new permission2 functions
authorDaniel Rosenberg <drosen@google.com>
Wed, 26 Oct 2016 23:48:45 +0000 (16:48 -0700)
committerAmit Pundir <amit.pundir@linaro.org>
Fri, 3 Feb 2017 09:34:29 +0000 (15:04 +0530)
Change-Id: Ic7e0fb8fdcebb31e657b079fe02ac834c4a50db9
Signed-off-by: Daniel Rosenberg <drosen@google.com>
fs/sdcardfs/inode.c
fs/sdcardfs/sdcardfs.h

index 3c353c95ef3ef8a92e6ea4a4499f556811d7dcdb..dc64c9e2f5e78e2758f6ed7ce14054df4de9d702 100644 (file)
@@ -54,6 +54,7 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
 {
        int err;
        struct dentry *lower_dentry;
+       struct vfsmount *lower_dentry_mnt;
        struct dentry *lower_parent_dentry = NULL;
        struct path lower_path;
        const struct cred *saved_cred = NULL;
@@ -73,6 +74,7 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
 
        sdcardfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
+       lower_dentry_mnt = lower_path.mnt;
        lower_parent_dentry = lock_parent(lower_dentry);
 
        /* set last 16bytes of mode field to 0664 */
@@ -87,7 +89,7 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
        }
        current->fs = copied_fs;
        current->fs->umask = 0;
-       err = vfs_create(d_inode(lower_parent_dentry), lower_dentry, mode, want_excl);
+       err = vfs_create2(lower_dentry_mnt, d_inode(lower_parent_dentry), lower_dentry, mode, want_excl);
        if (err)
                goto out;
 
@@ -154,6 +156,7 @@ static int sdcardfs_unlink(struct inode *dir, struct dentry *dentry)
 {
        int err;
        struct dentry *lower_dentry;
+       struct vfsmount *lower_mnt;
        struct inode *lower_dir_inode = sdcardfs_lower_inode(dir);
        struct dentry *lower_dir_dentry;
        struct path lower_path;
@@ -172,10 +175,11 @@ static int sdcardfs_unlink(struct inode *dir, struct dentry *dentry)
 
        sdcardfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
+       lower_mnt = lower_path.mnt;
        dget(lower_dentry);
        lower_dir_dentry = lock_parent(lower_dentry);
 
-       err = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
+       err = vfs_unlink2(lower_mnt, lower_dir_inode, lower_dentry, NULL);
 
        /*
         * Note: unlinking on top of NFS can cause silly-renamed files.
@@ -256,6 +260,7 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
        int err;
        int make_nomedia_in_obb = 0;
        struct dentry *lower_dentry;
+       struct vfsmount *lower_mnt;
        struct dentry *lower_parent_dentry = NULL;
        struct path lower_path;
        struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
@@ -286,6 +291,7 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
        /* the lower_dentry is negative here */
        sdcardfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
+       lower_mnt = lower_path.mnt;
        lower_parent_dentry = lock_parent(lower_dentry);
 
        /* set last 16bytes of mode field to 0775 */
@@ -301,7 +307,7 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
        }
        current->fs = copied_fs;
        current->fs->umask = 0;
-       err = vfs_mkdir(d_inode(lower_parent_dentry), lower_dentry, mode);
+       err = vfs_mkdir2(lower_mnt, d_inode(lower_parent_dentry), lower_dentry, mode);
 
        if (err) {
                unlock_dir(lower_parent_dentry);
@@ -370,6 +376,7 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
 {
        struct dentry *lower_dentry;
        struct dentry *lower_dir_dentry;
+       struct vfsmount *lower_mnt;
        int err;
        struct path lower_path;
        const struct cred *saved_cred = NULL;
@@ -390,9 +397,10 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
        sdcardfs_get_real_lower(dentry, &lower_path);
 
        lower_dentry = lower_path.dentry;
+       lower_mnt = lower_path.mnt;
        lower_dir_dentry = lock_parent(lower_dentry);
 
-       err = vfs_rmdir(d_inode(lower_dir_dentry), lower_dentry);
+       err = vfs_rmdir2(lower_mnt, d_inode(lower_dir_dentry), lower_dentry);
        if (err)
                goto out;
 
@@ -456,6 +464,7 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct dentry *lower_new_dentry = NULL;
        struct dentry *lower_old_dir_dentry = NULL;
        struct dentry *lower_new_dir_dentry = NULL;
+       struct vfsmount *lower_mnt = NULL;
        struct dentry *trap = NULL;
        struct dentry *new_parent = NULL;
        struct path lower_old_path, lower_new_path;
@@ -477,6 +486,7 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        sdcardfs_get_lower_path(new_dentry, &lower_new_path);
        lower_old_dentry = lower_old_path.dentry;
        lower_new_dentry = lower_new_path.dentry;
+       lower_mnt = lower_old_path.mnt;
        lower_old_dir_dentry = dget_parent(lower_old_dentry);
        lower_new_dir_dentry = dget_parent(lower_new_dentry);
 
@@ -492,7 +502,8 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                goto out;
        }
 
-       err = vfs_rename(d_inode(lower_old_dir_dentry), lower_old_dentry,
+       err = vfs_rename2(lower_mnt,
+                        d_inode(lower_old_dir_dentry), lower_old_dentry,
                         d_inode(lower_new_dir_dentry), lower_new_dentry,
                         NULL, 0);
        if (err)
@@ -642,6 +653,7 @@ static int sdcardfs_setattr(struct dentry *dentry, struct iattr *ia)
 {
        int err;
        struct dentry *lower_dentry;
+       struct vfsmount *lower_mnt;
        struct inode *inode;
        struct inode *lower_inode;
        struct path lower_path;
@@ -675,6 +687,7 @@ static int sdcardfs_setattr(struct dentry *dentry, struct iattr *ia)
 
        sdcardfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
+       lower_mnt = lower_path.mnt;
        lower_inode = sdcardfs_lower_inode(inode);
 
        /* prepare our own lower struct iattr (with the lower file) */
@@ -718,7 +731,7 @@ static int sdcardfs_setattr(struct dentry *dentry, struct iattr *ia)
         * tries to open(), unlink(), then ftruncate() a file.
         */
        mutex_lock(&d_inode(lower_dentry)->i_mutex);
-       err = notify_change(lower_dentry, &lower_ia, /* note: lower_ia */
+       err = notify_change2(lower_mnt, lower_dentry, &lower_ia, /* note: lower_ia */
                        NULL);
        mutex_unlock(&d_inode(lower_dentry)->i_mutex);
        if (current->mm)
index cfda98d257b6ff109d557089139e976c4ca2d894..5132f1dc5a4d9da280bd3867ec7868b11422541d 100644 (file)
@@ -476,7 +476,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;
@@ -487,7 +487,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: