]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFSD: Helper function for parsing uuid
authorKinglong Mee <kinglongmee@gmail.com>
Fri, 23 May 2014 11:59:06 +0000 (19:59 +0800)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 30 May 2014 21:32:19 +0000 (17:32 -0400)
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/export.c

index 9a41d3ddd8dfe1d11441b9401b030773880dc0dc..8771f417efa6a382386cb882715f053364da26b4 100644 (file)
@@ -480,6 +480,23 @@ static inline int
 secinfo_parse(char **mesg, char *buf, struct svc_export *exp) { return 0; }
 #endif
 
+static inline int
+uuid_parse(char **mesg, char *buf, unsigned char **puuid)
+{
+       int len;
+
+       /* expect a 16 byte uuid encoded as \xXXXX... */
+       len = qword_get(mesg, buf, PAGE_SIZE);
+       if (len != 16)
+               return -EINVAL;
+
+       *puuid = kmemdup(buf, 16, GFP_KERNEL);
+       if (*puuid == NULL)
+               return -ENOMEM;
+
+       return 0;
+}
+
 static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 {
        /* client path expiry [flags anonuid anongid fsid] */
@@ -558,18 +575,9 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
                while ((len = qword_get(&mesg, buf, PAGE_SIZE)) > 0) {
                        if (strcmp(buf, "fsloc") == 0)
                                err = fsloc_parse(&mesg, buf, &exp.ex_fslocs);
-                       else if (strcmp(buf, "uuid") == 0) {
-                               /* expect a 16 byte uuid encoded as \xXXXX... */
-                               len = qword_get(&mesg, buf, PAGE_SIZE);
-                               if (len != 16)
-                                       err  = -EINVAL;
-                               else {
-                                       exp.ex_uuid =
-                                               kmemdup(buf, 16, GFP_KERNEL);
-                                       if (exp.ex_uuid == NULL)
-                                               err = -ENOMEM;
-                               }
-                       } else if (strcmp(buf, "secinfo") == 0)
+                       else if (strcmp(buf, "uuid") == 0)
+                               err = uuid_parse(&mesg, buf, &exp.ex_uuid);
+                       else if (strcmp(buf, "secinfo") == 0)
                                err = secinfo_parse(&mesg, buf, &exp);
                        else
                                /* quietly ignore unknown words and anything