diff options
-rw-r--r-- | fs/coda/pioctl.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c index 773f2ce9aa06..96ace2ce7e6c 100644 --- a/fs/coda/pioctl.c +++ b/fs/coda/pioctl.c | |||
@@ -23,10 +23,12 @@ | |||
23 | #include <linux/coda_fs_i.h> | 23 | #include <linux/coda_fs_i.h> |
24 | #include <linux/coda_psdev.h> | 24 | #include <linux/coda_psdev.h> |
25 | 25 | ||
26 | #include <linux/smp_lock.h> | ||
27 | |||
26 | /* pioctl ops */ | 28 | /* pioctl ops */ |
27 | static int coda_ioctl_permission(struct inode *inode, int mask); | 29 | static int coda_ioctl_permission(struct inode *inode, int mask); |
28 | static int coda_pioctl(struct inode * inode, struct file * filp, | 30 | static long coda_pioctl(struct file *filp, unsigned int cmd, |
29 | unsigned int cmd, unsigned long user_data); | 31 | unsigned long user_data); |
30 | 32 | ||
31 | /* exported from this file */ | 33 | /* exported from this file */ |
32 | const struct inode_operations coda_ioctl_inode_operations = | 34 | const struct inode_operations coda_ioctl_inode_operations = |
@@ -37,7 +39,7 @@ const struct inode_operations coda_ioctl_inode_operations = | |||
37 | 39 | ||
38 | const struct file_operations coda_ioctl_operations = { | 40 | const struct file_operations coda_ioctl_operations = { |
39 | .owner = THIS_MODULE, | 41 | .owner = THIS_MODULE, |
40 | .ioctl = coda_pioctl, | 42 | .unlocked_ioctl = coda_pioctl, |
41 | }; | 43 | }; |
42 | 44 | ||
43 | /* the coda pioctl inode ops */ | 45 | /* the coda pioctl inode ops */ |
@@ -46,40 +48,43 @@ static int coda_ioctl_permission(struct inode *inode, int mask) | |||
46 | return (mask & MAY_EXEC) ? -EACCES : 0; | 48 | return (mask & MAY_EXEC) ? -EACCES : 0; |
47 | } | 49 | } |
48 | 50 | ||
49 | static int coda_pioctl(struct inode * inode, struct file * filp, | 51 | static long coda_pioctl(struct file *filp, unsigned int cmd, |
50 | unsigned int cmd, unsigned long user_data) | 52 | unsigned long user_data) |
51 | { | 53 | { |
52 | struct path path; | 54 | struct path path; |
53 | int error; | 55 | int error; |
54 | struct PioctlData data; | 56 | struct PioctlData data; |
57 | struct inode *inode = filp->f_dentry->d_inode; | ||
55 | struct inode *target_inode = NULL; | 58 | struct inode *target_inode = NULL; |
56 | struct coda_inode_info *cnp; | 59 | struct coda_inode_info *cnp; |
57 | 60 | ||
61 | lock_kernel(); | ||
62 | |||
58 | /* get the Pioctl data arguments from user space */ | 63 | /* get the Pioctl data arguments from user space */ |
59 | if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) { | 64 | if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) { |
60 | return -EINVAL; | 65 | error = -EINVAL; |
66 | goto out; | ||
61 | } | 67 | } |
62 | 68 | ||
63 | /* | 69 | /* |
64 | * Look up the pathname. Note that the pathname is in | 70 | * Look up the pathname. Note that the pathname is in |
65 | * user memory, and namei takes care of this | 71 | * user memory, and namei takes care of this |
66 | */ | 72 | */ |
67 | if (data.follow) { | 73 | if (data.follow) |
68 | error = user_path(data.path, &path); | 74 | error = user_path(data.path, &path); |
69 | } else { | 75 | else |
70 | error = user_lpath(data.path, &path); | 76 | error = user_lpath(data.path, &path); |
71 | } | 77 | |
72 | 78 | if (error) | |
73 | if ( error ) { | 79 | goto out; |
74 | return error; | 80 | else |
75 | } else { | ||
76 | target_inode = path.dentry->d_inode; | 81 | target_inode = path.dentry->d_inode; |
77 | } | 82 | |
78 | |||
79 | /* return if it is not a Coda inode */ | 83 | /* return if it is not a Coda inode */ |
80 | if ( target_inode->i_sb != inode->i_sb ) { | 84 | if ( target_inode->i_sb != inode->i_sb ) { |
81 | path_put(&path); | 85 | path_put(&path); |
82 | return -EINVAL; | 86 | error = -EINVAL; |
87 | goto out; | ||
83 | } | 88 | } |
84 | 89 | ||
85 | /* now proceed to make the upcall */ | 90 | /* now proceed to make the upcall */ |
@@ -88,6 +93,8 @@ static int coda_pioctl(struct inode * inode, struct file * filp, | |||
88 | error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); | 93 | error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); |
89 | 94 | ||
90 | path_put(&path); | 95 | path_put(&path); |
96 | |||
97 | out: | ||
98 | unlock_kernel(); | ||
91 | return error; | 99 | return error; |
92 | } | 100 | } |
93 | |||