aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/nfs3proc.c17
-rw-r--r--fs/nfs/nfs4proc.c11
2 files changed, 17 insertions, 11 deletions
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 72334c19d481..9d5d02f02515 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -181,13 +181,10 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name,
181 181
182static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) 182static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
183{ 183{
184 struct nfs_fattr fattr;
185 struct nfs3_accessargs arg = { 184 struct nfs3_accessargs arg = {
186 .fh = NFS_FH(inode), 185 .fh = NFS_FH(inode),
187 }; 186 };
188 struct nfs3_accessres res = { 187 struct nfs3_accessres res;
189 .fattr = &fattr,
190 };
191 struct rpc_message msg = { 188 struct rpc_message msg = {
192 .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], 189 .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS],
193 .rpc_argp = &arg, 190 .rpc_argp = &arg,
@@ -195,7 +192,7 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
195 .rpc_cred = entry->cred, 192 .rpc_cred = entry->cred,
196 }; 193 };
197 int mode = entry->mask; 194 int mode = entry->mask;
198 int status; 195 int status = -ENOMEM;
199 196
200 dprintk("NFS call access\n"); 197 dprintk("NFS call access\n");
201 198
@@ -212,9 +209,13 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
212 if (mode & MAY_EXEC) 209 if (mode & MAY_EXEC)
213 arg.access |= NFS3_ACCESS_EXECUTE; 210 arg.access |= NFS3_ACCESS_EXECUTE;
214 } 211 }
215 nfs_fattr_init(&fattr); 212
213 res.fattr = nfs_alloc_fattr();
214 if (res.fattr == NULL)
215 goto out;
216
216 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 217 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
217 nfs_refresh_inode(inode, &fattr); 218 nfs_refresh_inode(inode, res.fattr);
218 if (status == 0) { 219 if (status == 0) {
219 entry->mask = 0; 220 entry->mask = 0;
220 if (res.access & NFS3_ACCESS_READ) 221 if (res.access & NFS3_ACCESS_READ)
@@ -224,6 +225,8 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
224 if (res.access & (NFS3_ACCESS_LOOKUP|NFS3_ACCESS_EXECUTE)) 225 if (res.access & (NFS3_ACCESS_LOOKUP|NFS3_ACCESS_EXECUTE))
225 entry->mask |= MAY_EXEC; 226 entry->mask |= MAY_EXEC;
226 } 227 }
228 nfs_free_fattr(res.fattr);
229out:
227 dprintk("NFS reply access: %d\n", status); 230 dprintk("NFS reply access: %d\n", status);
228 return status; 231 return status;
229} 232}
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 071fcedd517c..6591bd852f84 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2404,14 +2404,12 @@ static int nfs4_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh
2404static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) 2404static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry)
2405{ 2405{
2406 struct nfs_server *server = NFS_SERVER(inode); 2406 struct nfs_server *server = NFS_SERVER(inode);
2407 struct nfs_fattr fattr;
2408 struct nfs4_accessargs args = { 2407 struct nfs4_accessargs args = {
2409 .fh = NFS_FH(inode), 2408 .fh = NFS_FH(inode),
2410 .bitmask = server->attr_bitmask, 2409 .bitmask = server->attr_bitmask,
2411 }; 2410 };
2412 struct nfs4_accessres res = { 2411 struct nfs4_accessres res = {
2413 .server = server, 2412 .server = server,
2414 .fattr = &fattr,
2415 }; 2413 };
2416 struct rpc_message msg = { 2414 struct rpc_message msg = {
2417 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], 2415 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS],
@@ -2438,7 +2436,11 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
2438 if (mode & MAY_EXEC) 2436 if (mode & MAY_EXEC)
2439 args.access |= NFS4_ACCESS_EXECUTE; 2437 args.access |= NFS4_ACCESS_EXECUTE;
2440 } 2438 }
2441 nfs_fattr_init(&fattr); 2439
2440 res.fattr = nfs_alloc_fattr();
2441 if (res.fattr == NULL)
2442 return -ENOMEM;
2443
2442 status = nfs4_call_sync(server, &msg, &args, &res, 0); 2444 status = nfs4_call_sync(server, &msg, &args, &res, 0);
2443 if (!status) { 2445 if (!status) {
2444 entry->mask = 0; 2446 entry->mask = 0;
@@ -2448,8 +2450,9 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
2448 entry->mask |= MAY_WRITE; 2450 entry->mask |= MAY_WRITE;
2449 if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE)) 2451 if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE))
2450 entry->mask |= MAY_EXEC; 2452 entry->mask |= MAY_EXEC;
2451 nfs_refresh_inode(inode, &fattr); 2453 nfs_refresh_inode(inode, res.fattr);
2452 } 2454 }
2455 nfs_free_fattr(res.fattr);
2453 return status; 2456 return status;
2454} 2457}
2455 2458