aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/bad_inode.c7
-rw-r--r--fs/compat_ioctl.c3
-rw-r--r--fs/ioctl.c18
-rw-r--r--fs/logfs/dir.c2
-rw-r--r--fs/logfs/file.c6
-rw-r--r--fs/logfs/logfs.h3
-rw-r--r--fs/proc/inode.c17
7 files changed, 14 insertions, 42 deletions
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 52e59bf4aa5f..f024d8aaddef 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -55,12 +55,6 @@ static unsigned int bad_file_poll(struct file *filp, poll_table *wait)
55 return POLLERR; 55 return POLLERR;
56} 56}
57 57
58static int bad_file_ioctl (struct inode *inode, struct file *filp,
59 unsigned int cmd, unsigned long arg)
60{
61 return -EIO;
62}
63
64static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd, 58static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd,
65 unsigned long arg) 59 unsigned long arg)
66{ 60{
@@ -159,7 +153,6 @@ static const struct file_operations bad_file_ops =
159 .aio_write = bad_file_aio_write, 153 .aio_write = bad_file_aio_write,
160 .readdir = bad_file_readdir, 154 .readdir = bad_file_readdir,
161 .poll = bad_file_poll, 155 .poll = bad_file_poll,
162 .ioctl = bad_file_ioctl,
163 .unlocked_ioctl = bad_file_unlocked_ioctl, 156 .unlocked_ioctl = bad_file_unlocked_ioctl,
164 .compat_ioctl = bad_file_compat_ioctl, 157 .compat_ioctl = bad_file_compat_ioctl,
165 .mmap = bad_file_mmap, 158 .mmap = bad_file_mmap,
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 70227e0dc01d..03e59aa318eb 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1699,8 +1699,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1699 goto out_fput; 1699 goto out_fput;
1700 } 1700 }
1701 1701
1702 if (!filp->f_op || 1702 if (!filp->f_op || !filp->f_op->unlocked_ioctl)
1703 (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
1704 goto do_ioctl; 1703 goto do_ioctl;
1705 break; 1704 break;
1706 } 1705 }
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 2d140a713861..f855ea4fc888 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -29,7 +29,6 @@
29 * @arg: command-specific argument for ioctl 29 * @arg: command-specific argument for ioctl
30 * 30 *
31 * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise 31 * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise
32 * invokes filesystem specific ->ioctl method. If neither method exists,
33 * returns -ENOTTY. 32 * returns -ENOTTY.
34 * 33 *
35 * Returns 0 on success, -errno on error. 34 * Returns 0 on success, -errno on error.
@@ -39,21 +38,12 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
39{ 38{
40 int error = -ENOTTY; 39 int error = -ENOTTY;
41 40
42 if (!filp->f_op) 41 if (!filp->f_op || !filp->f_op->unlocked_ioctl)
43 goto out; 42 goto out;
44 43
45 if (filp->f_op->unlocked_ioctl) { 44 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
46 error = filp->f_op->unlocked_ioctl(filp, cmd, arg); 45 if (error == -ENOIOCTLCMD)
47 if (error == -ENOIOCTLCMD) 46 error = -EINVAL;
48 error = -EINVAL;
49 goto out;
50 } else if (filp->f_op->ioctl) {
51 lock_kernel();
52 error = filp->f_op->ioctl(filp->f_path.dentry->d_inode,
53 filp, cmd, arg);
54 unlock_kernel();
55 }
56
57 out: 47 out:
58 return error; 48 return error;
59} 49}
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 675cc49197fe..9777eb5b5522 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -824,7 +824,7 @@ const struct inode_operations logfs_dir_iops = {
824}; 824};
825const struct file_operations logfs_dir_fops = { 825const struct file_operations logfs_dir_fops = {
826 .fsync = logfs_fsync, 826 .fsync = logfs_fsync,
827 .ioctl = logfs_ioctl, 827 .unlocked_ioctl = logfs_ioctl,
828 .readdir = logfs_readdir, 828 .readdir = logfs_readdir,
829 .read = generic_read_dir, 829 .read = generic_read_dir,
830}; 830};
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 4dd0f7c06e39..e86376b87af1 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -181,9 +181,9 @@ static int logfs_releasepage(struct page *page, gfp_t only_xfs_uses_this)
181} 181}
182 182
183 183
184int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 184long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
185 unsigned long arg)
186{ 185{
186 struct inode *inode = file->f_path.dentry->d_inode;
187 struct logfs_inode *li = logfs_inode(inode); 187 struct logfs_inode *li = logfs_inode(inode);
188 unsigned int oldflags, flags; 188 unsigned int oldflags, flags;
189 int err; 189 int err;
@@ -255,7 +255,7 @@ const struct file_operations logfs_reg_fops = {
255 .aio_read = generic_file_aio_read, 255 .aio_read = generic_file_aio_read,
256 .aio_write = generic_file_aio_write, 256 .aio_write = generic_file_aio_write,
257 .fsync = logfs_fsync, 257 .fsync = logfs_fsync,
258 .ioctl = logfs_ioctl, 258 .unlocked_ioctl = logfs_ioctl,
259 .llseek = generic_file_llseek, 259 .llseek = generic_file_llseek,
260 .mmap = generic_file_readonly_mmap, 260 .mmap = generic_file_readonly_mmap,
261 .open = generic_file_open, 261 .open = generic_file_open,
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index 5e3b72077951..b8786264d243 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -504,8 +504,7 @@ extern const struct inode_operations logfs_reg_iops;
504extern const struct file_operations logfs_reg_fops; 504extern const struct file_operations logfs_reg_fops;
505extern const struct address_space_operations logfs_reg_aops; 505extern const struct address_space_operations logfs_reg_aops;
506int logfs_readpage(struct file *file, struct page *page); 506int logfs_readpage(struct file *file, struct page *page);
507int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 507long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
508 unsigned long arg);
509int logfs_fsync(struct file *file, int datasync); 508int logfs_fsync(struct file *file, int datasync);
510 509
511/* gc.c */ 510/* gc.c */
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 23561cda7245..9c2b5f484879 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -214,8 +214,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
214{ 214{
215 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 215 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
216 long rv = -ENOTTY; 216 long rv = -ENOTTY;
217 long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); 217 long (*ioctl)(struct file *, unsigned int, unsigned long);
218 int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long);
219 218
220 spin_lock(&pde->pde_unload_lock); 219 spin_lock(&pde->pde_unload_lock);
221 if (!pde->proc_fops) { 220 if (!pde->proc_fops) {
@@ -223,19 +222,11 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
223 return rv; 222 return rv;
224 } 223 }
225 pde->pde_users++; 224 pde->pde_users++;
226 unlocked_ioctl = pde->proc_fops->unlocked_ioctl; 225 ioctl = pde->proc_fops->unlocked_ioctl;
227 ioctl = pde->proc_fops->ioctl;
228 spin_unlock(&pde->pde_unload_lock); 226 spin_unlock(&pde->pde_unload_lock);
229 227
230 if (unlocked_ioctl) { 228 if (ioctl)
231 rv = unlocked_ioctl(file, cmd, arg); 229 rv = ioctl(file, cmd, arg);
232 if (rv == -ENOIOCTLCMD)
233 rv = -EINVAL;
234 } else if (ioctl) {
235 WARN_ONCE(1, "Procfs ioctl handlers must use unlocked_ioctl, "
236 "%pf will be called without the Bkl held\n", ioctl);
237 rv = ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
238 }
239 230
240 pde_users_dec(pde); 231 pde_users_dec(pde);
241 return rv; 232 return rv;