| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
#ifdef INCLUDES |
|---|
| 14 |
#include <linux/config.h> |
|---|
| 15 |
#include <linux/types.h> |
|---|
| 16 |
#include <linux/compat.h> |
|---|
| 17 |
#include <linux/kernel.h> |
|---|
| 18 |
#include <linux/sched.h> |
|---|
| 19 |
#include <linux/smp.h> |
|---|
| 20 |
#include <linux/smp_lock.h> |
|---|
| 21 |
#include <linux/ioctl.h> |
|---|
| 22 |
#include <linux/if.h> |
|---|
| 23 |
#include <linux/if_bridge.h> |
|---|
| 24 |
#include <linux/slab.h> |
|---|
| 25 |
#include <linux/hdreg.h> |
|---|
| 26 |
#include <linux/raid/md.h> |
|---|
| 27 |
#include <linux/kd.h> |
|---|
| 28 |
#include <linux/dirent.h> |
|---|
| 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> |
|---|
| 35 |
#include <linux/fs.h> |
|---|
| 36 |
#include <linux/file.h> |
|---|
| 37 |
#include <linux/fd.h> |
|---|
| 38 |
#include <linux/ppp_defs.h> |
|---|
| 39 |
#include <linux/if_ppp.h> |
|---|
| 40 |
#include <linux/if_pppox.h> |
|---|
| 41 |
#include <linux/mtio.h> |
|---|
| 42 |
#include <linux/cdrom.h> |
|---|
| 43 |
#include <linux/loop.h> |
|---|
| 44 |
#include <linux/auto_fs.h> |
|---|
| 45 |
#include <linux/auto_fs4.h> |
|---|
| 46 |
#include <linux/devfs_fs.h> |
|---|
| 47 |
#include <linux/tty.h> |
|---|
| 48 |
#include <linux/vt_kern.h> |
|---|
| 49 |
#include <linux/fb.h> |
|---|
| 50 |
#include <linux/ext2_fs.h> |
|---|
| 51 |
#include <linux/videodev.h> |
|---|
| 52 |
#include <linux/netdevice.h> |
|---|
| 53 |
#include <linux/raw.h> |
|---|
| 54 |
#include <linux/smb_fs.h> |
|---|
| 55 |
#include <linux/blkpg.h> |
|---|
| 56 |
#include <linux/blkdev.h> |
|---|
| 57 |
#include <linux/elevator.h> |
|---|
| 58 |
#include <linux/rtc.h> |
|---|
| 59 |
#include <linux/pci.h> |
|---|
| 60 |
#include <linux/module.h> |
|---|
| 61 |
#include <linux/serial.h> |
|---|
| 62 |
#include <linux/reiserfs_fs.h> |
|---|
| 63 |
#include <linux/if_tun.h> |
|---|
| 64 |
#include <linux/ctype.h> |
|---|
| 65 |
#include <linux/ioctl32.h> |
|---|
| 66 |
#include <linux/syscalls.h> |
|---|
| 67 |
#include <linux/ncp_fs.h> |
|---|
| 68 |
#include <linux/i2c.h> |
|---|
| 69 |
#include <linux/i2c-dev.h> |
|---|
| 70 |
#include <linux/wireless.h> |
|---|
| 71 |
|
|---|
| 72 |
#include <net/sock.h> |
|---|
| 73 |
#include <net/bluetooth/bluetooth.h> |
|---|
| 74 |
#include <net/bluetooth/hci.h> |
|---|
| 75 |
#include <net/bluetooth/rfcomm.h> |
|---|
| 76 |
|
|---|
| 77 |
#include <linux/capi.h> |
|---|
| 78 |
|
|---|
| 79 |
#include <scsi/scsi.h> |
|---|
| 80 |
|
|---|
| 81 |
#undef __KERNEL__ |
|---|
| 82 |
#include <scsi/scsi_ioctl.h> |
|---|
| 83 |
#define __KERNEL__ |
|---|
| 84 |
#include <scsi/sg.h> |
|---|
| 85 |
|
|---|
| 86 |
#include <asm/types.h> |
|---|
| 87 |
#include <asm/uaccess.h> |
|---|
| 88 |
#include <linux/ethtool.h> |
|---|
| 89 |
#include <linux/mii.h> |
|---|
| 90 |
#include <linux/if_bonding.h> |
|---|
| 91 |
#include <linux/watchdog.h> |
|---|
| 92 |
#include <linux/dm-ioctl.h> |
|---|
| 93 |
|
|---|
| 94 |
#include <asm/module.h> |
|---|
| 95 |
#include <linux/soundcard.h> |
|---|
| 96 |
#include <linux/lp.h> |
|---|
| 97 |
|
|---|
| 98 |
#include <linux/atm.h> |
|---|
| 99 |
#include <linux/atmarp.h> |
|---|
| 100 |
#include <linux/atmclip.h> |
|---|
| 101 |
#include <linux/atmdev.h> |
|---|
| 102 |
#include <linux/atmioc.h> |
|---|
| 103 |
#include <linux/atmlec.h> |
|---|
| 104 |
#include <linux/atmmpc.h> |
|---|
| 105 |
#include <linux/atmsvc.h> |
|---|
| 106 |
#include <linux/atm_tcp.h> |
|---|
| 107 |
#include <linux/sonet.h> |
|---|
| 108 |
#include <linux/atm_suni.h> |
|---|
| 109 |
#include <linux/mtd/mtd.h> |
|---|
| 110 |
|
|---|
| 111 |
#include <linux/usb.h> |
|---|
| 112 |
#include <linux/usbdevice_fs.h> |
|---|
| 113 |
#include <linux/nbd.h> |
|---|
| 114 |
#include <linux/random.h> |
|---|
| 115 |
#include <linux/filter.h> |
|---|
| 116 |
#include <linux/msdos_fs.h> |
|---|
| 117 |
|
|---|
| 118 |
#undef INCLUDES |
|---|
| 119 |
#endif |
|---|
| 120 |
|
|---|
| 121 |
#ifdef CODE |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
#define EXT2_IOC32_GETFLAGS _IOR('f', 1, int) |
|---|
| 125 |
#define EXT2_IOC32_SETFLAGS _IOW('f', 2, int) |
|---|
| 126 |
#define EXT2_IOC32_GETVERSION _IOR('v', 1, int) |
|---|
| 127 |
#define EXT2_IOC32_SETVERSION _IOW('v', 2, int) |
|---|
| 128 |
|
|---|
| 129 |
static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 130 |
{ |
|---|
| 131 |
mm_segment_t old_fs = get_fs(); |
|---|
| 132 |
int err; |
|---|
| 133 |
unsigned long val; |
|---|
| 134 |
|
|---|
| 135 |
set_fs (KERNEL_DS); |
|---|
| 136 |
err = sys_ioctl(fd, cmd, (unsigned long)&val); |
|---|
| 137 |
set_fs (old_fs); |
|---|
| 138 |
if (!err && put_user(val, (u32 __user *)compat_ptr(arg))) |
|---|
| 139 |
return -EFAULT; |
|---|
| 140 |
return err; |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 144 |
{ |
|---|
| 145 |
mm_segment_t old_fs = get_fs(); |
|---|
| 146 |
u32 __user *argptr = compat_ptr(arg); |
|---|
| 147 |
int err; |
|---|
| 148 |
unsigned long val; |
|---|
| 149 |
|
|---|
| 150 |
if(get_user(val, argptr)) |
|---|
| 151 |
return -EFAULT; |
|---|
| 152 |
set_fs (KERNEL_DS); |
|---|
| 153 |
err = sys_ioctl(fd, cmd, (unsigned long)&val); |
|---|
| 154 |
set_fs (old_fs); |
|---|
| 155 |
if (!err && put_user(val, argptr)) |
|---|
| 156 |
return -EFAULT; |
|---|
| 157 |
return err; |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 161 |
{ |
|---|
| 162 |
|
|---|
| 163 |
switch (cmd) { |
|---|
| 164 |
case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break; |
|---|
| 165 |
case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break; |
|---|
| 166 |
case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break; |
|---|
| 167 |
case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break; |
|---|
| 168 |
} |
|---|
| 169 |
return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); |
|---|
| 170 |
} |
|---|
| 171 |
|
|---|
| 172 |
struct video_tuner32 { |
|---|
| 173 |
compat_int_t tuner; |
|---|
| 174 |
char name[32]; |
|---|
| 175 |
compat_ulong_t rangelow, rangehigh; |
|---|
| 176 |
u32 flags; |
|---|
| 177 |
u16 mode, signal; |
|---|
| 178 |
}; |
|---|
| 179 |
|
|---|
| 180 |
static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) |
|---|
| 181 |
{ |
|---|
| 182 |
int i; |
|---|
| 183 |
|
|---|
| 184 |
if(get_user(kp->tuner, &up->tuner)) |
|---|
| 185 |
return -EFAULT; |
|---|
| 186 |
for(i = 0; i < 32; i++) |
|---|
| 187 |
__get_user(kp->name[i], &up->name[i]); |
|---|
| 188 |
__get_user(kp->rangelow, &up->rangelow); |
|---|
| 189 |
__get_user(kp->rangehigh, &up->rangehigh); |
|---|
| 190 |
__get_user(kp->flags, &up->flags); |
|---|
| 191 |
__get_user(kp->mode, &up->mode); |
|---|
| 192 |
__get_user(kp->signal, &up->signal); |
|---|
| 193 |
return 0; |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) |
|---|
| 197 |
{ |
|---|
| 198 |
int i; |
|---|
| 199 |
|
|---|
| 200 |
if(put_user(kp->tuner, &up->tuner)) |
|---|
| 201 |
return -EFAULT; |
|---|
| 202 |
for(i = 0; i < 32; i++) |
|---|
| 203 |
__put_user(kp->name[i], &up->name[i]); |
|---|
| 204 |
__put_user(kp->rangelow, &up->rangelow); |
|---|
| 205 |
__put_user(kp->rangehigh, &up->rangehigh); |
|---|
| 206 |
__put_user(kp->flags, &up->flags); |
|---|
| 207 |
__put_user(kp->mode, &up->mode); |
|---|
| 208 |
__put_user(kp->signal, &up->signal); |
|---|
| 209 |
return 0; |
|---|
| 210 |
} |
|---|
| 211 |
|
|---|
| 212 |
struct video_buffer32 { |
|---|
| 213 |
compat_caddr_t base; |
|---|
| 214 |
compat_int_t height, width, depth, bytesperline; |
|---|
| 215 |
}; |
|---|
| 216 |
|
|---|
| 217 |
static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) |
|---|
| 218 |
{ |
|---|
| 219 |
u32 tmp; |
|---|
| 220 |
|
|---|
| 221 |
if (get_user(tmp, &up->base)) |
|---|
| 222 |
return -EFAULT; |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
kp->base = (void *)(unsigned long) tmp; |
|---|
| 228 |
|
|---|
| 229 |
__get_user(kp->height, &up->height); |
|---|
| 230 |
__get_user(kp->width, &up->width); |
|---|
| 231 |
__get_user(kp->depth, &up->depth); |
|---|
| 232 |
__get_user(kp->bytesperline, &up->bytesperline); |
|---|
| 233 |
return 0; |
|---|
| 234 |
} |
|---|
| 235 |
|
|---|
| 236 |
static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) |
|---|
| 237 |
{ |
|---|
| 238 |
u32 tmp = (u32)((unsigned long)kp->base); |
|---|
| 239 |
|
|---|
| 240 |
if(put_user(tmp, &up->base)) |
|---|
| 241 |
return -EFAULT; |
|---|
| 242 |
__put_user(kp->height, &up->height); |
|---|
| 243 |
__put_user(kp->width, &up->width); |
|---|
| 244 |
__put_user(kp->depth, &up->depth); |
|---|
| 245 |
__put_user(kp->bytesperline, &up->bytesperline); |
|---|
| 246 |
return 0; |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
struct video_clip32 { |
|---|
| 250 |
s32 x, y, width, height; |
|---|
| 251 |
compat_caddr_t next; |
|---|
| 252 |
}; |
|---|
| 253 |
|
|---|
| 254 |
struct video_window32 { |
|---|
| 255 |
u32 x, y, width, height, chromakey, flags; |
|---|
| 256 |
compat_caddr_t clips; |
|---|
| 257 |
compat_int_t clipcount; |
|---|
| 258 |
}; |
|---|
| 259 |
|
|---|
| 260 |
static void free_kvideo_clips(struct video_window *kp) |
|---|
| 261 |
{ |
|---|
| 262 |
struct video_clip *cp; |
|---|
| 263 |
|
|---|
| 264 |
cp = kp->clips; |
|---|
| 265 |
if(cp != NULL) |
|---|
| 266 |
kfree(cp); |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
static int get_video_window32(struct video_window *kp, struct video_window32 __user *up) |
|---|
| 270 |
{ |
|---|
| 271 |
struct video_clip32 __user *ucp; |
|---|
| 272 |
struct video_clip *kcp; |
|---|
| 273 |
int nclips, err, i; |
|---|
| 274 |
u32 tmp; |
|---|
| 275 |
|
|---|
| 276 |
if(get_user(kp->x, &up->x)) |
|---|
| 277 |
return -EFAULT; |
|---|
| 278 |
__get_user(kp->y, &up->y); |
|---|
| 279 |
__get_user(kp->width, &up->width); |
|---|
| 280 |
__get_user(kp->height, &up->height); |
|---|
| 281 |
__get_user(kp->chromakey, &up->chromakey); |
|---|
| 282 |
__get_user(kp->flags, &up->flags); |
|---|
| 283 |
__get_user(kp->clipcount, &up->clipcount); |
|---|
| 284 |
__get_user(tmp, &up->clips); |
|---|
| 285 |
ucp = compat_ptr(tmp); |
|---|
| 286 |
kp->clips = NULL; |
|---|
| 287 |
|
|---|
| 288 |
nclips = kp->clipcount; |
|---|
| 289 |
if(nclips == 0) |
|---|
| 290 |
return 0; |
|---|
| 291 |
|
|---|
| 292 |
if(ucp == 0) |
|---|
| 293 |
return -EINVAL; |
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
if(nclips < 0) |
|---|
| 297 |
nclips = VIDEO_CLIPMAP_SIZE; |
|---|
| 298 |
|
|---|
| 299 |
kcp = kmalloc(nclips * sizeof(struct video_clip), GFP_KERNEL); |
|---|
| 300 |
err = -ENOMEM; |
|---|
| 301 |
if(kcp == NULL) |
|---|
| 302 |
goto cleanup_and_err; |
|---|
| 303 |
|
|---|
| 304 |
kp->clips = kcp; |
|---|
| 305 |
for(i = 0; i < nclips; i++) { |
|---|
| 306 |
__get_user(kcp[i].x, &ucp[i].x); |
|---|
| 307 |
__get_user(kcp[i].y, &ucp[i].y); |
|---|
| 308 |
__get_user(kcp[i].width, &ucp[i].width); |
|---|
| 309 |
__get_user(kcp[i].height, &ucp[i].height); |
|---|
| 310 |
kcp[nclips].next = NULL; |
|---|
| 311 |
} |
|---|
| 312 |
|
|---|
| 313 |
return 0; |
|---|
| 314 |
|
|---|
| 315 |
cleanup_and_err: |
|---|
| 316 |
free_kvideo_clips(kp); |
|---|
| 317 |
return err; |
|---|
| 318 |
} |
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) |
|---|
| 322 |
{ |
|---|
| 323 |
if(put_user(kp->x, &up->x)) |
|---|
| 324 |
return -EFAULT; |
|---|
| 325 |
__put_user(kp->y, &up->y); |
|---|
| 326 |
__put_user(kp->width, &up->width); |
|---|
| 327 |
__put_user(kp->height, &up->height); |
|---|
| 328 |
__put_user(kp->chromakey, &up->chromakey); |
|---|
| 329 |
__put_user(kp->flags, &up->flags); |
|---|
| 330 |
__put_user(kp->clipcount, &up->clipcount); |
|---|
| 331 |
return 0; |
|---|
| 332 |
} |
|---|
| 333 |
|
|---|
| 334 |
#define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32) |
|---|
| 335 |
#define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32) |
|---|
| 336 |
#define VIDIOCGWIN32 _IOR('v',9, struct video_window32) |
|---|
| 337 |
#define VIDIOCSWIN32 _IOW('v',10, struct video_window32) |
|---|
| 338 |
#define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32) |
|---|
| 339 |
#define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32) |
|---|
| 340 |
#define VIDIOCGFREQ32 _IOR('v',14, u32) |
|---|
| 341 |
#define VIDIOCSFREQ32 _IOW('v',15, u32) |
|---|
| 342 |
|
|---|
| 343 |
static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 344 |
{ |
|---|
| 345 |
union { |
|---|
| 346 |
struct video_tuner vt; |
|---|
| 347 |
struct video_buffer vb; |
|---|
| 348 |
struct video_window vw; |
|---|
| 349 |
unsigned long vx; |
|---|
| 350 |
} karg; |
|---|
| 351 |
mm_segment_t old_fs = get_fs(); |
|---|
| 352 |
void __user *up = compat_ptr(arg); |
|---|
| 353 |
int err = 0; |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
switch(cmd) { |
|---|
| 357 |
case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; |
|---|
| 358 |
case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; |
|---|
| 359 |
case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; |
|---|
| 360 |
case VIDIOCSWIN32: cmd = VIDIOCSWIN; break; |
|---|
| 361 |
case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break; |
|---|
| 362 |
case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; |
|---|
| 363 |
case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; |
|---|
| 364 |
case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; |
|---|
| 365 |
}; |
|---|
| 366 |
|
|---|
| 367 |
switch(cmd) { |
|---|
| 368 |
case VIDIOCSTUNER: |
|---|
| 369 |
case VIDIOCGTUNER: |
|---|
| 370 |
err = get_video_tuner32(&karg.vt, up); |
|---|
| 371 |
break; |
|---|
| 372 |
|
|---|
| 373 |
case VIDIOCSWIN: |
|---|
| 374 |
err = get_video_window32(&karg.vw, up); |
|---|
| 375 |
break; |
|---|
| 376 |
|
|---|
| 377 |
case VIDIOCSFBUF: |
|---|
| 378 |
err = get_video_buffer32(&karg.vb, up); |
|---|
| 379 |
break; |
|---|
| 380 |
|
|---|
| 381 |
case VIDIOCSFREQ: |
|---|
| 382 |
err = get_user(karg.vx, (u32 __user *)up); |
|---|
| 383 |
break; |
|---|
| 384 |
}; |
|---|
| 385 |
if(err) |
|---|
| 386 |
goto out; |
|---|
| 387 |
|
|---|
| 388 |
set_fs(KERNEL_DS); |
|---|
| 389 |
err = sys_ioctl(fd, cmd, (unsigned long)&karg); |
|---|
| 390 |
set_fs(old_fs); |
|---|
| 391 |
|
|---|
| 392 |
if(cmd == VIDIOCSWIN) |
|---|
| 393 |
free_kvideo_clips(&karg.vw); |
|---|
| 394 |
|
|---|
| 395 |
if(err == 0) { |
|---|
| 396 |
switch(cmd) { |
|---|
| 397 |
case VIDIOCGTUNER: |
|---|
| 398 |
err = put_video_tuner32(&karg.vt, up); |
|---|
| 399 |
break; |
|---|
| 400 |
|
|---|
| 401 |
case VIDIOCGWIN: |
|---|
| 402 |
err = put_video_window32(&karg.vw, up); |
|---|
| 403 |
break; |
|---|
| 404 |
|
|---|
| 405 |
case VIDIOCGFBUF: |
|---|
| 406 |
err = put_video_buffer32(&karg.vb, up); |
|---|
| 407 |
break; |
|---|
| 408 |
|
|---|
| 409 |
case VIDIOCGFREQ: |
|---|
| 410 |
err = put_user(((u32)karg.vx), (u32 __user *)up); |
|---|
| 411 |
break; |
|---|
| 412 |
}; |
|---|
| 413 |
} |
|---|
| 414 |
out: |
|---|
| 415 |
return err; |
|---|
| 416 |
} |
|---|
| 417 |
|
|---|
| 418 |
static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 419 |
{ |
|---|
| 420 |
struct compat_timeval __user *up = compat_ptr(arg); |
|---|
| 421 |
struct timeval ktv; |
|---|
| 422 |
mm_segment_t old_fs = get_fs(); |
|---|
| 423 |
int err; |
|---|
| 424 |
|
|---|
| 425 |
set_fs(KERNEL_DS); |
|---|
| 426 |
err = sys_ioctl(fd, cmd, (unsigned long)&ktv); |
|---|
| 427 |
set_fs(old_fs); |
|---|
| 428 |
if(!err) { |
|---|
| 429 |
err = put_user(ktv.tv_sec, &up->tv_sec); |
|---|
| 430 |
err |= __put_user(ktv.tv_usec, &up->tv_usec); |
|---|
| 431 |
} |
|---|
| 432 |
return err; |
|---|
| 433 |
} |
|---|
| 434 |
|
|---|
| 435 |
struct ifmap32 { |
|---|
| 436 |
compat_ulong_t mem_start; |
|---|
| 437 |
compat_ulong_t mem_end; |
|---|
| 438 |
unsigned short base_addr; |
|---|
| 439 |
unsigned char irq; |
|---|
| 440 |
unsigned char dma; |
|---|
| 441 |
unsigned char port; |
|---|
| 442 |
}; |
|---|
| 443 |
|
|---|
| 444 |
struct ifreq32 { |
|---|
| 445 |
#define IFHWADDRLEN 6 |
|---|
| 446 |
#define IFNAMSIZ 16 |
|---|
| 447 |
union { |
|---|
| 448 |
char ifrn_name[IFNAMSIZ]; |
|---|
| 449 |
} ifr_ifrn; |
|---|
| 450 |
union { |
|---|
| 451 |
struct sockaddr ifru_addr; |
|---|
| 452 |
struct sockaddr ifru_dstaddr; |
|---|
| 453 |
struct sockaddr ifru_broadaddr; |
|---|
| 454 |
struct sockaddr ifru_netmask; |
|---|
| 455 |
struct sockaddr ifru_hwaddr; |
|---|
| 456 |
short ifru_flags; |
|---|
| 457 |
compat_int_t ifru_ivalue; |
|---|
| 458 |
compat_int_t ifru_mtu; |
|---|
| 459 |
struct ifmap32 ifru_map; |
|---|
| 460 |
char ifru_slave[IFNAMSIZ]; |
|---|
| 461 |
char ifru_newname[IFNAMSIZ]; |
|---|
| 462 |
compat_caddr_t ifru_data; |
|---|
| 463 |
|
|---|
| 464 |
} ifr_ifru; |
|---|
| 465 |
}; |
|---|
| 466 |
|
|---|
| 467 |
struct ifconf32 { |
|---|
| 468 |
compat_int_t ifc_len; |
|---|
| 469 |
compat_caddr_t ifcbuf; |
|---|
| 470 |
}; |
|---|
| 471 |
|
|---|
| 472 |
#ifdef CONFIG_NET |
|---|
| 473 |
static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 474 |
{ |
|---|
| 475 |
struct net_device *dev; |
|---|
| 476 |
struct ifreq32 ifr32; |
|---|
| 477 |
int err; |
|---|
| 478 |
|
|---|
| 479 |
if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32))) |
|---|
| 480 |
return -EFAULT; |
|---|
| 481 |
|
|---|
| 482 |
dev = dev_get_by_index(ifr32.ifr_ifindex); |
|---|
| 483 |
if (!dev) |
|---|
| 484 |
return -ENODEV; |
|---|
| 485 |
|
|---|
| 486 |
strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); |
|---|
| 487 |
dev_put(dev); |
|---|
| 488 |
|
|---|
| 489 |
err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); |
|---|
| 490 |
return (err ? -EFAULT : 0); |
|---|
| 491 |
} |
|---|
| 492 |
#endif |
|---|
| 493 |
|
|---|
| 494 |
static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 495 |
{ |
|---|
| 496 |
struct ifconf32 ifc32; |
|---|
| 497 |
struct ifconf ifc; |
|---|
| 498 |
struct ifconf __user *uifc; |
|---|
| 499 |
struct ifreq32 __user *ifr32; |
|---|
| 500 |
struct ifreq __user *ifr; |
|---|
| 501 |
unsigned int i, j; |
|---|
| 502 |
int err; |
|---|
| 503 |
|
|---|
| 504 |
if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32))) |
|---|
| 505 |
return -EFAULT; |
|---|
| 506 |
|
|---|
| 507 |
if (ifc32.ifcbuf == 0) { |
|---|
| 508 |
ifc32.ifc_len = 0; |
|---|
| 509 |
ifc.ifc_len = 0; |
|---|
| 510 |
ifc.ifc_req = NULL; |
|---|
| 511 |
uifc = compat_alloc_user_space(sizeof(struct ifconf)); |
|---|
| 512 |
} else { |
|---|
| 513 |
size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) * |
|---|
| 514 |
sizeof (struct ifreq); |
|---|
| 515 |
uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); |
|---|
| 516 |
ifc.ifc_len = len; |
|---|
| 517 |
ifr = ifc.ifc_req = (void __user *)(uifc + 1); |
|---|
| 518 |
ifr32 = compat_ptr(ifc32.ifcbuf); |
|---|
| 519 |
for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) { |
|---|
| 520 |
if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32))) |
|---|
| 521 |
return -EFAULT; |
|---|
| 522 |
ifr++; |
|---|
| 523 |
ifr32++; |
|---|
| 524 |
} |
|---|
| 525 |
} |
|---|
| 526 |
if (copy_to_user(uifc, &ifc, sizeof(struct ifconf))) |
|---|
| 527 |
return -EFAULT; |
|---|
| 528 |
|
|---|
| 529 |
err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc); |
|---|
| 530 |
if (err) |
|---|
| 531 |
return err; |
|---|
| 532 |
|
|---|
| 533 |
if (copy_from_user(&ifc, uifc, sizeof(struct ifconf))) |
|---|
| 534 |
return -EFAULT; |
|---|
| 535 |
|
|---|
| 536 |
ifr = ifc.ifc_req; |
|---|
| 537 |
ifr32 = compat_ptr(ifc32.ifcbuf); |
|---|
| 538 |
for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len; |
|---|
| 539 |
i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) { |
|---|
| 540 |
if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32))) |
|---|
| 541 |
return -EFAULT; |
|---|
| 542 |
ifr32++; |
|---|
| 543 |
ifr++; |
|---|
| 544 |
} |
|---|
| 545 |
|
|---|
| 546 |
if (ifc32.ifcbuf == 0) { |
|---|
| 547 |
|
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 |
i = ifc.ifc_len; |
|---|
| 551 |
i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32)); |
|---|
| 552 |
ifc32.ifc_len = i; |
|---|
| 553 |
} else { |
|---|
| 554 |
if (i <= ifc32.ifc_len) |
|---|
| 555 |
ifc32.ifc_len = i; |
|---|
| 556 |
else |
|---|
| 557 |
ifc32.ifc_len = i - sizeof (struct ifreq32); |
|---|
| 558 |
} |
|---|
| 559 |
if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32))) |
|---|
| 560 |
return -EFAULT; |
|---|
| 561 |
|
|---|
| 562 |
return 0; |
|---|
| 563 |
} |
|---|
| 564 |
|
|---|
| 565 |
static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 566 |
{ |
|---|
| 567 |
struct ifreq __user *ifr; |
|---|
| 568 |
struct ifreq32 __user *ifr32; |
|---|
| 569 |
u32 data; |
|---|
| 570 |
void __user *datap; |
|---|
| 571 |
|
|---|
| 572 |
ifr = compat_alloc_user_space(sizeof(*ifr)); |
|---|
| 573 |
ifr32 = compat_ptr(arg); |
|---|
| 574 |
|
|---|
| 575 |
if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) |
|---|
| 576 |
return -EFAULT; |
|---|
| 577 |
|
|---|
| 578 |
if (get_user(data, &ifr32->ifr_ifru.ifru_data)) |
|---|
| 579 |
return -EFAULT; |
|---|
| 580 |
|
|---|
| 581 |
datap = compat_ptr(data); |
|---|
| 582 |
if (put_user(datap, &ifr->ifr_ifru.ifru_data)) |
|---|
| 583 |
return -EFAULT; |
|---|
| 584 |
|
|---|
| 585 |
return sys_ioctl(fd, cmd, (unsigned long) ifr); |
|---|
| 586 |
} |
|---|
| 587 |
|
|---|
| 588 |
static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 589 |
{ |
|---|
| 590 |
struct ifreq kifr; |
|---|
| 591 |
struct ifreq __user *uifr; |
|---|
| 592 |
struct ifreq32 __user *ifr32 = compat_ptr(arg); |
|---|
| 593 |
mm_segment_t old_fs; |
|---|
| 594 |
int err; |
|---|
| 595 |
u32 data; |
|---|
| 596 |
void __user *datap; |
|---|
| 597 |
|
|---|
| 598 |
switch (cmd) { |
|---|
| 599 |
case SIOCBONDENSLAVE: |
|---|
| 600 |
case SIOCBONDRELEASE: |
|---|
| 601 |
case SIOCBONDSETHWADDR: |
|---|
| 602 |
case SIOCBONDCHANGEACTIVE: |
|---|
| 603 |
if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32))) |
|---|
| 604 |
return -EFAULT; |
|---|
| 605 |
|
|---|
| 606 |
old_fs = get_fs(); |
|---|
| 607 |
set_fs (KERNEL_DS); |
|---|
| 608 |
err = sys_ioctl (fd, cmd, (unsigned long)&kifr); |
|---|
| 609 |
set_fs (old_fs); |
|---|
| 610 |
|
|---|
| 611 |
return err; |
|---|
| 612 |
case SIOCBONDSLAVEINFOQUERY: |
|---|
| 613 |
case SIOCBONDINFOQUERY: |
|---|
| 614 |
uifr = compat_alloc_user_space(sizeof(*uifr)); |
|---|
| 615 |
if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) |
|---|
| 616 |
return -EFAULT; |
|---|
| 617 |
|
|---|
| 618 |
if (get_user(data, &ifr32->ifr_ifru.ifru_data)) |
|---|
| 619 |
return -EFAULT; |
|---|
| 620 |
|
|---|
| 621 |
datap = compat_ptr(data); |
|---|
| 622 |
if (put_user(datap, &uifr->ifr_ifru.ifru_data)) |
|---|
| 623 |
return -EFAULT; |
|---|
| 624 |
|
|---|
| 625 |
return sys_ioctl (fd, cmd, (unsigned long)uifr); |
|---|
| 626 |
default: |
|---|
| 627 |
return -EINVAL; |
|---|
| 628 |
}; |
|---|
| 629 |
} |
|---|
| 630 |
|
|---|
| 631 |
int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 632 |
{ |
|---|
| 633 |
struct ifreq __user *u_ifreq64; |
|---|
| 634 |
struct ifreq32 __user *u_ifreq32 = compat_ptr(arg); |
|---|
| 635 |
char tmp_buf[IFNAMSIZ]; |
|---|
| 636 |
void __user *data64; |
|---|
| 637 |
u32 data32; |
|---|
| 638 |
|
|---|
| 639 |
if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]), |
|---|
| 640 |
IFNAMSIZ)) |
|---|
| 641 |
return -EFAULT; |
|---|
| 642 |
if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data)) |
|---|
| 643 |
return -EFAULT; |
|---|
| 644 |
data64 = compat_ptr(data32); |
|---|
| 645 |
|
|---|
| 646 |
u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64)); |
|---|
| 647 |
|
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 |
copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0], IFNAMSIZ); |
|---|
| 652 |
__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data); |
|---|
| 653 |
|
|---|
| 654 |
return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64); |
|---|
| 655 |
} |
|---|
| 656 |
|
|---|
| 657 |
static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 658 |
{ |
|---|
| 659 |
struct ifreq ifr; |
|---|
| 660 |
struct ifreq32 __user *uifr32; |
|---|
| 661 |
struct ifmap32 __user *uifmap32; |
|---|
| 662 |
mm_segment_t old_fs; |
|---|
| 663 |
int err; |
|---|
| 664 |
|
|---|
| 665 |
uifr32 = compat_ptr(arg); |
|---|
| 666 |
uifmap32 = &uifr32->ifr_ifru.ifru_map; |
|---|
| 667 |
switch (cmd) { |
|---|
| 668 |
case SIOCSIFMAP: |
|---|
| 669 |
err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name)); |
|---|
| 670 |
err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start); |
|---|
| 671 |
err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end); |
|---|
| 672 |
err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr); |
|---|
| 673 |
err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq); |
|---|
| 674 |
err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma); |
|---|
| 675 |
err |= __get_user(ifr.ifr_map.port, &uifmap32->port); |
|---|
| 676 |
if (err) |
|---|
| 677 |
return -EFAULT; |
|---|
| 678 |
break; |
|---|
| 679 |
default: |
|---|
| 680 |
if (copy_from_user(&ifr, uifr32, sizeof(*uifr32))) |
|---|
| 681 |
return -EFAULT; |
|---|
| 682 |
break; |
|---|
| 683 |
} |
|---|
| 684 |
old_fs = get_fs(); |
|---|
| 685 |
set_fs (KERNEL_DS); |
|---|
| 686 |
err = sys_ioctl (fd, cmd, (unsigned long)&ifr); |
|---|
| 687 |
set_fs (old_fs); |
|---|
| 688 |
if (!err) { |
|---|
| 689 |
switch (cmd) { |
|---|
| 690 |
case SIOCGIFFLAGS: |
|---|
| 691 |
case SIOCGIFMETRIC: |
|---|
| 692 |
case SIOCGIFMTU: |
|---|
| 693 |
case SIOCGIFMEM: |
|---|
| 694 |
case SIOCGIFHWADDR: |
|---|
| 695 |
case SIOCGIFINDEX: |
|---|
| 696 |
case SIOCGIFADDR: |
|---|
| 697 |
case SIOCGIFBRDADDR: |
|---|
| 698 |
case SIOCGIFDSTADDR: |
|---|
| 699 |
case SIOCGIFNETMASK: |
|---|
| 700 |
case SIOCGIFTXQLEN: |
|---|
| 701 |
if (copy_to_user(uifr32, &ifr, sizeof(*uifr32))) |
|---|
| 702 |
return -EFAULT; |
|---|
| 703 |
break; |
|---|
| 704 |
case SIOCGIFMAP: |
|---|
| 705 |
err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); |
|---|
| 706 |
err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start); |
|---|
| 707 |
err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end); |
|---|
| 708 |
err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr); |
|---|
| 709 |
err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq); |
|---|
| 710 |
err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma); |
|---|
| 711 |
err |= __put_user(ifr.ifr_map.port, &uifmap32->port); |
|---|
| 712 |
if (err) |
|---|
| 713 |
err = -EFAULT; |
|---|
| 714 |
break; |
|---|
| 715 |
} |
|---|
| 716 |
} |
|---|
| 717 |
return err; |
|---|
| 718 |
} |
|---|
| 719 |
|
|---|
| 720 |
struct rtentry32 { |
|---|
| 721 |
u32 rt_pad1; |
|---|
| 722 |
struct sockaddr rt_dst; |
|---|
| 723 |
struct sockaddr rt_gateway; |
|---|
| 724 |
struct sockaddr rt_genmask; |
|---|
| 725 |
unsigned short rt_flags; |
|---|
| 726 |
short rt_pad2; |
|---|
| 727 |
u32 rt_pad3; |
|---|
| 728 |
unsigned char rt_tos; |
|---|
| 729 |
unsigned char rt_class; |
|---|
| 730 |
short rt_pad4; |
|---|
| 731 |
short rt_metric; |
|---|
| 732 |
u32 rt_dev; |
|---|
| 733 |
u32 rt_mtu; |
|---|
| 734 |
u32 rt_window; |
|---|
| 735 |
unsigned short rt_irtt; |
|---|
| 736 |
|
|---|
| 737 |
}; |
|---|
| 738 |
|
|---|
| 739 |
struct in6_rtmsg32 { |
|---|
| 740 |
struct in6_addr rtmsg_dst; |
|---|
| 741 |
struct in6_addr rtmsg_src; |
|---|
| 742 |
struct in6_addr rtmsg_gateway; |
|---|
| 743 |
u32 rtmsg_type; |
|---|
| 744 |
u16 rtmsg_dst_len; |
|---|
| 745 |
u16 rtmsg_src_len; |
|---|
| 746 |
u32 rtmsg_metric; |
|---|
| 747 |
u32 rtmsg_info; |
|---|
| 748 |
u32 rtmsg_flags; |
|---|
| 749 |
s32 rtmsg_ifindex; |
|---|
| 750 |
}; |
|---|
| 751 |
|
|---|
| 752 |
static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 753 |
{ |
|---|
| 754 |
int ret; |
|---|
| 755 |
void *r = NULL; |
|---|
| 756 |
struct in6_rtmsg r6; |
|---|
| 757 |
struct rtentry r4; |
|---|
| 758 |
char devname[16]; |
|---|
| 759 |
u32 rtdev; |
|---|
| 760 |
mm_segment_t old_fs = get_fs(); |
|---|
| 761 |
|
|---|
| 762 |
struct socket *mysock = sockfd_lookup(fd, &ret); |
|---|
| 763 |
|
|---|
| 764 |
if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { |
|---|
| 765 |
struct in6_rtmsg32 __user *ur6 = compat_ptr(arg); |
|---|
| 766 |
ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst), |
|---|
| 767 |
3 * sizeof(struct in6_addr)); |
|---|
| 768 |
ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type)); |
|---|
| 769 |
ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); |
|---|
| 770 |
ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); |
|---|
| 771 |
ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric)); |
|---|
| 772 |
ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info)); |
|---|
| 773 |
ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags)); |
|---|
| 774 |
ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); |
|---|
| 775 |
|
|---|
| 776 |
r = (void *) &r6; |
|---|
| 777 |
} else { |
|---|
| 778 |
struct rtentry32 __user *ur4 = compat_ptr(arg); |
|---|
| 779 |
ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst), |
|---|
| 780 |
3 * sizeof(struct sockaddr)); |
|---|
| 781 |
ret |= __get_user (r4.rt_flags, &(ur4->rt_flags)); |
|---|
| 782 |
ret |= __get_user (r4.rt_metric, &(ur4->rt_metric)); |
|---|
| 783 |
ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu)); |
|---|
| 784 |
ret |= __get_user (r4.rt_window, &(ur4->rt_window)); |
|---|
| 785 |
ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt)); |
|---|
| 786 |
ret |= __get_user (rtdev, &(ur4->rt_dev)); |
|---|
| 787 |
if (rtdev) { |
|---|
| 788 |
ret |= copy_from_user (devname, compat_ptr(rtdev), 15); |
|---|
| 789 |
r4.rt_dev = devname; devname[15] = 0; |
|---|
| 790 |
} else |
|---|
| 791 |
r4.rt_dev = 0; |
|---|
| 792 |
|
|---|
| 793 |
r = (void *) &r4; |
|---|
| 794 |
} |
|---|
| 795 |
|
|---|
| 796 |
if (ret) |
|---|
| 797 |
return -EFAULT; |
|---|
| 798 |
|
|---|
| 799 |
set_fs (KERNEL_DS); |
|---|
| 800 |
ret = sys_ioctl (fd, cmd, (unsigned long) r); |
|---|
| 801 |
set_fs (old_fs); |
|---|
| 802 |
|
|---|
| 803 |
if (mysock) |
|---|
| 804 |
sockfd_put(mysock); |
|---|
| 805 |
|
|---|
| 806 |
return ret; |
|---|
| 807 |
} |
|---|
| 808 |
|
|---|
| 809 |
struct hd_geometry32 { |
|---|
| 810 |
unsigned char heads; |
|---|
| 811 |
unsigned char sectors; |
|---|
| 812 |
unsigned short cylinders; |
|---|
| 813 |
u32 start; |
|---|
| 814 |
}; |
|---|
| 815 |
|
|---|
| 816 |
static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 817 |
{ |
|---|
| 818 |
mm_segment_t old_fs = get_fs(); |
|---|
| 819 |
struct hd_geometry geo; |
|---|
| 820 |
struct hd_geometry32 __user *ugeo; |
|---|
| 821 |
int err; |
|---|
| 822 |
|
|---|
| 823 |
set_fs (KERNEL_DS); |
|---|
| 824 |
err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo); |
|---|
| 825 |
set_fs (old_fs); |
|---|
| 826 |
ugeo = compat_ptr(arg); |
|---|
| 827 |
if (!err) { |
|---|
| 828 |
err = copy_to_user (ugeo, &geo, 4); |
|---|
| 829 |
err |= __put_user (geo.start, &ugeo->start); |
|---|
| 830 |
} |
|---|
| 831 |
return err ? -EFAULT : 0; |
|---|
| 832 |
} |
|---|
| 833 |
|
|---|
| 834 |
struct fb_fix_screeninfo32 { |
|---|
| 835 |
char id[16]; |
|---|
| 836 |
compat_caddr_t smem_start; |
|---|
| 837 |
u32 smem_len; |
|---|
| 838 |
u32 type; |
|---|
| 839 |
u32 type_aux; |
|---|
| 840 |
u32 visual; |
|---|
| 841 |
u16 xpanstep; |
|---|
| 842 |
u16 ypanstep; |
|---|
| 843 |
u16 ywrapstep; |
|---|
| 844 |
u32 line_length; |
|---|
| 845 |
compat_caddr_t mmio_start; |
|---|
| 846 |
u32 mmio_len; |
|---|
| 847 |
u32 accel; |
|---|
| 848 |
u16 reserved[3]; |
|---|
| 849 |
}; |
|---|
| 850 |
|
|---|
| 851 |
struct fb_cmap32 { |
|---|
| 852 |
u32 start; |
|---|
| 853 |
u32 len; |
|---|
| 854 |
compat_caddr_t red; |
|---|
| 855 |
compat_caddr_t green; |
|---|
| 856 |
compat_caddr_t blue; |
|---|
| 857 |
compat_caddr_t transp; |
|---|
| 858 |
}; |
|---|
| 859 |
|
|---|
| 860 |
static int fb_getput_cmap(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 861 |
{ |
|---|
| 862 |
struct fb_cmap __user *cmap; |
|---|
| 863 |
struct fb_cmap32 __user *cmap32; |
|---|
| 864 |
__u32 data; |
|---|
| 865 |
int err; |
|---|
| 866 |
|
|---|
| 867 |
cmap = compat_alloc_user_space(sizeof(*cmap)); |
|---|
| 868 |
cmap32 = compat_ptr(arg); |
|---|
| 869 |
|
|---|
| 870 |
if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32))) |
|---|
| 871 |
return -EFAULT; |
|---|
| 872 |
|
|---|
| 873 |
if (get_user(data, &cmap32->red) || |
|---|
| 874 |
put_user(compat_ptr(data), &cmap->red) || |
|---|
| 875 |
get_user(data, &cmap32->green) || |
|---|
| 876 |
put_user(compat_ptr(data), &cmap->green) || |
|---|
| 877 |
get_user(data, &cmap32->blue) || |
|---|
| 878 |
put_user(compat_ptr(data), &cmap->blue) || |
|---|
| 879 |
get_user(data, &cmap32->transp) || |
|---|
| 880 |
put_user(compat_ptr(data), &cmap->transp)) |
|---|
| 881 |
return -EFAULT; |
|---|
| 882 |
|
|---|
| 883 |
err = sys_ioctl(fd, cmd, (unsigned long) cmap); |
|---|
| 884 |
|
|---|
| 885 |
if (!err) { |
|---|
| 886 |
if (copy_in_user(&cmap32->start, |
|---|
| 887 |
&cmap->start, |
|---|
| 888 |
2 * sizeof(__u32))) |
|---|
| 889 |
err = -EFAULT; |
|---|
| 890 |
} |
|---|
| 891 |
return err; |
|---|
| 892 |
} |
|---|
| 893 |
|
|---|
| 894 |
static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix, |
|---|
| 895 |
struct fb_fix_screeninfo32 __user *fix32) |
|---|
| 896 |
{ |
|---|
| 897 |
__u32 data; |
|---|
| 898 |
int err; |
|---|
| 899 |
|
|---|
| 900 |
err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id)); |
|---|
| 901 |
|
|---|
| 902 |
data = (__u32) (unsigned long) fix->smem_start; |
|---|
| 903 |
err |= put_user(data, &fix32->smem_start); |
|---|
| 904 |
|
|---|
| 905 |
err |= put_user(fix->smem_len, &fix32->smem_len); |
|---|
| 906 |
err |= put_user(fix->type, &fix32->type); |
|---|
| 907 |
err |= put_user(fix->type_aux, &fix32->type_aux); |
|---|
| 908 |
err |= put_user(fix->visual, &fix32->visual); |
|---|
| 909 |
err |= put_user(fix->xpanstep, &fix32->xpanstep); |
|---|
| 910 |
err |= put_user(fix->ypanstep, &fix32->ypanstep); |
|---|
| 911 |
err |= put_user(fix->ywrapstep, &fix32->ywrapstep); |
|---|
| 912 |
err |= put_user(fix->line_length, &fix32->line_length); |
|---|
| 913 |
|
|---|
| 914 |
data = (__u32) (unsigned long) fix->mmio_start; |
|---|
| 915 |
err |= put_user(data, &fix32->mmio_start); |
|---|
| 916 |
|
|---|
| 917 |
err |= put_user(fix->mmio_len, &fix32->mmio_len); |
|---|
| 918 |
err |= put_user(fix->accel, &fix32->accel); |
|---|
| 919 |
err |= copy_to_user(fix32->reserved, fix->reserved, |
|---|
| 920 |
sizeof(fix->reserved)); |
|---|
| 921 |
|
|---|
| 922 |
return err; |
|---|
| 923 |
} |
|---|
| 924 |
|
|---|
| 925 |
static int fb_get_fscreeninfo(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 926 |
{ |
|---|
| 927 |
mm_segment_t old_fs; |
|---|
| 928 |
struct fb_fix_screeninfo fix; |
|---|
| 929 |
struct fb_fix_screeninfo32 __user *fix32; |
|---|
| 930 |
int err; |
|---|
| 931 |
|
|---|
| 932 |
fix32 = compat_ptr(arg); |
|---|
| 933 |
|
|---|
| 934 |
old_fs = get_fs(); |
|---|
| 935 |
set_fs(KERNEL_DS); |
|---|
| 936 |
err = sys_ioctl(fd, cmd, (unsigned long) &fix); |
|---|
| 937 |
set_fs(old_fs); |
|---|
| 938 |
|
|---|
| 939 |
if (!err) |
|---|
| 940 |
err = do_fscreeninfo_to_user(&fix, fix32); |
|---|
| 941 |
|
|---|
| 942 |
return err; |
|---|
| 943 |
} |
|---|
| 944 |
|
|---|
| 945 |
static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 946 |
{ |
|---|
| 947 |
int err; |
|---|
| 948 |
|
|---|
| 949 |
switch (cmd) { |
|---|
| 950 |
case FBIOGET_FSCREENINFO: |
|---|
| 951 |
err = fb_get_fscreeninfo(fd,cmd, arg); |
|---|
| 952 |
break; |
|---|
| 953 |
|
|---|
| 954 |
case FBIOGETCMAP: |
|---|
| 955 |
case FBIOPUTCMAP: |
|---|
| 956 |
err = fb_getput_cmap(fd, cmd, arg); |
|---|
| 957 |
break; |
|---|
| 958 |
|
|---|
| 959 |
default: |
|---|
| 960 |
do { |
|---|
| 961 |
static int count; |
|---|
| 962 |
if (++count <= 20) |
|---|
| 963 |
printk("%s: Unknown fb ioctl cmd fd(%d) " |
|---|
| 964 |
"cmd(%08x) arg(%08lx)\n", |
|---|
| 965 |
__FUNCTION__, fd, cmd, arg); |
|---|
| 966 |
} while(0); |
|---|
| 967 |
err = -ENOSYS; |
|---|
| 968 |
break; |
|---|
| 969 |
}; |
|---|
| 970 |
|
|---|
| 971 |
return err; |
|---|
| 972 |
} |
|---|
| 973 |
|
|---|
| 974 |
static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 975 |
{ |
|---|
| 976 |
mm_segment_t old_fs = get_fs(); |
|---|
| 977 |
unsigned long kval; |
|---|
| 978 |
unsigned int __user *uvp; |
|---|
| 979 |
int error; |
|---|
| 980 |
|
|---|
| 981 |
set_fs(KERNEL_DS); |
|---|
| 982 |
error = sys_ioctl(fd, cmd, (long)&kval); |
|---|
| 983 |
set_fs(old_fs); |
|---|
| 984 |
|
|---|
| 985 |
if(error == 0) { |
|---|
| 986 |
uvp = compat_ptr(arg); |
|---|
| 987 |
if(put_user(kval, uvp)) |
|---|
| 988 |
error = -EFAULT; |
|---|
| 989 |
} |
|---|
| 990 |
return error; |
|---|
| 991 |
} |
|---|
| 992 |
|
|---|
| 993 |
|
|---|
| 994 |
typedef struct sg_io_hdr32 { |
|---|
| 995 |
compat_int_t interface_id; |
|---|
| 996 |
compat_int_t dxfer_direction; |
|---|
| 997 |
unsigned char cmd_len; |
|---|
| 998 |
unsigned char mx_sb_len; |
|---|
| 999 |
unsigned short iovec_count; |
|---|
| 1000 |
compat_uint_t dxfer_len; |
|---|
| 1001 |
compat_uint_t dxferp; |
|---|
| 1002 |
or scatter gather list */ |
|---|
| 1003 |
compat_uptr_t cmdp; |
|---|
| 1004 |
compat_uptr_t sbp; |
|---|
| 1005 |
compat_uint_t timeout; |
|---|
| 1006 |
compat_uint_t flags; |
|---|
| 1007 |
compat_int_t pack_id; |
|---|
| 1008 |
compat_uptr_t usr_ptr; |
|---|
| 1009 |
unsigned char status; |
|---|
| 1010 |
unsigned char masked_status; |
|---|
| 1011 |
unsigned char msg_status; |
|---|
| 1012 |
unsigned char sb_len_wr; |
|---|
| 1013 |
unsigned short host_status; |
|---|
| 1014 |
unsigned short driver_status; |
|---|
| 1015 |
compat_int_t resid; |
|---|
| 1016 |
compat_uint_t duration; |
|---|
| 1017 |
compat_uint_t info; |
|---|
| 1018 |
} sg_io_hdr32_t; |
|---|
| 1019 |
|
|---|
| 1020 |
typedef struct sg_iovec32 { |
|---|
| 1021 |
compat_uint_t iov_base; |
|---|
| 1022 |
compat_uint_t iov_len; |
|---|
| 1023 |
} sg_iovec32_t; |
|---|
| 1024 |
|
|---|
| 1025 |
static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count) |
|---|
| 1026 |
{ |
|---|
| 1027 |
sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1); |
|---|
| 1028 |
sg_iovec32_t __user *iov32 = dxferp; |
|---|
| 1029 |
int i; |
|---|
| 1030 |
|
|---|
| 1031 |
for (i = 0; i < iovec_count; i++) { |
|---|
| 1032 |
u32 base, len; |
|---|
| 1033 |
|
|---|
| 1034 |
if (get_user(base, &iov32[i].iov_base) || |
|---|
| 1035 |
get_user(len, &iov32[i].iov_len) || |
|---|
| 1036 |
put_user(compat_ptr(base), &iov[i].iov_base) || |
|---|
| 1037 |
put_user(len, &iov[i].iov_len)) |
|---|
| 1038 |
return -EFAULT; |
|---|
| 1039 |
} |
|---|
| 1040 |
|
|---|
| 1041 |
if (put_user(iov, &sgio->dxferp)) |
|---|
| 1042 |
return -EFAULT; |
|---|
| 1043 |
return 0; |
|---|
| 1044 |
} |
|---|
| 1045 |
|
|---|
| 1046 |
static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1047 |
{ |
|---|
| 1048 |
sg_io_hdr_t __user *sgio; |
|---|
| 1049 |
sg_io_hdr32_t __user *sgio32; |
|---|
| 1050 |
u16 iovec_count; |
|---|
| 1051 |
u32 data; |
|---|
| 1052 |
void __user *dxferp; |
|---|
| 1053 |
int err; |
|---|
| 1054 |
|
|---|
| 1055 |
sgio32 = compat_ptr(arg); |
|---|
| 1056 |
if (get_user(iovec_count, &sgio32->iovec_count)) |
|---|
| 1057 |
return -EFAULT; |
|---|
| 1058 |
|
|---|
| 1059 |
{ |
|---|
| 1060 |
void __user *top = compat_alloc_user_space(0); |
|---|
| 1061 |
void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) + |
|---|
| 1062 |
(iovec_count * sizeof(sg_iovec_t))); |
|---|
| 1063 |
if (new > top) |
|---|
| 1064 |
return -EINVAL; |
|---|
| 1065 |
|
|---|
| 1066 |
sgio = new; |
|---|
| 1067 |
} |
|---|
| 1068 |
|
|---|
| 1069 |
|
|---|
| 1070 |
if (copy_in_user(&sgio->interface_id, &sgio32->interface_id, |
|---|
| 1071 |
(2 * sizeof(int)) + |
|---|
| 1072 |
(2 * sizeof(unsigned char)) + |
|---|
| 1073 |
(1 * sizeof(unsigned short)) + |
|---|
| 1074 |
(1 * sizeof(unsigned int)))) |
|---|
| 1075 |
return -EFAULT; |
|---|
| 1076 |
|
|---|
| 1077 |
if (get_user(data, &sgio32->dxferp)) |
|---|
| 1078 |
return -EFAULT; |
|---|
| 1079 |
dxferp = compat_ptr(data); |
|---|
| 1080 |
if (iovec_count) { |
|---|
| 1081 |
if (sg_build_iovec(sgio, dxferp, iovec_count)) |
|---|
| 1082 |
return -EFAULT; |
|---|
| 1083 |
} else { |
|---|
| 1084 |
if (put_user(dxferp, &sgio->dxferp)) |
|---|
| 1085 |
return -EFAULT; |
|---|
| 1086 |
} |
|---|
| 1087 |
|
|---|
| 1088 |
{ |
|---|
| 1089 |
unsigned char __user *cmdp; |
|---|
| 1090 |
unsigned char __user *sbp; |
|---|
| 1091 |
|
|---|
| 1092 |
if (get_user(data, &sgio32->cmdp)) |
|---|
| 1093 |
return -EFAULT; |
|---|
| 1094 |
cmdp = compat_ptr(data); |
|---|
| 1095 |
|
|---|
| 1096 |
if (get_user(data, &sgio32->sbp)) |
|---|
| 1097 |
return -EFAULT; |
|---|
| 1098 |
sbp = compat_ptr(data); |
|---|
| 1099 |
|
|---|
| 1100 |
if (put_user(cmdp, &sgio->cmdp) || |
|---|
| 1101 |
put_user(sbp, &sgio->sbp)) |
|---|
| 1102 |
return -EFAULT; |
|---|
| 1103 |
} |
|---|
| 1104 |
|
|---|
| 1105 |
if (copy_in_user(&sgio->timeout, &sgio32->timeout, |
|---|
| 1106 |
3 * sizeof(int))) |
|---|
| 1107 |
return -EFAULT; |
|---|
| 1108 |
|
|---|
| 1109 |
if (get_user(data, &sgio32->usr_ptr)) |
|---|
| 1110 |
return -EFAULT; |
|---|
| 1111 |
if (put_user(compat_ptr(data), &sgio->usr_ptr)) |
|---|
| 1112 |
return -EFAULT; |
|---|
| 1113 |
|
|---|
| 1114 |
if (copy_in_user(&sgio->status, &sgio32->status, |
|---|
| 1115 |
(4 * sizeof(unsigned char)) + |
|---|
| 1116 |
(2 * sizeof(unsigned (short))) + |
|---|
| 1117 |
(3 * sizeof(int)))) |
|---|
| 1118 |
return -EFAULT; |
|---|
| 1119 |
|
|---|
| 1120 |
err = sys_ioctl(fd, cmd, (unsigned long) sgio); |
|---|
| 1121 |
|
|---|
| 1122 |
if (err >= 0) { |
|---|
| 1123 |
void __user *datap; |
|---|
| 1124 |
|
|---|
| 1125 |
if (copy_in_user(&sgio32->pack_id, &sgio->pack_id, |
|---|
| 1126 |
sizeof(int)) || |
|---|
| 1127 |
get_user(datap, &sgio->usr_ptr) || |
|---|
| 1128 |
put_user((u32)(unsigned long)datap, |
|---|
| 1129 |
&sgio32->usr_ptr) || |
|---|
| 1130 |
copy_in_user(&sgio32->status, &sgio->status, |
|---|
| 1131 |
(4 * sizeof(unsigned char)) + |
|---|
| 1132 |
(2 * sizeof(unsigned short)) + |
|---|
| 1133 |
(3 * sizeof(int)))) |
|---|
| 1134 |
err = -EFAULT; |
|---|
| 1135 |
} |
|---|
| 1136 |
|
|---|
| 1137 |
return err; |
|---|
| 1138 |
} |
|---|
| 1139 |
|
|---|
| 1140 |
struct sock_fprog32 { |
|---|
| 1141 |
unsigned short len; |
|---|
| 1142 |
compat_caddr_t filter; |
|---|
| 1143 |
}; |
|---|
| 1144 |
|
|---|
| 1145 |
#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) |
|---|
| 1146 |
#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) |
|---|
| 1147 |
|
|---|
| 1148 |
static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1149 |
{ |
|---|
| 1150 |
struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg); |
|---|
| 1151 |
struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); |
|---|
| 1152 |
void __user *fptr64; |
|---|
| 1153 |
u32 fptr32; |
|---|
| 1154 |
u16 flen; |
|---|
| 1155 |
|
|---|
| 1156 |
if (get_user(flen, &u_fprog32->len) || |
|---|
| 1157 |
get_user(fptr32, &u_fprog32->filter)) |
|---|
| 1158 |
return -EFAULT; |
|---|
| 1159 |
|
|---|
| 1160 |
fptr64 = compat_ptr(fptr32); |
|---|
| 1161 |
|
|---|
| 1162 |
if (put_user(flen, &u_fprog64->len) || |
|---|
| 1163 |
put_user(fptr64, &u_fprog64->filter)) |
|---|
| 1164 |
return -EFAULT; |
|---|
| 1165 |
|
|---|
| 1166 |
if (cmd == PPPIOCSPASS32) |
|---|
| 1167 |
cmd = PPPIOCSPASS; |
|---|
| 1168 |
else |
|---|
| 1169 |
cmd = PPPIOCSACTIVE; |
|---|
| 1170 |
|
|---|
| 1171 |
return sys_ioctl(fd, cmd, (unsigned long) u_fprog64); |
|---|
| 1172 |
} |
|---|
| 1173 |
|
|---|
| 1174 |
struct ppp_option_data32 { |
|---|
| 1175 |
compat_caddr_t ptr; |
|---|
| 1176 |
u32 length; |
|---|
| 1177 |
compat_int_t transmit; |
|---|
| 1178 |
}; |
|---|
| 1179 |
#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32) |
|---|
| 1180 |
|
|---|
| 1181 |
struct ppp_idle32 { |
|---|
| 1182 |
compat_time_t xmit_idle; |
|---|
| 1183 |
compat_time_t recv_idle; |
|---|
| 1184 |
}; |
|---|
| 1185 |
#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) |
|---|
| 1186 |
|
|---|
| 1187 |
static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1188 |
{ |
|---|
| 1189 |
struct ppp_idle __user *idle; |
|---|
| 1190 |
struct ppp_idle32 __user *idle32; |
|---|
| 1191 |
__kernel_time_t xmit, recv; |
|---|
| 1192 |
int err; |
|---|
| 1193 |
|
|---|
| 1194 |
idle = compat_alloc_user_space(sizeof(*idle)); |
|---|
| 1195 |
idle32 = compat_ptr(arg); |
|---|
| 1196 |
|
|---|
| 1197 |
err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); |
|---|
| 1198 |
|
|---|
| 1199 |
if (!err) { |
|---|
| 1200 |
if (get_user(xmit, &idle->xmit_idle) || |
|---|
| 1201 |
get_user(recv, &idle->recv_idle) || |
|---|
| 1202 |
put_user(xmit, &idle32->xmit_idle) || |
|---|
| 1203 |
put_user(recv, &idle32->recv_idle)) |
|---|
| 1204 |
err = -EFAULT; |
|---|
| 1205 |
} |
|---|
| 1206 |
return err; |
|---|
| 1207 |
} |
|---|
| 1208 |
|
|---|
| 1209 |
static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1210 |
{ |
|---|
| 1211 |
struct ppp_option_data __user *odata; |
|---|
| 1212 |
struct ppp_option_data32 __user *odata32; |
|---|
| 1213 |
__u32 data; |
|---|
| 1214 |
void __user *datap; |
|---|
| 1215 |
|
|---|
| 1216 |
odata = compat_alloc_user_space(sizeof(*odata)); |
|---|
| 1217 |
odata32 = compat_ptr(arg); |
|---|
| 1218 |
|
|---|
| 1219 |
if (get_user(data, &odata32->ptr)) |
|---|
| 1220 |
return -EFAULT; |
|---|
| 1221 |
|
|---|
| 1222 |
datap = compat_ptr(data); |
|---|
| 1223 |
if (put_user(datap, &odata->ptr)) |
|---|
| 1224 |
return -EFAULT; |
|---|
| 1225 |
|
|---|
| 1226 |
if (copy_in_user(&odata->length, &odata32->length, |
|---|
| 1227 |
sizeof(__u32) + sizeof(int))) |
|---|
| 1228 |
return -EFAULT; |
|---|
| 1229 |
|
|---|
| 1230 |
return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); |
|---|
| 1231 |
} |
|---|
| 1232 |
|
|---|
| 1233 |
static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1234 |
{ |
|---|
| 1235 |
int err; |
|---|
| 1236 |
|
|---|
| 1237 |
switch (cmd) { |
|---|
| 1238 |
case PPPIOCGIDLE32: |
|---|
| 1239 |
err = ppp_gidle(fd, cmd, arg); |
|---|
| 1240 |
break; |
|---|
| 1241 |
|
|---|
| 1242 |
case PPPIOCSCOMPRESS32: |
|---|
| 1243 |
err = ppp_scompress(fd, cmd, arg); |
|---|
| 1244 |
break; |
|---|
| 1245 |
|
|---|
| 1246 |
default: |
|---|
| 1247 |
do { |
|---|
| 1248 |
static int count; |
|---|
| 1249 |
if (++count <= 20) |
|---|
| 1250 |
printk("ppp_ioctl: Unknown cmd fd(%d) " |
|---|
| 1251 |
"cmd(%08x) arg(%08x)\n", |
|---|
| 1252 |
(int)fd, (unsigned int)cmd, (unsigned int)arg); |
|---|
| 1253 |
} while(0); |
|---|
| 1254 |
err = -EINVAL; |
|---|
| 1255 |
break; |
|---|
| 1256 |
}; |
|---|
| 1257 |
|
|---|
| 1258 |
return err; |
|---|
| 1259 |
} |
|---|
| 1260 |
|
|---|
| 1261 |
|
|---|
| 1262 |
struct mtget32 { |
|---|
| 1263 |
compat_long_t mt_type; |
|---|
| 1264 |
compat_long_t mt_resid; |
|---|
| 1265 |
compat_long_t mt_dsreg; |
|---|
| 1266 |
compat_long_t mt_gstat; |
|---|
| 1267 |
compat_long_t mt_erreg; |
|---|
| 1268 |
compat_daddr_t mt_fileno; |
|---|
| 1269 |
compat_daddr_t mt_blkno; |
|---|
| 1270 |
}; |
|---|
| 1271 |
#define MTIOCGET32 _IOR('m', 2, struct mtget32) |
|---|
| 1272 |
|
|---|
| 1273 |
struct mtpos32 { |
|---|
| 1274 |
compat_long_t mt_blkno; |
|---|
| 1275 |
}; |
|---|
| 1276 |
#define MTIOCPOS32 _IOR('m', 3, struct mtpos32) |
|---|
| 1277 |
|
|---|
| 1278 |
struct mtconfiginfo32 { |
|---|
| 1279 |
compat_long_t mt_type; |
|---|
| 1280 |
compat_long_t ifc_type; |
|---|
| 1281 |
unsigned short irqnr; |
|---|
| 1282 |
unsigned short dmanr; |
|---|
| 1283 |
unsigned short port; |
|---|
| 1284 |
compat_ulong_t debug; |
|---|
| 1285 |
compat_uint_t have_dens:1; |
|---|
| 1286 |
compat_uint_t have_bsf:1; |
|---|
| 1287 |
compat_uint_t have_fsr:1; |
|---|
| 1288 |
compat_uint_t have_bsr:1; |
|---|
| 1289 |
compat_uint_t have_eod:1; |
|---|
| 1290 |
compat_uint_t have_seek:1; |
|---|
| 1291 |
compat_uint_t have_tell:1; |
|---|
| 1292 |
compat_uint_t have_ras1:1; |
|---|
| 1293 |
compat_uint_t have_ras2:1; |
|---|
| 1294 |
compat_uint_t have_ras3:1; |
|---|
| 1295 |
compat_uint_t have_qfa:1; |
|---|
| 1296 |
compat_uint_t pad1:5; |
|---|
| 1297 |
char reserved[10]; |
|---|
| 1298 |
}; |
|---|
| 1299 |
#define MTIOCGETCONFIG32 _IOR('m', 4, struct mtconfiginfo32) |
|---|
| 1300 |
#define MTIOCSETCONFIG32 _IOW('m', 5, struct mtconfiginfo32) |
|---|
| 1301 |
|
|---|
| 1302 |
static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1303 |
{ |
|---|
| 1304 |
mm_segment_t old_fs = get_fs(); |
|---|
| 1305 |
struct mtconfiginfo info; |
|---|
| 1306 |
struct mtconfiginfo32 __user *uinfo32; |
|---|
| 1307 |
struct mtget get; |
|---|
| 1308 |
struct mtget32 __user *umget32; |
|---|
| 1309 |
struct mtpos pos; |
|---|
| 1310 |
struct mtpos32 __user *upos32; |
|---|
| 1311 |
unsigned long kcmd; |
|---|
| 1312 |
void *karg; |
|---|
| 1313 |
int err = 0; |
|---|
| 1314 |
|
|---|
| 1315 |
switch(cmd) { |
|---|
| 1316 |
case MTIOCPOS32: |
|---|
| 1317 |
kcmd = MTIOCPOS; |
|---|
| 1318 |
karg = &pos; |
|---|
| 1319 |
break; |
|---|
| 1320 |
case MTIOCGET32: |
|---|
| 1321 |
kcmd = MTIOCGET; |
|---|
| 1322 |
karg = &get; |
|---|
| 1323 |
break; |
|---|
| 1324 |
case MTIOCGETCONFIG32: |
|---|
| 1325 |
kcmd = MTIOCGETCONFIG; |
|---|
| 1326 |
karg = &info; |
|---|
| 1327 |
break; |
|---|
| 1328 |
case MTIOCSETCONFIG32: |
|---|
| 1329 |
kcmd = MTIOCSETCONFIG; |
|---|
| 1330 |
karg = &info; |
|---|
| 1331 |
uinfo32 = compat_ptr(arg); |
|---|
| 1332 |
err = __get_user(info.mt_type, &uinfo32->mt_type); |
|---|
| 1333 |
err |= __get_user(info.ifc_type, &uinfo32->ifc_type); |
|---|
| 1334 |
err |= __get_user(info.irqnr, &uinfo32->irqnr); |
|---|
| 1335 |
err |= __get_user(info.dmanr, &uinfo32->dmanr); |
|---|
| 1336 |
err |= __get_user(info.port, &uinfo32->port); |
|---|
| 1337 |
err |= __get_user(info.debug, &uinfo32->debug); |
|---|
| 1338 |
err |= __copy_from_user((char *)&info.debug |
|---|
| 1339 |
+ sizeof(info.debug), |
|---|
| 1340 |
(char __user *)&uinfo32->debug |
|---|
| 1341 |
+ sizeof(uinfo32->debug), sizeof(__u32)); |
|---|
| 1342 |
if (err) |
|---|
| 1343 |
return -EFAULT; |
|---|
| 1344 |
break; |
|---|
| 1345 |
default: |
|---|
| 1346 |
do { |
|---|
| 1347 |
static int count; |
|---|
| 1348 |
if (++count <= 20) |
|---|
| 1349 |
printk("mt_ioctl: Unknown cmd fd(%d) " |
|---|
| 1350 |
"cmd(%08x) arg(%08x)\n", |
|---|
| 1351 |
(int)fd, (unsigned int)cmd, (unsigned int)arg); |
|---|
| 1352 |
} while(0); |
|---|
| 1353 |
return -EINVAL; |
|---|
| 1354 |
} |
|---|
| 1355 |
set_fs (KERNEL_DS); |
|---|
| 1356 |
err = sys_ioctl (fd, kcmd, (unsigned long)karg); |
|---|
| 1357 |
set_fs (old_fs); |
|---|
| 1358 |
if (err) |
|---|
| 1359 |
return err; |
|---|
| 1360 |
switch (cmd) { |
|---|
| 1361 |
case MTIOCPOS32: |
|---|
| 1362 |
upos32 = compat_ptr(arg); |
|---|
| 1363 |
err = __put_user(pos.mt_blkno, &upos32->mt_blkno); |
|---|
| 1364 |
break; |
|---|
| 1365 |
case MTIOCGET32: |
|---|
| 1366 |
umget32 = compat_ptr(arg); |
|---|
| 1367 |
err = __put_user(get.mt_type, &umget32->mt_type); |
|---|
| 1368 |
err |= __put_user(get.mt_resid, &umget32->mt_resid); |
|---|
| 1369 |
err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); |
|---|
| 1370 |
err |= __put_user(get.mt_gstat, &umget32->mt_gstat); |
|---|
| 1371 |
err |= __put_user(get.mt_erreg, &umget32->mt_erreg); |
|---|
| 1372 |
err |= __put_user(get.mt_fileno, &umget32->mt_fileno); |
|---|
| 1373 |
err |= __put_user(get.mt_blkno, &umget32->mt_blkno); |
|---|
| 1374 |
break; |
|---|
| 1375 |
case MTIOCGETCONFIG32: |
|---|
| 1376 |
uinfo32 = compat_ptr(arg); |
|---|
| 1377 |
err = __put_user(info.mt_type, &uinfo32->mt_type); |
|---|
| 1378 |
err |= __put_user(info.ifc_type, &uinfo32->ifc_type); |
|---|
| 1379 |
err |= __put_user(info.irqnr, &uinfo32->irqnr); |
|---|
| 1380 |
err |= __put_user(info.dmanr, &uinfo32->dmanr); |
|---|
| 1381 |
err |= __put_user(info.port, &uinfo32->port); |
|---|
| 1382 |
err |= __put_user(info.debug, &uinfo32->debug); |
|---|
| 1383 |
err |= __copy_to_user((char __user *)&uinfo32->debug |
|---|
| 1384 |
+ sizeof(uinfo32->debug), |
|---|
| 1385 |
(char *)&info.debug + sizeof(info.debug), sizeof(__u32)); |
|---|
| 1386 |
break; |
|---|
| 1387 |
case MTIOCSETCONFIG32: |
|---|
| 1388 |
break; |
|---|
| 1389 |
} |
|---|
| 1390 |
return err ? -EFAULT: 0; |
|---|
| 1391 |
} |
|---|
| 1392 |
|
|---|
| 1393 |
struct cdrom_read_audio32 { |
|---|
| 1394 |
union cdrom_addr addr; |
|---|
| 1395 |
u8 addr_format; |
|---|
| 1396 |
compat_int_t nframes; |
|---|
| 1397 |
compat_caddr_t buf; |
|---|
| 1398 |
}; |
|---|
| 1399 |
|
|---|
| 1400 |
struct cdrom_generic_command32 { |
|---|
| 1401 |
unsigned char cmd[CDROM_PACKET_SIZE]; |
|---|
| 1402 |
compat_caddr_t buffer; |
|---|
| 1403 |
compat_uint_t buflen; |
|---|
| 1404 |
compat_int_t stat; |
|---|
| 1405 |
compat_caddr_t sense; |
|---|
| 1406 |
unsigned char data_direction; |
|---|
| 1407 |
compat_int_t quiet; |
|---|
| 1408 |
compat_int_t timeout; |
|---|
| 1409 |
compat_caddr_t reserved[1]; |
|---|
| 1410 |
}; |
|---|
| 1411 |
|
|---|
| 1412 |
static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1413 |
{ |
|---|
| 1414 |
struct cdrom_read_audio __user *cdread_audio; |
|---|
| 1415 |
struct cdrom_read_audio32 __user *cdread_audio32; |
|---|
| 1416 |
__u32 data; |
|---|
| 1417 |
void __user *datap; |
|---|
| 1418 |
|
|---|
| 1419 |
cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio)); |
|---|
| 1420 |
cdread_audio32 = compat_ptr(arg); |
|---|
| 1421 |
|
|---|
| 1422 |
if (copy_in_user(&cdread_audio->addr, |
|---|
| 1423 |
&cdread_audio32->addr, |
|---|
| 1424 |
(sizeof(*cdread_audio32) - |
|---|
| 1425 |
sizeof(compat_caddr_t)))) |
|---|
| 1426 |
return -EFAULT; |
|---|
| 1427 |
|
|---|
| 1428 |
if (get_user(data, &cdread_audio32->buf)) |
|---|
| 1429 |
return -EFAULT; |
|---|
| 1430 |
datap = compat_ptr(data); |
|---|
| 1431 |
if (put_user(datap, &cdread_audio->buf)) |
|---|
| 1432 |
return -EFAULT; |
|---|
| 1433 |
|
|---|
| 1434 |
return sys_ioctl(fd, cmd, (unsigned long) cdread_audio); |
|---|
| 1435 |
} |
|---|
| 1436 |
|
|---|
| 1437 |
static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1438 |
{ |
|---|
| 1439 |
struct cdrom_generic_command __user *cgc; |
|---|
| 1440 |
struct cdrom_generic_command32 __user *cgc32; |
|---|
| 1441 |
u32 data; |
|---|
| 1442 |
unsigned char dir; |
|---|
| 1443 |
int itmp; |
|---|
| 1444 |
|
|---|
| 1445 |
cgc = compat_alloc_user_space(sizeof(*cgc)); |
|---|
| 1446 |
cgc32 = compat_ptr(arg); |
|---|
| 1447 |
|
|---|
| 1448 |
if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) || |
|---|
| 1449 |
get_user(data, &cgc32->buffer) || |
|---|
| 1450 |
put_user(compat_ptr(data), &cgc->buffer) || |
|---|
| 1451 |
copy_in_user(&cgc->buflen, &cgc32->buflen, |
|---|
| 1452 |
(sizeof(unsigned int) + sizeof(int))) || |
|---|
| 1453 |
get_user(data, &cgc32->sense) || |
|---|
| 1454 |
put_user(compat_ptr(data), &cgc->sense) || |
|---|
| 1455 |
get_user(dir, &cgc32->data_direction) || |
|---|
| 1456 |
put_user(dir, &cgc->data_direction) || |
|---|
| 1457 |
get_user(itmp, &cgc32->quiet) || |
|---|
| 1458 |
put_user(itmp, &cgc->quiet) || |
|---|
| 1459 |
get_user(itmp, &cgc32->timeout) || |
|---|
| 1460 |
put_user(itmp, &cgc->timeout) || |
|---|
| 1461 |
get_user(data, &cgc32->reserved[0]) || |
|---|
| 1462 |
put_user(compat_ptr(data), &cgc->reserved[0])) |
|---|
| 1463 |
return -EFAULT; |
|---|
| 1464 |
|
|---|
| 1465 |
return sys_ioctl(fd, cmd, (unsigned long) cgc); |
|---|
| 1466 |
} |
|---|
| 1467 |
|
|---|
| 1468 |
static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1469 |
{ |
|---|
| 1470 |
int err; |
|---|
| 1471 |
|
|---|
| 1472 |
switch(cmd) { |
|---|
| 1473 |
case CDROMREADAUDIO: |
|---|
| 1474 |
err = cdrom_do_read_audio(fd, cmd, arg); |
|---|
| 1475 |
break; |
|---|
| 1476 |
|
|---|
| 1477 |
case CDROM_SEND_PACKET: |
|---|
| 1478 |
err = cdrom_do_generic_command(fd, cmd, arg); |
|---|
| 1479 |
break; |
|---|
| 1480 |
|
|---|
| 1481 |
default: |
|---|
| 1482 |
do { |
|---|
| 1483 |
static int count; |
|---|
| 1484 |
if (++count <= 20) |
|---|
| 1485 |
printk("cdrom_ioctl: Unknown cmd fd(%d) " |
|---|
| 1486 |
"cmd(%08x) arg(%08x)\n", |
|---|
| 1487 |
(int)fd, (unsigned int)cmd, (unsigned int)arg); |
|---|
| 1488 |
} while(0); |
|---|
| 1489 |
err = -EINVAL; |
|---|
| 1490 |
break; |
|---|
| 1491 |
}; |
|---|
| 1492 |
|
|---|
| 1493 |
return err; |
|---|
| 1494 |
} |
|---|
| 1495 |
|
|---|
| 1496 |
struct loop_info32 { |
|---|
| 1497 |
compat_int_t lo_number; |
|---|
| 1498 |
compat_dev_t lo_device; |
|---|
| 1499 |
compat_ulong_t lo_inode; |
|---|
| 1500 |
compat_dev_t lo_rdevice; |
|---|
| 1501 |
compat_int_t lo_offset; |
|---|
| 1502 |
compat_int_t lo_encrypt_type; |
|---|
| 1503 |
compat_int_t lo_encrypt_key_size; |
|---|
| 1504 |
compat_int_t lo_flags; |
|---|
| 1505 |
char lo_name[LO_NAME_SIZE]; |
|---|
| 1506 |
unsigned char lo_encrypt_key[LO_KEY_SIZE]; |
|---|
| 1507 |
compat_ulong_t lo_init[2]; |
|---|
| 1508 |
char reserved[4]; |
|---|
| 1509 |
}; |
|---|
| 1510 |
|
|---|
| 1511 |
static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1512 |
{ |
|---|
| 1513 |
mm_segment_t old_fs = get_fs(); |
|---|
| 1514 |
struct loop_info l; |
|---|
| 1515 |
struct loop_info32 __user *ul; |
|---|
| 1516 |
int err = -EINVAL; |
|---|
| 1517 |
|
|---|
| 1518 |
ul = compat_ptr(arg); |
|---|
| 1519 |
switch(cmd) { |
|---|
| 1520 |
case LOOP_SET_STATUS: |
|---|
| 1521 |
err = get_user(l.lo_number, &ul->lo_number); |
|---|
| 1522 |
err |= __get_user(l.lo_device, &ul->lo_device); |
|---|
| 1523 |
err |= __get_user(l.lo_inode, &ul->lo_inode); |
|---|
| 1524 |
err |= __get_user(l.lo_rdevice, &ul->lo_rdevice); |
|---|
| 1525 |
err |= __copy_from_user(&l.lo_offset, &ul->lo_offset, |
|---|
| 1526 |
8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset); |
|---|
| 1527 |
if (err) { |
|---|
| 1528 |
err = -EFAULT; |
|---|
| 1529 |
} else { |
|---|
| 1530 |
set_fs (KERNEL_DS); |
|---|
| 1531 |
err = sys_ioctl (fd, cmd, (unsigned long)&l); |
|---|
| 1532 |
set_fs (old_fs); |
|---|
| 1533 |
} |
|---|
| 1534 |
break; |
|---|
| 1535 |
case LOOP_GET_STATUS: |
|---|
| 1536 |
set_fs (KERNEL_DS); |
|---|
| 1537 |
err = sys_ioctl (fd, cmd, (unsigned long)&l); |
|---|
| 1538 |
set_fs (old_fs); |
|---|
| 1539 |
if (!err) { |
|---|
| 1540 |
err = put_user(l.lo_number, &ul->lo_number); |
|---|
| 1541 |
err |= __put_user(l.lo_device, &ul->lo_device); |
|---|
| 1542 |
err |= __put_user(l.lo_inode, &ul->lo_inode); |
|---|
| 1543 |
err |= __put_user(l.lo_rdevice, &ul->lo_rdevice); |
|---|
| 1544 |
err |= __copy_to_user(&ul->lo_offset, &l.lo_offset, |
|---|
| 1545 |
(unsigned long)l.lo_init - (unsigned long)&l.lo_offset); |
|---|
| 1546 |
if (err) |
|---|
| 1547 |
err = -EFAULT; |
|---|
| 1548 |
} |
|---|
| 1549 |
break; |
|---|
| 1550 |
default: { |
|---|
| 1551 |
static int count; |
|---|
| 1552 |
if (++count <= 20) |
|---|
| 1553 |
printk("%s: Unknown loop ioctl cmd, fd(%d) " |
|---|
| 1554 |
"cmd(%08x) arg(%08lx)\n", |
|---|
| 1555 |
__FUNCTION__, fd, cmd, arg); |
|---|
| 1556 |
} |
|---|
| 1557 |
} |
|---|
| 1558 |
return err; |
|---|
| 1559 |
} |
|---|
| 1560 |
|
|---|
| 1561 |
extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); |
|---|
| 1562 |
|
|---|
| 1563 |
#ifdef CONFIG_VT |
|---|
| 1564 |
|
|---|
| 1565 |
static int vt_check(struct file *file) |
|---|
| 1566 |
{ |
|---|
| 1567 |
struct tty_struct *tty; |
|---|
| 1568 |
struct inode *inode = file->f_dentry->d_inode; |
|---|
| 1569 |
|
|---|
| 1570 |
if (file->f_op->ioctl != tty_ioctl) |
|---|
| 1571 |
return -EINVAL; |
|---|
| 1572 |
|
|---|
| 1573 |
tty = (struct tty_struct *)file->private_data; |
|---|
| 1574 |
if (tty_paranoia_check(tty, inode, "tty_ioctl")) |
|---|
| 1575 |
return -EINVAL; |
|---|
| 1576 |
|
|---|
| 1577 |
if (tty->driver->ioctl != vt_ioctl) |
|---|
| 1578 |
return -EINVAL; |
|---|
| 1579 |
|
|---|
| 1580 |
|
|---|
| 1581 |
|
|---|
| 1582 |
|
|---|
| 1583 |
|
|---|
| 1584 |
if (current->signal->tty == tty || capable(CAP_SYS_ADMIN)) |
|---|
| 1585 |
return 1; |
|---|
| 1586 |
return 0; |
|---|
| 1587 |
} |
|---|
| 1588 |
|
|---|
| 1589 |
struct consolefontdesc32 { |
|---|
| 1590 |
unsigned short charcount; |
|---|
| 1591 |
unsigned short charheight; |
|---|
| 1592 |
compat_caddr_t chardata; |
|---|
| 1593 |
}; |
|---|
| 1594 |
|
|---|
| 1595 |
static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) |
|---|
| 1596 |
{ |
|---|
| 1597 |
struct consolefontdesc32 __user *user_cfd = compat_ptr(arg); |
|---|
| 1598 |
struct console_font_op op; |
|---|
| 1599 |
compat_caddr_t data; |
|---|
| 1600 |
int i, perm; |
|---|
| 1601 |
|
|---|
| 1602 |
perm = vt_check(file); |
|---|
| 1603 |
if (perm < 0) return perm; |
|---|
| 1604 |
|
|---|
| 1605 |
switch (cmd) { |
|---|
| 1606 |
case PIO_FONTX: |
|---|
| 1607 |
if (!perm) |
|---|
| 1608 |
return -EPERM; |
|---|
| 1609 |
op.op = KD_FONT_OP_SET; |
|---|
| 1610 |
op.flags = 0; |
|---|
| 1611 |
op.width = 8; |
|---|
| 1612 |
if (get_user(op.height, &user_cfd->charheight) || |
|---|
| 1613 |
get_user(op.charcount, &user_cfd->charcount) || |
|---|
| 1614 |
get_user(data, &user_cfd->chardata)) |
|---|
| 1615 |
return -EFAULT; |
|---|
| 1616 |
op.data = compat_ptr(data); |
|---|
| 1617 |
return con_font_op(fg_console, &op); |
|---|
| 1618 |
case GIO_FONTX: |
|---|
| 1619 |
op.op = KD_FONT_OP_GET; |
|---|
| 1620 |
op.flags = 0; |
|---|
| 1621 |
op.width = 8; |
|---|
| 1622 |
if (get_user(op.height, &user_cfd->charheight) || |
|---|
| 1623 |
get_user(op.charcount, &user_cfd->charcount) || |
|---|
| 1624 |
get_user(data, &user_cfd->chardata)) |
|---|
| 1625 |
return -EFAULT; |
|---|
| 1626 |
if (!data) |
|---|
| 1627 |
return 0; |
|---|
| 1628 |
op.data = compat_ptr(data); |
|---|
| 1629 |
i = con_font_op(fg_console, &op); |
|---|
| 1630 |
if (i) |
|---|
| 1631 |
return i; |
|---|
| 1632 |
if (put_user(op.height, &user_cfd->charheight) || |
|---|
| 1633 |
put_user(op.charcount, &user_cfd->charcount) || |
|---|
| 1634 |
put_user((compat_caddr_t)(unsigned long)op.data, |
|---|
| 1635 |
&user_cfd->chardata)) |
|---|
| 1636 |
return -EFAULT; |
|---|
| 1637 |
return 0; |
|---|
| 1638 |
} |
|---|
| 1639 |
return -EINVAL; |
|---|
| 1640 |
} |
|---|
| 1641 |
|
|---|
| 1642 |
struct console_font_op32 { |
|---|
| 1643 |
compat_uint_t op; |
|---|
| 1644 |
compat_uint_t flags; |
|---|
| 1645 |
compat_uint_t width, height; |
|---|
| 1646 |
compat_uint_t charcount; |
|---|
| 1647 |
compat_caddr_t data; |
|---|
| 1648 |
}; |
|---|
| 1649 |
|
|---|
| 1650 |
static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) |
|---|
| 1651 |
{ |
|---|
| 1652 |
struct console_font_op op; |
|---|
| 1653 |
struct console_font_op32 __user *fontop = compat_ptr(arg); |
|---|
| 1654 |
int perm = vt_check(file), i; |
|---|
| 1655 |
struct vt_struct *vt; |
|---|
| 1656 |
|
|---|
| 1657 |
if (perm < 0) return perm; |
|---|
| 1658 |
|
|---|
| 1659 |
if (copy_from_user(&op, fontop, sizeof(struct console_font_op32))) |
|---|
| 1660 |
return -EFAULT; |
|---|
| 1661 |
if (!perm && op.op != KD_FONT_OP_GET) |
|---|
| 1662 |
return -EPERM; |
|---|
| 1663 |
op.data = compat_ptr(((struct console_font_op32 *)&op)->data); |
|---|
| 1664 |
op.flags |= KD_FONT_FLAG_OLD; |
|---|
| 1665 |
vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data; |
|---|
| 1666 |
i = con_font_op(vt->vc_num, &op); |
|---|
| 1667 |
if (i) return i; |
|---|
| 1668 |
((struct console_font_op32 *)&op)->data = (unsigned long)op.data; |
|---|
| 1669 |
if (copy_to_user(fontop, &op, sizeof(struct console_font_op32))) |
|---|
| 1670 |
return -EFAULT; |
|---|
| 1671 |
return 0; |
|---|
| 1672 |
} |
|---|
| 1673 |
|
|---|
| 1674 |
struct unimapdesc32 { |
|---|
| 1675 |
unsigned short entry_ct; |
|---|
| 1676 |
compat_caddr_t entries; |
|---|
| 1677 |
}; |
|---|
| 1678 |
|
|---|
| 1679 |
static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) |
|---|
| 1680 |
{ |
|---|
| 1681 |
struct unimapdesc32 tmp; |
|---|
| 1682 |
struct unimapdesc32 __user *user_ud = compat_ptr(arg); |
|---|
| 1683 |
int perm = vt_check(file); |
|---|
| 1684 |
|
|---|
| 1685 |
if (perm < 0) return perm; |
|---|
| 1686 |
if (copy_from_user(&tmp, user_ud, sizeof tmp)) |
|---|
| 1687 |
return -EFAULT; |
|---|
| 1688 |
switch (cmd) { |
|---|
| 1689 |
case PIO_UNIMAP: |
|---|
| 1690 |
if (!perm) return -EPERM; |
|---|
| 1691 |
return con_set_unimap(fg_console, tmp.entry_ct, compat_ptr(tmp.entries)); |
|---|
| 1692 |
case GIO_UNIMAP: |
|---|
| 1693 |
return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries)); |
|---|
| 1694 |
} |
|---|
| 1695 |
return 0; |
|---|
| 1696 |
} |
|---|
| 1697 |
|
|---|
| 1698 |
#endif |
|---|
| 1699 |
|
|---|
| 1700 |
static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1701 |
{ |
|---|
| 1702 |
mm_segment_t old_fs = get_fs(); |
|---|
| 1703 |
__kernel_uid_t kuid; |
|---|
| 1704 |
int err; |
|---|
| 1705 |
|
|---|
| 1706 |
cmd = SMB_IOC_GETMOUNTUID; |
|---|
| 1707 |
|
|---|
| 1708 |
set_fs(KERNEL_DS); |
|---|
| 1709 |
err = sys_ioctl(fd, cmd, (unsigned long)&kuid); |
|---|
| 1710 |
set_fs(old_fs); |
|---|
| 1711 |
|
|---|
| 1712 |
if (err >= 0) |
|---|
| 1713 |
err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg)); |
|---|
| 1714 |
|
|---|
| 1715 |
return err; |
|---|
| 1716 |
} |
|---|
| 1717 |
|
|---|
| 1718 |
struct atmif_sioc32 { |
|---|
| 1719 |
compat_int_t number; |
|---|
| 1720 |
compat_int_t length; |
|---|
| 1721 |
compat_caddr_t arg; |
|---|
| 1722 |
}; |
|---|
| 1723 |
|
|---|
| 1724 |
struct atm_iobuf32 { |
|---|
| 1725 |
compat_int_t length; |
|---|
| 1726 |
compat_caddr_t buffer; |
|---|
| 1727 |
}; |
|---|
| 1728 |
|
|---|
| 1729 |
#define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32) |
|---|
| 1730 |
#define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32) |
|---|
| 1731 |
#define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32) |
|---|
| 1732 |
#define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32) |
|---|
| 1733 |
#define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32) |
|---|
| 1734 |
#define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32) |
|---|
| 1735 |
#define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32) |
|---|
| 1736 |
#define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32) |
|---|
| 1737 |
#define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32) |
|---|
| 1738 |
#define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32) |
|---|
| 1739 |
#define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32) |
|---|
| 1740 |
#define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32) |
|---|
| 1741 |
#define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32) |
|---|
| 1742 |
#define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32) |
|---|
| 1743 |
#define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32) |
|---|
| 1744 |
#define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32) |
|---|
| 1745 |
#define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32) |
|---|
| 1746 |
|
|---|
| 1747 |
static struct { |
|---|
| 1748 |
unsigned int cmd32; |
|---|
| 1749 |
unsigned int cmd; |
|---|
| 1750 |
} atm_ioctl_map[] = { |
|---|
| 1751 |
{ ATM_GETLINKRATE32, ATM_GETLINKRATE }, |
|---|
| 1752 |
{ ATM_GETNAMES32, ATM_GETNAMES }, |
|---|
| 1753 |
{ ATM_GETTYPE32, ATM_GETTYPE }, |
|---|
| 1754 |
{ ATM_GETESI32, ATM_GETESI }, |
|---|
| 1755 |
{ ATM_GETADDR32, ATM_GETADDR }, |
|---|
| 1756 |
{ ATM_RSTADDR32, ATM_RSTADDR }, |
|---|
| 1757 |
{ ATM_ADDADDR32, ATM_ADDADDR }, |
|---|
| 1758 |
{ ATM_DELADDR32, ATM_DELADDR }, |
|---|
| 1759 |
{ ATM_GETCIRANGE32, ATM_GETCIRANGE }, |
|---|
| 1760 |
{ ATM_SETCIRANGE32, ATM_SETCIRANGE }, |
|---|
| 1761 |
{ ATM_SETESI32, ATM_SETESI }, |
|---|
| 1762 |
{ ATM_SETESIF32, ATM_SETESIF }, |
|---|
| 1763 |
{ ATM_GETSTAT32, ATM_GETSTAT }, |
|---|
| 1764 |
{ ATM_GETSTATZ32, ATM_GETSTATZ }, |
|---|
| 1765 |
{ ATM_GETLOOP32, ATM_GETLOOP }, |
|---|
| 1766 |
{ ATM_SETLOOP32, ATM_SETLOOP }, |
|---|
| 1767 |
{ ATM_QUERYLOOP32, ATM_QUERYLOOP } |
|---|
| 1768 |
}; |
|---|
| 1769 |
|
|---|
| 1770 |
#define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0])) |
|---|
| 1771 |
|
|---|
| 1772 |
|
|---|
| 1773 |
static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1774 |
{ |
|---|
| 1775 |
struct atm_iobuf __user *iobuf; |
|---|
| 1776 |
struct atm_iobuf32 __user *iobuf32; |
|---|
| 1777 |
u32 data; |
|---|
| 1778 |
void __user *datap; |
|---|
| 1779 |
int len, err; |
|---|
| 1780 |
|
|---|
| 1781 |
iobuf = compat_alloc_user_space(sizeof(*iobuf)); |
|---|
| 1782 |
iobuf32 = compat_ptr(arg); |
|---|
| 1783 |
|
|---|
| 1784 |
if (get_user(len, &iobuf32->length) || |
|---|
| 1785 |
get_user(data, &iobuf32->buffer)) |
|---|
| 1786 |
return -EFAULT; |
|---|
| 1787 |
datap = compat_ptr(data); |
|---|
| 1788 |
if (put_user(len, &iobuf->length) || |
|---|
| 1789 |
put_user(datap, &iobuf->buffer)) |
|---|
| 1790 |
return -EFAULT; |
|---|
| 1791 |
|
|---|
| 1792 |
err = sys_ioctl(fd, cmd, (unsigned long)iobuf); |
|---|
| 1793 |
|
|---|
| 1794 |
if (!err) { |
|---|
| 1795 |
if (copy_in_user(&iobuf32->length, &iobuf->length, |
|---|
| 1796 |
sizeof(int))) |
|---|
| 1797 |
err = -EFAULT; |
|---|
| 1798 |
} |
|---|
| 1799 |
|
|---|
| 1800 |
return err; |
|---|
| 1801 |
} |
|---|
| 1802 |
|
|---|
| 1803 |
static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1804 |
{ |
|---|
| 1805 |
struct atmif_sioc __user *sioc; |
|---|
| 1806 |
struct atmif_sioc32 __user *sioc32; |
|---|
| 1807 |
u32 data; |
|---|
| 1808 |
void __user *datap; |
|---|
| 1809 |
int err; |
|---|
| 1810 |
|
|---|
| 1811 |
sioc = compat_alloc_user_space(sizeof(*sioc)); |
|---|
| 1812 |
sioc32 = compat_ptr(arg); |
|---|
| 1813 |
|
|---|
| 1814 |
if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) || |
|---|
| 1815 |
get_user(data, &sioc32->arg)) |
|---|
| 1816 |
return -EFAULT; |
|---|
| 1817 |
datap = compat_ptr(data); |
|---|
| 1818 |
if (put_user(datap, &sioc->arg)) |
|---|
| 1819 |
return -EFAULT; |
|---|
| 1820 |
|
|---|
| 1821 |
err = sys_ioctl(fd, cmd, (unsigned long) sioc); |
|---|
| 1822 |
|
|---|
| 1823 |
if (!err) { |
|---|
| 1824 |
if (copy_in_user(&sioc32->length, &sioc->length, |
|---|
| 1825 |
sizeof(int))) |
|---|
| 1826 |
err = -EFAULT; |
|---|
| 1827 |
} |
|---|
| 1828 |
return err; |
|---|
| 1829 |
} |
|---|
| 1830 |
|
|---|
| 1831 |
static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg) |
|---|
| 1832 |
{ |
|---|
| 1833 |
int i; |
|---|
| 1834 |
unsigned int cmd = 0; |
|---|
| 1835 |
|
|---|
| 1836 |
switch (cmd32) { |
|---|
| 1837 |
case SONET_GETSTAT: |
|---|
| 1838 |
case SONET_GETSTATZ: |
|---|
| 1839 |
case SONET_GETDIAG: |
|---|
| 1840 |
case SONET_SETDIAG: |
|---|
| 1841 |
case SONET_CLRDIAG: |
|---|
| 1842 |
case SONET_SETFRAMING: |
|---|
| 1843 |
case SONET_GETFRAMING: |
|---|
| 1844 |
case SONET_GETFRSENSE: |
|---|
| 1845 |
return do_atmif_sioc(fd, cmd32, arg); |
|---|
| 1846 |
} |
|---|
| 1847 |
|
|---|
| 1848 |
for (i = 0; i < NR_ATM_IOCTL; i++) { |
|---|
| 1849 |
if (cmd32 == atm_ioctl_map[i].cmd32) { |
|---|
| 1850 |
cmd = atm_ioctl_map[i].cmd; |
|---|
| 1851 |
break; |
|---|
| 1852 |
} |
|---|
| 1853 |
} |
|---|
| 1854 |
if (i == NR_ATM_IOCTL) |
|---|
| 1855 |
return -EINVAL; |
|---|
| 1856 |
|
|---|
| 1857 |
switch (cmd) { |
|---|
| 1858 |
case ATM_GETNAMES: |
|---|
| 1859 |
return do_atm_iobuf(fd, cmd, arg); |
|---|
| 1860 |
|
|---|
| 1861 |
case ATM_GETLINKRATE: |
|---|
| 1862 |
case ATM_GETTYPE: |
|---|
| 1863 |
case ATM_GETESI: |
|---|
| 1864 |
case ATM_GETADDR: |
|---|
| 1865 |
case ATM_RSTADDR: |
|---|
| 1866 |
case ATM_ADDADDR: |
|---|
| 1867 |
case ATM_DELADDR: |
|---|
| 1868 |
case ATM_GETCIRANGE: |
|---|
| 1869 |
case ATM_SETCIRANGE: |
|---|
| 1870 |
case ATM_SETESI: |
|---|
| 1871 |
case ATM_SETESIF: |
|---|
| 1872 |
case ATM_GETSTAT: |
|---|
| 1873 |
case ATM_GETSTATZ: |
|---|
| 1874 |
case ATM_GETLOOP: |
|---|
| 1875 |
case ATM_SETLOOP: |
|---|
| 1876 |
case ATM_QUERYLOOP: |
|---|
| 1877 |
return do_atmif_sioc(fd, cmd, arg); |
|---|
| 1878 |
} |
|---|
| 1879 |
|
|---|
| 1880 |
return -EINVAL; |
|---|
| 1881 |
} |
|---|
| 1882 |
|
|---|
| 1883 |
static int ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1884 |
{ |
|---|
| 1885 |
return -EINVAL; |
|---|
| 1886 |
} |
|---|
| 1887 |
|
|---|
| 1888 |
static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1889 |
{ |
|---|
| 1890 |
|
|---|
| 1891 |
return w_long(fd, BLKGETSIZE, arg); |
|---|
| 1892 |
} |
|---|
| 1893 |
|
|---|
| 1894 |
struct blkpg_ioctl_arg32 { |
|---|
| 1895 |
compat_int_t op; |
|---|
| 1896 |
compat_int_t flags; |
|---|
| 1897 |
compat_int_t datalen; |
|---|
| 1898 |
compat_caddr_t data; |
|---|
| 1899 |
}; |
|---|
| 1900 |
|
|---|
| 1901 |
static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1902 |
{ |
|---|
| 1903 |
struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg); |
|---|
| 1904 |
struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a)); |
|---|
| 1905 |
compat_caddr_t udata; |
|---|
| 1906 |
compat_int_t n; |
|---|
| 1907 |
int err; |
|---|
| 1908 |
|
|---|
| 1909 |
err = get_user(n, &ua32->op); |
|---|
| 1910 |
err |= put_user(n, &a->op); |
|---|
| 1911 |
err |= get_user(n, &ua32->flags); |
|---|
| 1912 |
err |= put_user(n, &a->flags); |
|---|
| 1913 |
err |= get_user(n, &ua32->datalen); |
|---|
| 1914 |
err |= put_user(n, &a->datalen); |
|---|
| 1915 |
err |= get_user(udata, &ua32->data); |
|---|
| 1916 |
err |= put_user(compat_ptr(udata), &a->data); |
|---|
| 1917 |
if (err) |
|---|
| 1918 |
return err; |
|---|
| 1919 |
|
|---|
| 1920 |
return sys_ioctl(fd, cmd, (unsigned long)a); |
|---|
| 1921 |
} |
|---|
| 1922 |
|
|---|
| 1923 |
static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1924 |
{ |
|---|
| 1925 |
return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); |
|---|
| 1926 |
} |
|---|
| 1927 |
|
|---|
| 1928 |
|
|---|
| 1929 |
#define BLKBSZGET_32 _IOR(0x12,112,int) |
|---|
| 1930 |
#define BLKBSZSET_32 _IOW(0x12,113,int) |
|---|
| 1931 |
#define BLKGETSIZE64_32 _IOR(0x12,114,int) |
|---|
| 1932 |
|
|---|
| 1933 |
static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1934 |
{ |
|---|
| 1935 |
return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg)); |
|---|
| 1936 |
} |
|---|
| 1937 |
|
|---|
| 1938 |
static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 1939 |
{ |
|---|
| 1940 |
return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg)); |
|---|
| 1941 |
} |
|---|
| 1942 |
|
|---|
| 1943 |
static int do_blkgetsize64(unsigned int fd, unsigned int cmd, |
|---|
| 1944 |
unsigned long arg) |
|---|
| 1945 |
{ |
|---|
| 1946 |
return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg)); |
|---|
| 1947 |
} |
|---|
| 1948 |
|
|---|
| 1949 |
|
|---|
| 1950 |
#define HCIUARTSETPROTO _IOW('U', 200, int) |
|---|
| 1951 |
#define HCIUARTGETPROTO _IOR('U', 201, int) |
|---|
| 1952 |
|
|---|
| 1953 |
#define BNEPCONNADD _IOW('B', 200, int) |
|---|
| 1954 |
#define BNEPCONNDEL _IOW('B', 201, int) |
|---|
| 1955 |
#define BNEPGETCONNLIST _IOR('B', 210, int) |
|---|
| 1956 |
#define BNEPGETCONNINFO _IOR('B', 211, int) |
|---|
| 1957 |
|
|---|
| 1958 |
#define CMTPCONNADD _IOW('C', 200, int) |
|---|
| 1959 |
#define CMTPCONNDEL _IOW('C', 201, int) |
|---|
| 1960 |
#define CMTPGETCONNLIST _IOR('C', 210, int) |
|---|
| 1961 |
#define CMTPGETCONNINFO _IOR('C', 211, int) |
|---|
| 1962 |
|
|---|
| 1963 |
struct floppy_struct32 { |
|---|
| 1964 |
compat_uint_t size; |
|---|
| 1965 |
compat_uint_t sect; |
|---|
| 1966 |
compat_uint_t head; |
|---|
| 1967 |
compat_uint_t track; |
|---|
| 1968 |
compat_uint_t stretch; |
|---|
| 1969 |
unsigned char gap; |
|---|
| 1970 |
unsigned char rate; |
|---|
| 1971 |
unsigned char spec1; |
|---|
| 1972 |
unsigned char fmt_gap; |
|---|
| 1973 |
const compat_caddr_t name; |
|---|
| 1974 |
}; |
|---|
| 1975 |
|
|---|
| 1976 |
struct floppy_drive_params32 { |
|---|
| 1977 |
char cmos; |
|---|
| 1978 |
compat_ulong_t max_dtr; |
|---|
| 1979 |
compat_ulong_t hlt; |
|---|
| 1980 |
compat_ulong_t hut; |
|---|
| 1981 |
compat_ulong_t srt; |
|---|
| 1982 |
compat_ulong_t spinup; |
|---|
| 1983 |
compat_ulong_t spindown; |
|---|
| 1984 |
unsigned char spindown_offset; |
|---|
| 1985 |
unsigned char select_delay; |
|---|
| 1986 |
unsigned char rps; |
|---|
| 1987 |
unsigned char tracks; |
|---|
| 1988 |
compat_ulong_t timeout; |
|---|
| 1989 |
unsigned char interleave_sect; |
|---|
| 1990 |
struct floppy_max_errors max_errors; |
|---|
| 1991 |
char flags; |
|---|
| 1992 |
char read_track; |
|---|
| 1993 |
short autodetect[8]; |
|---|
| 1994 |
compat_int_t checkfreq; |
|---|
| 1995 |
compat_int_t native_format; |
|---|
| 1996 |
}; |
|---|
| 1997 |
|
|---|
| 1998 |
struct floppy_drive_struct32 { |
|---|
| 1999 |
signed char flags; |
|---|
| 2000 |
compat_ulong_t spinup_date; |
|---|
| 2001 |
compat_ulong_t select_date; |
|---|
| 2002 |
compat_ulong_t first_read_date; |
|---|
| 2003 |
short probed_format; |
|---|
| 2004 |
short track; |
|---|
| 2005 |
short maxblock; |
|---|
| 2006 |
short maxtrack; |
|---|
| 2007 |
compat_int_t generation; |
|---|
| 2008 |
compat_int_t keep_data; |
|---|
| 2009 |
compat_int_t fd_ref; |
|---|
| 2010 |
compat_int_t fd_device; |
|---|
| 2011 |
compat_int_t last_checked; |
|---|
| 2012 |
compat_caddr_t dmabuf; |
|---|
| 2013 |
compat_int_t bufblocks; |
|---|
| 2014 |
}; |
|---|
| 2015 |
|
|---|
| 2016 |
struct floppy_fdc_state32 { |
|---|
| 2017 |
compat_int_t spec1; |
|---|
| 2018 |
compat_int_t spec2; |
|---|
| 2019 |
compat_int_t dtr; |
|---|
| 2020 |
unsigned char version; |
|---|
| 2021 |
unsigned char dor; |
|---|
| 2022 |
compat_ulong_t address; |
|---|
| 2023 |
unsigned int rawcmd:2; |
|---|
| 2024 |
unsigned int reset:1; |
|---|
| 2025 |
unsigned int need_configure:1; |
|---|
| 2026 |
unsigned int perp_mode:2; |
|---|
| 2027 |
unsigned int has_fifo:1; |
|---|
| 2028 |
unsigned int driver_version; |
|---|
| 2029 |
unsigned char track[4]; |
|---|
| 2030 |
}; |
|---|
| 2031 |
|
|---|
| 2032 |
struct floppy_write_errors32 { |
|---|
| 2033 |
unsigned int write_errors; |
|---|
| 2034 |
compat_ulong_t first_error_sector; |
|---|
| 2035 |
compat_int_t first_error_generation; |
|---|
| 2036 |
compat_ulong_t last_error_sector; |
|---|
| 2037 |
compat_int_t last_error_generation; |
|---|
| 2038 |
compat_uint_t badness; |
|---|
| 2039 |
}; |
|---|
| 2040 |
|
|---|
| 2041 |
#define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32) |
|---|
| 2042 |
#define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32) |
|---|
| 2043 |
#define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32) |
|---|
| 2044 |
#define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32) |
|---|
| 2045 |
#define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32) |
|---|
| 2046 |
#define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32) |
|---|
| 2047 |
#define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32) |
|---|
| 2048 |
#define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32) |
|---|
| 2049 |
#define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32) |
|---|
| 2050 |
|
|---|
| 2051 |
static struct { |
|---|
| 2052 |
unsigned int cmd32; |
|---|
| 2053 |
unsigned int cmd; |
|---|
| 2054 |
} fd_ioctl_trans_table[] = { |
|---|
| 2055 |
{ FDSETPRM32, FDSETPRM }, |
|---|
| 2056 |
{ FDDEFPRM32, FDDEFPRM }, |
|---|
| 2057 |
{ FDGETPRM32, FDGETPRM }, |
|---|
| 2058 |
{ FDSETDRVPRM32, FDSETDRVPRM }, |
|---|
| 2059 |
{ FDGETDRVPRM32, FDGETDRVPRM }, |
|---|
| 2060 |
{ FDGETDRVSTAT32, FDGETDRVSTAT }, |
|---|
| 2061 |
{ FDPOLLDRVSTAT32, FDPOLLDRVSTAT }, |
|---|
| 2062 |
{ FDGETFDCSTAT32, FDGETFDCSTAT }, |
|---|
| 2063 |
{ FDWERRORGET32, FDWERRORGET } |
|---|
| 2064 |
}; |
|---|
| 2065 |
|
|---|
| 2066 |
#define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0])) |
|---|
| 2067 |
|
|---|
| 2068 |
static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2069 |
{ |
|---|
| 2070 |
mm_segment_t old_fs = get_fs(); |
|---|
| 2071 |
void *karg = NULL; |
|---|
| 2072 |
unsigned int kcmd = 0; |
|---|
| 2073 |
int i, err; |
|---|
| 2074 |
|
|---|
| 2075 |
for (i = 0; i < NR_FD_IOCTL_TRANS; i++) |
|---|
| 2076 |
if (cmd == fd_ioctl_trans_table[i].cmd32) { |
|---|
| 2077 |
kcmd = fd_ioctl_trans_table[i].cmd; |
|---|
| 2078 |
break; |
|---|
| 2079 |
} |
|---|
| 2080 |
if (!kcmd) |
|---|
| 2081 |
return -EINVAL; |
|---|
| 2082 |
|
|---|
| 2083 |
switch (cmd) { |
|---|
| 2084 |
case FDSETPRM32: |
|---|
| 2085 |
case FDDEFPRM32: |
|---|
| 2086 |
case FDGETPRM32: |
|---|
| 2087 |
{ |
|---|
| 2088 |
compat_uptr_t name; |
|---|
| 2089 |
struct floppy_struct32 __user *uf; |
|---|
| 2090 |
struct floppy_struct *f; |
|---|
| 2091 |
|
|---|
| 2092 |
uf = compat_ptr(arg); |
|---|
| 2093 |
f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL); |
|---|
| 2094 |
if (!karg) |
|---|
| 2095 |
return -ENOMEM; |
|---|
| 2096 |
if (cmd == FDGETPRM32) |
|---|
| 2097 |
break; |
|---|
| 2098 |
err = __get_user(f->size, &uf->size); |
|---|
| 2099 |
err |= __get_user(f->sect, &uf->sect); |
|---|
| 2100 |
err |= __get_user(f->head, &uf->head); |
|---|
| 2101 |
err |= __get_user(f->track, &uf->track); |
|---|
| 2102 |
err |= __get_user(f->stretch, &uf->stretch); |
|---|
| 2103 |
err |= __get_user(f->gap, &uf->gap); |
|---|
| 2104 |
err |= __get_user(f->rate, &uf->rate); |
|---|
| 2105 |
err |= __get_user(f->spec1, &uf->spec1); |
|---|
| 2106 |
err |= __get_user(f->fmt_gap, &uf->fmt_gap); |
|---|
| 2107 |
err |= __get_user(name, &uf->name); |
|---|
| 2108 |
f->name = compat_ptr(name); |
|---|
| 2109 |
if (err) { |
|---|
| 2110 |
err = -EFAULT; |
|---|
| 2111 |
goto out; |
|---|
| 2112 |
} |
|---|
| 2113 |
break; |
|---|
| 2114 |
} |
|---|
| 2115 |
case FDSETDRVPRM32: |
|---|
| 2116 |
case FDGETDRVPRM32: |
|---|
| 2117 |
{ |
|---|
| 2118 |
struct floppy_drive_params32 __user *uf; |
|---|
| 2119 |
struct floppy_drive_params *f; |
|---|
| 2120 |
|
|---|
| 2121 |
uf = compat_ptr(arg); |
|---|
| 2122 |
f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL); |
|---|
| 2123 |
if (!karg) |
|---|
| 2124 |
return -ENOMEM; |
|---|
| 2125 |
if (cmd == FDGETDRVPRM32) |
|---|
| 2126 |
break; |
|---|
| 2127 |
err = __get_user(f->cmos, &uf->cmos); |
|---|
| 2128 |
err |= __get_user(f->max_dtr, &uf->max_dtr); |
|---|
| 2129 |
err |= __get_user(f->hlt, &uf->hlt); |
|---|
| 2130 |
err |= __get_user(f->hut, &uf->hut); |
|---|
| 2131 |
err |= __get_user(f->srt, &uf->srt); |
|---|
| 2132 |
err |= __get_user(f->spinup, &uf->spinup); |
|---|
| 2133 |
err |= __get_user(f->spindown, &uf->spindown); |
|---|
| 2134 |
err |= __get_user(f->spindown_offset, &uf->spindown_offset); |
|---|
| 2135 |
err |= __get_user(f->select_delay, &uf->select_delay); |
|---|
| 2136 |
err |= __get_user(f->rps, &uf->rps); |
|---|
| 2137 |
err |= __get_user(f->tracks, &uf->tracks); |
|---|
| 2138 |
err |= __get_user(f->timeout, &uf->timeout); |
|---|
| 2139 |
err |= __get_user(f->interleave_sect, &uf->interleave_sect); |
|---|
| 2140 |
err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors)); |
|---|
| 2141 |
err |= __get_user(f->flags, &uf->flags); |
|---|
| 2142 |
err |= __get_user(f->read_track, &uf->read_track); |
|---|
| 2143 |
err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect)); |
|---|
| 2144 |
err |= __get_user(f->checkfreq, &uf->checkfreq); |
|---|
| 2145 |
err |= __get_user(f->native_format, &uf->native_format); |
|---|
| 2146 |
if (err) { |
|---|
| 2147 |
err = -EFAULT; |
|---|
| 2148 |
goto out; |
|---|
| 2149 |
} |
|---|
| 2150 |
break; |
|---|
| 2151 |
} |
|---|
| 2152 |
case FDGETDRVSTAT32: |
|---|
| 2153 |
case FDPOLLDRVSTAT32: |
|---|
| 2154 |
karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL); |
|---|
| 2155 |
if (!karg) |
|---|
| 2156 |
return -ENOMEM; |
|---|
| 2157 |
break; |
|---|
| 2158 |
case FDGETFDCSTAT32: |
|---|
| 2159 |
karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL); |
|---|
| 2160 |
if (!karg) |
|---|
| 2161 |
return -ENOMEM; |
|---|
| 2162 |
break; |
|---|
| 2163 |
case FDWERRORGET32: |
|---|
| 2164 |
karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL); |
|---|
| 2165 |
if (!karg) |
|---|
| 2166 |
return -ENOMEM; |
|---|
| 2167 |
break; |
|---|
| 2168 |
default: |
|---|
| 2169 |
return -EINVAL; |
|---|
| 2170 |
} |
|---|
| 2171 |
set_fs (KERNEL_DS); |
|---|
| 2172 |
err = sys_ioctl (fd, kcmd, (unsigned long)karg); |
|---|
| 2173 |
set_fs (old_fs); |
|---|
| 2174 |
if (err) |
|---|
| 2175 |
goto out; |
|---|
| 2176 |
switch (cmd) { |
|---|
| 2177 |
case FDGETPRM32: |
|---|
| 2178 |
{ |
|---|
| 2179 |
struct floppy_struct *f = karg; |
|---|
| 2180 |
struct floppy_struct32 __user *uf = compat_ptr(arg); |
|---|
| 2181 |
|
|---|
| 2182 |
err = __put_user(f->size, &uf->size); |
|---|
| 2183 |
err |= __put_user(f->sect, &uf->sect); |
|---|
| 2184 |
err |= __put_user(f->head, &uf->head); |
|---|
| 2185 |
err |= __put_user(f->track, &uf->track); |
|---|
| 2186 |
err |= __put_user(f->stretch, &uf->stretch); |
|---|
| 2187 |
err |= __put_user(f->gap, &uf->gap); |
|---|
| 2188 |
err |= __put_user(f->rate, &uf->rate); |
|---|
| 2189 |
err |= __put_user(f->spec1, &uf->spec1); |
|---|
| 2190 |
err |= __put_user(f->fmt_gap, &uf->fmt_gap); |
|---|
| 2191 |
err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name); |
|---|
| 2192 |
break; |
|---|
| 2193 |
} |
|---|
| 2194 |
case FDGETDRVPRM32: |
|---|
| 2195 |
{ |
|---|
| 2196 |
struct floppy_drive_params32 __user *uf; |
|---|
| 2197 |
struct floppy_drive_params *f = karg; |
|---|
| 2198 |
|
|---|
| 2199 |
uf = compat_ptr(arg); |
|---|
| 2200 |
err = __put_user(f->cmos, &uf->cmos); |
|---|
| 2201 |
err |= __put_user(f->max_dtr, &uf->max_dtr); |
|---|
| 2202 |
err |= __put_user(f->hlt, &uf->hlt); |
|---|
| 2203 |
err |= __put_user(f->hut, &uf->hut); |
|---|
| 2204 |
err |= __put_user(f->srt, &uf->srt); |
|---|
| 2205 |
err |= __put_user(f->spinup, &uf->spinup); |
|---|
| 2206 |
err |= __put_user(f->spindown, &uf->spindown); |
|---|
| 2207 |
err |= __put_user(f->spindown_offset, &uf->spindown_offset); |
|---|
| 2208 |
err |= __put_user(f->select_delay, &uf->select_delay); |
|---|
| 2209 |
err |= __put_user(f->rps, &uf->rps); |
|---|
| 2210 |
err |= __put_user(f->tracks, &uf->tracks); |
|---|
| 2211 |
err |= __put_user(f->timeout, &uf->timeout); |
|---|
| 2212 |
err |= __put_user(f->interleave_sect, &uf->interleave_sect); |
|---|
| 2213 |
err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors)); |
|---|
| 2214 |
err |= __put_user(f->flags, &uf->flags); |
|---|
| 2215 |
err |= __put_user(f->read_track, &uf->read_track); |
|---|
| 2216 |
err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect)); |
|---|
| 2217 |
err |= __put_user(f->checkfreq, &uf->checkfreq); |
|---|
| 2218 |
err |= __put_user(f->native_format, &uf->native_format); |
|---|
| 2219 |
break; |
|---|
| 2220 |
} |
|---|
| 2221 |
case FDGETDRVSTAT32: |
|---|
| 2222 |
case FDPOLLDRVSTAT32: |
|---|
| 2223 |
{ |
|---|
| 2224 |
struct floppy_drive_struct32 __user *uf; |
|---|
| 2225 |
struct floppy_drive_struct *f = karg; |
|---|
| 2226 |
|
|---|
| 2227 |
uf = compat_ptr(arg); |
|---|
| 2228 |
err = __put_user(f->flags, &uf->flags); |
|---|
| 2229 |
err |= __put_user(f->spinup_date, &uf->spinup_date); |
|---|
| 2230 |
err |= __put_user(f->select_date, &uf->select_date); |
|---|
| 2231 |
err |= __put_user(f->first_read_date, &uf->first_read_date); |
|---|
| 2232 |
err |= __put_user(f->probed_format, &uf->probed_format); |
|---|
| 2233 |
err |= __put_user(f->track, &uf->track); |
|---|
| 2234 |
err |= __put_user(f->maxblock, &uf->maxblock); |
|---|
| 2235 |
err |= __put_user(f->maxtrack, &uf->maxtrack); |
|---|
| 2236 |
err |= __put_user(f->generation, &uf->generation); |
|---|
| 2237 |
err |= __put_user(f->keep_data, &uf->keep_data); |
|---|
| 2238 |
err |= __put_user(f->fd_ref, &uf->fd_ref); |
|---|
| 2239 |
err |= __put_user(f->fd_device, &uf->fd_device); |
|---|
| 2240 |
err |= __put_user(f->last_checked, &uf->last_checked); |
|---|
| 2241 |
err |= __put_user((u64)f->dmabuf, &uf->dmabuf); |
|---|
| 2242 |
err |= __put_user((u64)f->bufblocks, &uf->bufblocks); |
|---|
| 2243 |
break; |
|---|
| 2244 |
} |
|---|
| 2245 |
case FDGETFDCSTAT32: |
|---|
| 2246 |
{ |
|---|
| 2247 |
struct floppy_fdc_state32 __user *uf; |
|---|
| 2248 |
struct floppy_fdc_state *f = karg; |
|---|
| 2249 |
|
|---|
| 2250 |
uf = compat_ptr(arg); |
|---|
| 2251 |
err = __put_user(f->spec1, &uf->spec1); |
|---|
| 2252 |
err |= __put_user(f->spec2, &uf->spec2); |
|---|
| 2253 |
err |= __put_user(f->dtr, &uf->dtr); |
|---|
| 2254 |
err |= __put_user(f->version, &uf->version); |
|---|
| 2255 |
err |= __put_user(f->dor, &uf->dor); |
|---|
| 2256 |
err |= __put_user(f->address, &uf->address); |
|---|
| 2257 |
err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address), |
|---|
| 2258 |
(char *)&f->address + sizeof(f->address), sizeof(int)); |
|---|
| 2259 |
err |= __put_user(f->driver_version, &uf->driver_version); |
|---|
| 2260 |
err |= __copy_to_user(uf->track, f->track, sizeof(f->track)); |
|---|
| 2261 |
break; |
|---|
| 2262 |
} |
|---|
| 2263 |
case FDWERRORGET32: |
|---|
| 2264 |
{ |
|---|
| 2265 |
struct floppy_write_errors32 __user *uf; |
|---|
| 2266 |
struct floppy_write_errors *f = karg; |
|---|
| 2267 |
|
|---|
| 2268 |
uf = compat_ptr(arg); |
|---|
| 2269 |
err = __put_user(f->write_errors, &uf->write_errors); |
|---|
| 2270 |
err |= __put_user(f->first_error_sector, &uf->first_error_sector); |
|---|
| 2271 |
err |= __put_user(f->first_error_generation, &uf->first_error_generation); |
|---|
| 2272 |
err |= __put_user(f->last_error_sector, &uf->last_error_sector); |
|---|
| 2273 |
err |= __put_user(f->last_error_generation, &uf->last_error_generation); |
|---|
| 2274 |
err |= __put_user(f->badness, &uf->badness); |
|---|
| 2275 |
break; |
|---|
| 2276 |
} |
|---|
| 2277 |
default: |
|---|
| 2278 |
break; |
|---|
| 2279 |
} |
|---|
| 2280 |
if (err) |
|---|
| 2281 |
err = -EFAULT; |
|---|
| 2282 |
|
|---|
| 2283 |
out: if (karg) kfree(karg); |
|---|
| 2284 |
return err; |
|---|
| 2285 |
} |
|---|
| 2286 |
|
|---|
| 2287 |
struct mtd_oob_buf32 { |
|---|
| 2288 |
u_int32_t start; |
|---|
| 2289 |
u_int32_t length; |
|---|
| 2290 |
compat_caddr_t ptr; |
|---|
| 2291 |
}; |
|---|
| 2292 |
|
|---|
| 2293 |
#define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32) |
|---|
| 2294 |
#define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32) |
|---|
| 2295 |
|
|---|
| 2296 |
static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2297 |
{ |
|---|
| 2298 |
struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf)); |
|---|
| 2299 |
struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg); |
|---|
| 2300 |
u32 data; |
|---|
| 2301 |
char __user *datap; |
|---|
| 2302 |
unsigned int real_cmd; |
|---|
| 2303 |
int err; |
|---|
| 2304 |
|
|---|
| 2305 |
real_cmd = (cmd == MEMREADOOB32) ? |
|---|
| 2306 |
MEMREADOOB : MEMWRITEOOB; |
|---|
| 2307 |
|
|---|
| 2308 |
if (copy_in_user(&buf->start, &buf32->start, |
|---|
| 2309 |
2 * sizeof(u32)) || |
|---|
| 2310 |
get_user(data, &buf32->ptr)) |
|---|
| 2311 |
return -EFAULT; |
|---|
| 2312 |
datap = compat_ptr(data); |
|---|
| 2313 |
if (put_user(datap, &buf->ptr)) |
|---|
| 2314 |
return -EFAULT; |
|---|
| 2315 |
|
|---|
| 2316 |
err = sys_ioctl(fd, real_cmd, (unsigned long) buf); |
|---|
| 2317 |
|
|---|
| 2318 |
if (!err) { |
|---|
| 2319 |
if (copy_in_user(&buf32->start, &buf->start, |
|---|
| 2320 |
2 * sizeof(u32))) |
|---|
| 2321 |
err = -EFAULT; |
|---|
| 2322 |
} |
|---|
| 2323 |
|
|---|
| 2324 |
return err; |
|---|
| 2325 |
} |
|---|
| 2326 |
|
|---|
| 2327 |
#define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2]) |
|---|
| 2328 |
#define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2]) |
|---|
| 2329 |
|
|---|
| 2330 |
static long |
|---|
| 2331 |
put_dirent32 (struct dirent *d, struct compat_dirent __user *d32) |
|---|
| 2332 |
{ |
|---|
| 2333 |
int ret; |
|---|
| 2334 |
|
|---|
| 2335 |
if ((ret = verify_area(VERIFY_WRITE, d32, |
|---|
| 2336 |
sizeof(struct compat_dirent)))) |
|---|
| 2337 |
return ret; |
|---|
| 2338 |
|
|---|
| 2339 |
__put_user(d->d_ino, &d32->d_ino); |
|---|
| 2340 |
__put_user(d->d_off, &d32->d_off); |
|---|
| 2341 |
__put_user(d->d_reclen, &d32->d_reclen); |
|---|
| 2342 |
__copy_to_user(d32->d_name, d->d_name, d->d_reclen); |
|---|
| 2343 |
return ret; |
|---|
| 2344 |
} |
|---|
| 2345 |
|
|---|
| 2346 |
static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg) |
|---|
| 2347 |
{ |
|---|
| 2348 |
struct compat_dirent __user *p = compat_ptr(arg); |
|---|
| 2349 |
int ret; |
|---|
| 2350 |
mm_segment_t oldfs = get_fs(); |
|---|
| 2351 |
struct dirent d[2]; |
|---|
| 2352 |
|
|---|
| 2353 |
switch(cmd) |
|---|
| 2354 |
{ |
|---|
| 2355 |
case VFAT_IOCTL_READDIR_BOTH32: |
|---|
| 2356 |
cmd = VFAT_IOCTL_READDIR_BOTH; |
|---|
| 2357 |
break; |
|---|
| 2358 |
case VFAT_IOCTL_READDIR_SHORT32: |
|---|
| 2359 |
cmd = VFAT_IOCTL_READDIR_SHORT; |
|---|
| 2360 |
break; |
|---|
| 2361 |
} |
|---|
| 2362 |
|
|---|
| 2363 |
set_fs(KERNEL_DS); |
|---|
| 2364 |
ret = sys_ioctl(fd,cmd,(unsigned long)&d); |
|---|
| 2365 |
set_fs(oldfs); |
|---|
| 2366 |
if (ret >= 0) { |
|---|
| 2367 |
ret |= put_dirent32(&d[0], p); |
|---|
| 2368 |
ret |= put_dirent32(&d[1], p + 1); |
|---|
| 2369 |
} |
|---|
| 2370 |
return ret; |
|---|
| 2371 |
} |
|---|
| 2372 |
|
|---|
| 2373 |
#define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int) |
|---|
| 2374 |
|
|---|
| 2375 |
static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr) |
|---|
| 2376 |
{ |
|---|
| 2377 |
if (cmd == REISERFS_IOC_UNPACK32) |
|---|
| 2378 |
cmd = REISERFS_IOC_UNPACK; |
|---|
| 2379 |
|
|---|
| 2380 |
return sys_ioctl(fd,cmd,ptr); |
|---|
| 2381 |
} |
|---|
| 2382 |
|
|---|
| 2383 |
struct raw32_config_request |
|---|
| 2384 |
{ |
|---|
| 2385 |
compat_int_t raw_minor; |
|---|
| 2386 |
__u64 block_major; |
|---|
| 2387 |
__u64 block_minor; |
|---|
| 2388 |
} __attribute__((packed)); |
|---|
| 2389 |
|
|---|
| 2390 |
static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req) |
|---|
| 2391 |
{ |
|---|
| 2392 |
int ret; |
|---|
| 2393 |
|
|---|
| 2394 |
if ((ret = verify_area(VERIFY_READ, user_req, |
|---|
| 2395 |
sizeof(struct raw32_config_request)))) |
|---|
| 2396 |
return ret; |
|---|
| 2397 |
|
|---|
| 2398 |
ret = __get_user(req->raw_minor, &user_req->raw_minor); |
|---|
| 2399 |
ret |= __get_user(req->block_major, &user_req->block_major); |
|---|
| 2400 |
ret |= __get_user(req->block_minor, &user_req->block_minor); |
|---|
| 2401 |
|
|---|
| 2402 |
return ret ? -EFAULT : 0; |
|---|
| 2403 |
} |
|---|
| 2404 |
|
|---|
| 2405 |
static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req) |
|---|
| 2406 |
{ |
|---|
| 2407 |
int ret; |
|---|
| 2408 |
|
|---|
| 2409 |
if ((ret = verify_area(VERIFY_WRITE, user_req, |
|---|
| 2410 |
sizeof(struct raw32_config_request)))) |
|---|
| 2411 |
return ret; |
|---|
| 2412 |
|
|---|
| 2413 |
ret = __put_user(req->raw_minor, &user_req->raw_minor); |
|---|
| 2414 |
ret |= __put_user(req->block_major, &user_req->block_major); |
|---|
| 2415 |
ret |= __put_user(req->block_minor, &user_req->block_minor); |
|---|
| 2416 |
|
|---|
| 2417 |
return ret ? -EFAULT : 0; |
|---|
| 2418 |
} |
|---|
| 2419 |
|
|---|
| 2420 |
static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) |
|---|
| 2421 |
{ |
|---|
| 2422 |
int ret; |
|---|
| 2423 |
|
|---|
| 2424 |
switch (cmd) { |
|---|
| 2425 |
case RAW_SETBIND: |
|---|
| 2426 |
case RAW_GETBIND: { |
|---|
| 2427 |
struct raw_config_request req; |
|---|
| 2428 |
struct raw32_config_request __user *user_req = compat_ptr(arg); |
|---|
| 2429 |
mm_segment_t oldfs = get_fs(); |
|---|
| 2430 |
|
|---|
| 2431 |
if ((ret = get_raw32_request(&req, user_req))) |
|---|
| 2432 |
return ret; |
|---|
| 2433 |
|
|---|
| 2434 |
set_fs(KERNEL_DS); |
|---|
| 2435 |
ret = sys_ioctl(fd,cmd,(unsigned long)&req); |
|---|
| 2436 |
set_fs(oldfs); |
|---|
| 2437 |
|
|---|
| 2438 |
if ((!ret) && (cmd == RAW_GETBIND)) { |
|---|
| 2439 |
ret = set_raw32_request(&req, user_req); |
|---|
| 2440 |
} |
|---|
| 2441 |
break; |
|---|
| 2442 |
} |
|---|
| 2443 |
default: |
|---|
| 2444 |
ret = sys_ioctl(fd, cmd, arg); |
|---|
| 2445 |
break; |
|---|
| 2446 |
} |
|---|
| 2447 |
return ret; |
|---|
| 2448 |
} |
|---|
| 2449 |
|
|---|
| 2450 |
struct serial_struct32 { |
|---|
| 2451 |
compat_int_t type; |
|---|
| 2452 |
compat_int_t line; |
|---|
| 2453 |
compat_uint_t port; |
|---|
| 2454 |
compat_int_t irq; |
|---|
| 2455 |
compat_int_t flags; |
|---|
| 2456 |
compat_int_t xmit_fifo_size; |
|---|
| 2457 |
compat_int_t custom_divisor; |
|---|
| 2458 |
compat_int_t baud_base; |
|---|
| 2459 |
unsigned short close_delay; |
|---|
| 2460 |
char io_type; |
|---|
| 2461 |
char reserved_char[1]; |
|---|
| 2462 |
compat_int_t hub6; |
|---|
| 2463 |
unsigned short closing_wait; |
|---|
| 2464 |
unsigned short closing_wait2; |
|---|
| 2465 |
compat_uint_t iomem_base; |
|---|
| 2466 |
unsigned short iomem_reg_shift; |
|---|
| 2467 |
unsigned int port_high; |
|---|
| 2468 |
|
|---|
| 2469 |
compat_int_t reserved[1]; |
|---|
| 2470 |
}; |
|---|
| 2471 |
|
|---|
| 2472 |
static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) |
|---|
| 2473 |
{ |
|---|
| 2474 |
typedef struct serial_struct SS; |
|---|
| 2475 |
typedef struct serial_struct32 SS32; |
|---|
| 2476 |
struct serial_struct32 __user *ss32 = compat_ptr(arg); |
|---|
| 2477 |
int err; |
|---|
| 2478 |
struct serial_struct ss; |
|---|
| 2479 |
mm_segment_t oldseg = get_fs(); |
|---|
| 2480 |
__u32 udata; |
|---|
| 2481 |
|
|---|
| 2482 |
if (cmd == TIOCSSERIAL) { |
|---|
| 2483 |
if (verify_area(VERIFY_READ, ss32, sizeof(SS32))) |
|---|
| 2484 |
return -EFAULT; |
|---|
| 2485 |
__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)); |
|---|
| 2486 |
__get_user(udata, &ss32->iomem_base); |
|---|
| 2487 |
ss.iomem_base = compat_ptr(udata); |
|---|
| 2488 |
__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); |
|---|
| 2489 |
__get_user(ss.port_high, &ss32->port_high); |
|---|
| 2490 |
ss.iomap_base = 0UL; |
|---|
| 2491 |
} |
|---|
| 2492 |
set_fs(KERNEL_DS); |
|---|
| 2493 |
err = sys_ioctl(fd,cmd,(unsigned long)(&ss)); |
|---|
| 2494 |
set_fs(oldseg); |
|---|
| 2495 |
if (cmd == TIOCGSERIAL && err >= 0) { |
|---|
| 2496 |
if (verify_area(VERIFY_WRITE, ss32, sizeof(SS32))) |
|---|
| 2497 |
return -EFAULT; |
|---|
| 2498 |
__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)); |
|---|
| 2499 |
__put_user((unsigned long)ss.iomem_base >> 32 ? |
|---|
| 2500 |
0xffffffff : (unsigned)(unsigned long)ss.iomem_base, |
|---|
| 2501 |
&ss32->iomem_base); |
|---|
| 2502 |
__put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); |
|---|
| 2503 |
__put_user(ss.port_high, &ss32->port_high); |
|---|
| 2504 |
|
|---|
| 2505 |
} |
|---|
| 2506 |
return err; |
|---|
| 2507 |
} |
|---|
| 2508 |
|
|---|
| 2509 |
struct usbdevfs_ctrltransfer32 { |
|---|
| 2510 |
u8 bRequestType; |
|---|
| 2511 |
u8 bRequest; |
|---|
| 2512 |
u16 wValue; |
|---|
| 2513 |
u16 wIndex; |
|---|
| 2514 |
u16 wLength; |
|---|
| 2515 |
u32 timeout; |
|---|
| 2516 |
compat_caddr_t data; |
|---|
| 2517 |
}; |
|---|
| 2518 |
|
|---|
| 2519 |
#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32) |
|---|
| 2520 |
|
|---|
| 2521 |
static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2522 |
{ |
|---|
| 2523 |
struct usbdevfs_ctrltransfer kctrl; |
|---|
| 2524 |
struct usbdevfs_ctrltransfer32 __user *uctrl; |
|---|
| 2525 |
mm_segment_t old_fs; |
|---|
| 2526 |
__u32 udata; |
|---|
| 2527 |
void __user *uptr; |
|---|
| 2528 |
void *kptr; |
|---|
| 2529 |
int err; |
|---|
| 2530 |
|
|---|
| 2531 |
uctrl = compat_ptr(arg); |
|---|
| 2532 |
|
|---|
| 2533 |
if (copy_from_user(&kctrl, uctrl, |
|---|
| 2534 |
(sizeof(struct usbdevfs_ctrltransfer32) - |
|---|
| 2535 |
sizeof(compat_caddr_t)))) |
|---|
| 2536 |
return -EFAULT; |
|---|
| 2537 |
|
|---|
| 2538 |
if (get_user(udata, &uctrl->data)) |
|---|
| 2539 |
return -EFAULT; |
|---|
| 2540 |
uptr = compat_ptr(udata); |
|---|
| 2541 |
|
|---|
| 2542 |
|
|---|
| 2543 |
|
|---|
| 2544 |
if (!uptr || kctrl.wLength > PAGE_SIZE) |
|---|
| 2545 |
return -EINVAL; |
|---|
| 2546 |
|
|---|
| 2547 |
kptr = (void *)__get_free_page(GFP_KERNEL); |
|---|
| 2548 |
|
|---|
| 2549 |
if ((kctrl.bRequestType & USB_DIR_IN) == 0) { |
|---|
| 2550 |
err = -EFAULT; |
|---|
| 2551 |
if (copy_from_user(kptr, uptr, kctrl.wLength)) |
|---|
| 2552 |
goto out; |
|---|
| 2553 |
} |
|---|
| 2554 |
|
|---|
| 2555 |
kctrl.data = kptr; |
|---|
| 2556 |
|
|---|
| 2557 |
old_fs = get_fs(); |
|---|
| 2558 |
set_fs(KERNEL_DS); |
|---|
| 2559 |
err = sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)&kctrl); |
|---|
| 2560 |
set_fs(old_fs); |
|---|
| 2561 |
|
|---|
| 2562 |
if (err >= 0 && |
|---|
| 2563 |
((kctrl.bRequestType & USB_DIR_IN) != 0)) { |
|---|
| 2564 |
if (copy_to_user(uptr, kptr, kctrl.wLength)) |
|---|
| 2565 |
err = -EFAULT; |
|---|
| 2566 |
} |
|---|
| 2567 |
|
|---|
| 2568 |
out: |
|---|
| 2569 |
free_page((unsigned long) kptr); |
|---|
| 2570 |
return err; |
|---|
| 2571 |
} |
|---|
| 2572 |
|
|---|
| 2573 |
|
|---|
| 2574 |
struct usbdevfs_bulktransfer32 { |
|---|
| 2575 |
compat_uint_t ep; |
|---|
| 2576 |
compat_uint_t len; |
|---|
| 2577 |
compat_uint_t timeout; |
|---|
| 2578 |
compat_caddr_t data; |
|---|
| 2579 |
}; |
|---|
| 2580 |
|
|---|
| 2581 |
#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32) |
|---|
| 2582 |
|
|---|
| 2583 |
static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2584 |
{ |
|---|
| 2585 |
struct usbdevfs_bulktransfer kbulk; |
|---|
| 2586 |
struct usbdevfs_bulktransfer32 __user *ubulk; |
|---|
| 2587 |
mm_segment_t old_fs; |
|---|
| 2588 |
__u32 udata; |
|---|
| 2589 |
void __user *uptr; |
|---|
| 2590 |
void *kptr; |
|---|
| 2591 |
int err; |
|---|
| 2592 |
|
|---|
| 2593 |
ubulk = compat_ptr(arg); |
|---|
| 2594 |
|
|---|
| 2595 |
if (get_user(kbulk.ep, &ubulk->ep) || |
|---|
| 2596 |
get_user(kbulk.len, &ubulk->len) || |
|---|
| 2597 |
get_user(kbulk.timeout, &ubulk->timeout) || |
|---|
| 2598 |
get_user(udata, &ubulk->data)) |
|---|
| 2599 |
return -EFAULT; |
|---|
| 2600 |
|
|---|
| 2601 |
uptr = compat_ptr(udata); |
|---|
| 2602 |
|
|---|
| 2603 |
|
|---|
| 2604 |
|
|---|
| 2605 |
|
|---|
| 2606 |
if (!uptr || kbulk.len > PAGE_SIZE) |
|---|
| 2607 |
return -EINVAL; |
|---|
| 2608 |
|
|---|
| 2609 |
kptr = (void *) __get_free_page(GFP_KERNEL); |
|---|
| 2610 |
|
|---|
| 2611 |
if ((kbulk.ep & 0x80) == 0) { |
|---|
| 2612 |
err = -EFAULT; |
|---|
| 2613 |
if (copy_from_user(kptr, uptr, kbulk.len)) |
|---|
| 2614 |
goto out; |
|---|
| 2615 |
} |
|---|
| 2616 |
|
|---|
| 2617 |
kbulk.data = kptr; |
|---|
| 2618 |
|
|---|
| 2619 |
old_fs = get_fs(); |
|---|
| 2620 |
set_fs(KERNEL_DS); |
|---|
| 2621 |
err = sys_ioctl(fd, USBDEVFS_BULK, (unsigned long) &kbulk); |
|---|
| 2622 |
set_fs(old_fs); |
|---|
| 2623 |
|
|---|
| 2624 |
if (err >= 0 && |
|---|
| 2625 |
((kbulk.ep & 0x80) != 0)) { |
|---|
| 2626 |
if (copy_to_user(uptr, kptr, kbulk.len)) |
|---|
| 2627 |
err = -EFAULT; |
|---|
| 2628 |
} |
|---|
| 2629 |
|
|---|
| 2630 |
out: |
|---|
| 2631 |
free_page((unsigned long) kptr); |
|---|
| 2632 |
return err; |
|---|
| 2633 |
} |
|---|
| 2634 |
|
|---|
| 2635 |
|
|---|
| 2636 |
|
|---|
| 2637 |
|
|---|
| 2638 |
|
|---|
| 2639 |
|
|---|
| 2640 |
|
|---|
| 2641 |
|
|---|
| 2642 |
|
|---|
| 2643 |
|
|---|
| 2644 |
|
|---|
| 2645 |
|
|---|
| 2646 |
|
|---|
| 2647 |
|
|---|
| 2648 |
|
|---|
| 2649 |
|
|---|
| 2650 |
|
|---|
| 2651 |
|
|---|
| 2652 |
|
|---|
| 2653 |
|
|---|
| 2654 |
|
|---|
| 2655 |
|
|---|
| 2656 |
|
|---|
| 2657 |
|
|---|
| 2658 |
|
|---|
| 2659 |
|
|---|
| 2660 |
|
|---|
| 2661 |
|
|---|
| 2662 |
|
|---|
| 2663 |
|
|---|
| 2664 |
|
|---|
| 2665 |
|
|---|
| 2666 |
|
|---|
| 2667 |
|
|---|
| 2668 |
|
|---|
| 2669 |
|
|---|
| 2670 |
|
|---|
| 2671 |
|
|---|
| 2672 |
|
|---|
| 2673 |
|
|---|
| 2674 |
|
|---|
| 2675 |
#if 0 |
|---|
| 2676 |
struct usbdevfs_urb32 { |
|---|
| 2677 |
unsigned char type; |
|---|
| 2678 |
unsigned char endpoint; |
|---|
| 2679 |
compat_int_t status; |
|---|
| 2680 |
compat_uint_t flags; |
|---|
| 2681 |
compat_caddr_t buffer; |
|---|
| 2682 |
compat_int_t buffer_length; |
|---|
| 2683 |
compat_int_t actual_length; |
|---|
| 2684 |
compat_int_t start_frame; |
|---|
| 2685 |
compat_int_t number_of_packets; |
|---|
| 2686 |
compat_int_t error_count; |
|---|
| 2687 |
compat_uint_t signr; |
|---|
| 2688 |
compat_caddr_t usercontext; |
|---|
| 2689 |
struct usbdevfs_iso_packet_desc iso_frame_desc[0]; |
|---|
| 2690 |
}; |
|---|
| 2691 |
|
|---|
| 2692 |
#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32) |
|---|
| 2693 |
|
|---|
| 2694 |
static int get_urb32(struct usbdevfs_urb *kurb, |
|---|
| 2695 |
struct usbdevfs_urb32 *uurb) |
|---|
| 2696 |
{ |
|---|
| 2697 |
if (get_user(kurb->type, &uurb->type) || |
|---|
| 2698 |
__get_user(kurb->endpoint, &uurb->endpoint) || |
|---|
| 2699 |
__get_user(kurb->status, &uurb->status) || |
|---|
| 2700 |
__get_user(kurb->flags, &uurb->flags) || |
|---|
| 2701 |
__get_user(kurb->buffer_length, &uurb->buffer_length) || |
|---|
| 2702 |
__get_user(kurb->actual_length, &uurb->actual_length) || |
|---|
| 2703 |
__get_user(kurb->start_frame, &uurb->start_frame) || |
|---|
| 2704 |
__get_user(kurb->number_of_packets, &uurb->number_of_packets) || |
|---|
| 2705 |
__get_user(kurb->error_count, &uurb->error_count) || |
|---|
| 2706 |
__get_user(kurb->signr, &uurb->signr)) |
|---|
| 2707 |
return -EFAULT; |
|---|
| 2708 |
|
|---|
| 2709 |
kurb->usercontext = 0; |
|---|
| 2710 |
|
|---|
| 2711 |
return 0; |
|---|
| 2712 |
} |
|---|
| 2713 |
|
|---|
| 2714 |
|
|---|
| 2715 |
static int put_urb32(struct usbdevfs_urb *kurb, |
|---|
| 2716 |
struct usbdevfs_urb32 *uurb) |
|---|
| 2717 |
{ |
|---|
| 2718 |
if (put_user(kurb->status, &uurb->status) || |
|---|
| 2719 |
__put_user(kurb->actual_length, &uurb->actual_length) || |
|---|
| 2720 |
__put_user(kurb->error_count, &uurb->error_count)) |
|---|
| 2721 |
return -EFAULT; |
|---|
| 2722 |
|
|---|
| 2723 |
if (kurb->number_of_packets != 0) { |
|---|
| 2724 |
int i; |
|---|
| 2725 |
|
|---|
| 2726 |
for (i = 0; i < kurb->number_of_packets; i++) { |
|---|
| 2727 |
if (__put_user(kurb->iso_frame_desc[i].actual_length, |
|---|
| 2728 |
&uurb->iso_frame_desc[i].actual_length) || |
|---|
| 2729 |
__put_user(kurb->iso_frame_desc[i].status, |
|---|
| 2730 |
&uurb->iso_frame_desc[i].status)) |
|---|
| 2731 |
return -EFAULT; |
|---|
| 2732 |
} |
|---|
| 2733 |
} |
|---|
| 2734 |
|
|---|
| 2735 |
return 0; |
|---|
| 2736 |
} |
|---|
| 2737 |
|
|---|
| 2738 |
static int get_urb32_isoframes(struct usbdevfs_urb *kurb, |
|---|
| 2739 |
struct usbdevfs_urb32 *uurb) |
|---|
| 2740 |
{ |
|---|
| 2741 |
unsigned int totlen; |
|---|
| 2742 |
int i; |
|---|
| 2743 |
|
|---|
| 2744 |
if (kurb->type != USBDEVFS_URB_TYPE_ISO) { |
|---|
| 2745 |
kurb->number_of_packets = 0; |
|---|
| 2746 |
return 0; |
|---|
| 2747 |
} |
|---|
| 2748 |
|
|---|
| 2749 |
if (kurb->number_of_packets < 1 || |
|---|
| 2750 |
kurb->number_of_packets > 128) |
|---|
| 2751 |
return -EINVAL; |
|---|
| 2752 |
|
|---|
| 2753 |
if (copy_from_user(&kurb->iso_frame_desc[0], |
|---|
| 2754 |
&uurb->iso_frame_desc[0], |
|---|
| 2755 |
sizeof(struct usbdevfs_iso_packet_desc) * |
|---|
| 2756 |
kurb->number_of_packets)) |
|---|
| 2757 |
return -EFAULT; |
|---|
| 2758 |
|
|---|
| 2759 |
totlen = 0; |
|---|
| 2760 |
for (i = 0; i < kurb->number_of_packets; i++) { |
|---|
| 2761 |
unsigned int this_len; |
|---|
| 2762 |
|
|---|
| 2763 |
this_len = kurb->iso_frame_desc[i].length; |
|---|
| 2764 |
if (this_len > 1023) |
|---|
| 2765 |
return -EINVAL; |
|---|
| 2766 |
|
|---|
| 2767 |
totlen += this_len; |
|---|
| 2768 |
} |
|---|
| 2769 |
|
|---|
| 2770 |
if (totlen > 32768) |
|---|
| 2771 |
return -EINVAL; |
|---|
| 2772 |
|
|---|
| 2773 |
kurb->buffer_length = totlen; |
|---|
| 2774 |
|
|---|
| 2775 |
return 0; |
|---|
| 2776 |
} |
|---|
| 2777 |
|
|---|
| 2778 |
static int do_usbdevfs_urb(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2779 |
{ |
|---|
| 2780 |
struct usbdevfs_urb *kurb; |
|---|
| 2781 |
struct usbdevfs_urb32 *uurb; |
|---|
| 2782 |
mm_segment_t old_fs; |
|---|
| 2783 |
__u32 udata; |
|---|
| 2784 |
void *uptr, *kptr; |
|---|
| 2785 |
unsigned int buflen; |
|---|
| 2786 |
int err; |
|---|
| 2787 |
|
|---|
| 2788 |
uurb = compat_ptr(arg); |
|---|
| 2789 |
|
|---|
| 2790 |
err = -ENOMEM; |
|---|
| 2791 |
kurb = kmalloc(sizeof(struct usbdevfs_urb) + |
|---|
| 2792 |
(sizeof(struct usbdevfs_iso_packet_desc) * 128), |
|---|
| 2793 |
GFP_KERNEL); |
|---|
| 2794 |
if (!kurb) |
|---|
| 2795 |
goto out; |
|---|
| 2796 |
|
|---|
| 2797 |
err = -EFAULT; |
|---|
| 2798 |
if (get_urb32(kurb, uurb)) |
|---|
| 2799 |
goto out; |
|---|
| 2800 |
|
|---|
| 2801 |
err = get_urb32_isoframes(kurb, uurb); |
|---|
| 2802 |
if (err) |
|---|
| 2803 |
goto out; |
|---|
| 2804 |
|
|---|
| 2805 |
err = -EFAULT; |
|---|
| 2806 |
if (__get_user(udata, &uurb->buffer)) |
|---|
| 2807 |
goto out; |
|---|
| 2808 |
uptr = compat_ptr(udata); |
|---|
| 2809 |
|
|---|
| 2810 |
buflen = kurb->buffer_length; |
|---|
| 2811 |
err = verify_area(VERIFY_WRITE, uptr, buflen); |
|---|
| 2812 |
if (err) |
|---|
| 2813 |
goto out; |
|---|
| 2814 |
|
|---|
| 2815 |
|
|---|
| 2816 |
old_fs = get_fs(); |
|---|
| 2817 |
set_fs(KERNEL_DS); |
|---|
| 2818 |
err = sys_ioctl(fd, USBDEVFS_SUBMITURB, (unsigned long) kurb); |
|---|
| 2819 |
set_fs(old_fs); |
|---|
| 2820 |
|
|---|
| 2821 |
if (err >= 0) { |
|---|
| 2822 |
|
|---|
| 2823 |
if (put_urb32(kurb, uurb)) { |
|---|
| 2824 |
err = -EFAULT; |
|---|
| 2825 |
} |
|---|
| 2826 |
} |
|---|
| 2827 |
|
|---|
| 2828 |
out: |
|---|
| 2829 |
kfree(kurb); |
|---|
| 2830 |
return err; |
|---|
| 2831 |
} |
|---|
| 2832 |
#endif |
|---|
| 2833 |
|
|---|
| 2834 |
#define USBDEVFS_REAPURB32 _IOW('U', 12, u32) |
|---|
| 2835 |
#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, u32) |
|---|
| 2836 |
|
|---|
| 2837 |
static int do_usbdevfs_reapurb(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2838 |
{ |
|---|
| 2839 |
mm_segment_t old_fs; |
|---|
| 2840 |
void *kptr; |
|---|
| 2841 |
int err; |
|---|
| 2842 |
|
|---|
| 2843 |
old_fs = get_fs(); |
|---|
| 2844 |
set_fs(KERNEL_DS); |
|---|
| 2845 |
err = sys_ioctl(fd, |
|---|
| 2846 |
(cmd == USBDEVFS_REAPURB32 ? |
|---|
| 2847 |
USBDEVFS_REAPURB : |
|---|
| 2848 |
USBDEVFS_REAPURBNDELAY), |
|---|
| 2849 |
(unsigned long) &kptr); |
|---|
| 2850 |
set_fs(old_fs); |
|---|
| 2851 |
|
|---|
| 2852 |
if (err >= 0 && |
|---|
| 2853 |
put_user((u32)(u64)kptr, (u32 __user *)compat_ptr(arg))) |
|---|
| 2854 |
err = -EFAULT; |
|---|
| 2855 |
|
|---|
| 2856 |
return err; |
|---|
| 2857 |
} |
|---|
| 2858 |
|
|---|
| 2859 |
struct usbdevfs_disconnectsignal32 { |
|---|
| 2860 |
compat_int_t signr; |
|---|
| 2861 |
compat_caddr_t context; |
|---|
| 2862 |
}; |
|---|
| 2863 |
|
|---|
| 2864 |
#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32) |
|---|
| 2865 |
|
|---|
| 2866 |
static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2867 |
{ |
|---|
| 2868 |
struct usbdevfs_disconnectsignal kdis; |
|---|
| 2869 |
struct usbdevfs_disconnectsignal32 __user *udis; |
|---|
| 2870 |
mm_segment_t old_fs; |
|---|
| 2871 |
u32 uctx; |
|---|
| 2872 |
int err; |
|---|
| 2873 |
|
|---|
| 2874 |
udis = compat_ptr(arg); |
|---|
| 2875 |
|
|---|
| 2876 |
if (get_user(kdis.signr, &udis->signr) || |
|---|
| 2877 |
__get_user(uctx, &udis->context)) |
|---|
| 2878 |
return -EFAULT; |
|---|
| 2879 |
|
|---|
| 2880 |
kdis.context = compat_ptr(uctx); |
|---|
| 2881 |
|
|---|
| 2882 |
old_fs = get_fs(); |
|---|
| 2883 |
set_fs(KERNEL_DS); |
|---|
| 2884 |
err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis); |
|---|
| 2885 |
set_fs(old_fs); |
|---|
| 2886 |
|
|---|
| 2887 |
return err; |
|---|
| 2888 |
} |
|---|
| 2889 |
|
|---|
| 2890 |
|
|---|
| 2891 |
|
|---|
| 2892 |
|
|---|
| 2893 |
|
|---|
| 2894 |
struct i2c_msg32 { |
|---|
| 2895 |
u16 addr; |
|---|
| 2896 |
u16 flags; |
|---|
| 2897 |
u16 len; |
|---|
| 2898 |
compat_caddr_t buf; |
|---|
| 2899 |
}; |
|---|
| 2900 |
|
|---|
| 2901 |
struct i2c_rdwr_ioctl_data32 { |
|---|
| 2902 |
compat_caddr_t msgs; |
|---|
| 2903 |
u32 nmsgs; |
|---|
| 2904 |
}; |
|---|
| 2905 |
|
|---|
| 2906 |
struct i2c_smbus_ioctl_data32 { |
|---|
| 2907 |
u8 read_write; |
|---|
| 2908 |
u8 command; |
|---|
| 2909 |
u32 size; |
|---|
| 2910 |
compat_caddr_t data; |
|---|
| 2911 |
}; |
|---|
| 2912 |
|
|---|
| 2913 |
static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2914 |
{ |
|---|
| 2915 |
struct i2c_rdwr_ioctl_data __user *tdata; |
|---|
| 2916 |
struct i2c_rdwr_ioctl_data32 __user *udata; |
|---|
| 2917 |
struct i2c_msg __user *tmsgs; |
|---|
| 2918 |
struct i2c_msg32 __user *umsgs; |
|---|
| 2919 |
compat_caddr_t datap; |
|---|
| 2920 |
int nmsgs, i; |
|---|
| 2921 |
|
|---|
| 2922 |
tdata = compat_alloc_user_space(sizeof(*tdata)); |
|---|
| 2923 |
if (tdata == NULL) |
|---|
| 2924 |
return -ENOMEM; |
|---|
| 2925 |
if (verify_area(VERIFY_WRITE, tdata, sizeof(*tdata))) |
|---|
| 2926 |
return -EFAULT; |
|---|
| 2927 |
|
|---|
| 2928 |
udata = compat_ptr(arg); |
|---|
| 2929 |
if (verify_area(VERIFY_READ, udata, sizeof(*udata))) |
|---|
| 2930 |
return -EFAULT; |
|---|
| 2931 |
if (__get_user(nmsgs, &udata->nmsgs) || __put_user(nmsgs, &tdata->nmsgs)) |
|---|
| 2932 |
return -EFAULT; |
|---|
| 2933 |
if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
|---|
| 2934 |
return -EINVAL; |
|---|
| 2935 |
if (__get_user(datap, &udata->msgs)) |
|---|
| 2936 |
return -EFAULT; |
|---|
| 2937 |
umsgs = compat_ptr(datap); |
|---|
| 2938 |
if (verify_area(VERIFY_READ, umsgs, sizeof(struct i2c_msg) * nmsgs)) |
|---|
| 2939 |
return -EFAULT; |
|---|
| 2940 |
|
|---|
| 2941 |
tmsgs = compat_alloc_user_space(sizeof(struct i2c_msg) * nmsgs); |
|---|
| 2942 |
if (tmsgs == NULL) |
|---|
| 2943 |
return -ENOMEM; |
|---|
| 2944 |
if (verify_area(VERIFY_WRITE, tmsgs, sizeof(struct i2c_msg) * nmsgs)) |
|---|
| 2945 |
return -EFAULT; |
|---|
| 2946 |
if (__put_user(tmsgs, &tdata->msgs)) |
|---|
| 2947 |
return -ENOMEM; |
|---|
| 2948 |
for (i = 0; i < nmsgs; i++) { |
|---|
| 2949 |
if (__copy_in_user(&tmsgs[i].addr, |
|---|
| 2950 |
&umsgs[i].addr, |
|---|
| 2951 |
3 * sizeof(u16))) |
|---|
| 2952 |
return -EFAULT; |
|---|
| 2953 |
if (__get_user(datap, &umsgs[i].buf) || |
|---|
| 2954 |
__put_user(compat_ptr(datap), &tmsgs[i].buf)) |
|---|
| 2955 |
return -EFAULT; |
|---|
| 2956 |
} |
|---|
| 2957 |
return sys_ioctl(fd, cmd, (unsigned long)tdata); |
|---|
| 2958 |
} |
|---|
| 2959 |
|
|---|
| 2960 |
static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2961 |
{ |
|---|
| 2962 |
struct i2c_smbus_ioctl_data __user *tdata; |
|---|
| 2963 |
struct i2c_smbus_ioctl_data32 __user *udata; |
|---|
| 2964 |
compat_caddr_t datap; |
|---|
| 2965 |
|
|---|
| 2966 |
tdata = compat_alloc_user_space(sizeof(*tdata)); |
|---|
| 2967 |
if (tdata == NULL) |
|---|
| 2968 |
return -ENOMEM; |
|---|
| 2969 |
if (verify_area(VERIFY_WRITE, tdata, sizeof(*tdata))) |
|---|
| 2970 |
return -EFAULT; |
|---|
| 2971 |
|
|---|
| 2972 |
udata = compat_ptr(arg); |
|---|
| 2973 |
if (verify_area(VERIFY_READ, udata, sizeof(*udata))) |
|---|
| 2974 |
return -EFAULT; |
|---|
| 2975 |
|
|---|
| 2976 |
if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8))) |
|---|
| 2977 |
return -EFAULT; |
|---|
| 2978 |
if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32))) |
|---|
| 2979 |
return -EFAULT; |
|---|
| 2980 |
if (__get_user(datap, &udata->data) || |
|---|
| 2981 |
__put_user(compat_ptr(datap), &tdata->data)) |
|---|
| 2982 |
return -EFAULT; |
|---|
| 2983 |
|
|---|
| 2984 |
return sys_ioctl(fd, cmd, (unsigned long)tdata); |
|---|
| 2985 |
} |
|---|
| 2986 |
|
|---|
| 2987 |
struct compat_iw_point { |
|---|
| 2988 |
compat_caddr_t pointer; |
|---|
| 2989 |
__u16 length; |
|---|
| 2990 |
__u16 flags; |
|---|
| 2991 |
}; |
|---|
| 2992 |
|
|---|
| 2993 |
static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 2994 |
{ |
|---|
| 2995 |
struct iwreq __user *iwr; |
|---|
| 2996 |
struct iwreq __user *iwr_u; |
|---|
| 2997 |
struct iw_point __user *iwp; |
|---|
| 2998 |
struct compat_iw_point __user *iwp_u; |
|---|
| 2999 |
compat_caddr_t pointer; |
|---|
| 3000 |
__u16 length, flags; |
|---|
| 3001 |
|
|---|
| 3002 |
iwr_u = compat_ptr(arg); |
|---|
| 3003 |
iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data; |
|---|
| 3004 |
iwr = compat_alloc_user_space(sizeof(*iwr)); |
|---|
| 3005 |
if (iwr == NULL) |
|---|
| 3006 |
return -ENOMEM; |
|---|
| 3007 |
|
|---|
| 3008 |
iwp = &iwr->u.data; |
|---|
| 3009 |
|
|---|
| 3010 |
if (verify_area(VERIFY_WRITE, iwr, sizeof(*iwr))) |
|---|
| 3011 |
return -EFAULT; |
|---|
| 3012 |
|
|---|
| 3013 |
if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0], |
|---|
| 3014 |
&iwr_u->ifr_ifrn.ifrn_name[0], |
|---|
| 3015 |
sizeof(iwr->ifr_ifrn.ifrn_name))) |
|---|
| 3016 |
return -EFAULT; |
|---|
| 3017 |
|
|---|
| 3018 |
if (__get_user(pointer, &iwp_u->pointer) || |
|---|
| 3019 |
__get_user(length, &iwp_u->length) || |
|---|
| 3020 |
__get_user(flags, &iwp_u->flags)) |
|---|
| 3021 |
return -EFAULT; |
|---|
| 3022 |
|
|---|
| 3023 |
if (__put_user(compat_ptr(pointer), &iwp->pointer) || |
|---|
| 3024 |
__put_user(length, &iwp->length) || |
|---|
| 3025 |
__put_user(flags, &iwp->flags)) |
|---|
| 3026 |
return -EFAULT; |
|---|
| 3027 |
|
|---|
| 3028 |
return sys_ioctl(fd, cmd, (unsigned long) iwr); |
|---|
| 3029 |
} |
|---|
| 3030 |
|
|---|
| 3031 |
|
|---|
| 3032 |
|
|---|
| 3033 |
|
|---|
| 3034 |
|
|---|
| 3035 |
static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3036 |
{ |
|---|
| 3037 |
u32 tmp; |
|---|
| 3038 |
|
|---|
| 3039 |
if (get_user(tmp, (u32 __user *) arg)) |
|---|
| 3040 |
return -EFAULT; |
|---|
| 3041 |
if (tmp == BRCTL_GET_VERSION) |
|---|
| 3042 |
return BRCTL_VERSION + 1; |
|---|
| 3043 |
return -EINVAL; |
|---|
| 3044 |
} |
|---|
| 3045 |
|
|---|
| 3046 |
#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE) |
|---|
| 3047 |
struct ncp_ioctl_request_32 { |
|---|
| 3048 |
u32 function; |
|---|
| 3049 |
u32 size; |
|---|
| 3050 |
compat_caddr_t data; |
|---|
| 3051 |
}; |
|---|
| 3052 |
|
|---|
| 3053 |
struct ncp_fs_info_v2_32 { |
|---|
| 3054 |
s32 version; |
|---|
| 3055 |
u32 mounted_uid; |
|---|
| 3056 |
u32 connection; |
|---|
| 3057 |
u32 buffer_size; |
|---|
| 3058 |
|
|---|
| 3059 |
u32 volume_number; |
|---|
| 3060 |
u32 directory_id; |
|---|
| 3061 |
|
|---|
| 3062 |
u32 dummy1; |
|---|
| 3063 |
u32 dummy2; |
|---|
| 3064 |
u32 dummy3; |
|---|
| 3065 |
}; |
|---|
| 3066 |
|
|---|
| 3067 |
struct ncp_objectname_ioctl_32 |
|---|
| 3068 |
{ |
|---|
| 3069 |
s32 auth_type; |
|---|
| 3070 |
u32 object_name_len; |
|---|
| 3071 |
compat_caddr_t object_name; |
|---|
| 3072 |
}; |
|---|
| 3073 |
|
|---|
| 3074 |
struct ncp_privatedata_ioctl_32 |
|---|
| 3075 |
{ |
|---|
| 3076 |
u32 len; |
|---|
| 3077 |
compat_caddr_t data; |
|---|
| 3078 |
}; |
|---|
| 3079 |
|
|---|
| 3080 |
#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32) |
|---|
| 3081 |
#define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32) |
|---|
| 3082 |
#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32) |
|---|
| 3083 |
#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32) |
|---|
| 3084 |
#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32) |
|---|
| 3085 |
#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32) |
|---|
| 3086 |
#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32) |
|---|
| 3087 |
|
|---|
| 3088 |
static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3089 |
{ |
|---|
| 3090 |
struct ncp_ioctl_request_32 n32; |
|---|
| 3091 |
struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p)); |
|---|
| 3092 |
|
|---|
| 3093 |
if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) || |
|---|
| 3094 |
put_user(n32.function, &p->function) || |
|---|
| 3095 |
put_user(n32.size, &p->size) || |
|---|
| 3096 |
put_user(compat_ptr(n32.data), &p->data)) |
|---|
| 3097 |
return -EFAULT; |
|---|
| 3098 |
|
|---|
| 3099 |
return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p); |
|---|
| 3100 |
} |
|---|
| 3101 |
|
|---|
| 3102 |
static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3103 |
{ |
|---|
| 3104 |
mm_segment_t old_fs = get_fs(); |
|---|
| 3105 |
__kernel_uid_t kuid; |
|---|
| 3106 |
int err; |
|---|
| 3107 |
|
|---|
| 3108 |
cmd = NCP_IOC_GETMOUNTUID2; |
|---|
| 3109 |
|
|---|
| 3110 |
set_fs(KERNEL_DS); |
|---|
| 3111 |
err = sys_ioctl(fd, cmd, (unsigned long)&kuid); |
|---|
| 3112 |
set_fs(old_fs); |
|---|
| 3113 |
|
|---|
| 3114 |
if (!err) |
|---|
| 3115 |
err = put_user(kuid, |
|---|
| 3116 |
(unsigned int __user *) compat_ptr(arg)); |
|---|
| 3117 |
|
|---|
| 3118 |
return err; |
|---|
| 3119 |
} |
|---|
| 3120 |
|
|---|
| 3121 |
static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3122 |
{ |
|---|
| 3123 |
mm_segment_t old_fs = get_fs(); |
|---|
| 3124 |
struct ncp_fs_info_v2_32 n32; |
|---|
| 3125 |
struct ncp_fs_info_v2 n; |
|---|
| 3126 |
int err; |
|---|
| 3127 |
|
|---|
| 3128 |
if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32))) |
|---|
| 3129 |
return -EFAULT; |
|---|
| 3130 |
if (n32.version != NCP_GET_FS_INFO_VERSION_V2) |
|---|
| 3131 |
return -EINVAL; |
|---|
| 3132 |
n.version = NCP_GET_FS_INFO_VERSION_V2; |
|---|
| 3133 |
|
|---|
| 3134 |
set_fs(KERNEL_DS); |
|---|
| 3135 |
err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n); |
|---|
| 3136 |
set_fs(old_fs); |
|---|
| 3137 |
|
|---|
| 3138 |
if (!err) { |
|---|
| 3139 |
n32.version = n.version; |
|---|
| 3140 |
n32.mounted_uid = n.mounted_uid; |
|---|
| 3141 |
n32.connection = n.connection; |
|---|
| 3142 |
n32.buffer_size = n.buffer_size; |
|---|
| 3143 |
n32.volume_number = n.volume_number; |
|---|
| 3144 |
n32.directory_id = n.directory_id; |
|---|
| 3145 |
n32.dummy1 = n.dummy1; |
|---|
| 3146 |
n32.dummy2 = n.dummy2; |
|---|
| 3147 |
n32.dummy3 = n.dummy3; |
|---|
| 3148 |
err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0; |
|---|
| 3149 |
} |
|---|
| 3150 |
return err; |
|---|
| 3151 |
} |
|---|
| 3152 |
|
|---|
| 3153 |
static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3154 |
{ |
|---|
| 3155 |
struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg); |
|---|
| 3156 |
struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p)); |
|---|
| 3157 |
s32 auth_type; |
|---|
| 3158 |
u32 name_len; |
|---|
| 3159 |
int err; |
|---|
| 3160 |
|
|---|
| 3161 |
if (copy_from_user(&n32, p32, sizeof(n32)) || |
|---|
| 3162 |
put_user(n32.object_name_len, &p->object_name_len) || |
|---|
| 3163 |
put_user(compat_ptr(n32.object_name), &p->object_name)) |
|---|
| 3164 |
return -EFAULT; |
|---|
| 3165 |
|
|---|
| 3166 |
err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p); |
|---|
| 3167 |
if (err) |
|---|
| 3168 |
return err; |
|---|
| 3169 |
|
|---|
| 3170 |
if (get_user(auth_type, &p->auth_type) || |
|---|
| 3171 |
put_user(auth_type, &p32->auth_type) || |
|---|
| 3172 |
get_user(name_len, &p->object_name_len) || |
|---|
| 3173 |
put_user(name_len, &p32->object_name_len)) |
|---|
| 3174 |
return -EFAULT; |
|---|
| 3175 |
|
|---|
| 3176 |
return 0; |
|---|
| 3177 |
} |
|---|
| 3178 |
|
|---|
| 3179 |
static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3180 |
{ |
|---|
| 3181 |
struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg); |
|---|
| 3182 |
struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p)); |
|---|
| 3183 |
|
|---|
| 3184 |
if (copy_from_user(&n32, p32, sizeof(n32)) || |
|---|
| 3185 |
put_user(n32.auth_type, &p->auth_type) || |
|---|
| 3186 |
put_user(n32.object_name_len, &p->object_name_len) || |
|---|
| 3187 |
put_user(compat_ptr(n32.object_name), &p->object_name)) |
|---|
| 3188 |
return -EFAULT; |
|---|
| 3189 |
|
|---|
| 3190 |
return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p); |
|---|
| 3191 |
} |
|---|
| 3192 |
|
|---|
| 3193 |
static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3194 |
{ |
|---|
| 3195 |
struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg); |
|---|
| 3196 |
struct ncp_privatedata_ioctl __user *p = |
|---|
| 3197 |
compat_alloc_user_space(sizeof(*p)); |
|---|
| 3198 |
u32 len; |
|---|
| 3199 |
int err; |
|---|
| 3200 |
|
|---|
| 3201 |
if (copy_from_user(&n32, p32, sizeof(n32)) || |
|---|
| 3202 |
put_user(n32.len, &p->len) || |
|---|
| 3203 |
put_user(compat_ptr(n32.data), &p->data)) |
|---|
| 3204 |
return -EFAULT; |
|---|
| 3205 |
|
|---|
| 3206 |
err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p); |
|---|
| 3207 |
if (err) |
|---|
| 3208 |
return err; |
|---|
| 3209 |
|
|---|
| 3210 |
if (get_user(len, &p->len) || |
|---|
| 3211 |
put_user(len, &p32->len)) |
|---|
| 3212 |
return -EFAULT; |
|---|
| 3213 |
|
|---|
| 3214 |
return 0; |
|---|
| 3215 |
} |
|---|
| 3216 |
|
|---|
| 3217 |
static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg) |
|---|
| 3218 |
{ |
|---|
| 3219 |
struct ncp_privatedata_ioctl_32 n32; |
|---|
| 3220 |
struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg); |
|---|
| 3221 |
struct ncp_privatedata_ioctl __user *p = |
|---|
| 3222 |
compat_alloc_user_space(sizeof(*p)); |
|---|
| 3223 |
|
|---|
| 3224 |
if (copy_from_user(&n32, p32, sizeof(n32)) || |
|---|
| 3225 |
put_user(n32.len, &p->len) || |
|---|
| 3226 |
put_user(compat_ptr(n32.data), &p->data)) |
|---|
| 3227 |
return -EFAULT; |
|---|
| 3228 |
|
|---|
| 3229 |
return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p); |
|---|
| 3230 |
} |
|---|
| 3231 |
#endif |
|---|
| 3232 |
|
|---|
| 3233 |
#undef CODE |
|---|
| 3234 |
#endif |
|---|
| 3235 |
|
|---|
| 3236 |
#ifdef DECLARES |
|---|
| 3237 |
HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob) |
|---|
| 3238 |
HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob) |
|---|
| 3239 |
#ifdef CONFIG_NET |
|---|
| 3240 |
HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32) |
|---|
| 3241 |
#endif |
|---|
| 3242 |
HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf) |
|---|
| 3243 |
HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc) |
|---|
| 3244 |
HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc) |
|---|
| 3245 |
HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc) |
|---|
| 3246 |
HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc) |
|---|
| 3247 |
HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc) |
|---|
| 3248 |
HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc) |
|---|
| 3249 |
HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc) |
|---|
| 3250 |
HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc) |
|---|
| 3251 |
HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc) |
|---|
| 3252 |
HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc) |
|---|
| 3253 |
HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc) |
|---|
| 3254 |
HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc) |
|---|
| 3255 |
HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc) |
|---|
| 3256 |
HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc) |
|---|
| 3257 |
HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc) |
|---|
| 3258 |
HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc) |
|---|
| 3259 |
HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc) |
|---|
| 3260 |
HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc) |
|---|
| 3261 |
HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc) |
|---|
| 3262 |
HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc) |
|---|
| 3263 |
HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc) |
|---|
| 3264 |
HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc) |
|---|
| 3265 |
HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc) |
|---|
| 3266 |
HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc) |
|---|
| 3267 |
HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc) |
|---|
| 3268 |
HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc) |
|---|
| 3269 |
HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc) |
|---|
| 3270 |
HANDLE_IOCTL(TUNSETIFF, dev_ifsioc) |
|---|
| 3271 |
HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl) |
|---|
| 3272 |
HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl) |
|---|
| 3273 |
HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl) |
|---|
| 3274 |
HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl) |
|---|
| 3275 |
HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl) |
|---|
| 3276 |
HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl) |
|---|
| 3277 |
HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl) |
|---|
| 3278 |
HANDLE_IOCTL(SIOCADDRT, routing_ioctl) |
|---|
| 3279 |
HANDLE_IOCTL(SIOCDELRT, routing_ioctl) |
|---|
| 3280 |
HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc) |
|---|
| 3281 |
HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc) |
|---|
| 3282 |
|
|---|
| 3283 |
HANDLE_IOCTL(SIOCRTMSG, ret_einval) |
|---|
| 3284 |
HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) |
|---|
| 3285 |
HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo) |
|---|
| 3286 |
HANDLE_IOCTL(BLKRAGET, w_long) |
|---|
| 3287 |
HANDLE_IOCTL(BLKGETSIZE, w_long) |
|---|
| 3288 |
HANDLE_IOCTL(0x1260, broken_blkgetsize) |
|---|
| 3289 |
HANDLE_IOCTL(BLKFRAGET, w_long) |
|---|
| 3290 |
HANDLE_IOCTL(BLKSECTGET, w_long) |
|---|
| 3291 |
HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans) |
|---|
| 3292 |
HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) |
|---|
| 3293 |
HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans) |
|---|
| 3294 |
HANDLE_IOCTL(FBIOPUTCMAP, fb_ioctl_trans) |
|---|
| 3295 |
HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans) |
|---|
| 3296 |
HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) |
|---|
| 3297 |
HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans) |
|---|
| 3298 |
HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans) |
|---|
| 3299 |
HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans) |
|---|
| 3300 |
HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans) |
|---|
| 3301 |
HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans) |
|---|
| 3302 |
HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans) |
|---|
| 3303 |
HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans) |
|---|
| 3304 |
HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans) |
|---|
| 3305 |
HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans) |
|---|
| 3306 |
HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans) |
|---|
| 3307 |
HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans) |
|---|
| 3308 |
HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans) |
|---|
| 3309 |
HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans) |
|---|
| 3310 |
HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans) |
|---|
| 3311 |
HANDLE_IOCTL(SG_IO,sg_ioctl_trans) |
|---|
| 3312 |
HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) |
|---|
| 3313 |
HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) |
|---|
| 3314 |
HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) |
|---|
| 3315 |
HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) |
|---|
| 3316 |
HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) |
|---|
| 3317 |
HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) |
|---|
| 3318 |
HANDLE_IOCTL(MTIOCGETCONFIG32, mt_ioctl_trans) |
|---|
| 3319 |
HANDLE_IOCTL(MTIOCSETCONFIG32, mt_ioctl_trans) |
|---|
| 3320 |
HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans) |
|---|
| 3321 |
HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans) |
|---|
| 3322 |
HANDLE_IOCTL(LOOP_SET_STATUS, loop_status) |
|---|
| 3323 |
HANDLE_IOCTL(LOOP_GET_STATUS, loop_status) |
|---|
| 3324 |
#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) |
|---|
| 3325 |
HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) |
|---|
| 3326 |
#ifdef CONFIG_VT |
|---|
| 3327 |
HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) |
|---|
| 3328 |
HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl) |
|---|
| 3329 |
HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) |
|---|
| 3330 |
HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) |
|---|
| 3331 |
HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) |
|---|
| 3332 |
#endif |
|---|
| 3333 |
HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl) |
|---|
| 3334 |
HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl) |
|---|
| 3335 |
HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl) |
|---|
| 3336 |
HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl) |
|---|
| 3337 |
HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl) |
|---|
| 3338 |
HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl) |
|---|
| 3339 |
HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl) |
|---|
| 3340 |
HANDLE_IOCTL(VIDIOCSWIN32, do_video_ioctl) |
|---|
| 3341 |
HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl) |
|---|
| 3342 |
HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl) |
|---|
| 3343 |
HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl) |
|---|
| 3344 |
HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl) |
|---|
| 3345 |
|
|---|
| 3346 |
#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) |
|---|
| 3347 |
HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) |
|---|
| 3348 |
HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl) |
|---|
| 3349 |
HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl) |
|---|
| 3350 |
HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl) |
|---|
| 3351 |
HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl) |
|---|
| 3352 |
HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl) |
|---|
| 3353 |
HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl) |
|---|
| 3354 |
HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl) |
|---|
| 3355 |
HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl) |
|---|
| 3356 |
HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl) |
|---|
| 3357 |
HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl) |
|---|
| 3358 |
HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl) |
|---|
| 3359 |
HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl) |
|---|
| 3360 |
HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl) |
|---|
| 3361 |
HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl) |
|---|
| 3362 |
HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl) |
|---|
| 3363 |
HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl) |
|---|
| 3364 |
HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl) |
|---|
| 3365 |
HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl) |
|---|
| 3366 |
HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl) |
|---|
| 3367 |
HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl) |
|---|
| 3368 |
HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl) |
|---|
| 3369 |
HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl) |
|---|
| 3370 |
HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl) |
|---|
| 3371 |
HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl) |
|---|
| 3372 |
HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) |
|---|
| 3373 |
|
|---|
| 3374 |
HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) |
|---|
| 3375 |
HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) |
|---|
| 3376 |
HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) |
|---|
| 3377 |
|
|---|
| 3378 |
HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32) |
|---|
| 3379 |
HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32) |
|---|
| 3380 |
HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32) |
|---|
| 3381 |
|
|---|
| 3382 |
HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) |
|---|
| 3383 |
HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) |
|---|
| 3384 |
|
|---|
| 3385 |
HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) |
|---|
| 3386 |
HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) |
|---|
| 3387 |
|
|---|
| 3388 |
HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) |
|---|
| 3389 |
HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) |
|---|
| 3390 |
|
|---|
| 3391 |
HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb) |
|---|
| 3392 |
HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb) |
|---|
| 3393 |
HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal) |
|---|
| 3394 |
|
|---|
| 3395 |
HANDLE_IOCTL(I2C_FUNCS, w_long) |
|---|
| 3396 |
HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) |
|---|
| 3397 |
HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) |
|---|
| 3398 |
|
|---|
| 3399 |
HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl) |
|---|
| 3400 |
HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl) |
|---|
| 3401 |
HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl) |
|---|
| 3402 |
HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl) |
|---|
| 3403 |
HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl) |
|---|
| 3404 |
HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl) |
|---|
| 3405 |
HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl) |
|---|
| 3406 |
HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl) |
|---|
| 3407 |
HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl) |
|---|
| 3408 |
HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl) |
|---|
| 3409 |
HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl) |
|---|
| 3410 |
HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl) |
|---|
| 3411 |
HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl) |
|---|
| 3412 |
HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl) |
|---|
| 3413 |
HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl) |
|---|
| 3414 |
|
|---|
| 3415 |
#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE) |
|---|
| 3416 |
HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest) |
|---|
| 3417 |
HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2) |
|---|
| 3418 |
HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2) |
|---|
| 3419 |
HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname) |
|---|
| 3420 |
HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname) |
|---|
| 3421 |
HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata) |
|---|
| 3422 |
HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata) |
|---|
| 3423 |
#endif |
|---|
| 3424 |
|
|---|
| 3425 |
#undef DECLARES |
|---|
| 3426 |
#endif |
|---|
| 3427 |
|
|---|