diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2014-05-23 07:59:06 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-30 17:32:19 -0400 |
commit | 0d63790c365852a6ce2913632b933633343ae479 (patch) | |
tree | 99b632c5161516c0f0b918590f34ce23e48c6735 /fs/nfsd/export.c | |
parent | a1f05514b016aeaed638dbf677f443af7e7bde4f (diff) |
NFSD: Helper function for parsing uuid
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/export.c')
-rw-r--r-- | fs/nfsd/export.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 9a41d3ddd8df..8771f417efa6 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -480,6 +480,23 @@ static inline int | |||
480 | secinfo_parse(char **mesg, char *buf, struct svc_export *exp) { return 0; } | 480 | secinfo_parse(char **mesg, char *buf, struct svc_export *exp) { return 0; } |
481 | #endif | 481 | #endif |
482 | 482 | ||
483 | static inline int | ||
484 | uuid_parse(char **mesg, char *buf, unsigned char **puuid) | ||
485 | { | ||
486 | int len; | ||
487 | |||
488 | /* expect a 16 byte uuid encoded as \xXXXX... */ | ||
489 | len = qword_get(mesg, buf, PAGE_SIZE); | ||
490 | if (len != 16) | ||
491 | return -EINVAL; | ||
492 | |||
493 | *puuid = kmemdup(buf, 16, GFP_KERNEL); | ||
494 | if (*puuid == NULL) | ||
495 | return -ENOMEM; | ||
496 | |||
497 | return 0; | ||
498 | } | ||
499 | |||
483 | static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | 500 | static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) |
484 | { | 501 | { |
485 | /* client path expiry [flags anonuid anongid fsid] */ | 502 | /* client path expiry [flags anonuid anongid fsid] */ |
@@ -558,18 +575,9 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
558 | while ((len = qword_get(&mesg, buf, PAGE_SIZE)) > 0) { | 575 | while ((len = qword_get(&mesg, buf, PAGE_SIZE)) > 0) { |
559 | if (strcmp(buf, "fsloc") == 0) | 576 | if (strcmp(buf, "fsloc") == 0) |
560 | err = fsloc_parse(&mesg, buf, &exp.ex_fslocs); | 577 | err = fsloc_parse(&mesg, buf, &exp.ex_fslocs); |
561 | else if (strcmp(buf, "uuid") == 0) { | 578 | else if (strcmp(buf, "uuid") == 0) |
562 | /* expect a 16 byte uuid encoded as \xXXXX... */ | 579 | err = uuid_parse(&mesg, buf, &exp.ex_uuid); |
563 | len = qword_get(&mesg, buf, PAGE_SIZE); | 580 | else if (strcmp(buf, "secinfo") == 0) |
564 | if (len != 16) | ||
565 | err = -EINVAL; | ||
566 | else { | ||
567 | exp.ex_uuid = | ||
568 | kmemdup(buf, 16, GFP_KERNEL); | ||
569 | if (exp.ex_uuid == NULL) | ||
570 | err = -ENOMEM; | ||
571 | } | ||
572 | } else if (strcmp(buf, "secinfo") == 0) | ||
573 | err = secinfo_parse(&mesg, buf, &exp); | 581 | err = secinfo_parse(&mesg, buf, &exp); |
574 | else | 582 | else |
575 | /* quietly ignore unknown words and anything | 583 | /* quietly ignore unknown words and anything |