aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4/root.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-07-03 18:15:07 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2010-08-08 18:13:34 -0400
commitc9243f5bdd6637b2bb7dc254b54d9edf957ef17e (patch)
tree254c0733f9d547651f467ed6502c7335804eaaf8 /fs/autofs4/root.c
parent86a5ef7d777cdd61dfe82379d559dbea069aea3d (diff)
autofs/autofs4: Move compat_ioctl handling into fs
Handling of autofs ioctl numbers does not need to be generic and can easily be done directly in autofs itself. This also pushes the BKL into autofs and autofs4 ioctl methods. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: H. Peter Anvin <hpa@zytor.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Ian Kent <raven@themaw.net> Cc: Autofs <autofs@linux.kernel.org> Cc: John Kacur <jkacur@redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'fs/autofs4/root.c')
-rw-r--r--fs/autofs4/root.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index db4117ed7803..48e056e70fd6 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -18,7 +18,9 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/param.h> 19#include <linux/param.h>
20#include <linux/time.h> 20#include <linux/time.h>
21#include <linux/compat.h>
21#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
23
22#include "autofs_i.h" 24#include "autofs_i.h"
23 25
24static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); 26static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
@@ -26,6 +28,7 @@ static int autofs4_dir_unlink(struct inode *,struct dentry *);
26static int autofs4_dir_rmdir(struct inode *,struct dentry *); 28static int autofs4_dir_rmdir(struct inode *,struct dentry *);
27static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); 29static int autofs4_dir_mkdir(struct inode *,struct dentry *,int);
28static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); 30static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long);
31static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long);
29static int autofs4_dir_open(struct inode *inode, struct file *file); 32static int autofs4_dir_open(struct inode *inode, struct file *file);
30static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); 33static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
31static void *autofs4_follow_link(struct dentry *, struct nameidata *); 34static void *autofs4_follow_link(struct dentry *, struct nameidata *);
@@ -40,6 +43,9 @@ const struct file_operations autofs4_root_operations = {
40 .readdir = dcache_readdir, 43 .readdir = dcache_readdir,
41 .llseek = dcache_dir_lseek, 44 .llseek = dcache_dir_lseek,
42 .unlocked_ioctl = autofs4_root_ioctl, 45 .unlocked_ioctl = autofs4_root_ioctl,
46#ifdef CONFIG_COMPAT
47 .compat_ioctl = autofs4_root_compat_ioctl,
48#endif
43}; 49};
44 50
45const struct file_operations autofs4_dir_operations = { 51const struct file_operations autofs4_dir_operations = {
@@ -840,6 +846,26 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
840} 846}
841 847
842/* Get/set timeout ioctl() operation */ 848/* Get/set timeout ioctl() operation */
849#ifdef CONFIG_COMPAT
850static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi,
851 compat_ulong_t __user *p)
852{
853 int rv;
854 unsigned long ntimeout;
855
856 if ((rv = get_user(ntimeout, p)) ||
857 (rv = put_user(sbi->exp_timeout/HZ, p)))
858 return rv;
859
860 if (ntimeout > UINT_MAX/HZ)
861 sbi->exp_timeout = 0;
862 else
863 sbi->exp_timeout = ntimeout * HZ;
864
865 return 0;
866}
867#endif
868
843static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi, 869static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi,
844 unsigned long __user *p) 870 unsigned long __user *p)
845{ 871{
@@ -933,6 +959,10 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
933 return autofs4_get_protosubver(sbi, p); 959 return autofs4_get_protosubver(sbi, p);
934 case AUTOFS_IOC_SETTIMEOUT: 960 case AUTOFS_IOC_SETTIMEOUT:
935 return autofs4_get_set_timeout(sbi, p); 961 return autofs4_get_set_timeout(sbi, p);
962#ifdef CONFIG_COMPAT
963 case AUTOFS_IOC_SETTIMEOUT32:
964 return autofs4_compat_get_set_timeout(sbi, p);
965#endif
936 966
937 case AUTOFS_IOC_ASKUMOUNT: 967 case AUTOFS_IOC_ASKUMOUNT:
938 return autofs4_ask_umount(filp->f_path.mnt, p); 968 return autofs4_ask_umount(filp->f_path.mnt, p);
@@ -961,3 +991,22 @@ static long autofs4_root_ioctl(struct file *filp,
961 991
962 return ret; 992 return ret;
963} 993}
994
995#ifdef CONFIG_COMPAT
996static long autofs4_root_compat_ioctl(struct file *filp,
997 unsigned int cmd, unsigned long arg)
998{
999 struct inode *inode = filp->f_path.dentry->d_inode;
1000 int ret;
1001
1002 lock_kernel();
1003 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
1004 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
1005 else
1006 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd,
1007 (unsigned long)compat_ptr(arg));
1008 unlock_kernel();
1009
1010 return ret;
1011}
1012#endif