diff options
author | Namhyung Kim <namhyung@gmail.com> | 2011-01-16 10:48:17 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-21 00:16:08 -0400 |
commit | 27a4f7e61e1eb4f18737926f4a66db7c48349fea (patch) | |
tree | d2c680038e2b1a3b56b26a4861db0bc0e25cef01 /fs/ioctl.c | |
parent | a44f99c7efdb88fa41128065c9a9445c19894e34 (diff) |
vfs: cleanup do_vfs_ioctl()
Move declaration of 'inode' to beginning of the function. Since it
is referenced directly or indirectly (in case of FIFREEZE/FITHAW/
FS_IOC_FIEMAP) it's not harmful IMHO. And remove unnecessary casts
using 'argp' instead.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ioctl.c')
-rw-r--r-- | fs/ioctl.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/fs/ioctl.c b/fs/ioctl.c index 1eebeb72b202..1d9b9fcb2db4 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c | |||
@@ -548,6 +548,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, | |||
548 | { | 548 | { |
549 | int error = 0; | 549 | int error = 0; |
550 | int __user *argp = (int __user *)arg; | 550 | int __user *argp = (int __user *)arg; |
551 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
551 | 552 | ||
552 | switch (cmd) { | 553 | switch (cmd) { |
553 | case FIOCLEX: | 554 | case FIOCLEX: |
@@ -567,13 +568,11 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, | |||
567 | break; | 568 | break; |
568 | 569 | ||
569 | case FIOQSIZE: | 570 | case FIOQSIZE: |
570 | if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) || | 571 | if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode) || |
571 | S_ISREG(filp->f_path.dentry->d_inode->i_mode) || | 572 | S_ISLNK(inode->i_mode)) { |
572 | S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) { | 573 | loff_t res = inode_get_bytes(inode); |
573 | loff_t res = | 574 | error = copy_to_user(argp, &res, sizeof(res)) ? |
574 | inode_get_bytes(filp->f_path.dentry->d_inode); | 575 | -EFAULT : 0; |
575 | error = copy_to_user((loff_t __user *)arg, &res, | ||
576 | sizeof(res)) ? -EFAULT : 0; | ||
577 | } else | 576 | } else |
578 | error = -ENOTTY; | 577 | error = -ENOTTY; |
579 | break; | 578 | break; |
@@ -590,14 +589,10 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, | |||
590 | return ioctl_fiemap(filp, arg); | 589 | return ioctl_fiemap(filp, arg); |
591 | 590 | ||
592 | case FIGETBSZ: | 591 | case FIGETBSZ: |
593 | { | 592 | return put_user(inode->i_sb->s_blocksize, argp); |
594 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
595 | int __user *p = (int __user *)arg; | ||
596 | return put_user(inode->i_sb->s_blocksize, p); | ||
597 | } | ||
598 | 593 | ||
599 | default: | 594 | default: |
600 | if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) | 595 | if (S_ISREG(inode->i_mode)) |
601 | error = file_ioctl(filp, cmd, arg); | 596 | error = file_ioctl(filp, cmd, arg); |
602 | else | 597 | else |
603 | error = vfs_ioctl(filp, cmd, arg); | 598 | error = vfs_ioctl(filp, cmd, arg); |