提交 c9845ff1 编写于 作者: E Erez Zadok 提交者: Linus Torvalds

VFS: apply coding standards to fs/ioctl.c

Signed-off-by: NErez Zadok <ezk@cs.sunysb.edu>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 4aa323bd
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/uaccess.h>
#include <asm/uaccess.h>
#include <asm/ioctls.h> #include <asm/ioctls.h>
static long do_ioctl(struct file *filp, unsigned int cmd, static long do_ioctl(struct file *filp, unsigned int cmd,
...@@ -45,7 +45,7 @@ static int file_ioctl(struct file *filp, unsigned int cmd, ...@@ -45,7 +45,7 @@ static int file_ioctl(struct file *filp, unsigned int cmd,
{ {
int error; int error;
int block; int block;
struct inode * inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
int __user *p = (int __user *)arg; int __user *p = (int __user *)arg;
switch (cmd) { switch (cmd) {
...@@ -58,9 +58,9 @@ static int file_ioctl(struct file *filp, unsigned int cmd, ...@@ -58,9 +58,9 @@ static int file_ioctl(struct file *filp, unsigned int cmd,
return -EINVAL; return -EINVAL;
if (!capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_RAWIO))
return -EPERM; return -EPERM;
if ((error = get_user(block, p)) != 0) error = get_user(block, p);
if (error)
return error; return error;
lock_kernel(); lock_kernel();
res = mapping->a_ops->bmap(mapping, block); res = mapping->a_ops->bmap(mapping, block);
unlock_kernel(); unlock_kernel();
...@@ -82,7 +82,8 @@ static int file_ioctl(struct file *filp, unsigned int cmd, ...@@ -82,7 +82,8 @@ static int file_ioctl(struct file *filp, unsigned int cmd,
* vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. * vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d.
* It's just a simple helper for sys_ioctl and compat_sys_ioctl. * It's just a simple helper for sys_ioctl and compat_sys_ioctl.
*/ */
int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned long arg) int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
unsigned long arg)
{ {
unsigned int flag; unsigned int flag;
int on, error = 0; int on, error = 0;
...@@ -97,12 +98,13 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon ...@@ -97,12 +98,13 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon
break; break;
case FIONBIO: case FIONBIO:
if ((error = get_user(on, (int __user *)arg)) != 0) error = get_user(on, (int __user *)arg);
if (error)
break; break;
flag = O_NONBLOCK; flag = O_NONBLOCK;
#ifdef __sparc__ #ifdef __sparc__
/* SunOS compatibility item. */ /* SunOS compatibility item. */
if(O_NONBLOCK != O_NDELAY) if (O_NONBLOCK != O_NDELAY)
flag |= O_NDELAY; flag |= O_NDELAY;
#endif #endif
if (on) if (on)
...@@ -112,7 +114,8 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon ...@@ -112,7 +114,8 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon
break; break;
case FIOASYNC: case FIOASYNC:
if ((error = get_user(on, (int __user *)arg)) != 0) error = get_user(on, (int __user *)arg);
if (error)
break; break;
flag = on ? FASYNC : 0; flag = on ? FASYNC : 0;
...@@ -122,8 +125,8 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon ...@@ -122,8 +125,8 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon
lock_kernel(); lock_kernel();
error = filp->f_op->fasync(fd, filp, on); error = filp->f_op->fasync(fd, filp, on);
unlock_kernel(); unlock_kernel();
} } else
else error = -ENOTTY; error = -ENOTTY;
} }
if (error != 0) if (error != 0)
break; break;
...@@ -138,10 +141,11 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon ...@@ -138,10 +141,11 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon
if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) || if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) ||
S_ISREG(filp->f_path.dentry->d_inode->i_mode) || S_ISREG(filp->f_path.dentry->d_inode->i_mode) ||
S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) { S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) {
loff_t res = inode_get_bytes(filp->f_path.dentry->d_inode); loff_t res =
error = copy_to_user((loff_t __user *)arg, &res, sizeof(res)) ? -EFAULT : 0; inode_get_bytes(filp->f_path.dentry->d_inode);
} error = copy_to_user((loff_t __user *)arg, &res,
else sizeof(res)) ? -EFAULT : 0;
} else
error = -ENOTTY; error = -ENOTTY;
break; break;
default: default:
...@@ -156,7 +160,7 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon ...@@ -156,7 +160,7 @@ int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned lon
asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
{ {
struct file * filp; struct file *filp;
int error = -EBADF; int error = -EBADF;
int fput_needed; int fput_needed;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册