| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * ioctl32.c: Conversion between 32bit and 64bit native ioctls. | 
 | 3 |  * | 
 | 4 |  * Copyright (C) 1997-2000  Jakub Jelinek  (jakub@redhat.com) | 
 | 5 |  * Copyright (C) 1998  Eddie C. Dost  (ecd@skynet.be) | 
 | 6 |  * Copyright (C) 2001,2002  Andi Kleen, SuSE Labs  | 
 | 7 |  * Copyright (C) 2003       Pavel Machek (pavel@suse.cz) | 
 | 8 |  * | 
 | 9 |  * These routines maintain argument size conversion between 32bit and 64bit | 
 | 10 |  * ioctls. | 
 | 11 |  */ | 
 | 12 |  | 
| Akos Maroy | 3fee37c | 2008-01-06 11:15:55 +0100 | [diff] [blame] | 13 | #include <linux/joystick.h> | 
 | 14 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/types.h> | 
 | 16 | #include <linux/compat.h> | 
 | 17 | #include <linux/kernel.h> | 
| Randy Dunlap | 16f7e0f | 2006-01-11 12:17:46 -0800 | [diff] [blame] | 18 | #include <linux/capability.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/compiler.h> | 
 | 20 | #include <linux/sched.h> | 
 | 21 | #include <linux/smp.h> | 
| Alexey Dobriyan | 405f557 | 2009-07-11 22:08:37 +0400 | [diff] [blame] | 22 | #include <linux/smp_lock.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/ioctl.h> | 
 | 24 | #include <linux/if.h> | 
 | 25 | #include <linux/if_bridge.h> | 
 | 26 | #include <linux/slab.h> | 
| NeilBrown | bff6197 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 27 | #include <linux/raid/md_u.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/kd.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/route.h> | 
 | 30 | #include <linux/in6.h> | 
 | 31 | #include <linux/ipv6_route.h> | 
 | 32 | #include <linux/skbuff.h> | 
 | 33 | #include <linux/netlink.h> | 
 | 34 | #include <linux/vt.h> | 
| Ankit Jain | 3e63cbb | 2009-06-19 14:28:07 -0400 | [diff] [blame] | 35 | #include <linux/falloc.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/fs.h> | 
 | 37 | #include <linux/file.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <linux/ppp_defs.h> | 
 | 39 | #include <linux/if_ppp.h> | 
 | 40 | #include <linux/if_pppox.h> | 
 | 41 | #include <linux/mtio.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <linux/auto_fs.h> | 
 | 43 | #include <linux/auto_fs4.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <linux/tty.h> | 
 | 45 | #include <linux/vt_kern.h> | 
 | 46 | #include <linux/fb.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/videodev.h> | 
 | 48 | #include <linux/netdevice.h> | 
 | 49 | #include <linux/raw.h> | 
 | 50 | #include <linux/smb_fs.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <linux/blkdev.h> | 
 | 52 | #include <linux/elevator.h> | 
 | 53 | #include <linux/rtc.h> | 
 | 54 | #include <linux/pci.h> | 
 | 55 | #include <linux/module.h> | 
 | 56 | #include <linux/serial.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #include <linux/if_tun.h> | 
 | 58 | #include <linux/ctype.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #include <linux/syscalls.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #include <linux/i2c.h> | 
 | 61 | #include <linux/i2c-dev.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #include <linux/atalk.h> | 
 | 63 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #include <net/bluetooth/bluetooth.h> | 
 | 65 | #include <net/bluetooth/hci.h> | 
 | 66 | #include <net/bluetooth/rfcomm.h> | 
 | 67 |  | 
 | 68 | #include <linux/capi.h> | 
| Hansjoerg Lipp | 5024ad4 | 2006-06-26 00:25:35 -0700 | [diff] [blame] | 69 | #include <linux/gigaset_dev.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 |  | 
| Randy Dunlap | 3c3622d | 2008-07-16 08:52:00 -0500 | [diff] [blame] | 71 | #ifdef CONFIG_BLOCK | 
| Alexander Beregalov | 1ba0c7d | 2009-04-20 12:23:02 +0400 | [diff] [blame] | 72 | #include <linux/loop.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #include <scsi/scsi.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | #include <scsi/scsi_ioctl.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #include <scsi/sg.h> | 
| Randy Dunlap | 3c3622d | 2008-07-16 08:52:00 -0500 | [diff] [blame] | 76 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #include <asm/uaccess.h> | 
 | 79 | #include <linux/ethtool.h> | 
 | 80 | #include <linux/mii.h> | 
 | 81 | #include <linux/if_bonding.h> | 
 | 82 | #include <linux/watchdog.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #include <linux/soundcard.h> | 
 | 85 | #include <linux/lp.h> | 
 | 86 | #include <linux/ppdev.h> | 
 | 87 |  | 
 | 88 | #include <linux/atm.h> | 
 | 89 | #include <linux/atmarp.h> | 
 | 90 | #include <linux/atmclip.h> | 
 | 91 | #include <linux/atmdev.h> | 
 | 92 | #include <linux/atmioc.h> | 
 | 93 | #include <linux/atmlec.h> | 
 | 94 | #include <linux/atmmpc.h> | 
 | 95 | #include <linux/atmsvc.h> | 
 | 96 | #include <linux/atm_tcp.h> | 
 | 97 | #include <linux/sonet.h> | 
 | 98 | #include <linux/atm_suni.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 |  | 
 | 100 | #include <linux/usb.h> | 
 | 101 | #include <linux/usbdevice_fs.h> | 
 | 102 | #include <linux/nbd.h> | 
 | 103 | #include <linux/random.h> | 
 | 104 | #include <linux/filter.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #include <linux/pktcdvd.h> | 
 | 106 |  | 
 | 107 | #include <linux/hiddev.h> | 
 | 108 |  | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 109 | #include <linux/dvb/audio.h> | 
 | 110 | #include <linux/dvb/dmx.h> | 
 | 111 | #include <linux/dvb/frontend.h> | 
 | 112 | #include <linux/dvb/video.h> | 
 | 113 |  | 
| David S. Miller | 8163904 | 2007-07-29 00:50:42 -0700 | [diff] [blame] | 114 | #ifdef CONFIG_SPARC | 
 | 115 | #include <asm/fbio.h> | 
 | 116 | #endif | 
 | 117 |  | 
| Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 118 | static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, | 
 | 119 | 			      unsigned long arg, struct file *f) | 
 | 120 | { | 
 | 121 | 	return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); | 
 | 122 | } | 
 | 123 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 125 | { | 
 | 126 | 	mm_segment_t old_fs = get_fs(); | 
 | 127 | 	int err; | 
 | 128 | 	unsigned long val; | 
 | 129 | 	 | 
 | 130 | 	set_fs (KERNEL_DS); | 
 | 131 | 	err = sys_ioctl(fd, cmd, (unsigned long)&val); | 
 | 132 | 	set_fs (old_fs); | 
 | 133 | 	if (!err && put_user(val, (u32 __user *)compat_ptr(arg))) | 
 | 134 | 		return -EFAULT; | 
 | 135 | 	return err; | 
 | 136 | } | 
 | 137 |   | 
 | 138 | static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 139 | { | 
 | 140 | 	mm_segment_t old_fs = get_fs(); | 
 | 141 | 	u32 __user *argptr = compat_ptr(arg); | 
 | 142 | 	int err; | 
 | 143 | 	unsigned long val; | 
 | 144 | 	 | 
 | 145 | 	if(get_user(val, argptr)) | 
 | 146 | 		return -EFAULT; | 
 | 147 | 	set_fs (KERNEL_DS); | 
 | 148 | 	err = sys_ioctl(fd, cmd, (unsigned long)&val); | 
 | 149 | 	set_fs (old_fs); | 
 | 150 | 	if (!err && put_user(val, argptr)) | 
 | 151 | 		return -EFAULT; | 
 | 152 | 	return err; | 
 | 153 | } | 
 | 154 |  | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 155 | struct compat_video_event { | 
 | 156 | 	int32_t		type; | 
 | 157 | 	compat_time_t	timestamp; | 
 | 158 | 	union { | 
 | 159 | 	        video_size_t size; | 
 | 160 | 		unsigned int frame_rate; | 
 | 161 | 	} u; | 
 | 162 | }; | 
 | 163 |  | 
 | 164 | static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 165 | { | 
 | 166 | 	struct video_event kevent; | 
 | 167 | 	mm_segment_t old_fs = get_fs(); | 
 | 168 | 	int err; | 
 | 169 |  | 
 | 170 | 	set_fs(KERNEL_DS); | 
 | 171 | 	err = sys_ioctl(fd, cmd, (unsigned long) &kevent); | 
 | 172 | 	set_fs(old_fs); | 
 | 173 |  | 
 | 174 | 	if (!err) { | 
 | 175 | 		struct compat_video_event __user *up = compat_ptr(arg); | 
 | 176 |  | 
 | 177 | 		err  = put_user(kevent.type, &up->type); | 
 | 178 | 		err |= put_user(kevent.timestamp, &up->timestamp); | 
 | 179 | 		err |= put_user(kevent.u.size.w, &up->u.size.w); | 
 | 180 | 		err |= put_user(kevent.u.size.h, &up->u.size.h); | 
 | 181 | 		err |= put_user(kevent.u.size.aspect_ratio, | 
 | 182 | 				&up->u.size.aspect_ratio); | 
 | 183 | 		if (err) | 
 | 184 | 			err = -EFAULT; | 
 | 185 | 	} | 
 | 186 |  | 
 | 187 | 	return err; | 
 | 188 | } | 
 | 189 |  | 
 | 190 | struct compat_video_still_picture { | 
 | 191 |         compat_uptr_t iFrame; | 
 | 192 |         int32_t size; | 
 | 193 | }; | 
 | 194 |  | 
 | 195 | static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 196 | { | 
 | 197 | 	struct compat_video_still_picture __user *up; | 
 | 198 | 	struct video_still_picture __user *up_native; | 
 | 199 | 	compat_uptr_t fp; | 
 | 200 | 	int32_t size; | 
 | 201 | 	int err; | 
 | 202 |  | 
 | 203 | 	up = (struct compat_video_still_picture __user *) arg; | 
 | 204 | 	err  = get_user(fp, &up->iFrame); | 
 | 205 | 	err |= get_user(size, &up->size); | 
 | 206 | 	if (err) | 
 | 207 | 		return -EFAULT; | 
 | 208 |  | 
 | 209 | 	up_native = | 
 | 210 | 		compat_alloc_user_space(sizeof(struct video_still_picture)); | 
 | 211 |  | 
| Heiko Carstens | 7116e99 | 2006-12-06 20:36:36 -0800 | [diff] [blame] | 212 | 	err =  put_user(compat_ptr(fp), &up_native->iFrame); | 
 | 213 | 	err |= put_user(size, &up_native->size); | 
 | 214 | 	if (err) | 
 | 215 | 		return -EFAULT; | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 216 |  | 
 | 217 | 	err = sys_ioctl(fd, cmd, (unsigned long) up_native); | 
 | 218 |  | 
 | 219 | 	return err; | 
 | 220 | } | 
 | 221 |  | 
 | 222 | struct compat_video_spu_palette { | 
 | 223 | 	int length; | 
 | 224 | 	compat_uptr_t palette; | 
 | 225 | }; | 
 | 226 |  | 
 | 227 | static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 228 | { | 
 | 229 | 	struct compat_video_spu_palette __user *up; | 
 | 230 | 	struct video_spu_palette __user *up_native; | 
 | 231 | 	compat_uptr_t palp; | 
 | 232 | 	int length, err; | 
 | 233 |  | 
 | 234 | 	up = (struct compat_video_spu_palette __user *) arg; | 
 | 235 | 	err  = get_user(palp, &up->palette); | 
 | 236 | 	err |= get_user(length, &up->length); | 
 | 237 |  | 
 | 238 | 	up_native = compat_alloc_user_space(sizeof(struct video_spu_palette)); | 
| Heiko Carstens | 7116e99 | 2006-12-06 20:36:36 -0800 | [diff] [blame] | 239 | 	err  = put_user(compat_ptr(palp), &up_native->palette); | 
 | 240 | 	err |= put_user(length, &up_native->length); | 
 | 241 | 	if (err) | 
 | 242 | 		return -EFAULT; | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 243 |  | 
 | 244 | 	err = sys_ioctl(fd, cmd, (unsigned long) up_native); | 
 | 245 |  | 
 | 246 | 	return err; | 
 | 247 | } | 
 | 248 |  | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 249 | #ifdef CONFIG_BLOCK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | typedef struct sg_io_hdr32 { | 
 | 251 | 	compat_int_t interface_id;	/* [i] 'S' for SCSI generic (required) */ | 
 | 252 | 	compat_int_t dxfer_direction;	/* [i] data transfer direction  */ | 
 | 253 | 	unsigned char cmd_len;		/* [i] SCSI command length ( <= 16 bytes) */ | 
 | 254 | 	unsigned char mx_sb_len;		/* [i] max length to write to sbp */ | 
 | 255 | 	unsigned short iovec_count;	/* [i] 0 implies no scatter gather */ | 
 | 256 | 	compat_uint_t dxfer_len;		/* [i] byte count of data transfer */ | 
 | 257 | 	compat_uint_t dxferp;		/* [i], [*io] points to data transfer memory | 
 | 258 | 					      or scatter gather list */ | 
 | 259 | 	compat_uptr_t cmdp;		/* [i], [*i] points to command to perform */ | 
 | 260 | 	compat_uptr_t sbp;		/* [i], [*o] points to sense_buffer memory */ | 
 | 261 | 	compat_uint_t timeout;		/* [i] MAX_UINT->no timeout (unit: millisec) */ | 
 | 262 | 	compat_uint_t flags;		/* [i] 0 -> default, see SG_FLAG... */ | 
 | 263 | 	compat_int_t pack_id;		/* [i->o] unused internally (normally) */ | 
 | 264 | 	compat_uptr_t usr_ptr;		/* [i->o] unused internally */ | 
 | 265 | 	unsigned char status;		/* [o] scsi status */ | 
 | 266 | 	unsigned char masked_status;	/* [o] shifted, masked scsi status */ | 
 | 267 | 	unsigned char msg_status;		/* [o] messaging level data (optional) */ | 
 | 268 | 	unsigned char sb_len_wr;		/* [o] byte count actually written to sbp */ | 
 | 269 | 	unsigned short host_status;	/* [o] errors from host adapter */ | 
 | 270 | 	unsigned short driver_status;	/* [o] errors from software driver */ | 
 | 271 | 	compat_int_t resid;		/* [o] dxfer_len - actual_transferred */ | 
 | 272 | 	compat_uint_t duration;		/* [o] time taken by cmd (unit: millisec) */ | 
 | 273 | 	compat_uint_t info;		/* [o] auxiliary information */ | 
 | 274 | } sg_io_hdr32_t;  /* 64 bytes long (on sparc32) */ | 
 | 275 |  | 
 | 276 | typedef struct sg_iovec32 { | 
 | 277 | 	compat_uint_t iov_base; | 
 | 278 | 	compat_uint_t iov_len; | 
 | 279 | } sg_iovec32_t; | 
 | 280 |  | 
 | 281 | static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count) | 
 | 282 | { | 
 | 283 | 	sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1); | 
 | 284 | 	sg_iovec32_t __user *iov32 = dxferp; | 
 | 285 | 	int i; | 
 | 286 |  | 
 | 287 | 	for (i = 0; i < iovec_count; i++) { | 
 | 288 | 		u32 base, len; | 
 | 289 |  | 
 | 290 | 		if (get_user(base, &iov32[i].iov_base) || | 
 | 291 | 		    get_user(len, &iov32[i].iov_len) || | 
 | 292 | 		    put_user(compat_ptr(base), &iov[i].iov_base) || | 
 | 293 | 		    put_user(len, &iov[i].iov_len)) | 
 | 294 | 			return -EFAULT; | 
 | 295 | 	} | 
 | 296 |  | 
 | 297 | 	if (put_user(iov, &sgio->dxferp)) | 
 | 298 | 		return -EFAULT; | 
 | 299 | 	return 0; | 
 | 300 | } | 
 | 301 |  | 
 | 302 | static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 303 | { | 
 | 304 | 	sg_io_hdr_t __user *sgio; | 
 | 305 | 	sg_io_hdr32_t __user *sgio32; | 
 | 306 | 	u16 iovec_count; | 
 | 307 | 	u32 data; | 
 | 308 | 	void __user *dxferp; | 
 | 309 | 	int err; | 
 | 310 |  | 
 | 311 | 	sgio32 = compat_ptr(arg); | 
 | 312 | 	if (get_user(iovec_count, &sgio32->iovec_count)) | 
 | 313 | 		return -EFAULT; | 
 | 314 |  | 
 | 315 | 	{ | 
 | 316 | 		void __user *top = compat_alloc_user_space(0); | 
 | 317 | 		void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) + | 
 | 318 | 				       (iovec_count * sizeof(sg_iovec_t))); | 
 | 319 | 		if (new > top) | 
 | 320 | 			return -EINVAL; | 
 | 321 |  | 
 | 322 | 		sgio = new; | 
 | 323 | 	} | 
 | 324 |  | 
 | 325 | 	/* Ok, now construct.  */ | 
 | 326 | 	if (copy_in_user(&sgio->interface_id, &sgio32->interface_id, | 
 | 327 | 			 (2 * sizeof(int)) + | 
 | 328 | 			 (2 * sizeof(unsigned char)) + | 
 | 329 | 			 (1 * sizeof(unsigned short)) + | 
 | 330 | 			 (1 * sizeof(unsigned int)))) | 
 | 331 | 		return -EFAULT; | 
 | 332 |  | 
 | 333 | 	if (get_user(data, &sgio32->dxferp)) | 
 | 334 | 		return -EFAULT; | 
 | 335 | 	dxferp = compat_ptr(data); | 
 | 336 | 	if (iovec_count) { | 
 | 337 | 		if (sg_build_iovec(sgio, dxferp, iovec_count)) | 
 | 338 | 			return -EFAULT; | 
 | 339 | 	} else { | 
 | 340 | 		if (put_user(dxferp, &sgio->dxferp)) | 
 | 341 | 			return -EFAULT; | 
 | 342 | 	} | 
 | 343 |  | 
 | 344 | 	{ | 
 | 345 | 		unsigned char __user *cmdp; | 
 | 346 | 		unsigned char __user *sbp; | 
 | 347 |  | 
 | 348 | 		if (get_user(data, &sgio32->cmdp)) | 
 | 349 | 			return -EFAULT; | 
 | 350 | 		cmdp = compat_ptr(data); | 
 | 351 |  | 
 | 352 | 		if (get_user(data, &sgio32->sbp)) | 
 | 353 | 			return -EFAULT; | 
 | 354 | 		sbp = compat_ptr(data); | 
 | 355 |  | 
 | 356 | 		if (put_user(cmdp, &sgio->cmdp) || | 
 | 357 | 		    put_user(sbp, &sgio->sbp)) | 
 | 358 | 			return -EFAULT; | 
 | 359 | 	} | 
 | 360 |  | 
 | 361 | 	if (copy_in_user(&sgio->timeout, &sgio32->timeout, | 
 | 362 | 			 3 * sizeof(int))) | 
 | 363 | 		return -EFAULT; | 
 | 364 |  | 
 | 365 | 	if (get_user(data, &sgio32->usr_ptr)) | 
 | 366 | 		return -EFAULT; | 
 | 367 | 	if (put_user(compat_ptr(data), &sgio->usr_ptr)) | 
 | 368 | 		return -EFAULT; | 
 | 369 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | 	err = sys_ioctl(fd, cmd, (unsigned long) sgio); | 
 | 371 |  | 
 | 372 | 	if (err >= 0) { | 
 | 373 | 		void __user *datap; | 
 | 374 |  | 
 | 375 | 		if (copy_in_user(&sgio32->pack_id, &sgio->pack_id, | 
 | 376 | 				 sizeof(int)) || | 
 | 377 | 		    get_user(datap, &sgio->usr_ptr) || | 
 | 378 | 		    put_user((u32)(unsigned long)datap, | 
 | 379 | 			     &sgio32->usr_ptr) || | 
 | 380 | 		    copy_in_user(&sgio32->status, &sgio->status, | 
 | 381 | 				 (4 * sizeof(unsigned char)) + | 
 | 382 | 				 (2 * sizeof(unsigned short)) + | 
 | 383 | 				 (3 * sizeof(int)))) | 
 | 384 | 			err = -EFAULT; | 
 | 385 | 	} | 
 | 386 |  | 
 | 387 | 	return err; | 
 | 388 | } | 
 | 389 |  | 
| Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 390 | struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ | 
 | 391 | 	char req_state; | 
 | 392 | 	char orphan; | 
 | 393 | 	char sg_io_owned; | 
 | 394 | 	char problem; | 
 | 395 | 	int pack_id; | 
 | 396 | 	compat_uptr_t usr_ptr; | 
 | 397 | 	unsigned int duration; | 
 | 398 | 	int unused; | 
 | 399 | }; | 
 | 400 |  | 
 | 401 | static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 402 | { | 
 | 403 | 	int err, i; | 
| Al Viro | 6b2b4e5 | 2006-02-01 06:33:33 -0500 | [diff] [blame] | 404 | 	sg_req_info_t __user *r; | 
 | 405 | 	struct compat_sg_req_info __user *o = (void __user *)arg; | 
| Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 406 | 	r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); | 
 | 407 | 	err = sys_ioctl(fd,cmd,(unsigned long)r); | 
 | 408 | 	if (err < 0) | 
 | 409 | 		return err; | 
 | 410 | 	for (i = 0; i < SG_MAX_QUEUE; i++) { | 
 | 411 | 		void __user *ptr; | 
 | 412 | 		int d; | 
 | 413 |  | 
 | 414 | 		if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) || | 
 | 415 | 		    get_user(ptr, &r[i].usr_ptr) || | 
 | 416 | 		    get_user(d, &r[i].duration) || | 
 | 417 | 		    put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) || | 
 | 418 | 		    put_user(d, &o[i].duration)) | 
 | 419 | 			return -EFAULT; | 
 | 420 | 	} | 
 | 421 | 	return err; | 
 | 422 | } | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 423 | #endif /* CONFIG_BLOCK */ | 
| Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 424 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | struct sock_fprog32 { | 
 | 426 | 	unsigned short	len; | 
 | 427 | 	compat_caddr_t	filter; | 
 | 428 | }; | 
 | 429 |  | 
 | 430 | #define PPPIOCSPASS32	_IOW('t', 71, struct sock_fprog32) | 
 | 431 | #define PPPIOCSACTIVE32	_IOW('t', 70, struct sock_fprog32) | 
 | 432 |  | 
 | 433 | static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 434 | { | 
 | 435 | 	struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg); | 
 | 436 | 	struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); | 
 | 437 | 	void __user *fptr64; | 
 | 438 | 	u32 fptr32; | 
 | 439 | 	u16 flen; | 
 | 440 |  | 
 | 441 | 	if (get_user(flen, &u_fprog32->len) || | 
 | 442 | 	    get_user(fptr32, &u_fprog32->filter)) | 
 | 443 | 		return -EFAULT; | 
 | 444 |  | 
 | 445 | 	fptr64 = compat_ptr(fptr32); | 
 | 446 |  | 
 | 447 | 	if (put_user(flen, &u_fprog64->len) || | 
 | 448 | 	    put_user(fptr64, &u_fprog64->filter)) | 
 | 449 | 		return -EFAULT; | 
 | 450 |  | 
 | 451 | 	if (cmd == PPPIOCSPASS32) | 
 | 452 | 		cmd = PPPIOCSPASS; | 
 | 453 | 	else | 
 | 454 | 		cmd = PPPIOCSACTIVE; | 
 | 455 |  | 
 | 456 | 	return sys_ioctl(fd, cmd, (unsigned long) u_fprog64); | 
 | 457 | } | 
 | 458 |  | 
 | 459 | struct ppp_option_data32 { | 
 | 460 | 	compat_caddr_t	ptr; | 
 | 461 | 	u32			length; | 
 | 462 | 	compat_int_t		transmit; | 
 | 463 | }; | 
 | 464 | #define PPPIOCSCOMPRESS32	_IOW('t', 77, struct ppp_option_data32) | 
 | 465 |  | 
 | 466 | struct ppp_idle32 { | 
 | 467 | 	compat_time_t xmit_idle; | 
 | 468 | 	compat_time_t recv_idle; | 
 | 469 | }; | 
 | 470 | #define PPPIOCGIDLE32		_IOR('t', 63, struct ppp_idle32) | 
 | 471 |  | 
 | 472 | static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 473 | { | 
 | 474 | 	struct ppp_idle __user *idle; | 
 | 475 | 	struct ppp_idle32 __user *idle32; | 
 | 476 | 	__kernel_time_t xmit, recv; | 
 | 477 | 	int err; | 
 | 478 |  | 
 | 479 | 	idle = compat_alloc_user_space(sizeof(*idle)); | 
 | 480 | 	idle32 = compat_ptr(arg); | 
 | 481 |  | 
 | 482 | 	err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); | 
 | 483 |  | 
 | 484 | 	if (!err) { | 
 | 485 | 		if (get_user(xmit, &idle->xmit_idle) || | 
 | 486 | 		    get_user(recv, &idle->recv_idle) || | 
 | 487 | 		    put_user(xmit, &idle32->xmit_idle) || | 
 | 488 | 		    put_user(recv, &idle32->recv_idle)) | 
 | 489 | 			err = -EFAULT; | 
 | 490 | 	} | 
 | 491 | 	return err; | 
 | 492 | } | 
 | 493 |  | 
 | 494 | static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 495 | { | 
 | 496 | 	struct ppp_option_data __user *odata; | 
 | 497 | 	struct ppp_option_data32 __user *odata32; | 
 | 498 | 	__u32 data; | 
 | 499 | 	void __user *datap; | 
 | 500 |  | 
 | 501 | 	odata = compat_alloc_user_space(sizeof(*odata)); | 
 | 502 | 	odata32 = compat_ptr(arg); | 
 | 503 |  | 
 | 504 | 	if (get_user(data, &odata32->ptr)) | 
 | 505 | 		return -EFAULT; | 
 | 506 |  | 
 | 507 | 	datap = compat_ptr(data); | 
 | 508 | 	if (put_user(datap, &odata->ptr)) | 
 | 509 | 		return -EFAULT; | 
 | 510 |  | 
 | 511 | 	if (copy_in_user(&odata->length, &odata32->length, | 
 | 512 | 			 sizeof(__u32) + sizeof(int))) | 
 | 513 | 		return -EFAULT; | 
 | 514 |  | 
 | 515 | 	return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); | 
 | 516 | } | 
 | 517 |  | 
 | 518 | static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 519 | { | 
 | 520 | 	int err; | 
 | 521 |  | 
 | 522 | 	switch (cmd) { | 
 | 523 | 	case PPPIOCGIDLE32: | 
 | 524 | 		err = ppp_gidle(fd, cmd, arg); | 
 | 525 | 		break; | 
 | 526 |  | 
 | 527 | 	case PPPIOCSCOMPRESS32: | 
 | 528 | 		err = ppp_scompress(fd, cmd, arg); | 
 | 529 | 		break; | 
 | 530 |  | 
 | 531 | 	default: | 
 | 532 | 		do { | 
 | 533 | 			static int count; | 
 | 534 | 			if (++count <= 20) | 
 | 535 | 				printk("ppp_ioctl: Unknown cmd fd(%d) " | 
 | 536 | 				       "cmd(%08x) arg(%08x)\n", | 
 | 537 | 				       (int)fd, (unsigned int)cmd, (unsigned int)arg); | 
 | 538 | 		} while(0); | 
 | 539 | 		err = -EINVAL; | 
 | 540 | 		break; | 
 | 541 | 	}; | 
 | 542 |  | 
 | 543 | 	return err; | 
 | 544 | } | 
 | 545 |  | 
 | 546 |  | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 547 | #ifdef CONFIG_BLOCK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | struct mtget32 { | 
 | 549 | 	compat_long_t	mt_type; | 
 | 550 | 	compat_long_t	mt_resid; | 
 | 551 | 	compat_long_t	mt_dsreg; | 
 | 552 | 	compat_long_t	mt_gstat; | 
 | 553 | 	compat_long_t	mt_erreg; | 
 | 554 | 	compat_daddr_t	mt_fileno; | 
 | 555 | 	compat_daddr_t	mt_blkno; | 
 | 556 | }; | 
 | 557 | #define MTIOCGET32	_IOR('m', 2, struct mtget32) | 
 | 558 |  | 
 | 559 | struct mtpos32 { | 
 | 560 | 	compat_long_t	mt_blkno; | 
 | 561 | }; | 
 | 562 | #define MTIOCPOS32	_IOR('m', 3, struct mtpos32) | 
 | 563 |  | 
 | 564 | static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 565 | { | 
 | 566 | 	mm_segment_t old_fs = get_fs(); | 
 | 567 | 	struct mtget get; | 
 | 568 | 	struct mtget32 __user *umget32; | 
 | 569 | 	struct mtpos pos; | 
 | 570 | 	struct mtpos32 __user *upos32; | 
 | 571 | 	unsigned long kcmd; | 
 | 572 | 	void *karg; | 
 | 573 | 	int err = 0; | 
 | 574 |  | 
 | 575 | 	switch(cmd) { | 
 | 576 | 	case MTIOCPOS32: | 
 | 577 | 		kcmd = MTIOCPOS; | 
 | 578 | 		karg = &pos; | 
 | 579 | 		break; | 
 | 580 | 	case MTIOCGET32: | 
 | 581 | 		kcmd = MTIOCGET; | 
 | 582 | 		karg = &get; | 
 | 583 | 		break; | 
 | 584 | 	default: | 
 | 585 | 		do { | 
 | 586 | 			static int count; | 
 | 587 | 			if (++count <= 20) | 
 | 588 | 				printk("mt_ioctl: Unknown cmd fd(%d) " | 
 | 589 | 				       "cmd(%08x) arg(%08x)\n", | 
 | 590 | 				       (int)fd, (unsigned int)cmd, (unsigned int)arg); | 
 | 591 | 		} while(0); | 
 | 592 | 		return -EINVAL; | 
 | 593 | 	} | 
 | 594 | 	set_fs (KERNEL_DS); | 
 | 595 | 	err = sys_ioctl (fd, kcmd, (unsigned long)karg); | 
 | 596 | 	set_fs (old_fs); | 
 | 597 | 	if (err) | 
 | 598 | 		return err; | 
 | 599 | 	switch (cmd) { | 
 | 600 | 	case MTIOCPOS32: | 
 | 601 | 		upos32 = compat_ptr(arg); | 
 | 602 | 		err = __put_user(pos.mt_blkno, &upos32->mt_blkno); | 
 | 603 | 		break; | 
 | 604 | 	case MTIOCGET32: | 
 | 605 | 		umget32 = compat_ptr(arg); | 
 | 606 | 		err = __put_user(get.mt_type, &umget32->mt_type); | 
 | 607 | 		err |= __put_user(get.mt_resid, &umget32->mt_resid); | 
 | 608 | 		err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); | 
 | 609 | 		err |= __put_user(get.mt_gstat, &umget32->mt_gstat); | 
 | 610 | 		err |= __put_user(get.mt_erreg, &umget32->mt_erreg); | 
 | 611 | 		err |= __put_user(get.mt_fileno, &umget32->mt_fileno); | 
 | 612 | 		err |= __put_user(get.mt_blkno, &umget32->mt_blkno); | 
 | 613 | 		break; | 
 | 614 | 	} | 
 | 615 | 	return err ? -EFAULT: 0; | 
 | 616 | } | 
 | 617 |  | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 618 | #endif /* CONFIG_BLOCK */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | #ifdef CONFIG_VT | 
 | 621 |  | 
 | 622 | static int vt_check(struct file *file) | 
 | 623 | { | 
 | 624 | 	struct tty_struct *tty; | 
| Josef "Jeff" Sipek | 0f7fc9e | 2006-12-08 02:36:35 -0800 | [diff] [blame] | 625 | 	struct inode *inode = file->f_path.dentry->d_inode; | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 626 | 	struct vc_data *vc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | 	 | 
| Alan Cox | 04f378b | 2008-04-30 00:53:29 -0700 | [diff] [blame] | 628 | 	if (file->f_op->unlocked_ioctl != tty_ioctl) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | 		return -EINVAL; | 
 | 630 | 	                 | 
 | 631 | 	tty = (struct tty_struct *)file->private_data; | 
 | 632 | 	if (tty_paranoia_check(tty, inode, "tty_ioctl")) | 
 | 633 | 		return -EINVAL; | 
 | 634 | 	                                                 | 
| Alan Cox | f34d7a5 | 2008-04-30 00:54:13 -0700 | [diff] [blame] | 635 | 	if (tty->ops->ioctl != vt_ioctl) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | 		return -EINVAL; | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 637 |  | 
 | 638 | 	vc = (struct vc_data *)tty->driver_data; | 
 | 639 | 	if (!vc_cons_allocated(vc->vc_num)) 	/* impossible? */ | 
 | 640 | 		return -ENOIOCTLCMD; | 
 | 641 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | 	/* | 
 | 643 | 	 * To have permissions to do most of the vt ioctls, we either have | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 644 | 	 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | 	 */ | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 646 | 	if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | 		return 1; | 
 | 648 | 	return 0;                                                     | 
 | 649 | } | 
 | 650 |  | 
 | 651 | struct consolefontdesc32 { | 
 | 652 | 	unsigned short charcount;       /* characters in font (256 or 512) */ | 
 | 653 | 	unsigned short charheight;      /* scan lines per character (1-32) */ | 
 | 654 | 	compat_caddr_t chardata;	/* font data in expanded form */ | 
 | 655 | }; | 
 | 656 |  | 
 | 657 | static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | 
 | 658 | { | 
 | 659 | 	struct consolefontdesc32 __user *user_cfd = compat_ptr(arg); | 
 | 660 | 	struct console_font_op op; | 
 | 661 | 	compat_caddr_t data; | 
 | 662 | 	int i, perm; | 
 | 663 |  | 
 | 664 | 	perm = vt_check(file); | 
 | 665 | 	if (perm < 0) return perm; | 
 | 666 | 	 | 
 | 667 | 	switch (cmd) { | 
 | 668 | 	case PIO_FONTX: | 
 | 669 | 		if (!perm) | 
 | 670 | 			return -EPERM; | 
 | 671 | 		op.op = KD_FONT_OP_SET; | 
 | 672 | 		op.flags = 0; | 
 | 673 | 		op.width = 8; | 
 | 674 | 		if (get_user(op.height, &user_cfd->charheight) || | 
 | 675 | 		    get_user(op.charcount, &user_cfd->charcount) || | 
 | 676 | 		    get_user(data, &user_cfd->chardata)) | 
 | 677 | 			return -EFAULT; | 
 | 678 | 		op.data = compat_ptr(data); | 
 | 679 | 		return con_font_op(vc_cons[fg_console].d, &op); | 
 | 680 | 	case GIO_FONTX: | 
 | 681 | 		op.op = KD_FONT_OP_GET; | 
 | 682 | 		op.flags = 0; | 
 | 683 | 		op.width = 8; | 
 | 684 | 		if (get_user(op.height, &user_cfd->charheight) || | 
 | 685 | 		    get_user(op.charcount, &user_cfd->charcount) || | 
 | 686 | 		    get_user(data, &user_cfd->chardata)) | 
 | 687 | 			return -EFAULT; | 
 | 688 | 		if (!data) | 
 | 689 | 			return 0; | 
 | 690 | 		op.data = compat_ptr(data); | 
 | 691 | 		i = con_font_op(vc_cons[fg_console].d, &op); | 
 | 692 | 		if (i) | 
 | 693 | 			return i; | 
 | 694 | 		if (put_user(op.height, &user_cfd->charheight) || | 
 | 695 | 		    put_user(op.charcount, &user_cfd->charcount) || | 
 | 696 | 		    put_user((compat_caddr_t)(unsigned long)op.data, | 
 | 697 | 				&user_cfd->chardata)) | 
 | 698 | 			return -EFAULT; | 
 | 699 | 		return 0; | 
 | 700 | 	} | 
 | 701 | 	return -EINVAL; | 
 | 702 | } | 
 | 703 |  | 
 | 704 | struct console_font_op32 { | 
 | 705 | 	compat_uint_t op;        /* operation code KD_FONT_OP_* */ | 
 | 706 | 	compat_uint_t flags;     /* KD_FONT_FLAG_* */ | 
 | 707 | 	compat_uint_t width, height;     /* font size */ | 
 | 708 | 	compat_uint_t charcount; | 
 | 709 | 	compat_caddr_t data;    /* font data with height fixed to 32 */ | 
 | 710 | }; | 
 | 711 |                                          | 
 | 712 | static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | 
 | 713 | { | 
 | 714 | 	struct console_font_op op; | 
 | 715 | 	struct console_font_op32 __user *fontop = compat_ptr(arg); | 
 | 716 | 	int perm = vt_check(file), i; | 
 | 717 | 	struct vc_data *vc; | 
 | 718 | 	 | 
 | 719 | 	if (perm < 0) return perm; | 
 | 720 | 	 | 
 | 721 | 	if (copy_from_user(&op, fontop, sizeof(struct console_font_op32))) | 
 | 722 | 		return -EFAULT; | 
 | 723 | 	if (!perm && op.op != KD_FONT_OP_GET) | 
 | 724 | 		return -EPERM; | 
 | 725 | 	op.data = compat_ptr(((struct console_font_op32 *)&op)->data); | 
 | 726 | 	op.flags |= KD_FONT_FLAG_OLD; | 
 | 727 | 	vc = ((struct tty_struct *)file->private_data)->driver_data; | 
 | 728 | 	i = con_font_op(vc, &op); | 
 | 729 | 	if (i) | 
 | 730 | 		return i; | 
 | 731 | 	((struct console_font_op32 *)&op)->data = (unsigned long)op.data; | 
 | 732 | 	if (copy_to_user(fontop, &op, sizeof(struct console_font_op32))) | 
 | 733 | 		return -EFAULT; | 
 | 734 | 	return 0; | 
 | 735 | } | 
 | 736 |  | 
 | 737 | struct unimapdesc32 { | 
 | 738 | 	unsigned short entry_ct; | 
 | 739 | 	compat_caddr_t entries; | 
 | 740 | }; | 
 | 741 |  | 
 | 742 | static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | 
 | 743 | { | 
 | 744 | 	struct unimapdesc32 tmp; | 
 | 745 | 	struct unimapdesc32 __user *user_ud = compat_ptr(arg); | 
 | 746 | 	int perm = vt_check(file); | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 747 | 	struct vc_data *vc; | 
 | 748 |  | 
 | 749 | 	if (perm < 0) | 
 | 750 | 		return perm; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | 	if (copy_from_user(&tmp, user_ud, sizeof tmp)) | 
 | 752 | 		return -EFAULT; | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 753 | 	if (tmp.entries) | 
 | 754 | 		if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries), | 
 | 755 | 				tmp.entry_ct*sizeof(struct unipair))) | 
 | 756 | 			return -EFAULT; | 
 | 757 | 	vc = ((struct tty_struct *)file->private_data)->driver_data; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | 	switch (cmd) { | 
 | 759 | 	case PIO_UNIMAP: | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 760 | 		if (!perm) | 
 | 761 | 			return -EPERM; | 
 | 762 | 		return con_set_unimap(vc, tmp.entry_ct, | 
 | 763 | 						compat_ptr(tmp.entries)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | 	case GIO_UNIMAP: | 
| Hugh Dickins | f4d43bd | 2007-05-26 00:39:17 +0100 | [diff] [blame] | 765 | 		if (!perm && fg_console != vc->vc_num) | 
 | 766 | 			return -EPERM; | 
 | 767 | 		return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), | 
 | 768 | 						compat_ptr(tmp.entries)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | 	} | 
 | 770 | 	return 0; | 
 | 771 | } | 
 | 772 |  | 
 | 773 | #endif /* CONFIG_VT */ | 
 | 774 |  | 
 | 775 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 776 | { | 
 | 777 | 	mm_segment_t old_fs = get_fs(); | 
 | 778 | 	__kernel_uid_t kuid; | 
 | 779 | 	int err; | 
 | 780 |  | 
 | 781 | 	cmd = SMB_IOC_GETMOUNTUID; | 
 | 782 |  | 
 | 783 | 	set_fs(KERNEL_DS); | 
 | 784 | 	err = sys_ioctl(fd, cmd, (unsigned long)&kuid); | 
 | 785 | 	set_fs(old_fs); | 
 | 786 |  | 
 | 787 | 	if (err >= 0) | 
 | 788 | 		err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg)); | 
 | 789 |  | 
 | 790 | 	return err; | 
 | 791 | } | 
 | 792 |  | 
| Adrian Bunk | 3ff6eec | 2008-01-24 22:16:20 +0100 | [diff] [blame] | 793 | static __used int | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 795 | { | 
 | 796 | 	return -EINVAL; | 
 | 797 | } | 
 | 798 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 800 | { | 
 | 801 | 	return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); | 
 | 802 | } | 
 | 803 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | /* Bluetooth ioctls */ | 
 | 805 | #define HCIUARTSETPROTO	_IOW('U', 200, int) | 
 | 806 | #define HCIUARTGETPROTO	_IOR('U', 201, int) | 
 | 807 |  | 
 | 808 | #define BNEPCONNADD	_IOW('B', 200, int) | 
 | 809 | #define BNEPCONNDEL	_IOW('B', 201, int) | 
 | 810 | #define BNEPGETCONNLIST	_IOR('B', 210, int) | 
 | 811 | #define BNEPGETCONNINFO	_IOR('B', 211, int) | 
 | 812 |  | 
 | 813 | #define CMTPCONNADD	_IOW('C', 200, int) | 
 | 814 | #define CMTPCONNDEL	_IOW('C', 201, int) | 
 | 815 | #define CMTPGETCONNLIST	_IOR('C', 210, int) | 
 | 816 | #define CMTPGETCONNINFO	_IOR('C', 211, int) | 
 | 817 |  | 
 | 818 | #define HIDPCONNADD	_IOW('H', 200, int) | 
 | 819 | #define HIDPCONNDEL	_IOW('H', 201, int) | 
 | 820 | #define HIDPGETCONNLIST	_IOR('H', 210, int) | 
 | 821 | #define HIDPGETCONNINFO	_IOR('H', 211, int) | 
 | 822 |  | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 823 | #ifdef CONFIG_BLOCK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | struct raw32_config_request | 
 | 825 | { | 
 | 826 |         compat_int_t    raw_minor; | 
 | 827 |         __u64   block_major; | 
 | 828 |         __u64   block_minor; | 
 | 829 | } __attribute__((packed)); | 
 | 830 |  | 
 | 831 | static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req) | 
 | 832 | { | 
 | 833 |         int ret; | 
 | 834 |  | 
 | 835 |         if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request))) | 
 | 836 |                 return -EFAULT; | 
 | 837 |  | 
 | 838 |         ret = __get_user(req->raw_minor, &user_req->raw_minor); | 
 | 839 |         ret |= __get_user(req->block_major, &user_req->block_major); | 
 | 840 |         ret |= __get_user(req->block_minor, &user_req->block_minor); | 
 | 841 |  | 
 | 842 |         return ret ? -EFAULT : 0; | 
 | 843 | } | 
 | 844 |  | 
 | 845 | static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req) | 
 | 846 | { | 
 | 847 | 	int ret; | 
 | 848 |  | 
 | 849 |         if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request))) | 
 | 850 |                 return -EFAULT; | 
 | 851 |  | 
 | 852 |         ret = __put_user(req->raw_minor, &user_req->raw_minor); | 
 | 853 |         ret |= __put_user(req->block_major, &user_req->block_major); | 
 | 854 |         ret |= __put_user(req->block_minor, &user_req->block_minor); | 
 | 855 |  | 
 | 856 |         return ret ? -EFAULT : 0; | 
 | 857 | } | 
 | 858 |  | 
 | 859 | static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 
 | 860 | { | 
 | 861 |         int ret; | 
 | 862 |  | 
 | 863 |         switch (cmd) { | 
 | 864 |         case RAW_SETBIND: | 
 | 865 |         case RAW_GETBIND: { | 
 | 866 |                 struct raw_config_request req; | 
 | 867 |                 struct raw32_config_request __user *user_req = compat_ptr(arg); | 
 | 868 |                 mm_segment_t oldfs = get_fs(); | 
 | 869 |  | 
 | 870 |                 if ((ret = get_raw32_request(&req, user_req))) | 
 | 871 |                         return ret; | 
 | 872 |  | 
 | 873 |                 set_fs(KERNEL_DS); | 
 | 874 |                 ret = sys_ioctl(fd,cmd,(unsigned long)&req); | 
 | 875 |                 set_fs(oldfs); | 
 | 876 |  | 
 | 877 |                 if ((!ret) && (cmd == RAW_GETBIND)) { | 
 | 878 |                         ret = set_raw32_request(&req, user_req); | 
 | 879 |                 } | 
 | 880 |                 break; | 
 | 881 |         } | 
 | 882 |         default: | 
 | 883 |                 ret = sys_ioctl(fd, cmd, arg); | 
 | 884 |                 break; | 
 | 885 |         } | 
 | 886 |         return ret; | 
 | 887 | } | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 888 | #endif /* CONFIG_BLOCK */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 |  | 
 | 890 | struct serial_struct32 { | 
 | 891 |         compat_int_t    type; | 
 | 892 |         compat_int_t    line; | 
 | 893 |         compat_uint_t   port; | 
 | 894 |         compat_int_t    irq; | 
 | 895 |         compat_int_t    flags; | 
 | 896 |         compat_int_t    xmit_fifo_size; | 
 | 897 |         compat_int_t    custom_divisor; | 
 | 898 |         compat_int_t    baud_base; | 
 | 899 |         unsigned short  close_delay; | 
 | 900 |         char    io_type; | 
 | 901 |         char    reserved_char[1]; | 
 | 902 |         compat_int_t    hub6; | 
 | 903 |         unsigned short  closing_wait; /* time to wait before closing */ | 
 | 904 |         unsigned short  closing_wait2; /* no longer used... */ | 
 | 905 |         compat_uint_t   iomem_base; | 
 | 906 |         unsigned short  iomem_reg_shift; | 
 | 907 |         unsigned int    port_high; | 
 | 908 |      /* compat_ulong_t  iomap_base FIXME */ | 
 | 909 |         compat_int_t    reserved[1]; | 
 | 910 | }; | 
 | 911 |  | 
 | 912 | static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 
 | 913 | { | 
 | 914 |         typedef struct serial_struct SS; | 
 | 915 |         typedef struct serial_struct32 SS32; | 
 | 916 |         struct serial_struct32 __user *ss32 = compat_ptr(arg); | 
 | 917 |         int err; | 
 | 918 |         struct serial_struct ss; | 
 | 919 |         mm_segment_t oldseg = get_fs(); | 
 | 920 |         __u32 udata; | 
| Heiko Carstens | 7116e99 | 2006-12-06 20:36:36 -0800 | [diff] [blame] | 921 | 	unsigned int base; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 |  | 
 | 923 |         if (cmd == TIOCSSERIAL) { | 
 | 924 |                 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32))) | 
 | 925 |                         return -EFAULT; | 
 | 926 |                 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base))) | 
 | 927 | 			return -EFAULT; | 
