diff options
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r-- | fs/udf/file.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c index 6ebc043f3a2..baae3a72394 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/quotaops.h> | 37 | #include <linux/quotaops.h> |
38 | #include <linux/buffer_head.h> | 38 | #include <linux/buffer_head.h> |
39 | #include <linux/aio.h> | 39 | #include <linux/aio.h> |
40 | #include <linux/smp_lock.h> | ||
40 | 41 | ||
41 | #include "udf_i.h" | 42 | #include "udf_i.h" |
42 | #include "udf_sb.h" | 43 | #include "udf_sb.h" |
@@ -144,50 +145,60 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
144 | return retval; | 145 | return retval; |
145 | } | 146 | } |
146 | 147 | ||
147 | int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 148 | long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
148 | unsigned long arg) | ||
149 | { | 149 | { |
150 | struct inode *inode = filp->f_dentry->d_inode; | ||
150 | long old_block, new_block; | 151 | long old_block, new_block; |
151 | int result = -EINVAL; | 152 | int result = -EINVAL; |
152 | 153 | ||
154 | lock_kernel(); | ||
155 | |||
153 | if (file_permission(filp, MAY_READ) != 0) { | 156 | if (file_permission(filp, MAY_READ) != 0) { |
154 | udf_debug("no permission to access inode %lu\n", | 157 | udf_debug("no permission to access inode %lu\n", inode->i_ino); |
155 | inode->i_ino); | 158 | result = -EPERM; |
156 | return -EPERM; | 159 | goto out; |
157 | } | 160 | } |
158 | 161 | ||
159 | if (!arg) { | 162 | if (!arg) { |
160 | udf_debug("invalid argument to udf_ioctl\n"); | 163 | udf_debug("invalid argument to udf_ioctl\n"); |
161 | return -EINVAL; | 164 | result = -EINVAL; |
165 | goto out; | ||
162 | } | 166 | } |
163 | 167 | ||
164 | switch (cmd) { | 168 | switch (cmd) { |
165 | case UDF_GETVOLIDENT: | 169 | case UDF_GETVOLIDENT: |
166 | if (copy_to_user((char __user *)arg, | 170 | if (copy_to_user((char __user *)arg, |
167 | UDF_SB(inode->i_sb)->s_volume_ident, 32)) | 171 | UDF_SB(inode->i_sb)->s_volume_ident, 32)) |
168 | return -EFAULT; | 172 | result = -EFAULT; |
169 | else | 173 | else |
170 | return 0; | 174 | result = 0; |
175 | goto out; | ||
171 | case UDF_RELOCATE_BLOCKS: | 176 | case UDF_RELOCATE_BLOCKS: |
172 | if (!capable(CAP_SYS_ADMIN)) | 177 | if (!capable(CAP_SYS_ADMIN)) { |
173 | return -EACCES; | 178 | result = -EACCES; |
174 | if (get_user(old_block, (long __user *)arg)) | 179 | goto out; |
175 | return -EFAULT; | 180 | } |
181 | if (get_user(old_block, (long __user *)arg)) { | ||
182 | result = -EFAULT; | ||
183 | goto out; | ||
184 | } | ||
176 | result = udf_relocate_blocks(inode->i_sb, | 185 | result = udf_relocate_blocks(inode->i_sb, |
177 | old_block, &new_block); | 186 | old_block, &new_block); |
178 | if (result == 0) | 187 | if (result == 0) |
179 | result = put_user(new_block, (long __user *)arg); | 188 | result = put_user(new_block, (long __user *)arg); |
180 | return result; | 189 | goto out; |
181 | case UDF_GETEASIZE: | 190 | case UDF_GETEASIZE: |
182 | result = put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg); | 191 | result = put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg); |
183 | break; | 192 | goto out; |
184 | case UDF_GETEABLOCK: | 193 | case UDF_GETEABLOCK: |
185 | result = copy_to_user((char __user *)arg, | 194 | result = copy_to_user((char __user *)arg, |
186 | UDF_I(inode)->i_ext.i_data, | 195 | UDF_I(inode)->i_ext.i_data, |
187 | UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0; | 196 | UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0; |
188 | break; | 197 | goto out; |
189 | } | 198 | } |
190 | 199 | ||
200 | out: | ||
201 | unlock_kernel(); | ||
191 | return result; | 202 | return result; |
192 | } | 203 | } |
193 | 204 | ||
@@ -207,7 +218,7 @@ static int udf_release_file(struct inode *inode, struct file *filp) | |||
207 | const struct file_operations udf_file_operations = { | 218 | const struct file_operations udf_file_operations = { |
208 | .read = do_sync_read, | 219 | .read = do_sync_read, |
209 | .aio_read = generic_file_aio_read, | 220 | .aio_read = generic_file_aio_read, |
210 | .ioctl = udf_ioctl, | 221 | .unlocked_ioctl = udf_ioctl, |
211 | .open = dquot_file_open, | 222 | .open = dquot_file_open, |
212 | .mmap = generic_file_mmap, | 223 | .mmap = generic_file_mmap, |
213 | .write = do_sync_write, | 224 | .write = do_sync_write, |