aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2008-02-07 21:09:56 -0500
committerAlasdair G Kergon <agk@redhat.com>2008-02-07 21:09:56 -0500
commit76c072b48e39e9291fbf02d6c912cf27d65e093d (patch)
tree5f5c523a48c014448b28a1a875ed8432fe79807a
parent27238b2bea89b1808b570bece6777ab2abc52fe2 (diff)
dm ioctl: move compat code
Move compat_ioctl handling into dm-ioctl.c. Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-ioctl.c15
-rw-r--r--fs/compat_ioctl.c34
-rw-r--r--include/linux/dm-ioctl.h34
3 files changed, 15 insertions, 68 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 4aa1f78b78f0..9c491397a51d 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -15,6 +15,7 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/dm-ioctl.h> 16#include <linux/dm-ioctl.h>
17#include <linux/hdreg.h> 17#include <linux/hdreg.h>
18#include <linux/compat.h>
18 19
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20 21
@@ -1350,10 +1351,10 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
1350{ 1351{
1351 struct dm_ioctl tmp, *dmi; 1352 struct dm_ioctl tmp, *dmi;
1352 1353
1353 if (copy_from_user(&tmp, user, sizeof(tmp))) 1354 if (copy_from_user(&tmp, user, sizeof(tmp) - sizeof(tmp.data)))
1354 return -EFAULT; 1355 return -EFAULT;
1355 1356
1356 if (tmp.data_size < sizeof(tmp)) 1357 if (tmp.data_size < (sizeof(tmp) - sizeof(tmp.data)))
1357 return -EINVAL; 1358 return -EINVAL;
1358 1359
1359 dmi = vmalloc(tmp.data_size); 1360 dmi = vmalloc(tmp.data_size);
@@ -1474,8 +1475,18 @@ static long dm_ctl_ioctl(struct file *file, uint command, ulong u)
1474 return (long)ctl_ioctl(command, (struct dm_ioctl __user *)u); 1475 return (long)ctl_ioctl(command, (struct dm_ioctl __user *)u);
1475} 1476}
1476 1477
1478#ifdef CONFIG_COMPAT
1479static long dm_compat_ctl_ioctl(struct file *file, uint command, ulong u)
1480{
1481 return (long)dm_ctl_ioctl(file, command, (ulong) compat_ptr(u));
1482}
1483#else
1484#define dm_compat_ctl_ioctl NULL
1485#endif
1486
1477static const struct file_operations _ctl_fops = { 1487static const struct file_operations _ctl_fops = {
1478 .unlocked_ioctl = dm_ctl_ioctl, 1488 .unlocked_ioctl = dm_ctl_ioctl,
1489 .compat_ioctl = dm_compat_ctl_ioctl,
1479 .owner = THIS_MODULE, 1490 .owner = THIS_MODULE,
1480}; 1491};
1481 1492
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 614bd75b5a4a..ee32c0eac7c1 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -78,7 +78,6 @@
78#include <linux/mii.h> 78#include <linux/mii.h>
79#include <linux/if_bonding.h> 79#include <linux/if_bonding.h>
80#include <linux/watchdog.h> 80#include <linux/watchdog.h>
81#include <linux/dm-ioctl.h>
82 81
83#include <linux/soundcard.h> 82#include <linux/soundcard.h>
84#include <linux/lp.h> 83#include <linux/lp.h>
@@ -1993,39 +1992,6 @@ COMPATIBLE_IOCTL(STOP_ARRAY_RO)
1993COMPATIBLE_IOCTL(RESTART_ARRAY_RW) 1992COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1994COMPATIBLE_IOCTL(GET_BITMAP_FILE) 1993COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1995ULONG_IOCTL(SET_BITMAP_FILE) 1994ULONG_IOCTL(SET_BITMAP_FILE)
1996/* DM */
1997COMPATIBLE_IOCTL(DM_VERSION_32)
1998COMPATIBLE_IOCTL(DM_REMOVE_ALL_32)
1999COMPATIBLE_IOCTL(DM_LIST_DEVICES_32)
2000COMPATIBLE_IOCTL(DM_DEV_CREATE_32)
2001COMPATIBLE_IOCTL(DM_DEV_REMOVE_32)
2002COMPATIBLE_IOCTL(DM_DEV_RENAME_32)
2003COMPATIBLE_IOCTL(DM_DEV_SUSPEND_32)
2004COMPATIBLE_IOCTL(DM_DEV_STATUS_32)
2005COMPATIBLE_IOCTL(DM_DEV_WAIT_32)
2006COMPATIBLE_IOCTL(DM_TABLE_LOAD_32)
2007COMPATIBLE_IOCTL(DM_TABLE_CLEAR_32)
2008COMPATIBLE_IOCTL(DM_TABLE_DEPS_32)
2009COMPATIBLE_IOCTL(DM_TABLE_STATUS_32)
2010COMPATIBLE_IOCTL(DM_LIST_VERSIONS_32)
2011COMPATIBLE_IOCTL(DM_TARGET_MSG_32)
2012COMPATIBLE_IOCTL(DM_DEV_SET_GEOMETRY_32)
2013COMPATIBLE_IOCTL(DM_VERSION)
2014COMPATIBLE_IOCTL(DM_REMOVE_ALL)
2015COMPATIBLE_IOCTL(DM_LIST_DEVICES)
2016COMPATIBLE_IOCTL(DM_DEV_CREATE)
2017COMPATIBLE_IOCTL(DM_DEV_REMOVE)
2018COMPATIBLE_IOCTL(DM_DEV_RENAME)
2019COMPATIBLE_IOCTL(DM_DEV_SUSPEND)
2020COMPATIBLE_IOCTL(DM_DEV_STATUS)
2021COMPATIBLE_IOCTL(DM_DEV_WAIT)
2022COMPATIBLE_IOCTL(DM_TABLE_LOAD)
2023COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
2024COMPATIBLE_IOCTL(DM_TABLE_DEPS)
2025COMPATIBLE_IOCTL(DM_TABLE_STATUS)
2026COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
2027COMPATIBLE_IOCTL(DM_TARGET_MSG)
2028COMPATIBLE_IOCTL(DM_DEV_SET_GEOMETRY)
2029/* Big K */ 1995/* Big K */
2030COMPATIBLE_IOCTL(PIO_FONT) 1996COMPATIBLE_IOCTL(PIO_FONT)
2031COMPATIBLE_IOCTL(GIO_FONT) 1997COMPATIBLE_IOCTL(GIO_FONT)
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
index 523281c5b7f5..b03c41bbfa14 100644
--- a/include/linux/dm-ioctl.h
+++ b/include/linux/dm-ioctl.h
@@ -232,36 +232,6 @@ enum {
232 DM_DEV_SET_GEOMETRY_CMD 232 DM_DEV_SET_GEOMETRY_CMD
233}; 233};
234 234
235/*
236 * The dm_ioctl struct passed into the ioctl is just the header
237 * on a larger chunk of memory. On x86-64 and other
238 * architectures the dm-ioctl struct will be padded to an 8 byte
239 * boundary so the size will be different, which would change the
240 * ioctl code - yes I really messed up. This hack forces these
241 * architectures to have the correct ioctl code.
242 */
243#ifdef CONFIG_COMPAT
244typedef char ioctl_struct[308];
245#define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
246#define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
247#define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
248
249#define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
250#define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
251#define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
252#define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
253#define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
254#define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
255
256#define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
257#define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
258#define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
259#define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
260#define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
261#define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
262#define DM_DEV_SET_GEOMETRY_32 _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, ioctl_struct)
263#endif
264
265#define DM_IOCTL 0xfd 235#define DM_IOCTL 0xfd
266 236
267#define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl) 237#define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
@@ -286,9 +256,9 @@ typedef char ioctl_struct[308];
286#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) 256#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
287 257
288#define DM_VERSION_MAJOR 4 258#define DM_VERSION_MAJOR 4
289#define DM_VERSION_MINOR 12 259#define DM_VERSION_MINOR 13
290#define DM_VERSION_PATCHLEVEL 0 260#define DM_VERSION_PATCHLEVEL 0
291#define DM_VERSION_EXTRA "-ioctl (2007-10-02)" 261#define DM_VERSION_EXTRA "-ioctl (2007-10-18)"
292 262
293/* Status bits */ 263/* Status bits */
294#define DM_READONLY_FLAG (1 << 0) /* In/Out */ 264#define DM_READONLY_FLAG (1 << 0) /* In/Out */