aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2007-10-09 07:23:56 -0400
committerJens Axboe <axboe@carl.home.kernel.dk>2007-10-10 03:26:00 -0400
commit18cf7f8723d913ce02bea43e468bebdd07bc880c (patch)
treea76588ab76db68fcb289babb1770e2fe13a6bd42
parent9617db085c119879cd371e3212806a15596e121a (diff)
compat_ioctl: move BLKPG handling to block/compat_ioctl.c
BLKPG is common to all block devices, so it should be handled by common code. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--block/compat_ioctl.c31
-rw-r--r--fs/compat_ioctl.c33
2 files changed, 31 insertions, 33 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index 5c6dafaad938..44807d38b1e7 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -92,6 +92,35 @@ static int compat_hdio_ioctl(struct inode *inode, struct file *file,
92 return error; 92 return error;
93} 93}
94 94
95struct compat_blkpg_ioctl_arg {
96 compat_int_t op;
97 compat_int_t flags;
98 compat_int_t datalen;
99 compat_caddr_t data;
100};
101
102static int compat_blkpg_ioctl(struct inode *inode, struct file *file,
103 unsigned int cmd, struct compat_blkpg_ioctl_arg __user *ua32)
104{
105 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
106 compat_caddr_t udata;
107 compat_int_t n;
108 int err;
109
110 err = get_user(n, &ua32->op);
111 err |= put_user(n, &a->op);
112 err |= get_user(n, &ua32->flags);
113 err |= put_user(n, &a->flags);
114 err |= get_user(n, &ua32->datalen);
115 err |= put_user(n, &a->datalen);
116 err |= get_user(udata, &ua32->data);
117 err |= put_user(compat_ptr(udata), &a->data);
118 if (err)
119 return err;
120
121 return blkdev_ioctl(inode, file, cmd, (unsigned long)a);
122}
123
95#define BLKBSZGET_32 _IOR(0x12, 112, int) 124#define BLKBSZGET_32 _IOR(0x12, 112, int)
96#define BLKBSZSET_32 _IOW(0x12, 113, int) 125#define BLKBSZSET_32 _IOW(0x12, 113, int)
97#define BLKGETSIZE64_32 _IOR(0x12, 114, int) 126#define BLKGETSIZE64_32 _IOR(0x12, 114, int)
@@ -348,6 +377,8 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
348 case BLKBSZSET_32: 377 case BLKBSZSET_32:
349 return blkdev_ioctl(inode, file, BLKBSZSET, 378 return blkdev_ioctl(inode, file, BLKBSZSET,
350 (unsigned long)compat_ptr(arg)); 379 (unsigned long)compat_ptr(arg));
380 case BLKPG:
381 return compat_blkpg_ioctl(inode, file, cmd, compat_ptr(arg));
351 } 382 }
352 383
353 lock_kernel(); 384 lock_kernel();
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index e6a94714b1b0..3baa90d31090 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -47,7 +47,6 @@
47#include <linux/netdevice.h> 47#include <linux/netdevice.h>
48#include <linux/raw.h> 48#include <linux/raw.h>
49#include <linux/smb_fs.h> 49#include <linux/smb_fs.h>
50#include <linux/blkpg.h>
51#include <linux/blkdev.h> 50#include <linux/blkdev.h>
52#include <linux/elevator.h> 51#include <linux/elevator.h>
53#include <linux/rtc.h> 52#include <linux/rtc.h>
@@ -1487,37 +1486,6 @@ ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1487 return -EINVAL; 1486 return -EINVAL;
1488} 1487}
1489 1488
1490#ifdef CONFIG_BLOCK
1491struct blkpg_ioctl_arg32 {
1492 compat_int_t op;
1493 compat_int_t flags;
1494 compat_int_t datalen;
1495 compat_caddr_t data;
1496};
1497
1498static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1499{
1500 struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
1501 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
1502 compat_caddr_t udata;
1503 compat_int_t n;
1504 int err;
1505
1506 err = get_user(n, &ua32->op);
1507 err |= put_user(n, &a->op);
1508 err |= get_user(n, &ua32->flags);
1509 err |= put_user(n, &a->flags);
1510 err |= get_user(n, &ua32->datalen);
1511 err |= put_user(n, &a->datalen);
1512 err |= get_user(udata, &ua32->data);
1513 err |= put_user(compat_ptr(udata), &a->data);
1514 if (err)
1515 return err;
1516
1517 return sys_ioctl(fd, cmd, (unsigned long)a);
1518}
1519#endif
1520
1521static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) 1489static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1522{ 1490{
1523 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); 1491 return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
@@ -3160,7 +3128,6 @@ HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
3160HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns) 3128HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
3161#endif 3129#endif
3162#ifdef CONFIG_BLOCK 3130#ifdef CONFIG_BLOCK
3163HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
3164HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans) 3131HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
3165HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans) 3132HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
3166HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans) 3133HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)