提交 a074faad 编写于 作者: F Fabian Frederick 提交者: Jan Kara

udf: simplify udf_ioctl()

"out" label was only returning error code.
Signed-off-by: NFabian Frederick <fabf@skynet.be>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 782deb2e
...@@ -176,57 +176,46 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -176,57 +176,46 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
long old_block, new_block; long old_block, new_block;
int result = -EINVAL; int result;
if (inode_permission(inode, MAY_READ) != 0) { if (inode_permission(inode, MAY_READ) != 0) {
udf_debug("no permission to access inode %lu\n", inode->i_ino); udf_debug("no permission to access inode %lu\n", inode->i_ino);
result = -EPERM; return -EPERM;
goto out;
} }
if (!arg && ((cmd == UDF_GETVOLIDENT) || (cmd == UDF_GETEASIZE) || if (!arg && ((cmd == UDF_GETVOLIDENT) || (cmd == UDF_GETEASIZE) ||
(cmd == UDF_RELOCATE_BLOCKS) || (cmd == UDF_GETEABLOCK))) { (cmd == UDF_RELOCATE_BLOCKS) || (cmd == UDF_GETEABLOCK))) {
udf_debug("invalid argument to udf_ioctl\n"); udf_debug("invalid argument to udf_ioctl\n");
result = -EINVAL; return -EINVAL;
goto out;
} }
switch (cmd) { switch (cmd) {
case UDF_GETVOLIDENT: case UDF_GETVOLIDENT:
if (copy_to_user((char __user *)arg, if (copy_to_user((char __user *)arg,
UDF_SB(inode->i_sb)->s_volume_ident, 32)) UDF_SB(inode->i_sb)->s_volume_ident, 32))
result = -EFAULT; return -EFAULT;
else return 0;
result = 0;
goto out;
case UDF_RELOCATE_BLOCKS: case UDF_RELOCATE_BLOCKS:
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN))
result = -EPERM; return -EPERM;
goto out; if (get_user(old_block, (long __user *)arg))
} return -EFAULT;
if (get_user(old_block, (long __user *)arg)) {
result = -EFAULT;
goto out;
}
result = udf_relocate_blocks(inode->i_sb, result = udf_relocate_blocks(inode->i_sb,
old_block, &new_block); old_block, &new_block);
if (result == 0) if (result == 0)
result = put_user(new_block, (long __user *)arg); result = put_user(new_block, (long __user *)arg);
goto out; return result;
case UDF_GETEASIZE: case UDF_GETEASIZE:
result = put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg); return put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg);
goto out;
case UDF_GETEABLOCK: case UDF_GETEABLOCK:
result = copy_to_user((char __user *)arg, return copy_to_user((char __user *)arg,
UDF_I(inode)->i_ext.i_data, UDF_I(inode)->i_ext.i_data,
UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0; UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0;
goto out;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
out: return 0;
return result;
} }
static int udf_release_file(struct inode *inode, struct file *filp) static int udf_release_file(struct inode *inode, struct file *filp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册