| Heiko Carstens | 7116e99 | 2006-12-06 20:36:36 -0800 | [diff] [blame] | 928 |                 if (__get_user(udata, &ss32->iomem_base)) | 
 | 929 | 			return -EFAULT; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 |                 ss.iomem_base = compat_ptr(udata); | 
| Heiko Carstens | 7116e99 | 2006-12-06 20:36:36 -0800 | [diff] [blame] | 931 |                 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) || | 
 | 932 | 		    __get_user(ss.port_high, &ss32->port_high)) | 
 | 933 | 			return -EFAULT; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 |                 ss.iomap_base = 0UL; | 
 | 935 |         } | 
 | 936 |         set_fs(KERNEL_DS); | 
 | 937 |                 err = sys_ioctl(fd,cmd,(unsigned long)(&ss)); | 
 | 938 |         set_fs(oldseg); | 
 | 939 |         if (cmd == TIOCGSERIAL && err >= 0) { | 
 | 940 |                 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32))) | 
 | 941 |                         return -EFAULT; | 
 | 942 |                 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base))) | 
 | 943 | 			return -EFAULT; | 
| Heiko Carstens | 7116e99 | 2006-12-06 20:36:36 -0800 | [diff] [blame] | 944 | 		base = (unsigned long)ss.iomem_base  >> 32 ? | 
 | 945 | 			0xffffffff : (unsigned)(unsigned long)ss.iomem_base; | 
 | 946 | 		if (__put_user(base, &ss32->iomem_base) || | 
 | 947 | 		    __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) || | 
 | 948 | 		    __put_user(ss.port_high, &ss32->port_high)) | 
 | 949 | 			return -EFAULT; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 |         } | 
 | 951 |         return err; | 
 | 952 | } | 
 | 953 |  | 
 | 954 | struct usbdevfs_ctrltransfer32 { | 
 | 955 |         u8 bRequestType; | 
 | 956 |         u8 bRequest; | 
 | 957 |         u16 wValue; | 
 | 958 |         u16 wIndex; | 
 | 959 |         u16 wLength; | 
 | 960 |         u32 timeout;  /* in milliseconds */ | 
 | 961 |         compat_caddr_t data; | 
 | 962 | }; | 
 | 963 |  | 
 | 964 | #define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32) | 
 | 965 |  | 
 | 966 | static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 967 | { | 
 | 968 |         struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg); | 
 | 969 |         struct usbdevfs_ctrltransfer __user *p; | 
 | 970 |         __u32 udata; | 
 | 971 |         p = compat_alloc_user_space(sizeof(*p)); | 
 | 972 |         if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || | 
 | 973 |             get_user(udata, &p32->data) || | 
 | 974 | 	    put_user(compat_ptr(udata), &p->data)) | 
 | 975 | 		return -EFAULT; | 
 | 976 |         return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p); | 
 | 977 | } | 
 | 978 |  | 
 | 979 |  | 
 | 980 | struct usbdevfs_bulktransfer32 { | 
 | 981 |         compat_uint_t ep; | 
 | 982 |         compat_uint_t len; | 
 | 983 |         compat_uint_t timeout; /* in milliseconds */ | 
 | 984 |         compat_caddr_t data; | 
 | 985 | }; | 
 | 986 |  | 
 | 987 | #define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32) | 
 | 988 |  | 
 | 989 | static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 990 | { | 
 | 991 |         struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg); | 
 | 992 |         struct usbdevfs_bulktransfer __user *p; | 
 | 993 |         compat_uint_t n; | 
 | 994 |         compat_caddr_t addr; | 
 | 995 |  | 
 | 996 |         p = compat_alloc_user_space(sizeof(*p)); | 
 | 997 |  | 
 | 998 |         if (get_user(n, &p32->ep) || put_user(n, &p->ep) || | 
 | 999 |             get_user(n, &p32->len) || put_user(n, &p->len) || | 
 | 1000 |             get_user(n, &p32->timeout) || put_user(n, &p->timeout) || | 
 | 1001 |             get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data)) | 
 | 1002 |                 return -EFAULT; | 
 | 1003 |  | 
 | 1004 |         return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p); | 
 | 1005 | } | 
 | 1006 |  | 
 | 1007 |  | 
 | 1008 | /* | 
 | 1009 |  *  USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY | 
 | 1010 |  *  are handled in usbdevfs core.			-Christopher Li | 
 | 1011 |  */ | 
 | 1012 |  | 
 | 1013 | struct usbdevfs_disconnectsignal32 { | 
 | 1014 |         compat_int_t signr; | 
 | 1015 |         compat_caddr_t context; | 
 | 1016 | }; | 
 | 1017 |  | 
 | 1018 | #define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32) | 
 | 1019 |  | 
 | 1020 | static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 1021 | { | 
 | 1022 |         struct usbdevfs_disconnectsignal kdis; | 
 | 1023 |         struct usbdevfs_disconnectsignal32 __user *udis; | 
 | 1024 |         mm_segment_t old_fs; | 
 | 1025 |         u32 uctx; | 
 | 1026 |         int err; | 
 | 1027 |  | 
 | 1028 |         udis = compat_ptr(arg); | 
 | 1029 |  | 
 | 1030 |         if (get_user(kdis.signr, &udis->signr) || | 
 | 1031 |             __get_user(uctx, &udis->context)) | 
 | 1032 |                 return -EFAULT; | 
 | 1033 |  | 
 | 1034 |         kdis.context = compat_ptr(uctx); | 
 | 1035 |  | 
 | 1036 |         old_fs = get_fs(); | 
 | 1037 |         set_fs(KERNEL_DS); | 
 | 1038 |         err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis); | 
 | 1039 |         set_fs(old_fs); | 
 | 1040 |  | 
 | 1041 |         return err; | 
 | 1042 | } | 
 | 1043 |  | 
 | 1044 | /* | 
 | 1045 |  * I2C layer ioctls | 
 | 1046 |  */ | 
 | 1047 |  | 
 | 1048 | struct i2c_msg32 { | 
 | 1049 | 	u16 addr; | 
 | 1050 | 	u16 flags; | 
 | 1051 | 	u16 len; | 
 | 1052 | 	compat_caddr_t buf; | 
 | 1053 | }; | 
 | 1054 |  | 
 | 1055 | struct i2c_rdwr_ioctl_data32 { | 
 | 1056 | 	compat_caddr_t msgs; /* struct i2c_msg __user *msgs */ | 
 | 1057 | 	u32 nmsgs; | 
 | 1058 | }; | 
 | 1059 |  | 
 | 1060 | struct i2c_smbus_ioctl_data32 { | 
 | 1061 | 	u8 read_write; | 
 | 1062 | 	u8 command; | 
 | 1063 | 	u32 size; | 
 | 1064 | 	compat_caddr_t data; /* union i2c_smbus_data *data */ | 
 | 1065 | }; | 
 | 1066 |  | 
 | 1067 | struct i2c_rdwr_aligned { | 
 | 1068 | 	struct i2c_rdwr_ioctl_data cmd; | 
 | 1069 | 	struct i2c_msg msgs[0]; | 
 | 1070 | }; | 
 | 1071 |  | 
 | 1072 | static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 1073 | { | 
 | 1074 | 	struct i2c_rdwr_ioctl_data32	__user *udata = compat_ptr(arg); | 
 | 1075 | 	struct i2c_rdwr_aligned		__user *tdata; | 
 | 1076 | 	struct i2c_msg			__user *tmsgs; | 
 | 1077 | 	struct i2c_msg32		__user *umsgs; | 
 | 1078 | 	compat_caddr_t			datap; | 
 | 1079 | 	int				nmsgs, i; | 
 | 1080 |  | 
 | 1081 | 	if (get_user(nmsgs, &udata->nmsgs)) | 
 | 1082 | 		return -EFAULT; | 
 | 1083 | 	if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) | 
 | 1084 | 		return -EINVAL; | 
 | 1085 |  | 
 | 1086 | 	if (get_user(datap, &udata->msgs)) | 
 | 1087 | 		return -EFAULT; | 
 | 1088 | 	umsgs = compat_ptr(datap); | 
 | 1089 |  | 
 | 1090 | 	tdata = compat_alloc_user_space(sizeof(*tdata) + | 
 | 1091 | 				      nmsgs * sizeof(struct i2c_msg)); | 
 | 1092 | 	tmsgs = &tdata->msgs[0]; | 
 | 1093 |  | 
 | 1094 | 	if (put_user(nmsgs, &tdata->cmd.nmsgs) || | 
 | 1095 | 	    put_user(tmsgs, &tdata->cmd.msgs)) | 
 | 1096 | 		return -EFAULT; | 
 | 1097 |  | 
 | 1098 | 	for (i = 0; i < nmsgs; i++) { | 
 | 1099 | 		if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16))) | 
 | 1100 | 			return -EFAULT; | 
 | 1101 | 		if (get_user(datap, &umsgs[i].buf) || | 
 | 1102 | 		    put_user(compat_ptr(datap), &tmsgs[i].buf)) | 
 | 1103 | 			return -EFAULT; | 
 | 1104 | 	} | 
 | 1105 | 	return sys_ioctl(fd, cmd, (unsigned long)tdata); | 
 | 1106 | } | 
 | 1107 |  | 
 | 1108 | static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 1109 | { | 
 | 1110 | 	struct i2c_smbus_ioctl_data	__user *tdata; | 
 | 1111 | 	struct i2c_smbus_ioctl_data32	__user *udata; | 
 | 1112 | 	compat_caddr_t			datap; | 
 | 1113 |  | 
 | 1114 | 	tdata = compat_alloc_user_space(sizeof(*tdata)); | 
 | 1115 | 	if (tdata == NULL) | 
 | 1116 | 		return -ENOMEM; | 
 | 1117 | 	if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata))) | 
 | 1118 | 		return -EFAULT; | 
 | 1119 |  | 
 | 1120 | 	udata = compat_ptr(arg); | 
 | 1121 | 	if (!access_ok(VERIFY_READ, udata, sizeof(*udata))) | 
 | 1122 | 		return -EFAULT; | 
 | 1123 |  | 
 | 1124 | 	if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8))) | 
 | 1125 | 		return -EFAULT; | 
 | 1126 | 	if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32))) | 
 | 1127 | 		return -EFAULT; | 
 | 1128 | 	if (__get_user(datap, &udata->data) || | 
 | 1129 | 	    __put_user(compat_ptr(datap), &tdata->data)) | 
 | 1130 | 		return -EFAULT; | 
 | 1131 |  | 
 | 1132 | 	return sys_ioctl(fd, cmd, (unsigned long)tdata); | 
 | 1133 | } | 
 | 1134 |  | 
| Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 1135 | #define RTC_IRQP_READ32		_IOR('p', 0x0b, compat_ulong_t) | 
 | 1136 | #define RTC_IRQP_SET32		_IOW('p', 0x0c, compat_ulong_t) | 
 | 1137 | #define RTC_EPOCH_READ32	_IOR('p', 0x0d, compat_ulong_t) | 
 | 1138 | #define RTC_EPOCH_SET32		_IOW('p', 0x0e, compat_ulong_t) | 
 | 1139 |  | 
 | 1140 | static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 
 | 1141 | { | 
 | 1142 | 	mm_segment_t oldfs = get_fs(); | 
 | 1143 | 	compat_ulong_t val32; | 
 | 1144 | 	unsigned long kval; | 
 | 1145 | 	int ret; | 
 | 1146 |  | 
 | 1147 | 	switch (cmd) { | 
 | 1148 | 	case RTC_IRQP_READ32: | 
 | 1149 | 	case RTC_EPOCH_READ32: | 
 | 1150 | 		set_fs(KERNEL_DS); | 
 | 1151 | 		ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ? | 
 | 1152 | 					RTC_IRQP_READ : RTC_EPOCH_READ, | 
 | 1153 | 					(unsigned long)&kval); | 
 | 1154 | 		set_fs(oldfs); | 
 | 1155 | 		if (ret) | 
 | 1156 | 			return ret; | 
 | 1157 | 		val32 = kval; | 
 | 1158 | 		return put_user(val32, (unsigned int __user *)arg); | 
 | 1159 | 	case RTC_IRQP_SET32: | 
| Andi Kleen | fc5870f | 2006-02-26 04:18:55 +0100 | [diff] [blame] | 1160 | 		return sys_ioctl(fd, RTC_IRQP_SET, arg);  | 
| Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 1161 | 	case RTC_EPOCH_SET32: | 
| Andi Kleen | fc5870f | 2006-02-26 04:18:55 +0100 | [diff] [blame] | 1162 | 		return sys_ioctl(fd, RTC_EPOCH_SET, arg); | 
| Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 1163 | 	default: | 
 | 1164 | 		/* unreached */ | 
 | 1165 | 		return -ENOIOCTLCMD; | 
 | 1166 | 	} | 
 | 1167 | } | 
 | 1168 |  | 
| Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 1169 | static int | 
 | 1170 | lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 
 | 1171 | { | 
| Al Viro | 6b2b4e5 | 2006-02-01 06:33:33 -0500 | [diff] [blame] | 1172 | 	struct compat_timeval __user *tc = (struct compat_timeval __user *)arg; | 
 | 1173 | 	struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval)); | 
| Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 1174 | 	struct timeval ts; | 
 | 1175 | 	if (get_user(ts.tv_sec, &tc->tv_sec) || | 
 | 1176 | 	    get_user(ts.tv_usec, &tc->tv_usec) || | 
 | 1177 | 	    put_user(ts.tv_sec, &tn->tv_sec) || | 
 | 1178 | 	    put_user(ts.tv_usec, &tn->tv_usec)) | 
 | 1179 | 		return -EFAULT; | 
 | 1180 | 	return sys_ioctl(fd, cmd, (unsigned long)tn); | 
 | 1181 | } | 
 | 1182 |  | 
| Ankit Jain | 3e63cbb | 2009-06-19 14:28:07 -0400 | [diff] [blame] | 1183 | /* on ia32 l_start is on a 32-bit boundary */ | 
 | 1184 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | 
 | 1185 | struct space_resv_32 { | 
 | 1186 | 	__s16		l_type; | 
 | 1187 | 	__s16		l_whence; | 
 | 1188 | 	__s64		l_start	__attribute__((packed)); | 
 | 1189 | 			/* len == 0 means until end of file */ | 
 | 1190 | 	__s64		l_len __attribute__((packed)); | 
 | 1191 | 	__s32		l_sysid; | 
 | 1192 | 	__u32		l_pid; | 
 | 1193 | 	__s32		l_pad[4];	/* reserve area */ | 
 | 1194 | }; | 
 | 1195 |  | 
 | 1196 | #define FS_IOC_RESVSP_32		_IOW ('X', 40, struct space_resv_32) | 
 | 1197 | #define FS_IOC_RESVSP64_32	_IOW ('X', 42, struct space_resv_32) | 
 | 1198 |  | 
 | 1199 | /* just account for different alignment */ | 
 | 1200 | static int compat_ioctl_preallocate(struct file *file, unsigned long arg) | 
 | 1201 | { | 
| Heiko Carstens | 7779d7b | 2009-11-11 14:26:34 -0800 | [diff] [blame] | 1202 | 	struct space_resv_32	__user *p32 = compat_ptr(arg); | 
| Ankit Jain | 3e63cbb | 2009-06-19 14:28:07 -0400 | [diff] [blame] | 1203 | 	struct space_resv	__user *p = compat_alloc_user_space(sizeof(*p)); | 
 | 1204 |  | 
 | 1205 | 	if (copy_in_user(&p->l_type,	&p32->l_type,	sizeof(s16)) || | 
 | 1206 | 	    copy_in_user(&p->l_whence,	&p32->l_whence, sizeof(s16)) || | 
 | 1207 | 	    copy_in_user(&p->l_start,	&p32->l_start,	sizeof(s64)) || | 
 | 1208 | 	    copy_in_user(&p->l_len,	&p32->l_len,	sizeof(s64)) || | 
 | 1209 | 	    copy_in_user(&p->l_sysid,	&p32->l_sysid,	sizeof(s32)) || | 
 | 1210 | 	    copy_in_user(&p->l_pid,	&p32->l_pid,	sizeof(u32)) || | 
 | 1211 | 	    copy_in_user(&p->l_pad,	&p32->l_pad,	4*sizeof(u32))) | 
 | 1212 | 		return -EFAULT; | 
 | 1213 |  | 
 | 1214 | 	return ioctl_preallocate(file, p); | 
 | 1215 | } | 
 | 1216 | #endif | 
 | 1217 |  | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 1218 |  | 
 | 1219 | typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, | 
 | 1220 | 					unsigned long, struct file *); | 
 | 1221 |  | 
 | 1222 | struct ioctl_trans { | 
 | 1223 | 	unsigned long cmd; | 
 | 1224 | 	ioctl_trans_handler_t handler; | 
 | 1225 | 	struct ioctl_trans *next; | 
 | 1226 | }; | 
 | 1227 |  | 
| Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 1228 | #define HANDLE_IOCTL(cmd,handler) \ | 
 | 1229 | 	{ (cmd), (ioctl_trans_handler_t)(handler) }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 |  | 
| Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 1231 | /* pointer to compatible structure or no argument */ | 
 | 1232 | #define COMPATIBLE_IOCTL(cmd) \ | 
 | 1233 | 	{ (cmd), do_ioctl32_pointer }, | 
 | 1234 |  | 
 | 1235 | /* argument is an unsigned long integer, not a pointer */ | 
 | 1236 | #define ULONG_IOCTL(cmd) \ | 
 | 1237 | 	{ (cmd), (ioctl_trans_handler_t)sys_ioctl }, | 
 | 1238 |  | 
| Andi Kleen | 421f028 | 2007-05-02 19:27:20 +0200 | [diff] [blame] | 1239 | /* ioctl should not be warned about even if it's not implemented. | 
 | 1240 |    Valid reasons to use this: | 
 | 1241 |    - It is implemented with ->compat_ioctl on some device, but programs | 
 | 1242 |    call it on others too. | 
 | 1243 |    - The ioctl is not implemented in the native kernel, but programs | 
 | 1244 |    call it commonly anyways. | 
 | 1245 |    Most other reasons are not valid. */ | 
 | 1246 | #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd) | 
| Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 1247 |  | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 1248 | static struct ioctl_trans ioctl_start[] = { | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1249 | /* compatible ioctls first */ | 
 | 1250 | COMPATIBLE_IOCTL(0x4B50)   /* KDGHWCLK - not in the kernel, but don't complain */ | 
 | 1251 | COMPATIBLE_IOCTL(0x4B51)   /* KDSHWCLK - not in the kernel, but don't complain */ | 
 | 1252 |  | 
 | 1253 | /* Big T */ | 
 | 1254 | COMPATIBLE_IOCTL(TCGETA) | 
 | 1255 | COMPATIBLE_IOCTL(TCSETA) | 
 | 1256 | COMPATIBLE_IOCTL(TCSETAW) | 
 | 1257 | COMPATIBLE_IOCTL(TCSETAF) | 
 | 1258 | COMPATIBLE_IOCTL(TCSBRK) | 
 | 1259 | ULONG_IOCTL(TCSBRKP) | 
 | 1260 | COMPATIBLE_IOCTL(TCXONC) | 
 | 1261 | COMPATIBLE_IOCTL(TCFLSH) | 
 | 1262 | COMPATIBLE_IOCTL(TCGETS) | 
 | 1263 | COMPATIBLE_IOCTL(TCSETS) | 
 | 1264 | COMPATIBLE_IOCTL(TCSETSW) | 
 | 1265 | COMPATIBLE_IOCTL(TCSETSF) | 
 | 1266 | COMPATIBLE_IOCTL(TIOCLINUX) | 
 | 1267 | COMPATIBLE_IOCTL(TIOCSBRK) | 
 | 1268 | COMPATIBLE_IOCTL(TIOCCBRK) | 
 | 1269 | ULONG_IOCTL(TIOCMIWAIT) | 
 | 1270 | COMPATIBLE_IOCTL(TIOCGICOUNT) | 
 | 1271 | /* Little t */ | 
 | 1272 | COMPATIBLE_IOCTL(TIOCGETD) | 
 | 1273 | COMPATIBLE_IOCTL(TIOCSETD) | 
 | 1274 | COMPATIBLE_IOCTL(TIOCEXCL) | 
 | 1275 | COMPATIBLE_IOCTL(TIOCNXCL) | 
 | 1276 | COMPATIBLE_IOCTL(TIOCCONS) | 
 | 1277 | COMPATIBLE_IOCTL(TIOCGSOFTCAR) | 
 | 1278 | COMPATIBLE_IOCTL(TIOCSSOFTCAR) | 
 | 1279 | COMPATIBLE_IOCTL(TIOCSWINSZ) | 
 | 1280 | COMPATIBLE_IOCTL(TIOCGWINSZ) | 
 | 1281 | COMPATIBLE_IOCTL(TIOCMGET) | 
 | 1282 | COMPATIBLE_IOCTL(TIOCMBIC) | 
 | 1283 | COMPATIBLE_IOCTL(TIOCMBIS) | 
 | 1284 | COMPATIBLE_IOCTL(TIOCMSET) | 
 | 1285 | COMPATIBLE_IOCTL(TIOCPKT) | 
 | 1286 | COMPATIBLE_IOCTL(TIOCNOTTY) | 
 | 1287 | COMPATIBLE_IOCTL(TIOCSTI) | 
 | 1288 | COMPATIBLE_IOCTL(TIOCOUTQ) | 
 | 1289 | COMPATIBLE_IOCTL(TIOCSPGRP) | 
 | 1290 | COMPATIBLE_IOCTL(TIOCGPGRP) | 
 | 1291 | ULONG_IOCTL(TIOCSCTTY) | 
 | 1292 | COMPATIBLE_IOCTL(TIOCGPTN) | 
 | 1293 | COMPATIBLE_IOCTL(TIOCSPTLCK) | 
 | 1294 | COMPATIBLE_IOCTL(TIOCSERGETLSR) | 
| Heiko Carstens | 81257de | 2007-11-28 16:22:07 -0800 | [diff] [blame] | 1295 | #ifdef TCGETS2 | 
 | 1296 | COMPATIBLE_IOCTL(TCGETS2) | 
 | 1297 | COMPATIBLE_IOCTL(TCSETS2) | 
 | 1298 | COMPATIBLE_IOCTL(TCSETSW2) | 
 | 1299 | COMPATIBLE_IOCTL(TCSETSF2) | 
 | 1300 | #endif | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1301 | /* Little f */ | 
 | 1302 | COMPATIBLE_IOCTL(FIOCLEX) | 
 | 1303 | COMPATIBLE_IOCTL(FIONCLEX) | 
 | 1304 | COMPATIBLE_IOCTL(FIOASYNC) | 
 | 1305 | COMPATIBLE_IOCTL(FIONBIO) | 
 | 1306 | COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */ | 
| Eric Sandeen | 69130c7 | 2009-08-06 15:07:37 -0700 | [diff] [blame] | 1307 | COMPATIBLE_IOCTL(FS_IOC_FIEMAP) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1308 | /* 0x00 */ | 
 | 1309 | COMPATIBLE_IOCTL(FIBMAP) | 
 | 1310 | COMPATIBLE_IOCTL(FIGETBSZ) | 
| Christoph Hellwig | 5cf8cf4 | 2009-02-26 21:32:51 +0100 | [diff] [blame] | 1311 | /* 'X' - originally XFS but some now in the VFS */ | 
 | 1312 | COMPATIBLE_IOCTL(FIFREEZE) | 
 | 1313 | COMPATIBLE_IOCTL(FITHAW) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1314 | /* RAID */ | 
 | 1315 | COMPATIBLE_IOCTL(RAID_VERSION) | 
 | 1316 | COMPATIBLE_IOCTL(GET_ARRAY_INFO) | 
 | 1317 | COMPATIBLE_IOCTL(GET_DISK_INFO) | 
 | 1318 | COMPATIBLE_IOCTL(PRINT_RAID_DEBUG) | 
 | 1319 | COMPATIBLE_IOCTL(RAID_AUTORUN) | 
 | 1320 | COMPATIBLE_IOCTL(CLEAR_ARRAY) | 
 | 1321 | COMPATIBLE_IOCTL(ADD_NEW_DISK) | 
 | 1322 | ULONG_IOCTL(HOT_REMOVE_DISK) | 
 | 1323 | COMPATIBLE_IOCTL(SET_ARRAY_INFO) | 
 | 1324 | COMPATIBLE_IOCTL(SET_DISK_INFO) | 
 | 1325 | COMPATIBLE_IOCTL(WRITE_RAID_INFO) | 
 | 1326 | COMPATIBLE_IOCTL(UNPROTECT_ARRAY) | 
 | 1327 | COMPATIBLE_IOCTL(PROTECT_ARRAY) | 
 | 1328 | ULONG_IOCTL(HOT_ADD_DISK) | 
 | 1329 | ULONG_IOCTL(SET_DISK_FAULTY) | 
 | 1330 | COMPATIBLE_IOCTL(RUN_ARRAY) | 
 | 1331 | COMPATIBLE_IOCTL(STOP_ARRAY) | 
 | 1332 | COMPATIBLE_IOCTL(STOP_ARRAY_RO) | 
 | 1333 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) | 
 | 1334 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) | 
 | 1335 | ULONG_IOCTL(SET_BITMAP_FILE) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1336 | /* Big K */ | 
 | 1337 | COMPATIBLE_IOCTL(PIO_FONT) | 
 | 1338 | COMPATIBLE_IOCTL(GIO_FONT) | 
| Bill Nottingham | 2db69a9 | 2009-02-18 14:48:39 -0800 | [diff] [blame] | 1339 | COMPATIBLE_IOCTL(PIO_CMAP) | 
 | 1340 | COMPATIBLE_IOCTL(GIO_CMAP) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1341 | ULONG_IOCTL(KDSIGACCEPT) | 
 | 1342 | COMPATIBLE_IOCTL(KDGETKEYCODE) | 
 | 1343 | COMPATIBLE_IOCTL(KDSETKEYCODE) | 
 | 1344 | ULONG_IOCTL(KIOCSOUND) | 
 | 1345 | ULONG_IOCTL(KDMKTONE) | 
 | 1346 | COMPATIBLE_IOCTL(KDGKBTYPE) | 
 | 1347 | ULONG_IOCTL(KDSETMODE) | 
 | 1348 | COMPATIBLE_IOCTL(KDGETMODE) | 
 | 1349 | ULONG_IOCTL(KDSKBMODE) | 
 | 1350 | COMPATIBLE_IOCTL(KDGKBMODE) | 
 | 1351 | ULONG_IOCTL(KDSKBMETA) | 
 | 1352 | COMPATIBLE_IOCTL(KDGKBMETA) | 
 | 1353 | COMPATIBLE_IOCTL(KDGKBENT) | 
 | 1354 | COMPATIBLE_IOCTL(KDSKBENT) | 
 | 1355 | COMPATIBLE_IOCTL(KDGKBSENT) | 
 | 1356 | COMPATIBLE_IOCTL(KDSKBSENT) | 
 | 1357 | COMPATIBLE_IOCTL(KDGKBDIACR) | 
 | 1358 | COMPATIBLE_IOCTL(KDSKBDIACR) | 
 | 1359 | COMPATIBLE_IOCTL(KDKBDREP) | 
 | 1360 | COMPATIBLE_IOCTL(KDGKBLED) | 
 | 1361 | ULONG_IOCTL(KDSKBLED) | 
 | 1362 | COMPATIBLE_IOCTL(KDGETLED) | 
 | 1363 | ULONG_IOCTL(KDSETLED) | 
 | 1364 | COMPATIBLE_IOCTL(GIO_SCRNMAP) | 
 | 1365 | COMPATIBLE_IOCTL(PIO_SCRNMAP) | 
 | 1366 | COMPATIBLE_IOCTL(GIO_UNISCRNMAP) | 
 | 1367 | COMPATIBLE_IOCTL(PIO_UNISCRNMAP) | 
 | 1368 | COMPATIBLE_IOCTL(PIO_FONTRESET) | 
 | 1369 | COMPATIBLE_IOCTL(PIO_UNIMAPCLR) | 
| Randy Dunlap | 3c3622d | 2008-07-16 08:52:00 -0500 | [diff] [blame] | 1370 | #ifdef CONFIG_BLOCK | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1371 | /* Big S */ | 
 | 1372 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) | 
 | 1373 | COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK) | 
 | 1374 | COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK) | 
 | 1375 | COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY) | 
 | 1376 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER) | 
 | 1377 | COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND) | 
 | 1378 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) | 
 | 1379 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) | 
