aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2016-10-11 16:53:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-11 18:06:31 -0400
commitd9e1923207f7e099c376d8bd01424423e962aeee (patch)
tree7e58495a4bfd62bf376486f103620102beae5a4d
parentaa8419367b62044e92bd7993eeb83d861b59bafa (diff)
autofs: add autofs_dev_ioctl_version() for AUTOFS_DEV_IOCTL_VERSION_CMD
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. Link: http://lkml.kernel.org/r/20160812024846.12352.9885.stgit@pluto.themaw.net Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Signed-off-by: Ian Kent <ikent@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/autofs4/dev-ioctl.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 13e75177f892..7289216708d2 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)
172 return sbi; 172 return sbi;
173} 173}
174 174
175/* Return autofs dev ioctl version */
176static int autofs_dev_ioctl_version(struct file *fp,
177 struct autofs_sb_info *sbi,
178 struct autofs_dev_ioctl *param)
179{
180 /* This should have already been set. */
181 param->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
182 param->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
183 return 0;
184}
185
175/* Return autofs module protocol version */ 186/* Return autofs module protocol version */
176static int autofs_dev_ioctl_protover(struct file *fp, 187static int autofs_dev_ioctl_protover(struct file *fp,
177 struct autofs_sb_info *sbi, 188 struct autofs_sb_info *sbi,
@@ -590,7 +601,8 @@ static ioctl_fn lookup_dev_ioctl(unsigned int cmd)
590 int cmd; 601 int cmd;
591 ioctl_fn fn; 602 ioctl_fn fn;
592 } _ioctls[] = { 603 } _ioctls[] = {
593 {cmd_idx(AUTOFS_DEV_IOCTL_VERSION_CMD), NULL}, 604 {cmd_idx(AUTOFS_DEV_IOCTL_VERSION_CMD),
605 autofs_dev_ioctl_version},
594 {cmd_idx(AUTOFS_DEV_IOCTL_PROTOVER_CMD), 606 {cmd_idx(AUTOFS_DEV_IOCTL_PROTOVER_CMD),
595 autofs_dev_ioctl_protover}, 607 autofs_dev_ioctl_protover},
596 {cmd_idx(AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD), 608 {cmd_idx(AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD),
@@ -655,10 +667,6 @@ static int _autofs_dev_ioctl(unsigned int command,
655 if (err) 667 if (err)
656 goto out; 668 goto out;
657 669
658 /* The validate routine above always sets the version */
659 if (cmd == AUTOFS_DEV_IOCTL_VERSION_CMD)
660 goto done;
661
662 fn = lookup_dev_ioctl(cmd); 670 fn = lookup_dev_ioctl(cmd);
663 if (!fn) { 671 if (!fn) {
664 pr_warn("unknown command 0x%08x\n", command); 672 pr_warn("unknown command 0x%08x\n", command);
@@ -672,9 +680,11 @@ static int _autofs_dev_ioctl(unsigned int command,
672 /* 680 /*
673 * For obvious reasons the openmount can't have a file 681 * For obvious reasons the openmount can't have a file
674 * descriptor yet. We don't take a reference to the 682 * descriptor yet. We don't take a reference to the
675 * file during close to allow for immediate release. 683 * file during close to allow for immediate release,
684 * and the same for retrieving ioctl version.
676 */ 685 */
677 if (cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD && 686 if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD &&
687 cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD &&
678 cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) { 688 cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) {
679 fp = fget(param->ioctlfd); 689 fp = fget(param->ioctlfd);
680 if (!fp) { 690 if (!fp) {
@@ -707,7 +717,6 @@ cont:
707 717
708 if (fp) 718 if (fp)
709 fput(fp); 719 fput(fp);
710done:
711 if (err >= 0 && copy_to_user(user, param, AUTOFS_DEV_IOCTL_SIZE)) 720 if (err >= 0 && copy_to_user(user, param, AUTOFS_DEV_IOCTL_SIZE))
712 err = -EFAULT; 721 err = -EFAULT;
713out: 722out: