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