Commit 27a4f7e6 authored by Namhyung Kim's avatar Namhyung Kim Committed by Al Viro

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: default avatarNamhyung Kim <namhyung@gmail.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a44f99c7
...@@ -548,6 +548,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, ...@@ -548,6 +548,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
{ {
int error = 0; int error = 0;
int __user *argp = (int __user *)arg; int __user *argp = (int __user *)arg;
struct inode *inode = filp->f_path.dentry->d_inode;
switch (cmd) { switch (cmd) {
case FIOCLEX: case FIOCLEX:
...@@ -567,13 +568,11 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, ...@@ -567,13 +568,11 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
break; break;
case FIOQSIZE: case FIOQSIZE:
if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) || if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode) ||
S_ISREG(filp->f_path.dentry->d_inode->i_mode) || S_ISLNK(inode->i_mode)) {
S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) { loff_t res = inode_get_bytes(inode);
loff_t res = error = copy_to_user(argp, &res, sizeof(res)) ?
inode_get_bytes(filp->f_path.dentry->d_inode); -EFAULT : 0;
error = copy_to_user((loff_t __user *)arg, &res,
sizeof(res)) ? -EFAULT : 0;
} else } else
error = -ENOTTY; error = -ENOTTY;
break; break;
...@@ -590,14 +589,10 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, ...@@ -590,14 +589,10 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
return ioctl_fiemap(filp, arg); return ioctl_fiemap(filp, arg);
case FIGETBSZ: case FIGETBSZ:
{ return put_user(inode->i_sb->s_blocksize, argp);
struct inode *inode = filp->f_path.dentry->d_inode;
int __user *p = (int __user *)arg;
return put_user(inode->i_sb->s_blocksize, p);
}
default: default:
if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) if (S_ISREG(inode->i_mode))
error = file_ioctl(filp, cmd, arg); error = file_ioctl(filp, cmd, arg);
else else
error = vfs_ioctl(filp, cmd, arg); error = vfs_ioctl(filp, cmd, arg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment