diff options
Diffstat (limited to 'fs/nfs/mount_clnt.c')
-rw-r--r-- | fs/nfs/mount_clnt.c | 91 |
1 files changed, 39 insertions, 52 deletions
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index 59047f8d7d72..d4c2d6b7507e 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c | |||
@@ -153,6 +153,7 @@ int nfs_mount(struct nfs_mount_request *info) | |||
153 | .rpc_resp = &result, | 153 | .rpc_resp = &result, |
154 | }; | 154 | }; |
155 | struct rpc_create_args args = { | 155 | struct rpc_create_args args = { |
156 | .net = &init_net, | ||
156 | .protocol = info->protocol, | 157 | .protocol = info->protocol, |
157 | .address = info->sap, | 158 | .address = info->sap, |
158 | .addrsize = info->salen, | 159 | .addrsize = info->salen, |
@@ -224,6 +225,7 @@ void nfs_umount(const struct nfs_mount_request *info) | |||
224 | .to_retries = 2, | 225 | .to_retries = 2, |
225 | }; | 226 | }; |
226 | struct rpc_create_args args = { | 227 | struct rpc_create_args args = { |
228 | .net = &init_net, | ||
227 | .protocol = IPPROTO_UDP, | 229 | .protocol = IPPROTO_UDP, |
228 | .address = info->sap, | 230 | .address = info->sap, |
229 | .addrsize = info->salen, | 231 | .addrsize = info->salen, |
@@ -234,10 +236,8 @@ void nfs_umount(const struct nfs_mount_request *info) | |||
234 | .authflavor = RPC_AUTH_UNIX, | 236 | .authflavor = RPC_AUTH_UNIX, |
235 | .flags = RPC_CLNT_CREATE_NOPING, | 237 | .flags = RPC_CLNT_CREATE_NOPING, |
236 | }; | 238 | }; |
237 | struct mountres result; | ||
238 | struct rpc_message msg = { | 239 | struct rpc_message msg = { |
239 | .rpc_argp = info->dirpath, | 240 | .rpc_argp = info->dirpath, |
240 | .rpc_resp = &result, | ||
241 | }; | 241 | }; |
242 | struct rpc_clnt *clnt; | 242 | struct rpc_clnt *clnt; |
243 | int status; | 243 | int status; |
@@ -246,7 +246,7 @@ void nfs_umount(const struct nfs_mount_request *info) | |||
246 | args.flags |= RPC_CLNT_CREATE_NONPRIVPORT; | 246 | args.flags |= RPC_CLNT_CREATE_NONPRIVPORT; |
247 | 247 | ||
248 | clnt = rpc_create(&args); | 248 | clnt = rpc_create(&args); |
249 | if (unlikely(IS_ERR(clnt))) | 249 | if (IS_ERR(clnt)) |
250 | goto out_clnt_err; | 250 | goto out_clnt_err; |
251 | 251 | ||
252 | dprintk("NFS: sending UMNT request for %s:%s\n", | 252 | dprintk("NFS: sending UMNT request for %s:%s\n", |
@@ -278,29 +278,20 @@ out_call_err: | |||
278 | * XDR encode/decode functions for MOUNT | 278 | * XDR encode/decode functions for MOUNT |
279 | */ | 279 | */ |
280 | 280 | ||
281 | static int encode_mntdirpath(struct xdr_stream *xdr, const char *pathname) | 281 | static void encode_mntdirpath(struct xdr_stream *xdr, const char *pathname) |
282 | { | 282 | { |
283 | const u32 pathname_len = strlen(pathname); | 283 | const u32 pathname_len = strlen(pathname); |
284 | __be32 *p; | 284 | __be32 *p; |
285 | 285 | ||
286 | if (unlikely(pathname_len > MNTPATHLEN)) | 286 | BUG_ON(pathname_len > MNTPATHLEN); |
287 | return -EIO; | 287 | p = xdr_reserve_space(xdr, 4 + pathname_len); |
288 | |||
289 | p = xdr_reserve_space(xdr, sizeof(u32) + pathname_len); | ||
290 | if (unlikely(p == NULL)) | ||
291 | return -EIO; | ||
292 | xdr_encode_opaque(p, pathname, pathname_len); | 288 | xdr_encode_opaque(p, pathname, pathname_len); |
293 | |||
294 | return 0; | ||
295 | } | 289 | } |
296 | 290 | ||
297 | static int mnt_enc_dirpath(struct rpc_rqst *req, __be32 *p, | 291 | static void mnt_xdr_enc_dirpath(struct rpc_rqst *req, struct xdr_stream *xdr, |
298 | const char *dirpath) | 292 | const char *dirpath) |
299 | { | 293 | { |
300 | struct xdr_stream xdr; | 294 | encode_mntdirpath(xdr, dirpath); |
301 | |||
302 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
303 | return encode_mntdirpath(&xdr, dirpath); | ||
304 | } | 295 | } |
305 | 296 | ||
306 | /* | 297 | /* |
@@ -318,10 +309,10 @@ static int decode_status(struct xdr_stream *xdr, struct mountres *res) | |||
318 | u32 status; | 309 | u32 status; |
319 | __be32 *p; | 310 | __be32 *p; |
320 | 311 | ||
321 | p = xdr_inline_decode(xdr, sizeof(status)); | 312 | p = xdr_inline_decode(xdr, 4); |
322 | if (unlikely(p == NULL)) | 313 | if (unlikely(p == NULL)) |
323 | return -EIO; | 314 | return -EIO; |
324 | status = ntohl(*p); | 315 | status = be32_to_cpup(p); |
325 | 316 | ||
326 | for (i = 0; i < ARRAY_SIZE(mnt_errtbl); i++) { | 317 | for (i = 0; i < ARRAY_SIZE(mnt_errtbl); i++) { |
327 | if (mnt_errtbl[i].status == status) { | 318 | if (mnt_errtbl[i].status == status) { |
@@ -349,18 +340,16 @@ static int decode_fhandle(struct xdr_stream *xdr, struct mountres *res) | |||
349 | return 0; | 340 | return 0; |
350 | } | 341 | } |
351 | 342 | ||
352 | static int mnt_dec_mountres(struct rpc_rqst *req, __be32 *p, | 343 | static int mnt_xdr_dec_mountres(struct rpc_rqst *req, |
353 | struct mountres *res) | 344 | struct xdr_stream *xdr, |
345 | struct mountres *res) | ||
354 | { | 346 | { |
355 | struct xdr_stream xdr; | ||
356 | int status; | 347 | int status; |
357 | 348 | ||
358 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 349 | status = decode_status(xdr, res); |
359 | |||
360 | status = decode_status(&xdr, res); | ||
361 | if (unlikely(status != 0 || res->errno != 0)) | 350 | if (unlikely(status != 0 || res->errno != 0)) |
362 | return status; | 351 | return status; |
363 | return decode_fhandle(&xdr, res); | 352 | return decode_fhandle(xdr, res); |
364 | } | 353 | } |
365 | 354 | ||
366 | static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res) | 355 | static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res) |
@@ -369,10 +358,10 @@ static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res) | |||
369 | u32 status; | 358 | u32 status; |
370 | __be32 *p; | 359 | __be32 *p; |
371 | 360 | ||
372 | p = xdr_inline_decode(xdr, sizeof(status)); | 361 | p = xdr_inline_decode(xdr, 4); |
373 | if (unlikely(p == NULL)) | 362 | if (unlikely(p == NULL)) |
374 | return -EIO; | 363 | return -EIO; |
375 | status = ntohl(*p); | 364 | status = be32_to_cpup(p); |
376 | 365 | ||
377 | for (i = 0; i < ARRAY_SIZE(mnt3_errtbl); i++) { | 366 | for (i = 0; i < ARRAY_SIZE(mnt3_errtbl); i++) { |
378 | if (mnt3_errtbl[i].status == status) { | 367 | if (mnt3_errtbl[i].status == status) { |
@@ -392,11 +381,11 @@ static int decode_fhandle3(struct xdr_stream *xdr, struct mountres *res) | |||
392 | u32 size; | 381 | u32 size; |
393 | __be32 *p; | 382 | __be32 *p; |
394 | 383 | ||
395 | p = xdr_inline_decode(xdr, sizeof(size)); | 384 | p = xdr_inline_decode(xdr, 4); |
396 | if (unlikely(p == NULL)) | 385 | if (unlikely(p == NULL)) |
397 | return -EIO; | 386 | return -EIO; |
398 | 387 | ||
399 | size = ntohl(*p++); | 388 | size = be32_to_cpup(p); |
400 | if (size > NFS3_FHSIZE || size == 0) | 389 | if (size > NFS3_FHSIZE || size == 0) |
401 | return -EIO; | 390 | return -EIO; |
402 | 391 | ||
@@ -419,15 +408,15 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res) | |||
419 | if (*count == 0) | 408 | if (*count == 0) |
420 | return 0; | 409 | return 0; |
421 | 410 | ||
422 | p = xdr_inline_decode(xdr, sizeof(entries)); | 411 | p = xdr_inline_decode(xdr, 4); |
423 | if (unlikely(p == NULL)) | 412 | if (unlikely(p == NULL)) |
424 | return -EIO; | 413 | return -EIO; |
425 | entries = ntohl(*p); | 414 | entries = be32_to_cpup(p); |
426 | dprintk("NFS: received %u auth flavors\n", entries); | 415 | dprintk("NFS: received %u auth flavors\n", entries); |
427 | if (entries > NFS_MAX_SECFLAVORS) | 416 | if (entries > NFS_MAX_SECFLAVORS) |
428 | entries = NFS_MAX_SECFLAVORS; | 417 | entries = NFS_MAX_SECFLAVORS; |
429 | 418 | ||
430 | p = xdr_inline_decode(xdr, sizeof(u32) * entries); | 419 | p = xdr_inline_decode(xdr, 4 * entries); |
431 | if (unlikely(p == NULL)) | 420 | if (unlikely(p == NULL)) |
432 | return -EIO; | 421 | return -EIO; |
433 | 422 | ||
@@ -435,38 +424,36 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res) | |||
435 | entries = *count; | 424 | entries = *count; |
436 | 425 | ||
437 | for (i = 0; i < entries; i++) { | 426 | for (i = 0; i < entries; i++) { |
438 | flavors[i] = ntohl(*p++); | 427 | flavors[i] = be32_to_cpup(p++); |
439 | dprintk("NFS:\tflavor %u: %d\n", i, flavors[i]); | 428 | dprintk("NFS: auth flavor[%u]: %d\n", i, flavors[i]); |
440 | } | 429 | } |
441 | *count = i; | 430 | *count = i; |
442 | 431 | ||
443 | return 0; | 432 | return 0; |
444 | } | 433 | } |
445 | 434 | ||
446 | static int mnt_dec_mountres3(struct rpc_rqst *req, __be32 *p, | 435 | static int mnt_xdr_dec_mountres3(struct rpc_rqst *req, |
447 | struct mountres *res) | 436 | struct xdr_stream *xdr, |
437 | struct mountres *res) | ||
448 | { | 438 | { |
449 | struct xdr_stream xdr; | ||
450 | int status; | 439 | int status; |
451 | 440 | ||
452 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 441 | status = decode_fhs_status(xdr, res); |
453 | |||
454 | status = decode_fhs_status(&xdr, res); | ||
455 | if (unlikely(status != 0 || res->errno != 0)) | 442 | if (unlikely(status != 0 || res->errno != 0)) |
456 | return status; | 443 | return status; |
457 | status = decode_fhandle3(&xdr, res); | 444 | status = decode_fhandle3(xdr, res); |
458 | if (unlikely(status != 0)) { | 445 | if (unlikely(status != 0)) { |
459 | res->errno = -EBADHANDLE; | 446 | res->errno = -EBADHANDLE; |
460 | return 0; | 447 | return 0; |
461 | } | 448 | } |
462 | return decode_auth_flavors(&xdr, res); | 449 | return decode_auth_flavors(xdr, res); |
463 | } | 450 | } |
464 | 451 | ||
465 | static struct rpc_procinfo mnt_procedures[] = { | 452 | static struct rpc_procinfo mnt_procedures[] = { |
466 | [MOUNTPROC_MNT] = { | 453 | [MOUNTPROC_MNT] = { |
467 | .p_proc = MOUNTPROC_MNT, | 454 | .p_proc = MOUNTPROC_MNT, |
468 | .p_encode = (kxdrproc_t)mnt_enc_dirpath, | 455 | .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath, |
469 | .p_decode = (kxdrproc_t)mnt_dec_mountres, | 456 | .p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres, |
470 | .p_arglen = MNT_enc_dirpath_sz, | 457 | .p_arglen = MNT_enc_dirpath_sz, |
471 | .p_replen = MNT_dec_mountres_sz, | 458 | .p_replen = MNT_dec_mountres_sz, |
472 | .p_statidx = MOUNTPROC_MNT, | 459 | .p_statidx = MOUNTPROC_MNT, |
@@ -474,7 +461,7 @@ static struct rpc_procinfo mnt_procedures[] = { | |||
474 | }, | 461 | }, |
475 | [MOUNTPROC_UMNT] = { | 462 | [MOUNTPROC_UMNT] = { |
476 | .p_proc = MOUNTPROC_UMNT, | 463 | .p_proc = MOUNTPROC_UMNT, |
477 | .p_encode = (kxdrproc_t)mnt_enc_dirpath, | 464 | .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath, |
478 | .p_arglen = MNT_enc_dirpath_sz, | 465 | .p_arglen = MNT_enc_dirpath_sz, |
479 | .p_statidx = MOUNTPROC_UMNT, | 466 | .p_statidx = MOUNTPROC_UMNT, |
480 | .p_name = "UMOUNT", | 467 | .p_name = "UMOUNT", |
@@ -484,8 +471,8 @@ static struct rpc_procinfo mnt_procedures[] = { | |||
484 | static struct rpc_procinfo mnt3_procedures[] = { | 471 | static struct rpc_procinfo mnt3_procedures[] = { |
485 | [MOUNTPROC3_MNT] = { | 472 | [MOUNTPROC3_MNT] = { |
486 | .p_proc = MOUNTPROC3_MNT, | 473 | .p_proc = MOUNTPROC3_MNT, |
487 | .p_encode = (kxdrproc_t)mnt_enc_dirpath, | 474 | .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath, |
488 | .p_decode = (kxdrproc_t)mnt_dec_mountres3, | 475 | .p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres3, |
489 | .p_arglen = MNT_enc_dirpath_sz, | 476 | .p_arglen = MNT_enc_dirpath_sz, |
490 | .p_replen = MNT_dec_mountres3_sz, | 477 | .p_replen = MNT_dec_mountres3_sz, |
491 | .p_statidx = MOUNTPROC3_MNT, | 478 | .p_statidx = MOUNTPROC3_MNT, |
@@ -493,7 +480,7 @@ static struct rpc_procinfo mnt3_procedures[] = { | |||
493 | }, | 480 | }, |
494 | [MOUNTPROC3_UMNT] = { | 481 | [MOUNTPROC3_UMNT] = { |
495 | .p_proc = MOUNTPROC3_UMNT, | 482 | .p_proc = MOUNTPROC3_UMNT, |
496 | .p_encode = (kxdrproc_t)mnt_enc_dirpath, | 483 | .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath, |
497 | .p_arglen = MNT_enc_dirpath_sz, | 484 | .p_arglen = MNT_enc_dirpath_sz, |
498 | .p_statidx = MOUNTPROC3_UMNT, | 485 | .p_statidx = MOUNTPROC3_UMNT, |
499 | .p_name = "UMOUNT", | 486 | .p_name = "UMOUNT", |
@@ -503,13 +490,13 @@ static struct rpc_procinfo mnt3_procedures[] = { | |||
503 | 490 | ||
504 | static struct rpc_version mnt_version1 = { | 491 | static struct rpc_version mnt_version1 = { |
505 | .number = 1, | 492 | .number = 1, |
506 | .nrprocs = 2, | 493 | .nrprocs = ARRAY_SIZE(mnt_procedures), |
507 | .procs = mnt_procedures, | 494 | .procs = mnt_procedures, |
508 | }; | 495 | }; |
509 | 496 | ||
510 | static struct rpc_version mnt_version3 = { | 497 | static struct rpc_version mnt_version3 = { |
511 | .number = 3, | 498 | .number = 3, |
512 | .nrprocs = 2, | 499 | .nrprocs = ARRAY_SIZE(mnt3_procedures), |
513 | .procs = mnt3_procedures, | 500 | .procs = mnt3_procedures, |
514 | }; | 501 | }; |
515 | 502 | ||