| Randy Dunlap | 3c3622d | 2008-07-16 08:52:00 -0500 | [diff] [blame] | 1380 | #endif | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1381 | /* Big V */ | 
 | 1382 | COMPATIBLE_IOCTL(VT_SETMODE) | 
 | 1383 | COMPATIBLE_IOCTL(VT_GETMODE) | 
 | 1384 | COMPATIBLE_IOCTL(VT_GETSTATE) | 
 | 1385 | COMPATIBLE_IOCTL(VT_OPENQRY) | 
 | 1386 | ULONG_IOCTL(VT_ACTIVATE) | 
 | 1387 | ULONG_IOCTL(VT_WAITACTIVE) | 
 | 1388 | ULONG_IOCTL(VT_RELDISP) | 
 | 1389 | ULONG_IOCTL(VT_DISALLOCATE) | 
 | 1390 | COMPATIBLE_IOCTL(VT_RESIZE) | 
 | 1391 | COMPATIBLE_IOCTL(VT_RESIZEX) | 
 | 1392 | COMPATIBLE_IOCTL(VT_LOCKSWITCH) | 
 | 1393 | COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) | 
 | 1394 | COMPATIBLE_IOCTL(VT_GETHIFONTMASK) | 
 | 1395 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ | 
 | 1396 | COMPATIBLE_IOCTL(RTC_AIE_ON) | 
 | 1397 | COMPATIBLE_IOCTL(RTC_AIE_OFF) | 
 | 1398 | COMPATIBLE_IOCTL(RTC_UIE_ON) | 
 | 1399 | COMPATIBLE_IOCTL(RTC_UIE_OFF) | 
 | 1400 | COMPATIBLE_IOCTL(RTC_PIE_ON) | 
 | 1401 | COMPATIBLE_IOCTL(RTC_PIE_OFF) | 
 | 1402 | COMPATIBLE_IOCTL(RTC_WIE_ON) | 
 | 1403 | COMPATIBLE_IOCTL(RTC_WIE_OFF) | 
 | 1404 | COMPATIBLE_IOCTL(RTC_ALM_SET) | 
 | 1405 | COMPATIBLE_IOCTL(RTC_ALM_READ) | 
 | 1406 | COMPATIBLE_IOCTL(RTC_RD_TIME) | 
 | 1407 | COMPATIBLE_IOCTL(RTC_SET_TIME) | 
 | 1408 | COMPATIBLE_IOCTL(RTC_WKALM_SET) | 
 | 1409 | COMPATIBLE_IOCTL(RTC_WKALM_RD) | 
 | 1410 | /* | 
 | 1411 |  * These two are only for the sbus rtc driver, but | 
 | 1412 |  * hwclock tries them on every rtc device first when | 
 | 1413 |  * running on sparc.  On other architectures the entries | 
 | 1414 |  * are useless but harmless. | 
 | 1415 |  */ | 
 | 1416 | COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */ | 
 | 1417 | COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */ | 
 | 1418 | /* Little m */ | 
 | 1419 | COMPATIBLE_IOCTL(MTIOCTOP) | 
 | 1420 | /* Socket level stuff */ | 
 | 1421 | COMPATIBLE_IOCTL(FIOQSIZE) | 
| Randy Dunlap | 3c3622d | 2008-07-16 08:52:00 -0500 | [diff] [blame] | 1422 | #ifdef CONFIG_BLOCK | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1423 | /* SG stuff */ | 
 | 1424 | COMPATIBLE_IOCTL(SG_SET_TIMEOUT) | 
 | 1425 | COMPATIBLE_IOCTL(SG_GET_TIMEOUT) | 
 | 1426 | COMPATIBLE_IOCTL(SG_EMULATED_HOST) | 
 | 1427 | ULONG_IOCTL(SG_SET_TRANSFORM) | 
 | 1428 | COMPATIBLE_IOCTL(SG_GET_TRANSFORM) | 
 | 1429 | COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE) | 
 | 1430 | COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE) | 
 | 1431 | COMPATIBLE_IOCTL(SG_GET_SCSI_ID) | 
 | 1432 | COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA) | 
 | 1433 | COMPATIBLE_IOCTL(SG_GET_LOW_DMA) | 
 | 1434 | COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID) | 
 | 1435 | COMPATIBLE_IOCTL(SG_GET_PACK_ID) | 
 | 1436 | COMPATIBLE_IOCTL(SG_GET_NUM_WAITING) | 
 | 1437 | COMPATIBLE_IOCTL(SG_SET_DEBUG) | 
 | 1438 | COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE) | 
 | 1439 | COMPATIBLE_IOCTL(SG_GET_COMMAND_Q) | 
 | 1440 | COMPATIBLE_IOCTL(SG_SET_COMMAND_Q) | 
 | 1441 | COMPATIBLE_IOCTL(SG_GET_VERSION_NUM) | 
 | 1442 | COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN) | 
 | 1443 | COMPATIBLE_IOCTL(SG_SCSI_RESET) | 
 | 1444 | COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE) | 
 | 1445 | COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN) | 
 | 1446 | COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN) | 
| Randy Dunlap | 3c3622d | 2008-07-16 08:52:00 -0500 | [diff] [blame] | 1447 | #endif | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1448 | /* PPP stuff */ | 
 | 1449 | COMPATIBLE_IOCTL(PPPIOCGFLAGS) | 
 | 1450 | COMPATIBLE_IOCTL(PPPIOCSFLAGS) | 
 | 1451 | COMPATIBLE_IOCTL(PPPIOCGASYNCMAP) | 
 | 1452 | COMPATIBLE_IOCTL(PPPIOCSASYNCMAP) | 
 | 1453 | COMPATIBLE_IOCTL(PPPIOCGUNIT) | 
 | 1454 | COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP) | 
 | 1455 | COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP) | 
 | 1456 | COMPATIBLE_IOCTL(PPPIOCGMRU) | 
 | 1457 | COMPATIBLE_IOCTL(PPPIOCSMRU) | 
 | 1458 | COMPATIBLE_IOCTL(PPPIOCSMAXCID) | 
 | 1459 | COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP) | 
 | 1460 | COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP) | 
 | 1461 | COMPATIBLE_IOCTL(PPPIOCXFERUNIT) | 
 | 1462 | /* PPPIOCSCOMPRESS is translated */ | 
 | 1463 | COMPATIBLE_IOCTL(PPPIOCGNPMODE) | 
 | 1464 | COMPATIBLE_IOCTL(PPPIOCSNPMODE) | 
 | 1465 | COMPATIBLE_IOCTL(PPPIOCGDEBUG) | 
 | 1466 | COMPATIBLE_IOCTL(PPPIOCSDEBUG) | 
 | 1467 | /* PPPIOCSPASS is translated */ | 
 | 1468 | /* PPPIOCSACTIVE is translated */ | 
 | 1469 | /* PPPIOCGIDLE is translated */ | 
 | 1470 | COMPATIBLE_IOCTL(PPPIOCNEWUNIT) | 
 | 1471 | COMPATIBLE_IOCTL(PPPIOCATTACH) | 
 | 1472 | COMPATIBLE_IOCTL(PPPIOCDETACH) | 
 | 1473 | COMPATIBLE_IOCTL(PPPIOCSMRRU) | 
 | 1474 | COMPATIBLE_IOCTL(PPPIOCCONNECT) | 
 | 1475 | COMPATIBLE_IOCTL(PPPIOCDISCONN) | 
 | 1476 | COMPATIBLE_IOCTL(PPPIOCATTCHAN) | 
 | 1477 | COMPATIBLE_IOCTL(PPPIOCGCHAN) | 
 | 1478 | /* PPPOX */ | 
 | 1479 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) | 
 | 1480 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) | 
 | 1481 | /* LP */ | 
 | 1482 | COMPATIBLE_IOCTL(LPGETSTATUS) | 
 | 1483 | /* ppdev */ | 
 | 1484 | COMPATIBLE_IOCTL(PPSETMODE) | 
 | 1485 | COMPATIBLE_IOCTL(PPRSTATUS) | 
 | 1486 | COMPATIBLE_IOCTL(PPRCONTROL) | 
 | 1487 | COMPATIBLE_IOCTL(PPWCONTROL) | 
 | 1488 | COMPATIBLE_IOCTL(PPFCONTROL) | 
 | 1489 | COMPATIBLE_IOCTL(PPRDATA) | 
 | 1490 | COMPATIBLE_IOCTL(PPWDATA) | 
 | 1491 | COMPATIBLE_IOCTL(PPCLAIM) | 
 | 1492 | COMPATIBLE_IOCTL(PPRELEASE) | 
 | 1493 | COMPATIBLE_IOCTL(PPYIELD) | 
 | 1494 | COMPATIBLE_IOCTL(PPEXCL) | 
 | 1495 | COMPATIBLE_IOCTL(PPDATADIR) | 
 | 1496 | COMPATIBLE_IOCTL(PPNEGOT) | 
 | 1497 | COMPATIBLE_IOCTL(PPWCTLONIRQ) | 
 | 1498 | COMPATIBLE_IOCTL(PPCLRIRQ) | 
 | 1499 | COMPATIBLE_IOCTL(PPSETPHASE) | 
 | 1500 | COMPATIBLE_IOCTL(PPGETMODES) | 
 | 1501 | COMPATIBLE_IOCTL(PPGETMODE) | 
 | 1502 | COMPATIBLE_IOCTL(PPGETPHASE) | 
 | 1503 | COMPATIBLE_IOCTL(PPGETFLAGS) | 
 | 1504 | COMPATIBLE_IOCTL(PPSETFLAGS) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1505 | /* pktcdvd */ | 
 | 1506 | COMPATIBLE_IOCTL(PACKET_CTRL_CMD) | 
 | 1507 | /* Big A */ | 
 | 1508 | /* sparc only */ | 
 | 1509 | /* Big Q for sound/OSS */ | 
 | 1510 | COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET) | 
 | 1511 | COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC) | 
 | 1512 | COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO) | 
 | 1513 | COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE) | 
 | 1514 | COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT) | 
 | 1515 | COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT) | 
 | 1516 | COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE) | 
 | 1517 | COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR) | 
 | 1518 | COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI) | 
 | 1519 | COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES) | 
 | 1520 | COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS) | 
 | 1521 | COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS) | 
 | 1522 | COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO) | 
 | 1523 | COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD) | 
 | 1524 | COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL) | 
 | 1525 | COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE) | 
 | 1526 | COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC) | 
 | 1527 | COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND) | 
 | 1528 | COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME) | 
 | 1529 | COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID) | 
 | 1530 | COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL) | 
 | 1531 | COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE) | 
 | 1532 | /* Big T for sound/OSS */ | 
 | 1533 | COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE) | 
 | 1534 | COMPATIBLE_IOCTL(SNDCTL_TMR_START) | 
 | 1535 | COMPATIBLE_IOCTL(SNDCTL_TMR_STOP) | 
 | 1536 | COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE) | 
 | 1537 | COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO) | 
 | 1538 | COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE) | 
 | 1539 | COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME) | 
 | 1540 | COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT) | 
 | 1541 | /* Little m for sound/OSS */ | 
 | 1542 | COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME) | 
 | 1543 | COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE) | 
 | 1544 | COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD) | 
 | 1545 | /* Big P for sound/OSS */ | 
 | 1546 | COMPATIBLE_IOCTL(SNDCTL_DSP_RESET) | 
 | 1547 | COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC) | 
 | 1548 | COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED) | 
 | 1549 | COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO) | 
 | 1550 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE) | 
 | 1551 | COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS) | 
 | 1552 | COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER) | 
 | 1553 | COMPATIBLE_IOCTL(SNDCTL_DSP_POST) | 
 | 1554 | COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE) | 
 | 1555 | COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT) | 
 | 1556 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS) | 
 | 1557 | COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT) | 
 | 1558 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE) | 
 | 1559 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE) | 
 | 1560 | COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK) | 
 | 1561 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS) | 
 | 1562 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER) | 
 | 1563 | COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER) | 
 | 1564 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR) | 
 | 1565 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR) | 
 | 1566 | /* SNDCTL_DSP_MAPINBUF,  XXX needs translation */ | 
 | 1567 | /* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */ | 
 | 1568 | COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO) | 
 | 1569 | COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX) | 
 | 1570 | COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY) | 
 | 1571 | COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE) | 
 | 1572 | COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE) | 
 | 1573 | COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS) | 
 | 1574 | COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS) | 
 | 1575 | COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER) | 
 | 1576 | /* Big C for sound/OSS */ | 
 | 1577 | COMPATIBLE_IOCTL(SNDCTL_COPR_RESET) | 
 | 1578 | COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD) | 
 | 1579 | COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA) | 
 | 1580 | COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE) | 
 | 1581 | COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA) | 
 | 1582 | COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE) | 
 | 1583 | COMPATIBLE_IOCTL(SNDCTL_COPR_RUN) | 
 | 1584 | COMPATIBLE_IOCTL(SNDCTL_COPR_HALT) | 
 | 1585 | COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG) | 
 | 1586 | COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG) | 
 | 1587 | /* Big M for sound/OSS */ | 
 | 1588 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME) | 
 | 1589 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS) | 
 | 1590 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE) | 
 | 1591 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH) | 
 | 1592 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM) | 
 | 1593 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER) | 
 | 1594 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE) | 
 | 1595 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC) | 
 | 1596 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD) | 
 | 1597 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX) | 
 | 1598 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM) | 
 | 1599 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV) | 
 | 1600 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN) | 
 | 1601 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN) | 
 | 1602 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1) | 
 | 1603 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2) | 
 | 1604 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3) | 
 | 1605 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1)) | 
 | 1606 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2)) | 
 | 1607 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3)) | 
 | 1608 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN)) | 
 | 1609 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT)) | 
 | 1610 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO)) | 
 | 1611 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO)) | 
 | 1612 | COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR)) | 
 | 1613 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE) | 
 | 1614 | /* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */ | 
 | 1615 | /* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */ | 
 | 1616 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC) | 
 | 1617 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK) | 
 | 1618 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK) | 
 | 1619 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS) | 
 | 1620 | COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS) | 
 | 1621 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME) | 
 | 1622 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS) | 
 | 1623 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE) | 
 | 1624 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH) | 
 | 1625 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM) | 
 | 1626 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER) | 
 | 1627 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE) | 
 | 1628 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC) | 
 | 1629 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD) | 
 | 1630 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX) | 
 | 1631 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM) | 
 | 1632 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV) | 
 | 1633 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN) | 
 | 1634 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN) | 
 | 1635 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1) | 
 | 1636 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2) | 
 | 1637 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3) | 
 | 1638 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1)) | 
 | 1639 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2)) | 
 | 1640 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3)) | 
 | 1641 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN)) | 
 | 1642 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT)) | 
 | 1643 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO)) | 
 | 1644 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO)) | 
 | 1645 | COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR)) | 
 | 1646 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE) | 
 | 1647 | /* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */ | 
 | 1648 | /* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */ | 
 | 1649 | COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC) | 
 | 1650 | COMPATIBLE_IOCTL(SOUND_MIXER_INFO) | 
 | 1651 | COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO) | 
 | 1652 | COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS) | 
 | 1653 | COMPATIBLE_IOCTL(SOUND_MIXER_AGC) | 
 | 1654 | COMPATIBLE_IOCTL(SOUND_MIXER_3DSE) | 
 | 1655 | COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1) | 
 | 1656 | COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2) | 
 | 1657 | COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3) | 
 | 1658 | COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4) | 
 | 1659 | COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5) | 
 | 1660 | COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS) | 
 | 1661 | COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) | 
 | 1662 | COMPATIBLE_IOCTL(OSS_GETVERSION) | 
 | 1663 | /* AUTOFS */ | 
 | 1664 | ULONG_IOCTL(AUTOFS_IOC_READY) | 
 | 1665 | ULONG_IOCTL(AUTOFS_IOC_FAIL) | 
 | 1666 | COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) | 
 | 1667 | COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) | 
 | 1668 | COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) | 
 | 1669 | COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI) | 
 | 1670 | COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1671 | COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT) | 
 | 1672 | /* Raw devices */ | 
 | 1673 | COMPATIBLE_IOCTL(RAW_SETBIND) | 
 | 1674 | COMPATIBLE_IOCTL(RAW_GETBIND) | 
 | 1675 | /* SMB ioctls which do not need any translations */ | 
 | 1676 | COMPATIBLE_IOCTL(SMB_IOC_NEWCONN) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1677 | /* Watchdog */ | 
 | 1678 | COMPATIBLE_IOCTL(WDIOC_GETSUPPORT) | 
 | 1679 | COMPATIBLE_IOCTL(WDIOC_GETSTATUS) | 
 | 1680 | COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS) | 
 | 1681 | COMPATIBLE_IOCTL(WDIOC_GETTEMP) | 
 | 1682 | COMPATIBLE_IOCTL(WDIOC_SETOPTIONS) | 
 | 1683 | COMPATIBLE_IOCTL(WDIOC_KEEPALIVE) | 
 | 1684 | COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT) | 
 | 1685 | COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT) | 
 | 1686 | /* Big R */ | 
 | 1687 | COMPATIBLE_IOCTL(RNDGETENTCNT) | 
 | 1688 | COMPATIBLE_IOCTL(RNDADDTOENTCNT) | 
 | 1689 | COMPATIBLE_IOCTL(RNDGETPOOL) | 
 | 1690 | COMPATIBLE_IOCTL(RNDADDENTROPY) | 
 | 1691 | COMPATIBLE_IOCTL(RNDZAPENTCNT) | 
 | 1692 | COMPATIBLE_IOCTL(RNDCLEARPOOL) | 
 | 1693 | /* Bluetooth */ | 
 | 1694 | COMPATIBLE_IOCTL(HCIDEVUP) | 
 | 1695 | COMPATIBLE_IOCTL(HCIDEVDOWN) | 
 | 1696 | COMPATIBLE_IOCTL(HCIDEVRESET) | 
 | 1697 | COMPATIBLE_IOCTL(HCIDEVRESTAT) | 
 | 1698 | COMPATIBLE_IOCTL(HCIGETDEVLIST) | 
 | 1699 | COMPATIBLE_IOCTL(HCIGETDEVINFO) | 
 | 1700 | COMPATIBLE_IOCTL(HCIGETCONNLIST) | 
 | 1701 | COMPATIBLE_IOCTL(HCIGETCONNINFO) | 
| Marcel Holtmann | 40be492 | 2008-07-14 20:13:50 +0200 | [diff] [blame] | 1702 | COMPATIBLE_IOCTL(HCIGETAUTHINFO) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1703 | COMPATIBLE_IOCTL(HCISETRAW) | 
 | 1704 | COMPATIBLE_IOCTL(HCISETSCAN) | 
 | 1705 | COMPATIBLE_IOCTL(HCISETAUTH) | 
 | 1706 | COMPATIBLE_IOCTL(HCISETENCRYPT) | 
 | 1707 | COMPATIBLE_IOCTL(HCISETPTYPE) | 
 | 1708 | COMPATIBLE_IOCTL(HCISETLINKPOL) | 
 | 1709 | COMPATIBLE_IOCTL(HCISETLINKMODE) | 
 | 1710 | COMPATIBLE_IOCTL(HCISETACLMTU) | 
 | 1711 | COMPATIBLE_IOCTL(HCISETSCOMTU) | 
 | 1712 | COMPATIBLE_IOCTL(HCIINQUIRY) | 
 | 1713 | COMPATIBLE_IOCTL(HCIUARTSETPROTO) | 
 | 1714 | COMPATIBLE_IOCTL(HCIUARTGETPROTO) | 
 | 1715 | COMPATIBLE_IOCTL(RFCOMMCREATEDEV) | 
 | 1716 | COMPATIBLE_IOCTL(RFCOMMRELEASEDEV) | 
 | 1717 | COMPATIBLE_IOCTL(RFCOMMGETDEVLIST) | 
 | 1718 | COMPATIBLE_IOCTL(RFCOMMGETDEVINFO) | 
 | 1719 | COMPATIBLE_IOCTL(RFCOMMSTEALDLC) | 
 | 1720 | COMPATIBLE_IOCTL(BNEPCONNADD) | 
 | 1721 | COMPATIBLE_IOCTL(BNEPCONNDEL) | 
 | 1722 | COMPATIBLE_IOCTL(BNEPGETCONNLIST) | 
 | 1723 | COMPATIBLE_IOCTL(BNEPGETCONNINFO) | 
 | 1724 | COMPATIBLE_IOCTL(CMTPCONNADD) | 
 | 1725 | COMPATIBLE_IOCTL(CMTPCONNDEL) | 
 | 1726 | COMPATIBLE_IOCTL(CMTPGETCONNLIST) | 
 | 1727 | COMPATIBLE_IOCTL(CMTPGETCONNINFO) | 
 | 1728 | COMPATIBLE_IOCTL(HIDPCONNADD) | 
 | 1729 | COMPATIBLE_IOCTL(HIDPCONNDEL) | 
 | 1730 | COMPATIBLE_IOCTL(HIDPGETCONNLIST) | 
 | 1731 | COMPATIBLE_IOCTL(HIDPGETCONNINFO) | 
 | 1732 | /* CAPI */ | 
 | 1733 | COMPATIBLE_IOCTL(CAPI_REGISTER) | 
 | 1734 | COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER) | 
 | 1735 | COMPATIBLE_IOCTL(CAPI_GET_VERSION) | 
 | 1736 | COMPATIBLE_IOCTL(CAPI_GET_SERIAL) | 
 | 1737 | COMPATIBLE_IOCTL(CAPI_GET_PROFILE) | 
 | 1738 | COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD) | 
 | 1739 | COMPATIBLE_IOCTL(CAPI_GET_ERRCODE) | 
 | 1740 | COMPATIBLE_IOCTL(CAPI_INSTALLED) | 
 | 1741 | COMPATIBLE_IOCTL(CAPI_GET_FLAGS) | 
 | 1742 | COMPATIBLE_IOCTL(CAPI_SET_FLAGS) | 
 | 1743 | COMPATIBLE_IOCTL(CAPI_CLR_FLAGS) | 
 | 1744 | COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT) | 
 | 1745 | COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT) | 
 | 1746 | /* Siemens Gigaset */ | 
 | 1747 | COMPATIBLE_IOCTL(GIGASET_REDIR) | 
 | 1748 | COMPATIBLE_IOCTL(GIGASET_CONFIG) | 
 | 1749 | COMPATIBLE_IOCTL(GIGASET_BRKCHARS) | 
 | 1750 | COMPATIBLE_IOCTL(GIGASET_VERSION) | 
 | 1751 | /* Misc. */ | 
 | 1752 | COMPATIBLE_IOCTL(0x41545900)		/* ATYIO_CLKR */ | 
 | 1753 | COMPATIBLE_IOCTL(0x41545901)		/* ATYIO_CLKW */ | 
 | 1754 | COMPATIBLE_IOCTL(PCIIOC_CONTROLLER) | 
 | 1755 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO) | 
 | 1756 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM) | 
 | 1757 | COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE) | 
 | 1758 | /* USB */ | 
 | 1759 | COMPATIBLE_IOCTL(USBDEVFS_RESETEP) | 
 | 1760 | COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE) | 
 | 1761 | COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION) | 
 | 1762 | COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER) | 
 | 1763 | COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB) | 
 | 1764 | COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE) | 
 | 1765 | COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE) | 
 | 1766 | COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO) | 
 | 1767 | COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO) | 
 | 1768 | COMPATIBLE_IOCTL(USBDEVFS_RESET) | 
 | 1769 | COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32) | 
 | 1770 | COMPATIBLE_IOCTL(USBDEVFS_REAPURB32) | 
 | 1771 | COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) | 
 | 1772 | COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1773 | /* NBD */ | 
 | 1774 | ULONG_IOCTL(NBD_SET_SOCK) | 
 | 1775 | ULONG_IOCTL(NBD_SET_BLKSIZE) | 
 | 1776 | ULONG_IOCTL(NBD_SET_SIZE) | 
 | 1777 | COMPATIBLE_IOCTL(NBD_DO_IT) | 
 | 1778 | COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) | 
 | 1779 | COMPATIBLE_IOCTL(NBD_CLEAR_QUE) | 
 | 1780 | COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) | 
 | 1781 | ULONG_IOCTL(NBD_SET_SIZE_BLOCKS) | 
 | 1782 | COMPATIBLE_IOCTL(NBD_DISCONNECT) | 
 | 1783 | /* i2c */ | 
 | 1784 | COMPATIBLE_IOCTL(I2C_SLAVE) | 
 | 1785 | COMPATIBLE_IOCTL(I2C_SLAVE_FORCE) | 
 | 1786 | COMPATIBLE_IOCTL(I2C_TENBIT) | 
 | 1787 | COMPATIBLE_IOCTL(I2C_PEC) | 
 | 1788 | COMPATIBLE_IOCTL(I2C_RETRIES) | 
 | 1789 | COMPATIBLE_IOCTL(I2C_TIMEOUT) | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1790 | /* hiddev */ | 
 | 1791 | COMPATIBLE_IOCTL(HIDIOCGVERSION) | 
 | 1792 | COMPATIBLE_IOCTL(HIDIOCAPPLICATION) | 
 | 1793 | COMPATIBLE_IOCTL(HIDIOCGDEVINFO) | 
 | 1794 | COMPATIBLE_IOCTL(HIDIOCGSTRING) | 
 | 1795 | COMPATIBLE_IOCTL(HIDIOCINITREPORT) | 
 | 1796 | COMPATIBLE_IOCTL(HIDIOCGREPORT) | 
 | 1797 | COMPATIBLE_IOCTL(HIDIOCSREPORT) | 
 | 1798 | COMPATIBLE_IOCTL(HIDIOCGREPORTINFO) | 
 | 1799 | COMPATIBLE_IOCTL(HIDIOCGFIELDINFO) | 
 | 1800 | COMPATIBLE_IOCTL(HIDIOCGUSAGE) | 
 | 1801 | COMPATIBLE_IOCTL(HIDIOCSUSAGE) | 
 | 1802 | COMPATIBLE_IOCTL(HIDIOCGUCODE) | 
 | 1803 | COMPATIBLE_IOCTL(HIDIOCGFLAG) | 
 | 1804 | COMPATIBLE_IOCTL(HIDIOCSFLAG) | 
 | 1805 | COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX) | 
 | 1806 | COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO) | 
 | 1807 | /* dvb */ | 
 | 1808 | COMPATIBLE_IOCTL(AUDIO_STOP) | 
 | 1809 | COMPATIBLE_IOCTL(AUDIO_PLAY) | 
 | 1810 | COMPATIBLE_IOCTL(AUDIO_PAUSE) | 
 | 1811 | COMPATIBLE_IOCTL(AUDIO_CONTINUE) | 
 | 1812 | COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE) | 
 | 1813 | COMPATIBLE_IOCTL(AUDIO_SET_MUTE) | 
 | 1814 | COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC) | 
 | 1815 | COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE) | 
 | 1816 | COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT) | 
 | 1817 | COMPATIBLE_IOCTL(AUDIO_GET_STATUS) | 
 | 1818 | COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES) | 
 | 1819 | COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER) | 
 | 1820 | COMPATIBLE_IOCTL(AUDIO_SET_ID) | 
 | 1821 | COMPATIBLE_IOCTL(AUDIO_SET_MIXER) | 
 | 1822 | COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE) | 
 | 1823 | COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID) | 
 | 1824 | COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES) | 
 | 1825 | COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE) | 
 | 1826 | COMPATIBLE_IOCTL(DMX_START) | 
 | 1827 | COMPATIBLE_IOCTL(DMX_STOP) | 
 | 1828 | COMPATIBLE_IOCTL(DMX_SET_FILTER) | 
 | 1829 | COMPATIBLE_IOCTL(DMX_SET_PES_FILTER) | 
 | 1830 | COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE) | 
 | 1831 | COMPATIBLE_IOCTL(DMX_GET_PES_PIDS) | 
 | 1832 | COMPATIBLE_IOCTL(DMX_GET_CAPS) | 
 | 1833 | COMPATIBLE_IOCTL(DMX_SET_SOURCE) | 
 | 1834 | COMPATIBLE_IOCTL(DMX_GET_STC) | 
 | 1835 | COMPATIBLE_IOCTL(FE_GET_INFO) | 
 | 1836 | COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD) | 
 | 1837 | COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD) | 
 | 1838 | COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY) | 
 | 1839 | COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST) | 
 | 1840 | COMPATIBLE_IOCTL(FE_SET_TONE) | 
 | 1841 | COMPATIBLE_IOCTL(FE_SET_VOLTAGE) | 
 | 1842 | COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE) | 
 | 1843 | COMPATIBLE_IOCTL(FE_READ_STATUS) | 
 | 1844 | COMPATIBLE_IOCTL(FE_READ_BER) | 
 | 1845 | COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH) | 
 | 1846 | COMPATIBLE_IOCTL(FE_READ_SNR) | 
 | 1847 | COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS) | 
 | 1848 | COMPATIBLE_IOCTL(FE_SET_FRONTEND) | 
 | 1849 | COMPATIBLE_IOCTL(FE_GET_FRONTEND) | 
 | 1850 | COMPATIBLE_IOCTL(FE_GET_EVENT) | 
 | 1851 | COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD) | 
 | 1852 | COMPATIBLE_IOCTL(VIDEO_STOP) | 
 | 1853 | COMPATIBLE_IOCTL(VIDEO_PLAY) | 
 | 1854 | COMPATIBLE_IOCTL(VIDEO_FREEZE) | 
 | 1855 | COMPATIBLE_IOCTL(VIDEO_CONTINUE) | 
 | 1856 | COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE) | 
 | 1857 | COMPATIBLE_IOCTL(VIDEO_SET_BLANK) | 
 | 1858 | COMPATIBLE_IOCTL(VIDEO_GET_STATUS) | 
 | 1859 | COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT) | 
 | 1860 | COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD) | 
 | 1861 | COMPATIBLE_IOCTL(VIDEO_SLOWMOTION) | 
 | 1862 | COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES) | 
 | 1863 | COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER) | 
 | 1864 | COMPATIBLE_IOCTL(VIDEO_SET_ID) | 
 | 1865 | COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE) | 
 | 1866 | COMPATIBLE_IOCTL(VIDEO_SET_FORMAT) | 
 | 1867 | COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM) | 
 | 1868 | COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT) | 
 | 1869 | COMPATIBLE_IOCTL(VIDEO_SET_SPU) | 
 | 1870 | COMPATIBLE_IOCTL(VIDEO_GET_NAVI) | 
 | 1871 | COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES) | 
 | 1872 | COMPATIBLE_IOCTL(VIDEO_GET_SIZE) | 
 | 1873 | COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE) | 
 | 1874 |  | 
| Akos Maroy | 3fee37c | 2008-01-06 11:15:55 +0100 | [diff] [blame] | 1875 | /* joystick */ | 
 | 1876 | COMPATIBLE_IOCTL(JSIOCGVERSION) | 
 | 1877 | COMPATIBLE_IOCTL(JSIOCGAXES) | 
 | 1878 | COMPATIBLE_IOCTL(JSIOCGBUTTONS) | 
 | 1879 | COMPATIBLE_IOCTL(JSIOCGNAME(0)) | 
 | 1880 |  | 
| Christoph Hellwig | 644fd4f | 2007-05-08 00:29:07 -0700 | [diff] [blame] | 1881 | /* now things that need handlers */ | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1882 | #ifdef CONFIG_BLOCK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1883 | HANDLE_IOCTL(SG_IO,sg_ioctl_trans) | 
| Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 1884 | HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1885 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1886 | HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) | 
 | 1887 | HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) | 
 | 1888 | HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) | 
 | 1889 | HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1890 | #ifdef CONFIG_BLOCK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) | 
 | 1892 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1893 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1894 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | 
 | 1895 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) | 
 | 1896 | #ifdef CONFIG_VT | 
 | 1897 | HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) | 
 | 1898 | HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl) | 
 | 1899 | HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) | 
 | 1900 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) | 
 | 1901 | HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) | 
 | 1902 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1903 | /* One SMB ioctl needs translations. */ | 
 | 1904 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | 
 | 1905 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | /* block stuff */ | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1907 | #ifdef CONFIG_BLOCK | 
| Alexander Beregalov | 1ba0c7d | 2009-04-20 12:23:02 +0400 | [diff] [blame] | 1908 | /* loop */ | 
 | 1909 | IGNORE_IOCTL(LOOP_CLR_FD) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1910 | /* Raw devices */ | 
 | 1911 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) | 
 | 1912 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) | 
| David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1913 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1914 | /* Serial */ | 
 | 1915 | HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) | 
 | 1916 | HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) | 
| Christoph Hellwig | 9c0cbd5 | 2005-10-30 15:01:41 -0800 | [diff] [blame] | 1917 | #ifdef TIOCGLTC | 
 | 1918 | COMPATIBLE_IOCTL(TIOCGLTC) | 
 | 1919 | COMPATIBLE_IOCTL(TIOCSLTC) | 
 | 1920 | #endif | 
| Christoph Hellwig | 7a81e31 | 2005-11-08 21:35:07 -0800 | [diff] [blame] | 1921 | #ifdef TIOCSTART | 
 | 1922 | /* | 
| Adam Buchbinder | 6070d81 | 2009-12-04 15:47:01 -0500 | [diff] [blame] | 1923 |  * For these two we have definitions in ioctls.h and/or termios.h on | 
| Christoph Hellwig | 7a81e31 | 2005-11-08 21:35:07 -0800 | [diff] [blame] | 1924 |  * some architectures but no actual implemention.  Some applications | 
 | 1925 |  * like bash call them if they are defined in the headers, so we provide | 
 | 1926 |  * entries here to avoid syslog message spew. | 
 | 1927 |  */ | 
 | 1928 | COMPATIBLE_IOCTL(TIOCSTART) | 
 | 1929 | COMPATIBLE_IOCTL(TIOCSTOP) | 
 | 1930 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1931 | /* Usbdevfs */ | 
 | 1932 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) | 
 | 1933 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) | 
 | 1934 | HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal) | 
| Pete Zaitcev | c36fc88 | 2005-10-17 18:15:54 -0700 | [diff] [blame] | 1935 | COMPATIBLE_IOCTL(USBDEVFS_IOCTL32) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1936 | /* i2c */ | 
 | 1937 | HANDLE_IOCTL(I2C_FUNCS, w_long) | 
 | 1938 | HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) | 
 | 1939 | HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) | 
| Andi Kleen | 9d016dd | 2007-05-02 19:27:20 +0200 | [diff] [blame] | 1940 | /* Not implemented in the native kernel */ | 
| Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 1941 | HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl) | 
 | 1942 | HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl) | 
 | 1943 | HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) | 
 | 1944 | HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1945 |  | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 1946 | /* dvb */ | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 1947 | HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) | 
 | 1948 | HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) | 
 | 1949 | HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette) | 
| Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 1950 |  | 
 | 1951 | /* parport */ | 
 | 1952 | COMPATIBLE_IOCTL(LPTIME) | 
 | 1953 | COMPATIBLE_IOCTL(LPCHAR) | 
 | 1954 | COMPATIBLE_IOCTL(LPABORTOPEN) | 
 | 1955 | COMPATIBLE_IOCTL(LPCAREFUL) | 
 | 1956 | COMPATIBLE_IOCTL(LPWAIT) | 
 | 1957 | COMPATIBLE_IOCTL(LPSETIRQ) | 
 | 1958 | COMPATIBLE_IOCTL(LPGETSTATUS) | 
 | 1959 | COMPATIBLE_IOCTL(LPGETSTATUS) | 
 | 1960 | COMPATIBLE_IOCTL(LPRESET) | 
 | 1961 | /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/ | 
 | 1962 | COMPATIBLE_IOCTL(LPGETFLAGS) | 
 | 1963 | HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans) | 
| Andi Kleen | 2724b6d | 2007-05-02 19:27:21 +0200 | [diff] [blame] | 1964 |  | 
 | 1965 | /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, | 
 | 1966 |    but we don't want warnings on other file systems. So declare | 
 | 1967 |    them as compatible here. */ | 
 | 1968 | #define VFAT_IOCTL_READDIR_BOTH32       _IOR('r', 1, struct compat_dirent[2]) | 
 | 1969 | #define VFAT_IOCTL_READDIR_SHORT32      _IOR('r', 2, struct compat_dirent[2]) | 
 | 1970 |  | 
 | 1971 | IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32) | 
 | 1972 | IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32) | 
| Geert Uytterhoeven | 98701dc | 2007-07-15 23:42:01 -0700 | [diff] [blame] | 1973 |  | 
| David S. Miller | 8163904 | 2007-07-29 00:50:42 -0700 | [diff] [blame] | 1974 | #ifdef CONFIG_SPARC | 
 | 1975 | /* Sparc framebuffers, handled in sbusfb_compat_ioctl() */ | 
 | 1976 | IGNORE_IOCTL(FBIOGTYPE) | 
 | 1977 | IGNORE_IOCTL(FBIOSATTR) | 
 | 1978 | IGNORE_IOCTL(FBIOGATTR) | 
 | 1979 | IGNORE_IOCTL(FBIOSVIDEO) | 
 | 1980 | IGNORE_IOCTL(FBIOGVIDEO) | 
 | 1981 | IGNORE_IOCTL(FBIOSCURPOS) | 
 | 1982 | IGNORE_IOCTL(FBIOGCURPOS) | 
 | 1983 | IGNORE_IOCTL(FBIOGCURMAX) | 
 | 1984 | IGNORE_IOCTL(FBIOPUTCMAP32) | 
 | 1985 | IGNORE_IOCTL(FBIOGETCMAP32) | 
 | 1986 | IGNORE_IOCTL(FBIOSCURSOR32) | 
 | 1987 | IGNORE_IOCTL(FBIOGCURSOR32) | 
 | 1988 | #endif | 
| Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 1989 | }; | 
| David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 1990 |  | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 1991 | #define IOCTL_HASHSIZE 256 | 
 | 1992 | static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE]; | 
 | 1993 |  | 
 | 1994 | static inline unsigned long ioctl32_hash(unsigned long cmd) | 
 | 1995 | { | 
 | 1996 | 	return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE; | 
 | 1997 | } | 
 | 1998 |  | 
 | 1999 | static void compat_ioctl_error(struct file *filp, unsigned int fd, | 
 | 2000 | 		unsigned int cmd, unsigned long arg) | 
 | 2001 | { | 
 | 2002 | 	char buf[10]; | 
 | 2003 | 	char *fn = "?"; | 
 | 2004 | 	char *path; | 
 | 2005 |  | 
 | 2006 | 	/* find the name of the device. */ | 
 | 2007 | 	path = (char *)__get_free_page(GFP_KERNEL); | 
 | 2008 | 	if (path) { | 
| Jan Blunck | cf28b48 | 2008-02-14 19:38:44 -0800 | [diff] [blame] | 2009 | 		fn = d_path(&filp->f_path, path, PAGE_SIZE); | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 2010 | 		if (IS_ERR(fn)) | 
 | 2011 | 			fn = "?"; | 
 | 2012 | 	} | 
 | 2013 |  | 
 | 2014 | 	 sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK); | 
 | 2015 | 	if (!isprint(buf[1])) | 
 | 2016 | 		sprintf(buf, "%02x", buf[1]); | 
 | 2017 | 	compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) " | 
 | 2018 | 			"cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n", | 
 | 2019 | 			current->comm, current->pid, | 
 | 2020 | 			(int)fd, (unsigned int)cmd, buf, | 
 | 2021 | 			(cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK, | 
 | 2022 | 			(unsigned int)arg, fn); | 
 | 2023 |  | 
 | 2024 | 	if (path) | 
 | 2025 | 		free_page((unsigned long)path); | 
 | 2026 | } | 
 | 2027 |  | 
 | 2028 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | 
 | 2029 | 				unsigned long arg) | 
 | 2030 | { | 
 | 2031 | 	struct file *filp; | 
 | 2032 | 	int error = -EBADF; | 
 | 2033 | 	struct ioctl_trans *t; | 
 | 2034 | 	int fput_needed; | 
 | 2035 |  | 
 | 2036 | 	filp = fget_light(fd, &fput_needed); | 
 | 2037 | 	if (!filp) | 
 | 2038 | 		goto out; | 
 | 2039 |  | 
 | 2040 | 	/* RED-PEN how should LSM module know it's handling 32bit? */ | 
 | 2041 | 	error = security_file_ioctl(filp, cmd, arg); | 
 | 2042 | 	if (error) | 
 | 2043 | 		goto out_fput; | 
 | 2044 |  | 
 | 2045 | 	/* | 
 | 2046 | 	 * To allow the compat_ioctl handlers to be self contained | 
 | 2047 | 	 * we need to check the common ioctls here first. | 
 | 2048 | 	 * Just handle them with the standard handlers below. | 
 | 2049 | 	 */ | 
 | 2050 | 	switch (cmd) { | 
 | 2051 | 	case FIOCLEX: | 
 | 2052 | 	case FIONCLEX: | 
 | 2053 | 	case FIONBIO: | 
 | 2054 | 	case FIOASYNC: | 
 | 2055 | 	case FIOQSIZE: | 
 | 2056 | 		break; | 
 | 2057 |  | 
| Ankit Jain | 3e63cbb | 2009-06-19 14:28:07 -0400 | [diff] [blame] | 2058 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | 
 | 2059 | 	case FS_IOC_RESVSP_32: | 
 | 2060 | 	case FS_IOC_RESVSP64_32: | 
 | 2061 | 		error = compat_ioctl_preallocate(filp, arg); | 
 | 2062 | 		goto out_fput; | 
 | 2063 | #else | 
 | 2064 | 	case FS_IOC_RESVSP: | 
 | 2065 | 	case FS_IOC_RESVSP64: | 
| Heiko Carstens | 7779d7b | 2009-11-11 14:26:34 -0800 | [diff] [blame] | 2066 | 		error = ioctl_preallocate(filp, compat_ptr(arg)); | 
| Ankit Jain | 3e63cbb | 2009-06-19 14:28:07 -0400 | [diff] [blame] | 2067 | 		goto out_fput; | 
 | 2068 | #endif | 
 | 2069 |  | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 2070 | 	case FIBMAP: | 
 | 2071 | 	case FIGETBSZ: | 
 | 2072 | 	case FIONREAD: | 
 | 2073 | 		if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) | 
 | 2074 | 			break; | 
 | 2075 | 		/*FALL THROUGH*/ | 
 | 2076 |  | 
 | 2077 | 	default: | 
 | 2078 | 		if (filp->f_op && filp->f_op->compat_ioctl) { | 
 | 2079 | 			error = filp->f_op->compat_ioctl(filp, cmd, arg); | 
 | 2080 | 			if (error != -ENOIOCTLCMD) | 
 | 2081 | 				goto out_fput; | 
 | 2082 | 		} | 
 | 2083 |  | 
 | 2084 | 		if (!filp->f_op || | 
 | 2085 | 		    (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl)) | 
 | 2086 | 			goto do_ioctl; | 
 | 2087 | 		break; | 
 | 2088 | 	} | 
 | 2089 |  | 
 | 2090 | 	for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) { | 
 | 2091 | 		if (t->cmd == cmd) | 
 | 2092 | 			goto found_handler; | 
 | 2093 | 	} | 
 | 2094 |  | 
| Simon Horman | d9de262 | 2007-05-10 11:51:11 -0700 | [diff] [blame] | 2095 | 	{ | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 2096 | 		static int count; | 
 | 2097 |  | 
 | 2098 | 		if (++count <= 50) | 
 | 2099 | 			compat_ioctl_error(filp, fd, cmd, arg); | 
 | 2100 | 		error = -EINVAL; | 
 | 2101 | 	} | 
 | 2102 |  | 
 | 2103 | 	goto out_fput; | 
 | 2104 |  | 
 | 2105 |  found_handler: | 
 | 2106 | 	if (t->handler) { | 
 | 2107 | 		lock_kernel(); | 
 | 2108 | 		error = t->handler(fd, cmd, arg, filp); | 
 | 2109 | 		unlock_kernel(); | 
 | 2110 | 		goto out_fput; | 
 | 2111 | 	} | 
 | 2112 |  | 
 | 2113 |  do_ioctl: | 
| Erez Zadok | deb21db | 2008-02-07 00:13:25 -0800 | [diff] [blame] | 2114 | 	error = do_vfs_ioctl(filp, fd, cmd, arg); | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 2115 |  out_fput: | 
 | 2116 | 	fput_light(filp, fput_needed); | 
 | 2117 |  out: | 
 | 2118 | 	return error; | 
 | 2119 | } | 
 | 2120 |  | 
 | 2121 | static void ioctl32_insert_translation(struct ioctl_trans *trans) | 
 | 2122 | { | 
 | 2123 | 	unsigned long hash; | 
 | 2124 | 	struct ioctl_trans *t; | 
 | 2125 |  | 
 | 2126 | 	hash = ioctl32_hash (trans->cmd); | 
 | 2127 | 	if (!ioctl32_hash_table[hash]) | 
 | 2128 | 		ioctl32_hash_table[hash] = trans; | 
 | 2129 | 	else { | 
 | 2130 | 		t = ioctl32_hash_table[hash]; | 
 | 2131 | 		while (t->next) | 
 | 2132 | 			t = t->next; | 
 | 2133 | 		trans->next = NULL; | 
 | 2134 | 		t->next = trans; | 
 | 2135 | 	} | 
 | 2136 | } | 
 | 2137 |  | 
 | 2138 | static int __init init_sys32_ioctl(void) | 
 | 2139 | { | 
 | 2140 | 	int i; | 
 | 2141 |  | 
 | 2142 | 	for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) { | 
| Stephen Hemminger | c80544d | 2007-10-18 03:07:05 -0700 | [diff] [blame] | 2143 | 		if (ioctl_start[i].next) { | 
| Christoph Hellwig | 6272e26 | 2007-05-08 00:29:21 -0700 | [diff] [blame] | 2144 | 			printk("ioctl translation %d bad\n",i); | 
 | 2145 | 			return -1; | 
 | 2146 | 		} | 
 | 2147 |  | 
 | 2148 | 		ioctl32_insert_translation(&ioctl_start[i]); | 
 | 2149 | 	} | 
 | 2150 | 	return 0; | 
 | 2151 | } | 
 | 2152 | __initcall(init_sys32_ioctl); |