Commit ae3771d6 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] Convert XFS to unlocked_ioctl and compat_ioctl

Convert the XFS ioctl handlers over to unlocked_ioctl and compat_ioctl.
Signed-off-by: default avatarAndi Kleen <ak@muc.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2feb53c6
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_ioctl32.h"
#include <linux/dcache.h> #include <linux/dcache.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
...@@ -415,20 +416,18 @@ linvfs_file_mmap( ...@@ -415,20 +416,18 @@ linvfs_file_mmap(
} }
STATIC int STATIC long
linvfs_ioctl( linvfs_ioctl(
struct inode *inode,
struct file *filp, struct file *filp,
unsigned int cmd, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
int error; int error;
struct inode *inode = filp->f_dentry->d_inode;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
unlock_kernel();
VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error); VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error);
VMODIFY(vp); VMODIFY(vp);
lock_kernel();
/* NOTE: some of the ioctl's return positive #'s as a /* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as * byte count indicating success, such as
...@@ -439,21 +438,19 @@ linvfs_ioctl( ...@@ -439,21 +438,19 @@ linvfs_ioctl(
return error; return error;
} }
STATIC int STATIC long
linvfs_ioctl_invis( linvfs_ioctl_invis(
struct inode *inode,
struct file *filp, struct file *filp,
unsigned int cmd, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
int error; int error;
struct inode *inode = filp->f_dentry->d_inode;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
unlock_kernel();
ASSERT(vp); ASSERT(vp);
VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error); VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error);
VMODIFY(vp); VMODIFY(vp);
lock_kernel();
/* NOTE: some of the ioctl's return positive #'s as a /* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as * byte count indicating success, such as
...@@ -495,7 +492,10 @@ struct file_operations linvfs_file_operations = { ...@@ -495,7 +492,10 @@ struct file_operations linvfs_file_operations = {
.aio_read = linvfs_read, .aio_read = linvfs_read,
.aio_write = linvfs_write, .aio_write = linvfs_write,
.sendfile = linvfs_sendfile, .sendfile = linvfs_sendfile,
.ioctl = linvfs_ioctl, .unlocked_ioctl = linvfs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = xfs_compat_ioctl,
#endif
.mmap = linvfs_file_mmap, .mmap = linvfs_file_mmap,
.open = linvfs_open, .open = linvfs_open,
.release = linvfs_release, .release = linvfs_release,
...@@ -511,7 +511,10 @@ struct file_operations linvfs_invis_file_operations = { ...@@ -511,7 +511,10 @@ struct file_operations linvfs_invis_file_operations = {
.aio_read = linvfs_read_invis, .aio_read = linvfs_read_invis,
.aio_write = linvfs_write_invis, .aio_write = linvfs_write_invis,
.sendfile = linvfs_sendfile, .sendfile = linvfs_sendfile,
.ioctl = linvfs_ioctl_invis, .unlocked_ioctl = linvfs_ioctl_invis,
#ifdef CONFIG_COMPAT
.compat_ioctl = xfs_compat_invis_ioctl,
#endif
.mmap = linvfs_file_mmap, .mmap = linvfs_file_mmap,
.open = linvfs_open, .open = linvfs_open,
.release = linvfs_release, .release = linvfs_release,
...@@ -522,7 +525,7 @@ struct file_operations linvfs_invis_file_operations = { ...@@ -522,7 +525,7 @@ struct file_operations linvfs_invis_file_operations = {
struct file_operations linvfs_dir_operations = { struct file_operations linvfs_dir_operations = {
.read = generic_read_dir, .read = generic_read_dir,
.readdir = linvfs_readdir, .readdir = linvfs_readdir,
.ioctl = linvfs_ioctl, .unlocked_ioctl = linvfs_ioctl,
.fsync = linvfs_fsync, .fsync = linvfs_fsync,
}; };
......
...@@ -37,10 +37,14 @@ ...@@ -37,10 +37,14 @@
#include <linux/ioctl32.h> #include <linux/ioctl32.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/fs.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "xfs.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_vfs.h"
#include "xfs_vnode.h"
#include "xfs_dfrag.h" #include "xfs_dfrag.h"
#if defined(CONFIG_IA64) || defined(CONFIG_X86_64) #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
...@@ -54,12 +58,8 @@ typedef struct xfs_fsop_bulkreq32 { ...@@ -54,12 +58,8 @@ typedef struct xfs_fsop_bulkreq32 {
__s32 ocount; /* output count pointer */ __s32 ocount; /* output count pointer */
} xfs_fsop_bulkreq32_t; } xfs_fsop_bulkreq32_t;
static int static unsigned long
xfs_ioctl32_bulkstat( xfs_ioctl32_bulkstat(unsigned long arg)
unsigned int fd,
unsigned int cmd,
unsigned long arg,
struct file * file)
{ {
xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg; xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg;
xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p)); xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p));
...@@ -74,89 +74,90 @@ xfs_ioctl32_bulkstat( ...@@ -74,89 +74,90 @@ xfs_ioctl32_bulkstat(
put_user(compat_ptr(addr), &p->ocount)) put_user(compat_ptr(addr), &p->ocount))
return -EFAULT; return -EFAULT;
return sys_ioctl(fd, cmd, (unsigned long)p); return (unsigned long)p;
} }
#endif #endif
struct ioctl_trans xfs_ioctl32_trans[] = { static long
{ XFS_IOC_DIOINFO, }, __xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
{ XFS_IOC_FSGEOMETRY_V1, }, {
{ XFS_IOC_FSGEOMETRY, }, int error;
{ XFS_IOC_GETVERSION, }, struct inode *inode = f->f_dentry->d_inode;
{ XFS_IOC_GETXFLAGS, }, vnode_t *vp = LINVFS_GET_VP(inode);
{ XFS_IOC_SETXFLAGS, },
{ XFS_IOC_FSGETXATTR, }, switch (cmd) {
{ XFS_IOC_FSSETXATTR, }, case XFS_IOC_DIOINFO:
{ XFS_IOC_FSGETXATTRA, }, case XFS_IOC_FSGEOMETRY_V1:
{ XFS_IOC_FSSETDM, }, case XFS_IOC_FSGEOMETRY:
{ XFS_IOC_GETBMAP, }, case XFS_IOC_GETVERSION:
{ XFS_IOC_GETBMAPA, }, case XFS_IOC_GETXFLAGS:
{ XFS_IOC_GETBMAPX, }, case XFS_IOC_SETXFLAGS:
case XFS_IOC_FSGETXATTR:
case XFS_IOC_FSSETXATTR:
case XFS_IOC_FSGETXATTRA:
case XFS_IOC_FSSETDM:
case XFS_IOC_GETBMAP:
case XFS_IOC_GETBMAPA:
case XFS_IOC_GETBMAPX:
/* not handled /* not handled
{ XFS_IOC_FD_TO_HANDLE, }, case XFS_IOC_FD_TO_HANDLE:
{ XFS_IOC_PATH_TO_HANDLE, }, case XFS_IOC_PATH_TO_HANDLE:
{ XFS_IOC_PATH_TO_HANDLE, }, case XFS_IOC_PATH_TO_HANDLE:
{ XFS_IOC_PATH_TO_FSHANDLE, }, case XFS_IOC_PATH_TO_FSHANDLE:
{ XFS_IOC_OPEN_BY_HANDLE, }, case XFS_IOC_OPEN_BY_HANDLE:
{ XFS_IOC_FSSETDM_BY_HANDLE, }, case XFS_IOC_FSSETDM_BY_HANDLE:
{ XFS_IOC_READLINK_BY_HANDLE, }, case XFS_IOC_READLINK_BY_HANDLE:
{ XFS_IOC_ATTRLIST_BY_HANDLE, }, case XFS_IOC_ATTRLIST_BY_HANDLE:
{ XFS_IOC_ATTRMULTI_BY_HANDLE, }, case XFS_IOC_ATTRMULTI_BY_HANDLE:
*/ */
{ XFS_IOC_FSCOUNTS, NULL, }, case XFS_IOC_FSCOUNTS:
{ XFS_IOC_SET_RESBLKS, NULL, }, case XFS_IOC_SET_RESBLKS:
{ XFS_IOC_GET_RESBLKS, NULL, }, case XFS_IOC_GET_RESBLKS:
{ XFS_IOC_FSGROWFSDATA, NULL, }, case XFS_IOC_FSGROWFSDATA:
{ XFS_IOC_FSGROWFSLOG, NULL, }, case XFS_IOC_FSGROWFSLOG:
{ XFS_IOC_FSGROWFSRT, NULL, }, case XFS_IOC_FSGROWFSRT:
{ XFS_IOC_FREEZE, NULL, }, case XFS_IOC_FREEZE:
{ XFS_IOC_THAW, NULL, }, case XFS_IOC_THAW:
{ XFS_IOC_GOINGDOWN, NULL, }, case XFS_IOC_GOINGDOWN:
{ XFS_IOC_ERROR_INJECTION, NULL, }, case XFS_IOC_ERROR_INJECTION:
{ XFS_IOC_ERROR_CLEARALL, NULL, }, case XFS_IOC_ERROR_CLEARALL:
break;
#ifndef BROKEN_X86_ALIGNMENT #ifndef BROKEN_X86_ALIGNMENT
/* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */ /* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */
{ XFS_IOC_ALLOCSP, }, case XFS_IOC_ALLOCSP:
{ XFS_IOC_FREESP, }, case XFS_IOC_FREESP:
{ XFS_IOC_RESVSP, }, case XFS_IOC_RESVSP:
{ XFS_IOC_UNRESVSP, }, case XFS_IOC_UNRESVSP:
{ XFS_IOC_ALLOCSP64, }, case XFS_IOC_ALLOCSP64:
{ XFS_IOC_FREESP64, }, case XFS_IOC_FREESP64:
{ XFS_IOC_RESVSP64, }, case XFS_IOC_RESVSP64:
{ XFS_IOC_UNRESVSP64, }, case XFS_IOC_UNRESVSP64:
{ XFS_IOC_SWAPEXT, }, case XFS_IOC_SWAPEXT:
{ XFS_IOC_FSBULKSTAT_SINGLE, xfs_ioctl32_bulkstat }, break;
{ XFS_IOC_FSBULKSTAT, xfs_ioctl32_bulkstat},
{ XFS_IOC_FSINUMBERS, xfs_ioctl32_bulkstat},
#endif
{ 0, },
};
int __init case XFS_IOC_FSBULKSTAT_SINGLE:
xfs_ioctl32_init(void) case XFS_IOC_FSBULKSTAT:
{ case XFS_IOC_FSINUMBERS:
int error, i; arg = xfs_ioctl32_bulkstat(arg);
break;
for (i = 0; xfs_ioctl32_trans[i].cmd != 0; i++) { #endif
error = register_ioctl32_conversion(xfs_ioctl32_trans[i].cmd, default:
xfs_ioctl32_trans[i].handler); return -ENOIOCTLCMD;
if (error)
goto fail;
} }
return 0; VOP_IOCTL(vp, inode, f, mode, cmd, (void __user *)arg, error);
VMODIFY(vp);
fail:
while (--i)
unregister_ioctl32_conversion(xfs_ioctl32_trans[i].cmd);
return error; return error;
} }
void long xfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg)
xfs_ioctl32_exit(void)
{ {
int i; return __xfs_compat_ioctl(0, f, cmd, arg);
}
for (i = 0; xfs_ioctl32_trans[i].cmd != 0; i++) long xfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg)
unregister_ioctl32_conversion(xfs_ioctl32_trans[i].cmd); {
return __xfs_compat_ioctl(IO_INVIS, f, cmd, arg);
} }
...@@ -30,12 +30,5 @@ ...@@ -30,12 +30,5 @@
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/ */
#include <linux/config.h> long xfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg);
long xfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg);
#ifdef CONFIG_COMPAT
extern int xfs_ioctl32_init(void);
extern void xfs_ioctl32_exit(void);
#else
static inline int xfs_ioctl32_init(void) { return 0; }
static inline void xfs_ioctl32_exit(void) { }
#endif
...@@ -947,10 +947,6 @@ init_xfs_fs( void ) ...@@ -947,10 +947,6 @@ init_xfs_fs( void )
goto undo_shaker; goto undo_shaker;
} }
error = xfs_ioctl32_init();
if (error)
goto undo_ioctl32;
error = register_filesystem(&xfs_fs_type); error = register_filesystem(&xfs_fs_type);
if (error) if (error)
goto undo_register; goto undo_register;
...@@ -958,9 +954,6 @@ init_xfs_fs( void ) ...@@ -958,9 +954,6 @@ init_xfs_fs( void )
return 0; return 0;
undo_register: undo_register:
xfs_ioctl32_exit();
undo_ioctl32:
kmem_shake_deregister(xfs_inode_shaker); kmem_shake_deregister(xfs_inode_shaker);
undo_shaker: undo_shaker:
...@@ -979,7 +972,6 @@ exit_xfs_fs( void ) ...@@ -979,7 +972,6 @@ exit_xfs_fs( void )
vfs_exitquota(); vfs_exitquota();
XFS_DM_EXIT(&xfs_fs_type); XFS_DM_EXIT(&xfs_fs_type);
unregister_filesystem(&xfs_fs_type); unregister_filesystem(&xfs_fs_type);
xfs_ioctl32_exit();
kmem_shake_deregister(xfs_inode_shaker); kmem_shake_deregister(xfs_inode_shaker);
xfs_cleanup(); xfs_cleanup();
pagebuf_terminate(); pagebuf_terminate();
......
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