diff options
| author | Cyrus Massoumi <cyrusm@gmx.net> | 2009-04-02 19:57:12 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-02 22:04:52 -0400 |
| commit | 039fd8ce6258e01ec29f1637f9bf1868dd877c55 (patch) | |
| tree | dcc90b006655eecad1d0cd82850feef2398976fa /fs/ext3 | |
| parent | b277c884f7856ce0791b1e72079023a86767981b (diff) | |
ext3: remove the BKL in ext3/ioctl.c
Reformat ext3/ioctl.c to make it look more like ext4/ioctl.c and remove
the BKL around ext3_ioctl().
Signed-off-by: Cyrus Massoumi <cyrusm@gmx.net>
Cc: <linux-ext4@vger.kernel.org>
Acked-by: Jan Kara <jack@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3')
| -rw-r--r-- | fs/ext3/dir.c | 2 | ||||
| -rw-r--r-- | fs/ext3/file.c | 2 | ||||
| -rw-r--r-- | fs/ext3/ioctl.c | 59 |
3 files changed, 22 insertions, 41 deletions
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c index 5853f4440af4..3d724a95882f 100644 --- a/fs/ext3/dir.c +++ b/fs/ext3/dir.c | |||
| @@ -42,7 +42,7 @@ const struct file_operations ext3_dir_operations = { | |||
| 42 | .llseek = generic_file_llseek, | 42 | .llseek = generic_file_llseek, |
| 43 | .read = generic_read_dir, | 43 | .read = generic_read_dir, |
| 44 | .readdir = ext3_readdir, /* we take BKL. needed?*/ | 44 | .readdir = ext3_readdir, /* we take BKL. needed?*/ |
| 45 | .ioctl = ext3_ioctl, /* BKL held */ | 45 | .unlocked_ioctl = ext3_ioctl, |
| 46 | #ifdef CONFIG_COMPAT | 46 | #ifdef CONFIG_COMPAT |
| 47 | .compat_ioctl = ext3_compat_ioctl, | 47 | .compat_ioctl = ext3_compat_ioctl, |
| 48 | #endif | 48 | #endif |
diff --git a/fs/ext3/file.c b/fs/ext3/file.c index 3be1e0689c9a..521f8238b2fa 100644 --- a/fs/ext3/file.c +++ b/fs/ext3/file.c | |||
| @@ -112,7 +112,7 @@ const struct file_operations ext3_file_operations = { | |||
| 112 | .write = do_sync_write, | 112 | .write = do_sync_write, |
| 113 | .aio_read = generic_file_aio_read, | 113 | .aio_read = generic_file_aio_read, |
| 114 | .aio_write = ext3_file_write, | 114 | .aio_write = ext3_file_write, |
| 115 | .ioctl = ext3_ioctl, | 115 | .unlocked_ioctl = ext3_ioctl, |
| 116 | #ifdef CONFIG_COMPAT | 116 | #ifdef CONFIG_COMPAT |
| 117 | .compat_ioctl = ext3_compat_ioctl, | 117 | .compat_ioctl = ext3_compat_ioctl, |
| 118 | #endif | 118 | #endif |
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c index 5e86ce9a86e0..88974814783a 100644 --- a/fs/ext3/ioctl.c +++ b/fs/ext3/ioctl.c | |||
| @@ -15,12 +15,11 @@ | |||
| 15 | #include <linux/mount.h> | 15 | #include <linux/mount.h> |
| 16 | #include <linux/time.h> | 16 | #include <linux/time.h> |
| 17 | #include <linux/compat.h> | 17 | #include <linux/compat.h> |
| 18 | #include <linux/smp_lock.h> | ||
| 19 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
| 20 | 19 | ||
| 21 | int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | 20 | long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
| 22 | unsigned long arg) | ||
| 23 | { | 21 | { |
| 22 | struct inode *inode = filp->f_dentry->d_inode; | ||
| 24 | struct ext3_inode_info *ei = EXT3_I(inode); | 23 | struct ext3_inode_info *ei = EXT3_I(inode); |
| 25 | unsigned int flags; | 24 | unsigned int flags; |
| 26 | unsigned short rsv_window_size; | 25 | unsigned short rsv_window_size; |
| @@ -39,29 +38,25 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
| 39 | unsigned int oldflags; | 38 | unsigned int oldflags; |
| 40 | unsigned int jflag; | 39 | unsigned int jflag; |
| 41 | 40 | ||
| 41 | if (!is_owner_or_cap(inode)) | ||
| 42 | return -EACCES; | ||
| 43 | |||
| 44 | if (get_user(flags, (int __user *) arg)) | ||
| 45 | return -EFAULT; | ||
| 46 | |||
| 42 | err = mnt_want_write(filp->f_path.mnt); | 47 | err = mnt_want_write(filp->f_path.mnt); |
| 43 | if (err) | 48 | if (err) |
| 44 | return err; | 49 | return err; |
| 45 | 50 | ||
| 46 | if (!is_owner_or_cap(inode)) { | ||
| 47 | err = -EACCES; | ||
| 48 | goto flags_out; | ||
| 49 | } | ||
| 50 | |||
| 51 | if (get_user(flags, (int __user *) arg)) { | ||
| 52 | err = -EFAULT; | ||
| 53 | goto flags_out; | ||
| 54 | } | ||
| 55 | |||
| 56 | flags = ext3_mask_flags(inode->i_mode, flags); | 51 | flags = ext3_mask_flags(inode->i_mode, flags); |
| 57 | 52 | ||
| 58 | mutex_lock(&inode->i_mutex); | 53 | mutex_lock(&inode->i_mutex); |
| 54 | |||
| 59 | /* Is it quota file? Do not allow user to mess with it */ | 55 | /* Is it quota file? Do not allow user to mess with it */ |
| 60 | if (IS_NOQUOTA(inode)) { | 56 | err = -EPERM; |
| 61 | mutex_unlock(&inode->i_mutex); | 57 | if (IS_NOQUOTA(inode)) |
| 62 | err = -EPERM; | ||
| 63 | goto flags_out; | 58 | goto flags_out; |
| 64 | } | 59 | |
| 65 | oldflags = ei->i_flags; | 60 | oldflags = ei->i_flags; |
| 66 | 61 | ||
| 67 | /* The JOURNAL_DATA flag is modifiable only by root */ | 62 | /* The JOURNAL_DATA flag is modifiable only by root */ |
| @@ -74,11 +69,8 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
| 74 | * This test looks nicer. Thanks to Pauline Middelink | 69 | * This test looks nicer. Thanks to Pauline Middelink |
| 75 | */ | 70 | */ |
| 76 | if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) { | 71 | if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) { |
| 77 | if (!capable(CAP_LINUX_IMMUTABLE)) { | 72 | if (!capable(CAP_LINUX_IMMUTABLE)) |
| 78 | mutex_unlock(&inode->i_mutex); | ||
| 79 | err = -EPERM; | ||
| 80 | goto flags_out; | 73 | goto flags_out; |
| 81 | } | ||
| 82 | } | 74 | } |
| 83 | 75 | ||
| 84 | /* | 76 | /* |
| @@ -86,17 +78,12 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
| 86 | * the relevant capability. | 78 | * the relevant capability. |
| 87 | */ | 79 | */ |
| 88 | if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL)) { | 80 | if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL)) { |
| 89 | if (!capable(CAP_SYS_RESOURCE)) { | 81 | if (!capable(CAP_SYS_RESOURCE)) |
| 90 | mutex_unlock(&inode->i_mutex); | ||
| 91 | err = -EPERM; | ||
| 92 | goto flags_out; | 82 | goto flags_out; |
| 93 | } | ||
| 94 | } | 83 | } |
| 95 | 84 | ||
| 96 | |||
| 97 | handle = ext3_journal_start(inode, 1); | 85 | handle = ext3_journal_start(inode, 1); |
| 98 | if (IS_ERR(handle)) { | 86 | if (IS_ERR(handle)) { |
| 99 | mutex_unlock(&inode->i_mutex); | ||
| 100 | err = PTR_ERR(handle); | 87 | err = PTR_ERR(handle); |
| 101 | goto flags_out; | 88 | goto flags_out; |
| 102 | } | 89 | } |
| @@ -116,15 +103,13 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
| 116 | err = ext3_mark_iloc_dirty(handle, inode, &iloc); | 103 | err = ext3_mark_iloc_dirty(handle, inode, &iloc); |
| 117 | flags_err: | 104 | flags_err: |
| 118 | ext3_journal_stop(handle); | 105 | ext3_journal_stop(handle); |
| 119 | if (err) { | 106 | if (err) |
| 120 | mutex_unlock(&inode->i_mutex); | 107 | goto flags_out; |
| 121 | return err; | ||
| 122 | } | ||
| 123 | 108 | ||
| 124 | if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL)) | 109 | if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL)) |
| 125 | err = ext3_change_inode_journal_flag(inode, jflag); | 110 | err = ext3_change_inode_journal_flag(inode, jflag); |
| 126 | mutex_unlock(&inode->i_mutex); | ||
| 127 | flags_out: | 111 | flags_out: |
| 112 | mutex_unlock(&inode->i_mutex); | ||
| 128 | mnt_drop_write(filp->f_path.mnt); | 113 | mnt_drop_write(filp->f_path.mnt); |
| 129 | return err; | 114 | return err; |
| 130 | } | 115 | } |
| @@ -140,6 +125,7 @@ flags_out: | |||
| 140 | 125 | ||
| 141 | if (!is_owner_or_cap(inode)) | 126 | if (!is_owner_or_cap(inode)) |
| 142 | return -EPERM; | 127 | return -EPERM; |
| 128 | |||
| 143 | err = mnt_want_write(filp->f_path.mnt); | 129 | err = mnt_want_write(filp->f_path.mnt); |
| 144 | if (err) | 130 | if (err) |
| 145 | return err; | 131 | return err; |
| @@ -147,6 +133,7 @@ flags_out: | |||
| 147 | err = -EFAULT; | 133 | err = -EFAULT; |
| 148 | goto setversion_out; | 134 | goto setversion_out; |
| 149 | } | 135 | } |
| 136 | |||
| 150 | handle = ext3_journal_start(inode, 1); | 137 | handle = ext3_journal_start(inode, 1); |
| 151 | if (IS_ERR(handle)) { | 138 | if (IS_ERR(handle)) { |
| 152 | err = PTR_ERR(handle); | 139 | err = PTR_ERR(handle); |
| @@ -299,9 +286,6 @@ group_add_out: | |||
| 299 | #ifdef CONFIG_COMPAT | 286 | #ifdef CONFIG_COMPAT |
| 300 | long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 287 | long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 301 | { | 288 | { |
| 302 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 303 | int ret; | ||
| 304 | |||
| 305 | /* These are just misnamed, they actually get/put from/to user an int */ | 289 | /* These are just misnamed, they actually get/put from/to user an int */ |
| 306 | switch (cmd) { | 290 | switch (cmd) { |
| 307 | case EXT3_IOC32_GETFLAGS: | 291 | case EXT3_IOC32_GETFLAGS: |
| @@ -341,9 +325,6 @@ long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 341 | default: | 325 | default: |
| 342 | return -ENOIOCTLCMD; | 326 | return -ENOIOCTLCMD; |
| 343 | } | 327 | } |
| 344 | lock_kernel(); | 328 | return ext3_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); |
| 345 | ret = ext3_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg)); | ||
| 346 | unlock_kernel(); | ||
| 347 | return ret; | ||
| 348 | } | 329 | } |
| 349 | #endif | 330 | #endif |
