diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-10 16:58:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-10 16:58:28 -0400 |
commit | 7233e392760b3493095d3d5885cb15e44493d74a (patch) | |
tree | e2095425fe34c635ee2cf77f9ef6022f7cddfbb1 /fs/autofs4/root.c | |
parent | 4c619407b0439c59c20398b9459020c0d297f424 (diff) | |
parent | 5ef06839f50c7e5e479d3595257131edf1f84f36 (diff) |
Merge branch 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing
* 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing:
staging: Pushdown bkl to easycap ioctl handlers
autofs/autofs4: Move compat_ioctl handling into fs
v4l: Convert v4l2-dev to unlocked_ioctl
ia64/perfmon: Convert to unlocked_ioctl
sunrpc: Remove duplicated #include
ncpfs: Remove duplicated #include
Diffstat (limited to 'fs/autofs4/root.c')
-rw-r--r-- | fs/autofs4/root.c | 49 |
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 | ||
24 | static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); | 26 | static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); |
@@ -26,6 +28,7 @@ static int autofs4_dir_unlink(struct inode *,struct dentry *); | |||
26 | static int autofs4_dir_rmdir(struct inode *,struct dentry *); | 28 | static int autofs4_dir_rmdir(struct inode *,struct dentry *); |
27 | static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); | 29 | static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); |
28 | static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); | 30 | static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); |
31 | static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); | ||
29 | static int autofs4_dir_open(struct inode *inode, struct file *file); | 32 | static int autofs4_dir_open(struct inode *inode, struct file *file); |
30 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); | 33 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); |
31 | static void *autofs4_follow_link(struct dentry *, struct nameidata *); | 34 | static 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 | ||
45 | const struct file_operations autofs4_dir_operations = { | 51 | const 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 | ||
850 | static 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 | |||
843 | static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi, | 869 | static 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 | ||
996 | static 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 | ||