aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/mount_clnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/mount_clnt.c')
-rw-r--r--fs/nfs/mount_clnt.c63
1 files changed, 49 insertions, 14 deletions
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index ed0a27ed538d..618d815c3093 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -39,6 +39,9 @@
39 * XDR argument and result sizes 39 * XDR argument and result sizes
40 */ 40 */
41#define MNT_enc_dirpath_sz encode_dirpath_sz 41#define MNT_enc_dirpath_sz encode_dirpath_sz
42#define MNT_dec_mountres_sz (MNT_status_sz + MNT_fhandle_sz)
43#define MNT_dec_mountres3_sz (MNT_status_sz + MNT_fhandle_sz + \
44 MNT_authflav3_sz)
42 45
43/* 46/*
44 * Defined by RFC 1094, section A.5 47 * Defined by RFC 1094, section A.5
@@ -140,8 +143,10 @@ struct mnt_fhstatus {
140 */ 143 */
141int nfs_mount(struct nfs_mount_request *info) 144int nfs_mount(struct nfs_mount_request *info)
142{ 145{
143 struct mnt_fhstatus result = { 146 struct mountres result = {
144 .fh = info->fh 147 .fh = info->fh,
148 .auth_count = info->auth_flav_len,
149 .auth_flavors = info->auth_flavs,
145 }; 150 };
146 struct rpc_message msg = { 151 struct rpc_message msg = {
147 .rpc_argp = info->dirpath, 152 .rpc_argp = info->dirpath,
@@ -180,7 +185,7 @@ int nfs_mount(struct nfs_mount_request *info)
180 185
181 if (status < 0) 186 if (status < 0)
182 goto out_call_err; 187 goto out_call_err;
183 if (result.status != 0) 188 if (result.errno != 0)
184 goto out_mnt_err; 189 goto out_mnt_err;
185 190
186 dprintk("NFS: MNT request succeeded\n"); 191 dprintk("NFS: MNT request succeeded\n");
@@ -191,16 +196,16 @@ out:
191 196
192out_clnt_err: 197out_clnt_err:
193 status = PTR_ERR(mnt_clnt); 198 status = PTR_ERR(mnt_clnt);
194 dprintk("NFS: failed to create RPC client, status=%d\n", status); 199 dprintk("NFS: failed to create MNT RPC client, status=%d\n", status);
195 goto out; 200 goto out;
196 201
197out_call_err: 202out_call_err:
198 dprintk("NFS: failed to start MNT request, status=%d\n", status); 203 dprintk("NFS: MNT request failed, status=%d\n", status);
199 goto out; 204 goto out;
200 205
201out_mnt_err: 206out_mnt_err:
202 dprintk("NFS: MNT server returned result %d\n", result.status); 207 dprintk("NFS: MNT server returned result %d\n", result.errno);
203 status = nfs_stat_to_errno(result.status); 208 status = result.errno;
204 goto out; 209 goto out;
205} 210}
206 211
@@ -291,6 +296,20 @@ static int decode_fhandle(struct xdr_stream *xdr, struct mountres *res)
291 return 0; 296 return 0;
292} 297}
293 298
299static int mnt_dec_mountres(struct rpc_rqst *req, __be32 *p,
300 struct mountres *res)
301{
302 struct xdr_stream xdr;
303 int status;
304
305 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
306
307 status = decode_status(&xdr, res);
308 if (unlikely(status != 0 || res->errno != 0))
309 return status;
310 return decode_fhandle(&xdr, res);
311}
312
294static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res) 313static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res)
295{ 314{
296 unsigned int i; 315 unsigned int i;
@@ -371,6 +390,25 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res)
371 return 0; 390 return 0;
372} 391}
373 392
393static int mnt_dec_mountres3(struct rpc_rqst *req, __be32 *p,
394 struct mountres *res)
395{
396 struct xdr_stream xdr;
397 int status;
398
399 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
400
401 status = decode_fhs_status(&xdr, res);
402 if (unlikely(status != 0 || res->errno != 0))
403 return status;
404 status = decode_fhandle3(&xdr, res);
405 if (unlikely(status != 0)) {
406 res->errno = -EBADHANDLE;
407 return 0;
408 }
409 return decode_auth_flavors(&xdr, res);
410}
411
374static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, 412static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p,
375 struct mnt_fhstatus *res) 413 struct mnt_fhstatus *res)
376{ 414{
@@ -388,16 +426,13 @@ static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p,
388 return 0; 426 return 0;
389} 427}
390 428
391#define MNT_fhstatus_sz (1 + 8)
392#define MNT_fhstatus3_sz (1 + 16)
393
394static struct rpc_procinfo mnt_procedures[] = { 429static struct rpc_procinfo mnt_procedures[] = {
395 [MOUNTPROC_MNT] = { 430 [MOUNTPROC_MNT] = {
396 .p_proc = MOUNTPROC_MNT, 431 .p_proc = MOUNTPROC_MNT,
397 .p_encode = (kxdrproc_t)mnt_enc_dirpath, 432 .p_encode = (kxdrproc_t)mnt_enc_dirpath,
398 .p_decode = (kxdrproc_t) xdr_decode_fhstatus, 433 .p_decode = (kxdrproc_t)mnt_dec_mountres,
399 .p_arglen = MNT_enc_dirpath_sz, 434 .p_arglen = MNT_enc_dirpath_sz,
400 .p_replen = MNT_fhstatus_sz, 435 .p_replen = MNT_dec_mountres_sz,
401 .p_statidx = MOUNTPROC_MNT, 436 .p_statidx = MOUNTPROC_MNT,
402 .p_name = "MOUNT", 437 .p_name = "MOUNT",
403 }, 438 },
@@ -407,9 +442,9 @@ static struct rpc_procinfo mnt3_procedures[] = {
407 [MOUNTPROC3_MNT] = { 442 [MOUNTPROC3_MNT] = {
408 .p_proc = MOUNTPROC3_MNT, 443 .p_proc = MOUNTPROC3_MNT,
409 .p_encode = (kxdrproc_t)mnt_enc_dirpath, 444 .p_encode = (kxdrproc_t)mnt_enc_dirpath,
410 .p_decode = (kxdrproc_t) xdr_decode_fhstatus3, 445 .p_decode = (kxdrproc_t)mnt_dec_mountres3,
411 .p_arglen = MNT_enc_dirpath_sz, 446 .p_arglen = MNT_enc_dirpath_sz,
412 .p_replen = MNT_fhstatus3_sz, 447 .p_replen = MNT_dec_mountres3_sz,
413 .p_statidx = MOUNTPROC3_MNT, 448 .p_statidx = MOUNTPROC3_MNT,
414 .p_name = "MOUNT", 449 .p_name = "MOUNT",
415 }, 450 },