aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4/root.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/autofs4/root.c')
-rw-r--r--fs/autofs4/root.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index db4117ed7803..cb1bd38dc08c 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 = {
@@ -198,8 +204,7 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
198 } 204 }
199 205
200 /* Initialize expiry counter after successful mount */ 206 /* Initialize expiry counter after successful mount */
201 if (ino) 207 ino->last_used = jiffies;
202 ino->last_used = jiffies;
203 208
204 spin_lock(&sbi->fs_lock); 209 spin_lock(&sbi->fs_lock);
205 ino->flags &= ~AUTOFS_INF_PENDING; 210 ino->flags &= ~AUTOFS_INF_PENDING;
@@ -840,6 +845,26 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
840} 845}
841 846
842/* Get/set timeout ioctl() operation */ 847/* Get/set timeout ioctl() operation */
848#ifdef CONFIG_COMPAT
849static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi,
850 compat_ulong_t __user *p)
851{
852 int rv;
853 unsigned long ntimeout;
854
855 if ((rv = get_user(ntimeout, p)) ||
856 (rv = put_user(sbi->exp_timeout/HZ, p)))
857 return rv;
858
859 if (ntimeout > UINT_MAX/HZ)
860 sbi->exp_timeout = 0;
861 else
862 sbi->exp_timeout = ntimeout * HZ;
863
864 return 0;
865}
866#endif
867
843static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi, 868static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi,
844 unsigned long __user *p) 869 unsigned long __user *p)
845{ 870{
@@ -933,6 +958,10 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
933 return autofs4_get_protosubver(sbi, p); 958 return autofs4_get_protosubver(sbi, p);
934 case AUTOFS_IOC_SETTIMEOUT: 959 case AUTOFS_IOC_SETTIMEOUT:
935 return autofs4_get_set_timeout(sbi, p); 960 return autofs4_get_set_timeout(sbi, p);
961#ifdef CONFIG_COMPAT
962 case AUTOFS_IOC_SETTIMEOUT32:
963 return autofs4_compat_get_set_timeout(sbi, p);
964#endif
936 965
937 case AUTOFS_IOC_ASKUMOUNT: 966 case AUTOFS_IOC_ASKUMOUNT:
938 return autofs4_ask_umount(filp->f_path.mnt, p); 967 return autofs4_ask_umount(filp->f_path.mnt, p);
@@ -961,3 +990,22 @@ static long autofs4_root_ioctl(struct file *filp,
961 990
962 return ret; 991 return ret;
963} 992}
993
994#ifdef CONFIG_COMPAT
995static long autofs4_root_compat_ioctl(struct file *filp,
996 unsigned int cmd, unsigned long arg)
997{
998 struct inode *inode = filp->f_path.dentry->d_inode;
999 int ret;
1000
1001 lock_kernel();
1002 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
1003 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
1004 else
1005 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd,
1006 (unsigned long)compat_ptr(arg));
1007 unlock_kernel();
1008
1009 return ret;
1010}
1011#endif