autofs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
To: raven@themaw.net, autofs@vger.kernel.org
Cc: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Subject: [PATCH 10/12] autofs: Add autofs_dev_ioctl_version() for AUTOFS_DEV_IOCTL_VERSION_CMD
Date: Sun, 10 Jul 2016 17:07:51 +0900	[thread overview]
Message-ID: <1468138073-4870-10-git-send-email-kusumi.tomohiro@gmail.com> (raw)
In-Reply-To: <1468138073-4870-1-git-send-email-kusumi.tomohiro@gmail.com>

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 <kusumi.tomohiro@gmail.com>
---
 fs/autofs4/dev-ioctl.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index d47b35a..3a1a969 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:
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

  parent reply	other threads:[~2016-07-10  8:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-10  8:07 [PATCH 01/12] autofs: Remove obsolete sb fields Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 02/12] autofs: Don't fail to free_dev_ioctl(param) Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 03/12] autofs: Fix AUTOFS_DEV_IOCTL_IOC_COUNT value Tomohiro Kusumi
2016-07-19  1:34   ` Ian Kent
2016-07-19 19:29     ` Tomohiro Kusumi
2016-07-20  0:47       ` Ian Kent
2016-07-20 17:53         ` Tomohiro Kusumi
2016-07-21  2:02           ` Ian Kent
2016-07-21 18:12             ` Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 04/12] autofs: Change _LINUX_AUTO_FS4_H to _UAPI_LINUX_AUTO_FS4_H Tomohiro Kusumi
2016-07-19  1:40   ` Ian Kent
2016-07-10  8:07 ` [PATCH 05/12] autofs: Remove AUTOFS_DEVID_LEN Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 06/12] autofs: Fix Documentation regarding devid on ioctl Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 07/12] autofs: Update struct autofs_dev_ioctl in Documentation Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 08/12] autofs: Fix pr_debug() message Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 09/12] autofs: Fix wrong file/function/macro names in comments Tomohiro Kusumi
2016-07-10  8:07 ` Tomohiro Kusumi [this message]
2016-07-10  8:07 ` [PATCH 11/12] autofs: Fix print format for ioctl warning message Tomohiro Kusumi
2016-07-10  8:07 ` [PATCH 12/12] autofs: Move inclusion of linux/limits.h to uapi Tomohiro Kusumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468138073-4870-10-git-send-email-kusumi.tomohiro@gmail.com \
    --to=kusumi.tomohiro@gmail.com \
    --cc=autofs@vger.kernel.org \
    --cc=raven@themaw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).