From patchwork Fri May 23 11:59:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 4231901 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E8BBBF90B for ; Fri, 23 May 2014 11:59:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98A572034B for ; Fri, 23 May 2014 11:59:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1D1D2022A for ; Fri, 23 May 2014 11:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752460AbaEWL7c (ORCPT ); Fri, 23 May 2014 07:59:32 -0400 Received: from mail-qg0-f51.google.com ([209.85.192.51]:47307 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751962AbaEWL7c (ORCPT ); Fri, 23 May 2014 07:59:32 -0400 Received: by mail-qg0-f51.google.com with SMTP id q107so7817475qgd.38 for ; Fri, 23 May 2014 04:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=LkrfNAVP18EncKsbl8ZEN2qcnpfqKLb+jkZTdrzMR3A=; b=gVf4E5RL7zMIF2agWbpQFmsBXdRf8ShAknqzYn7VTFLkmMHiYjE+lpbUMnCxd3kTQd 4CDgxvNSyusKRrekrNGLf3QBffcYFJLFVeObNLneJqAAa2wcbFbqqLfl6A69mbYQlrfx Xl3kcj1jv4Nzlkgr0ytBKQ2rBpGbyk32dCyu6r8/CVxcKx+rI9Q7LMKh7EFaboH4vErG pXT1JB0e/bV5nJfHyWX2tN3AJd8jXKu/pua5OKYlZLpyOXO13okpGoidAIvRSMPcu9CQ V84SZ/yjqo7GBhtP5F5Ka42jdR+osQEqUDyTz/cKjfa0Ld1zOEM5qUxtUft/v3MHkJx6 u9ZA== X-Received: by 10.140.83.73 with SMTP id i67mr5462931qgd.22.1400846371814; Fri, 23 May 2014 04:59:31 -0700 (PDT) Received: from [192.168.31.158] ([118.117.113.227]) by mx.google.com with ESMTPSA id o16sm4548888qax.23.2014.05.23.04.59.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 04:59:30 -0700 (PDT) Message-ID: <537F380A.5010302@gmail.com> Date: Fri, 23 May 2014 19:59:06 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "J. Bruce Fields" CC: Linux NFS Mailing List , kinglongmee@gmail.com Subject: [PATCH 2/4] NFSD: Helper function for parsing uuid Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Kinglong Mee --- fs/nfsd/export.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 9a41d3d..8771f41 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -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