diff options
Diffstat (limited to 'fs/ecryptfs/file.c')
| -rw-r--r-- | fs/ecryptfs/file.c | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index e8fcf4e2ed7d..622c95140802 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
| @@ -199,7 +199,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
| 199 | "the persistent file for the dentry with name " | 199 | "the persistent file for the dentry with name " |
| 200 | "[%s]; rc = [%d]\n", __func__, | 200 | "[%s]; rc = [%d]\n", __func__, |
| 201 | ecryptfs_dentry->d_name.name, rc); | 201 | ecryptfs_dentry->d_name.name, rc); |
| 202 | goto out; | 202 | goto out_free; |
| 203 | } | 203 | } |
| 204 | } | 204 | } |
| 205 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY) | 205 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY) |
| @@ -207,7 +207,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
| 207 | rc = -EPERM; | 207 | rc = -EPERM; |
| 208 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " | 208 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " |
| 209 | "file must hence be opened RO\n", __func__); | 209 | "file must hence be opened RO\n", __func__); |
| 210 | goto out; | 210 | goto out_free; |
| 211 | } | 211 | } |
| 212 | ecryptfs_set_file_lower( | 212 | ecryptfs_set_file_lower( |
| 213 | file, ecryptfs_inode_to_private(inode)->lower_file); | 213 | file, ecryptfs_inode_to_private(inode)->lower_file); |
| @@ -292,12 +292,40 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag) | |||
| 292 | return rc; | 292 | return rc; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | static int ecryptfs_ioctl(struct inode *inode, struct file *file, | 295 | static long |
| 296 | unsigned int cmd, unsigned long arg); | 296 | ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 297 | { | ||
| 298 | struct file *lower_file = NULL; | ||
| 299 | long rc = -ENOTTY; | ||
| 300 | |||
| 301 | if (ecryptfs_file_to_private(file)) | ||
| 302 | lower_file = ecryptfs_file_to_lower(file); | ||
| 303 | if (lower_file && lower_file->f_op && lower_file->f_op->unlocked_ioctl) | ||
| 304 | rc = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg); | ||
| 305 | return rc; | ||
| 306 | } | ||
| 307 | |||
| 308 | #ifdef CONFIG_COMPAT | ||
| 309 | static long | ||
| 310 | ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
| 311 | { | ||
| 312 | struct file *lower_file = NULL; | ||
| 313 | long rc = -ENOIOCTLCMD; | ||
| 314 | |||
| 315 | if (ecryptfs_file_to_private(file)) | ||
| 316 | lower_file = ecryptfs_file_to_lower(file); | ||
| 317 | if (lower_file && lower_file->f_op && lower_file->f_op->compat_ioctl) | ||
| 318 | rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg); | ||
| 319 | return rc; | ||
| 320 | } | ||
| 321 | #endif | ||
| 297 | 322 | ||
| 298 | const struct file_operations ecryptfs_dir_fops = { | 323 | const struct file_operations ecryptfs_dir_fops = { |
| 299 | .readdir = ecryptfs_readdir, | 324 | .readdir = ecryptfs_readdir, |
| 300 | .ioctl = ecryptfs_ioctl, | 325 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, |
| 326 | #ifdef CONFIG_COMPAT | ||
| 327 | .compat_ioctl = ecryptfs_compat_ioctl, | ||
| 328 | #endif | ||
| 301 | .open = ecryptfs_open, | 329 | .open = ecryptfs_open, |
| 302 | .flush = ecryptfs_flush, | 330 | .flush = ecryptfs_flush, |
| 303 | .release = ecryptfs_release, | 331 | .release = ecryptfs_release, |
| @@ -313,7 +341,10 @@ const struct file_operations ecryptfs_main_fops = { | |||
| 313 | .write = do_sync_write, | 341 | .write = do_sync_write, |
| 314 | .aio_write = generic_file_aio_write, | 342 | .aio_write = generic_file_aio_write, |
| 315 | .readdir = ecryptfs_readdir, | 343 | .readdir = ecryptfs_readdir, |
| 316 | .ioctl = ecryptfs_ioctl, | 344 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, |
| 345 | #ifdef CONFIG_COMPAT | ||
| 346 | .compat_ioctl = ecryptfs_compat_ioctl, | ||
| 347 | #endif | ||
| 317 | .mmap = generic_file_mmap, | 348 | .mmap = generic_file_mmap, |
| 318 | .open = ecryptfs_open, | 349 | .open = ecryptfs_open, |
| 319 | .flush = ecryptfs_flush, | 350 | .flush = ecryptfs_flush, |
| @@ -322,20 +353,3 @@ const struct file_operations ecryptfs_main_fops = { | |||
| 322 | .fasync = ecryptfs_fasync, | 353 | .fasync = ecryptfs_fasync, |
| 323 | .splice_read = generic_file_splice_read, | 354 | .splice_read = generic_file_splice_read, |
| 324 | }; | 355 | }; |
| 325 | |||
| 326 | static int | ||
| 327 | ecryptfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | ||
| 328 | unsigned long arg) | ||
| 329 | { | ||
| 330 | int rc = 0; | ||
| 331 | struct file *lower_file = NULL; | ||
| 332 | |||
| 333 | if (ecryptfs_file_to_private(file)) | ||
| 334 | lower_file = ecryptfs_file_to_lower(file); | ||
| 335 | if (lower_file && lower_file->f_op && lower_file->f_op->ioctl) | ||
| 336 | rc = lower_file->f_op->ioctl(ecryptfs_inode_to_lower(inode), | ||
| 337 | lower_file, cmd, arg); | ||
| 338 | else | ||
| 339 | rc = -ENOTTY; | ||
| 340 | return rc; | ||
| 341 | } | ||
