1 From: Tony Jones <tonyj@suse.de>
2 Subject: Add struct vfsmount parameters to vfs_rename()
4 The vfsmount will be passed down to the LSM hook so that LSMs can compute
7 Signed-off-by: Tony Jones <tonyj@suse.de>
8 Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
9 Signed-off-by: John Johansen <jjohansen@suse.de>
12 fs/ecryptfs/inode.c | 7 ++++++-
13 fs/namei.c | 19 ++++++++++++-------
15 include/linux/fs.h | 2 +-
16 4 files changed, 21 insertions(+), 10 deletions(-)
18 --- a/fs/ecryptfs/inode.c
19 +++ b/fs/ecryptfs/inode.c
20 @@ -590,19 +590,24 @@ ecryptfs_rename(struct inode *old_dir, s
23 struct dentry *lower_old_dentry;
24 + struct vfsmount *lower_old_mnt;
25 struct dentry *lower_new_dentry;
26 + struct vfsmount *lower_new_mnt;
27 struct dentry *lower_old_dir_dentry;
28 struct dentry *lower_new_dir_dentry;
30 lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
31 + lower_old_mnt = ecryptfs_dentry_to_lower_mnt(old_dentry);
32 lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
33 + lower_new_mnt = ecryptfs_dentry_to_lower_mnt(new_dentry);
34 dget(lower_old_dentry);
35 dget(lower_new_dentry);
36 lower_old_dir_dentry = dget_parent(lower_old_dentry);
37 lower_new_dir_dentry = dget_parent(lower_new_dentry);
38 lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
39 rc = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry,
40 - lower_new_dir_dentry->d_inode, lower_new_dentry);
41 + lower_old_mnt, lower_new_dir_dentry->d_inode,
42 + lower_new_dentry, lower_new_mnt);
45 fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL);
48 @@ -2547,7 +2547,8 @@ SYSCALL_DEFINE2(link, const char __user
51 static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
52 - struct inode *new_dir, struct dentry *new_dentry)
53 + struct vfsmount *old_mnt, struct inode *new_dir,
54 + struct dentry *new_dentry, struct vfsmount *new_mnt)
58 @@ -2590,7 +2591,8 @@ static int vfs_rename_dir(struct inode *
61 static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
62 - struct inode *new_dir, struct dentry *new_dentry)
63 + struct vfsmount *old_mnt, struct inode *new_dir,
64 + struct dentry *new_dentry, struct vfsmount *new_mnt)
68 @@ -2618,7 +2620,8 @@ static int vfs_rename_other(struct inode
71 int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
72 - struct inode *new_dir, struct dentry *new_dentry)
73 + struct vfsmount *old_mnt, struct inode *new_dir,
74 + struct dentry *new_dentry, struct vfsmount *new_mnt)
77 int is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
78 @@ -2647,9 +2650,11 @@ int vfs_rename(struct inode *old_dir, st
79 old_name = fsnotify_oldname_init(old_dentry->d_name.name);
82 - error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
83 + error = vfs_rename_dir(old_dir, old_dentry, old_mnt,
84 + new_dir, new_dentry, new_mnt);
86 - error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
87 + error = vfs_rename_other(old_dir, old_dentry, old_mnt,
88 + new_dir, new_dentry, new_mnt);
90 const char *new_name = old_dentry->d_name.name;
91 fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
92 @@ -2726,8 +2731,8 @@ SYSCALL_DEFINE4(renameat, int, olddfd, c
93 error = mnt_want_write(oldnd.path.mnt);
96 - error = vfs_rename(old_dir->d_inode, old_dentry,
97 - new_dir->d_inode, new_dentry);
98 + error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt,
99 + new_dir->d_inode, new_dentry, newnd.path.mnt);
100 mnt_drop_write(oldnd.path.mnt);
105 @@ -1752,7 +1752,8 @@ nfsd_rename(struct svc_rqst *rqstp, stru
109 - host_err = vfs_rename(fdir, odentry, tdir, ndentry);
110 + host_err = vfs_rename(fdir, odentry, ffhp->fh_export->ex_path.mnt,
111 + tdir, ndentry, tfhp->fh_export->ex_path.mnt);
112 if (!host_err && EX_ISSYNC(tfhp->fh_export)) {
113 host_err = nfsd_sync_dir(tdentry);
115 --- a/include/linux/fs.h
116 +++ b/include/linux/fs.h
117 @@ -1184,7 +1184,7 @@ extern int vfs_symlink(struct inode *, s
118 extern int vfs_link(struct dentry *, struct vfsmount *, struct inode *, struct dentry *, struct vfsmount *);
119 extern int vfs_rmdir(struct inode *, struct dentry *, struct vfsmount *);
120 extern int vfs_unlink(struct inode *, struct dentry *, struct vfsmount *);
121 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
122 +extern int vfs_rename(struct inode *, struct dentry *, struct vfsmount *, struct inode *, struct dentry *, struct vfsmount *);
125 * VFS dentry helper functions.