From patchwork Fri Aug 12 02:48:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 9276237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF9766022E for ; Fri, 12 Aug 2016 02:49:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C106C205AD for ; Fri, 12 Aug 2016 02:49:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B50DC2880A; Fri, 12 Aug 2016 02:49:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E9AF205AD for ; Fri, 12 Aug 2016 02:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752885AbcHLCsx (ORCPT ); Thu, 11 Aug 2016 22:48:53 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:53135 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbcHLCsu (ORCPT ); Thu, 11 Aug 2016 22:48:50 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 3E43F20345; Thu, 11 Aug 2016 22:48:49 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Thu, 11 Aug 2016 22:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=themaw.net; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=lnQljWMjz8kTm9p6tN0vsLGtgX4=; b=jh89RN JTXNz/520GZpxzFxtE01TwmMA5s/Df/j6ewhA+rNggMD9lWp3uLcNbtLs8J8CP4U IBPuWn8qBS/8RPByYnk+jcY2h4D8g/yVjmhe5Eyyqpp+GVGIcmsfCdI7KjI84NSr e2PnByrncysHYg9Lgpm8NF+UDRLxKO2oiSrd0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=lnQljWMjz8kTm9p 6tN0vsLGtgX4=; b=Arq5w75/6423BODI43aDY0Mhy0Ohaozs/zj8dq7kSzQp1aJ mNkQ5y0Elp8qpRcqFm6BKLG0PX1z+khaMVrluHByHziYL1z3/UXMyVM5mV/0yPP/ NQFgy7BV20seG5I99uvAtT7VRC+//EwWzBAWHOCVtoppTUfu6Jfd9c1eDCKE= X-Sasl-enc: oTZjFTC3B3/lbZC7XT6Cg3siddhg/TIpqu87iUABjT/z 1470970128 Received: from pluto.themaw.net (58-7-183-14.dyn.iinet.net.au [58.7.183.14]) by mail.messagingengine.com (Postfix) with ESMTPA id A5734F2C78; Thu, 11 Aug 2016 22:48:48 -0400 (EDT) Received: from pluto.themaw.net (localhost [127.0.0.1]) by pluto.themaw.net (Postfix) with ESMTP id 9AE45A0078; Fri, 12 Aug 2016 10:48:46 +0800 (AWST) Subject: [PATCH 15/18] autofs: Add autofs_dev_ioctl_version() for AUTOFS_DEV_IOCTL_VERSION_CMD From: Ian Kent To: Andrew Morton Cc: linux-fsdevel , Tomohiro Kusumi , autofs mailing list , Kernel Mailing List Date: Fri, 12 Aug 2016 10:48:46 +0800 Message-ID: <20160812024846.12352.9885.stgit@pluto.themaw.net> In-Reply-To: <20160812024734.12352.17122.stgit@pluto.themaw.net> References: <20160812024734.12352.17122.stgit@pluto.themaw.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tomohiro Kusumi No functional changes, based on the following justification. 1. Make the code more consistent using the ioctl vector _ioctls[], rather than assigning NULL only for this ioctl command. 2. Remove goto done; for better maintainability in the long run. 3. The existing code is based on the fact that validate_dev_ioctl() sets ioctl version for any command, but AUTOFS_DEV_IOCTL_VERSION_CMD should explicitly set it regardless of the default behavior. Signed-off-by: Tomohiro Kusumi Signed-off-by: Ian Kent --- fs/autofs4/dev-ioctl.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index 13e7517..7289216 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c @@ -172,6 +172,17 @@ static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct file *f) return sbi; } +/* Return autofs dev ioctl version */ +static int autofs_dev_ioctl_version(struct file *fp, + struct autofs_sb_info *sbi, + struct autofs_dev_ioctl *param) +{ + /* This should have already been set. */ + param->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR; + param->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR; + return 0; +} + /* Return autofs module protocol version */ static int autofs_dev_ioctl_protover(struct file *fp, struct autofs_sb_info *sbi, @@ -590,7 +601,8 @@ static ioctl_fn lookup_dev_ioctl(unsigned int cmd) int cmd; ioctl_fn fn; } _ioctls[] = { - {cmd_idx(AUTOFS_DEV_IOCTL_VERSION_CMD), NULL}, + {cmd_idx(AUTOFS_DEV_IOCTL_VERSION_CMD), + autofs_dev_ioctl_version}, {cmd_idx(AUTOFS_DEV_IOCTL_PROTOVER_CMD), autofs_dev_ioctl_protover}, {cmd_idx(AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD), @@ -655,10 +667,6 @@ static int _autofs_dev_ioctl(unsigned int command, if (err) goto out; - /* The validate routine above always sets the version */ - if (cmd == AUTOFS_DEV_IOCTL_VERSION_CMD) - goto done; - fn = lookup_dev_ioctl(cmd); if (!fn) { pr_warn("unknown command 0x%08x\n", command); @@ -672,9 +680,11 @@ static int _autofs_dev_ioctl(unsigned int command, /* * For obvious reasons the openmount can't have a file * descriptor yet. We don't take a reference to the - * file during close to allow for immediate release. + * file during close to allow for immediate release, + * and the same for retrieving ioctl version. */ - if (cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD && + if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD && + cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD && cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) { fp = fget(param->ioctlfd); if (!fp) { @@ -707,7 +717,6 @@ cont: if (fp) fput(fp); -done: if (err >= 0 && copy_to_user(user, param, AUTOFS_DEV_IOCTL_SIZE)) err = -EFAULT; out: