1
From: Andreas Gruenbacher <agruen@suse.de>
2
Subject: Pass nameidata2 to vfs_symlink()
4
Instead of passing independent dentry and vfsmount parameters, use a
7
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
10
fs/ecryptfs/inode.c | 16 +++++++---------
11
fs/namei.c | 10 +++++-----
12
fs/nfsd/vfs.c | 18 +++++++++---------
13
include/linux/fs.h | 2 +-
14
4 files changed, 22 insertions(+), 24 deletions(-)
16
--- a/fs/ecryptfs/inode.c
17
+++ b/fs/ecryptfs/inode.c
18
@@ -474,10 +474,9 @@ out_unlock:
19
static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
22
+ struct nameidata2 nd = {};
24
struct dentry *lower_dentry;
25
- struct vfsmount *lower_mnt;
26
- struct dentry *lower_dir_dentry;
28
char *encoded_symname;
29
unsigned int encoded_symlen;
30
@@ -485,8 +484,8 @@ static int ecryptfs_symlink(struct inode
32
lower_dentry = ecryptfs_dentry_to_lower(dentry);
34
- lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
35
- lower_dir_dentry = lock_parent(lower_dentry);
36
+ nd.mnt = ecryptfs_dentry_to_lower_mnt(dentry);
37
+ nd.dentry = lock_parent(lower_dentry);
39
encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname,
41
@@ -495,18 +494,17 @@ static int ecryptfs_symlink(struct inode
45
- rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, lower_mnt,
46
- encoded_symname, mode);
47
+ rc = vfs_symlink(&nd, lower_dentry, encoded_symname, mode);
48
kfree(encoded_symname);
49
if (rc || !lower_dentry->d_inode)
51
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
54
- fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
55
- fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
56
+ fsstack_copy_attr_times(dir, nd.dentry->d_inode);
57
+ fsstack_copy_inode_size(dir, nd.dentry->d_inode);
59
- unlock_dir(lower_dir_dentry);
60
+ unlock_dir(nd.dentry);
66
@@ -2228,10 +2228,11 @@ asmlinkage long sys_unlink(const char __
67
return do_unlinkat(AT_FDCWD, pathname);
70
-int vfs_symlink(struct inode *dir, struct dentry *dentry, struct vfsmount *mnt,
71
+int vfs_symlink(struct nameidata2 *nd, struct dentry *dentry,
72
const char *oldname, int mode)
74
- int error = may_create(dir, dentry, NULL);
75
+ struct inode *dir = nd->dentry->d_inode;
76
+ int error = may_create(dir, dentry, nd);
80
@@ -2239,7 +2240,7 @@ int vfs_symlink(struct inode *dir, struc
81
if (!dir->i_op || !dir->i_op->symlink)
84
- error = security_inode_symlink(dir, dentry, mnt, oldname);
85
+ error = security_inode_symlink(dir, dentry, nd->mnt, oldname);
89
@@ -2275,8 +2276,7 @@ asmlinkage long sys_symlinkat(const char
93
- error = vfs_symlink(nd.dentry->d_inode, dentry, nd.mnt, from,
95
+ error = vfs_symlink(ND2(&nd), dentry, from, S_IALLUGO);
98
mutex_unlock(&nd.dentry->d_inode->i_mutex);
101
@@ -1447,7 +1447,8 @@ nfsd_symlink(struct svc_rqst *rqstp, str
102
struct svc_fh *resfhp,
105
- struct dentry *dentry, *dnew;
106
+ struct nameidata2 nd = {};
107
+ struct dentry *dnew;
108
struct svc_export *exp;
111
@@ -1464,8 +1465,10 @@ nfsd_symlink(struct svc_rqst *rqstp, str
115
- dentry = fhp->fh_dentry;
116
- dnew = lookup_one_len(fname, dentry, flen);
117
+ nd.dentry = fhp->fh_dentry;
118
+ exp = fhp->fh_export;
119
+ nd.mnt = exp->ex_mnt;
120
+ dnew = lookup_one_len(fname, nd.dentry, flen);
121
host_err = PTR_ERR(dnew);
124
@@ -1475,7 +1478,6 @@ nfsd_symlink(struct svc_rqst *rqstp, str
125
if (iap && (iap->ia_valid & ATTR_MODE))
126
mode = iap->ia_mode & S_IALLUGO;
128
- exp = fhp->fh_export;
129
if (unlikely(path[plen] != 0)) {
130
char *path_alloced = kmalloc(plen+1, GFP_KERNEL);
131
if (path_alloced == NULL)
132
@@ -1483,17 +1485,15 @@ nfsd_symlink(struct svc_rqst *rqstp, str
134
strncpy(path_alloced, path, plen);
135
path_alloced[plen] = 0;
136
- host_err = vfs_symlink(dentry->d_inode, dnew,
137
- exp->ex_mnt, path_alloced, mode);
138
+ host_err = vfs_symlink(&nd, dnew, path_alloced, mode);
142
- host_err = vfs_symlink(dentry->d_inode, dnew, exp->ex_mnt, path,
144
+ host_err = vfs_symlink(&nd, dnew, path, mode);
148
- host_err = nfsd_sync_dir(dentry);
149
+ host_err = nfsd_sync_dir(nd.dentry);
151
err = nfserrno(host_err);
153
--- a/include/linux/fs.h
154
+++ b/include/linux/fs.h
155
@@ -991,7 +991,7 @@ extern int vfs_permission(struct nameida
156
extern int vfs_create(struct nameidata2 *, struct dentry *, int);
157
extern int vfs_mkdir(struct nameidata2 *, struct dentry *, int);
158
extern int vfs_mknod(struct nameidata2 *, struct dentry *, int, dev_t);
159
-extern int vfs_symlink(struct inode *, struct dentry *, struct vfsmount *, const char *, int);
160
+extern int vfs_symlink(struct nameidata2 *, struct dentry *, const char *, int);
161
extern int vfs_link(struct dentry *, struct vfsmount *, struct inode *, struct dentry *, struct vfsmount *);
162
extern int vfs_rmdir(struct inode *, struct dentry *, struct vfsmount *);
163
extern int vfs_unlink(struct inode *, struct dentry *, struct vfsmount *);