OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [mips64/] [kernel/] [ioctl32.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3
 *
4
 * Copyright (C) 2000 Silicon Graphics, Inc.
5
 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
6
 * Copyright (C) 2000 Ralf Baechle
7
 * Copyright (C) 2002, 2003  Maciej W. Rozycki
8
 *
9
 * Mostly stolen from the sparc64 ioctl32 implementation.
10
 */
11
#include <linux/config.h>
12
#include <linux/types.h>
13
#include <linux/kernel.h>
14
#include <linux/sched.h>
15
#include <linux/sched.h>
16
#include <linux/smp.h>
17
#include <linux/smp_lock.h>
18
#include <linux/ioctl.h>
19
#include <linux/if.h>
20
#include <linux/slab.h>
21
#include <linux/hdreg.h>
22
#include <linux/raid/md_u.h>
23
#include <linux/kd.h>
24
#include <linux/route.h>
25
#include <linux/vt.h>
26
#include <linux/fs.h>
27
#include <linux/ppp_defs.h>
28
#include <linux/if_ppp.h>
29
#include <linux/if_pppox.h>
30
#include <linux/if_tun.h>
31
#include <linux/mtio.h>
32
#include <linux/cdrom.h>
33
#include <linux/loop.h>
34
#include <linux/auto_fs.h>
35
#include <linux/auto_fs4.h>
36
#include <linux/devfs_fs.h>
37
#include <linux/tty.h>
38
#include <linux/vt_kern.h>
39
#include <linux/fb.h>
40
#include <linux/ext2_fs.h>
41
#include <linux/videodev.h>
42
#include <linux/netdevice.h>
43
#include <linux/raw.h>
44
#include <linux/blkpg.h>
45
#include <linux/blk.h>
46
#include <linux/elevator.h>
47
#include <linux/rtc.h>
48
#include <linux/pci.h>
49
#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
50
#include <linux/lvm.h>
51
#endif /* LVM */
52
 
53
#include <scsi/scsi.h>
54
#undef __KERNEL__               /* This file was born to be ugly ...  */
55
#include <scsi/scsi_ioctl.h>
56
#define __KERNEL__
57
#include <scsi/sg.h>
58
 
59
#include <asm/types.h>
60
#include <asm/uaccess.h>
61
#include <linux/soundcard.h>
62
 
63
#include <linux/mtd/mtd.h>
64
#include <linux/serial.h>
65
 
66
#ifdef CONFIG_SIBYTE_TBPROF
67
#include <asm/sibyte/trace_prof.h>
68
#endif
69
 
70
long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
71
 
72
static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
73
{
74
        mm_segment_t old_fs = get_fs();
75
        int err;
76
        unsigned long val;
77
 
78
        set_fs (KERNEL_DS);
79
        err = sys_ioctl(fd, cmd, (unsigned long)&val);
80
        set_fs (old_fs);
81
        if (!err && put_user((unsigned int) val, (u32 *)arg))
82
                return -EFAULT;
83
        return err;
84
}
85
 
86
static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
87
{
88
        mm_segment_t old_fs = get_fs();
89
        int err;
90
        unsigned long val;
91
 
92
        if (get_user(val, (u32 *)arg))
93
                return -EFAULT;
94
        set_fs(KERNEL_DS);
95
        err = sys_ioctl(fd, cmd, (unsigned long)&val);
96
        set_fs (old_fs);
97
        if (!err && put_user(val, (u32 *)arg))
98
                return -EFAULT;
99
        return err;
100
}
101
 
102
#define A(__x) ((unsigned long)(__x))
103
 
104
 
105
#ifdef CONFIG_FB
106
 
107
struct fb_fix_screeninfo32 {
108
        char id[16];                    /* identification string eg "TT Builtin" */
109
        __u32 smem_start;               /* Start of frame buffer mem */
110
                                        /* (physical address) */
111
        __u32 smem_len;                 /* Length of frame buffer mem */
112
        __u32 type;                     /* see FB_TYPE_*                */
113
        __u32 type_aux;                 /* Interleave for interleaved Planes */
114
        __u32 visual;                   /* see FB_VISUAL_*              */
115
        __u16 xpanstep;                 /* zero if no hardware panning  */
116
        __u16 ypanstep;                 /* zero if no hardware panning  */
117
        __u16 ywrapstep;                /* zero if no hardware ywrap    */
118
        __u32 line_length;              /* length of a line in bytes    */
119
        __u32 mmio_start;               /* Start of Memory Mapped I/O   */
120
                                        /* (physical address) */
121
        __u32 mmio_len;                 /* Length of Memory Mapped I/O  */
122
        __u32 accel;                    /* Type of acceleration available */
123
        __u16 reserved[3];              /* Reserved for future compatibility */
124
};
125
 
126
static int do_fbioget_fscreeninfo_ioctl(unsigned int fd, unsigned int cmd,
127
                                        unsigned long arg)
128
{
129
        mm_segment_t old_fs = get_fs();
130
        struct fb_fix_screeninfo fix;
131
        struct fb_fix_screeninfo32 *fix32 = (struct fb_fix_screeninfo32 *)arg;
132
        int err;
133
 
134
        set_fs(KERNEL_DS);
135
        err = sys_ioctl(fd, cmd, (unsigned long)&fix);
136
        set_fs(old_fs);
137
 
138
        if (err == 0) {
139
                err = __copy_to_user((char *)fix32->id, (char *)fix.id,
140
                                     sizeof(fix.id));
141
                err |= __put_user((__u32)(unsigned long)fix.smem_start,
142
                                  &fix32->smem_start);
143
                err |= __put_user(fix.smem_len, &fix32->smem_len);
144
                err |= __put_user(fix.type, &fix32->type);
145
                err |= __put_user(fix.type_aux, &fix32->type_aux);
146
                err |= __put_user(fix.visual, &fix32->visual);
147
                err |= __put_user(fix.xpanstep, &fix32->xpanstep);
148
                err |= __put_user(fix.ypanstep, &fix32->ypanstep);
149
                err |= __put_user(fix.ywrapstep, &fix32->ywrapstep);
150
                err |= __put_user(fix.line_length, &fix32->line_length);
151
                err |= __put_user((__u32)(unsigned long)fix.mmio_start,
152
                                  &fix32->mmio_start);
153
                err |= __put_user(fix.mmio_len, &fix32->mmio_len);
154
                err |= __put_user(fix.accel, &fix32->accel);
155
                err |= __copy_to_user((char *)fix32->reserved,
156
                                      (char *)fix.reserved,
157
                                      sizeof(fix.reserved));
158
                if (err)
159
                        err = -EFAULT;
160
        }
161
 
162
        return err;
163
}
164
 
165
struct fb_cmap32 {
166
        __u32 start;                    /* First entry  */
167
        __u32 len;                      /* Number of entries */
168
        __u32 red;                      /* Red values   */
169
        __u32 green;
170
        __u32 blue;
171
        __u32 transp;                   /* transparency, can be NULL */
172
};
173
 
174
static int do_fbiocmap_ioctl(unsigned int fd, unsigned int cmd,
175
                             unsigned long arg)
176
{
177
        mm_segment_t old_fs = get_fs();
178
        u32 red = 0, green = 0, blue = 0, transp = 0;
179
        struct fb_cmap cmap;
180
        struct fb_cmap32 *cmap32 = (struct fb_cmap32 *)arg;
181
        int err;
182
 
183
        memset(&cmap, 0, sizeof(cmap));
184
 
185
        err = __get_user(cmap.start, &cmap32->start);
186
        err |= __get_user(cmap.len, &cmap32->len);
187
        err |= __get_user(red, &cmap32->red);
188
        err |= __get_user(green, &cmap32->green);
189
        err |= __get_user(blue, &cmap32->blue);
190
        err |= __get_user(transp, &cmap32->transp);
191
        if (err)
192
                return -EFAULT;
193
 
194
        err = -ENOMEM;
195
        cmap.red = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
196
        if (!cmap.red)
197
                goto out;
198
        cmap.green = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
199
        if (!cmap.green)
200
                goto out;
201
        cmap.blue = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
202
        if (!cmap.blue)
203
                goto out;
204
        if (transp) {
205
                cmap.transp = kmalloc(cmap.len * sizeof(__u16), GFP_KERNEL);
206
                if (!cmap.transp)
207
                        goto out;
208
        }
209
 
210
        if (cmd == FBIOPUTCMAP) {
211
                err = __copy_from_user(cmap.red, (char *)A(red),
212
                                       cmap.len * sizeof(__u16));
213
                err |= __copy_from_user(cmap.green, (char *)A(green),
214
                                        cmap.len * sizeof(__u16));
215
                err |= __copy_from_user(cmap.blue, (char *)A(blue),
216
                                        cmap.len * sizeof(__u16));
217
                if (cmap.transp)
218
                        err |= __copy_from_user(cmap.transp, (char *)A(transp),
219
                                                cmap.len * sizeof(__u16));
220
                if (err) {
221
                        err = -EFAULT;
222
                        goto out;
223
                }
224
        }
225
 
226
        set_fs(KERNEL_DS);
227
        err = sys_ioctl(fd, cmd, (unsigned long)&cmap);
228
        set_fs(old_fs);
229
        if (err)
230
                goto out;
231
 
232
        if (cmd == FBIOGETCMAP) {
233
                err = __copy_to_user((char *)A(red), cmap.red,
234
                                     cmap.len * sizeof(__u16));
235
                err |= __copy_to_user((char *)A(green), cmap.blue,
236
                                      cmap.len * sizeof(__u16));
237
                err |= __copy_to_user((char *)A(blue), cmap.blue,
238
                                      cmap.len * sizeof(__u16));
239
                if (cmap.transp)
240
                        err |= __copy_to_user((char *)A(transp), cmap.transp,
241
                                              cmap.len * sizeof(__u16));
242
                if (err) {
243
                        err = -EFAULT;
244
                        goto out;
245
                }
246
        }
247
 
248
out:
249
        if (cmap.red)
250
                kfree(cmap.red);
251
        if (cmap.green)
252
                kfree(cmap.green);
253
        if (cmap.blue)
254
                kfree(cmap.blue);
255
        if (cmap.transp)
256
                kfree(cmap.transp);
257
 
258
        return err;
259
}
260
 
261
#endif /* CONFIG_FB */
262
 
263
 
264
struct timeval32 {
265
        int tv_sec;
266
        int tv_usec;
267
};
268
 
269
static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
270
{
271
        struct timeval32 *up = (struct timeval32 *)arg;
272
        struct timeval ktv;
273
        mm_segment_t old_fs = get_fs();
274
        int err;
275
 
276
        set_fs(KERNEL_DS);
277
        err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
278
        set_fs(old_fs);
279
        if (!err) {
280
                err = put_user(ktv.tv_sec, &up->tv_sec);
281
                err |= __put_user(ktv.tv_usec, &up->tv_usec);
282
        }
283
 
284
        return err;
285
}
286
 
287
#define EXT2_IOC32_GETFLAGS               _IOR('f', 1, int)
288
#define EXT2_IOC32_SETFLAGS               _IOW('f', 2, int)
289
#define EXT2_IOC32_GETVERSION             _IOR('v', 1, int)
290
#define EXT2_IOC32_SETVERSION             _IOW('v', 2, int)
291
 
292
struct ifmap32 {
293
        unsigned int mem_start;
294
        unsigned int mem_end;
295
        unsigned short base_addr;
296
        unsigned char irq;
297
        unsigned char dma;
298
        unsigned char port;
299
};
300
 
301
struct ifreq32 {
302
#define IFHWADDRLEN     6
303
#define IFNAMSIZ        16
304
        union {
305
                char    ifrn_name[IFNAMSIZ];    /* if name, e.g. "en0" */
306
        } ifr_ifrn;
307
        union {
308
                struct  sockaddr ifru_addr;
309
                struct  sockaddr ifru_dstaddr;
310
                struct  sockaddr ifru_broadaddr;
311
                struct  sockaddr ifru_netmask;
312
                struct  sockaddr ifru_hwaddr;
313
                short   ifru_flags;
314
                int     ifru_ivalue;
315
                int     ifru_mtu;
316
                struct  ifmap32 ifru_map;
317
                char    ifru_slave[IFNAMSIZ];   /* Just fits the size */
318
                char    ifru_newname[IFNAMSIZ];
319
                __kernel_caddr_t32 ifru_data;
320
        } ifr_ifru;
321
};
322
 
323
struct ifconf32 {
324
        int     ifc_len;                        /* size of buffer       */
325
        __kernel_caddr_t32  ifcbuf;
326
};
327
 
328
#ifdef CONFIG_NET
329
 
330
static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
331
{
332
        struct ireq32 *uir32 = (struct ireq32 *)arg;
333
        struct net_device *dev;
334
        struct ifreq32 ifr32;
335
 
336
        if (copy_from_user(&ifr32, uir32, sizeof(struct ifreq32)))
337
                return -EFAULT;
338
 
339
        read_lock(&dev_base_lock);
340
        dev = __dev_get_by_index(ifr32.ifr_ifindex);
341
        if (!dev) {
342
                read_unlock(&dev_base_lock);
343
                return -ENODEV;
344
        }
345
 
346
        strcpy(ifr32.ifr_name, dev->name);
347
        read_unlock(&dev_base_lock);
348
 
349
        if (copy_to_user(uir32, &ifr32, sizeof(struct ifreq32)))
350
            return -EFAULT;
351
 
352
        return 0;
353
}
354
 
355
static inline int dev_ifconf(unsigned int fd, unsigned int cmd,
356
                             unsigned long arg)
357
{
358
        struct ioconf32 *uifc32 = (struct ioconf32 *)arg;
359
        struct ifconf32 ifc32;
360
        struct ifconf ifc;
361
        struct ifreq32 *ifr32;
362
        struct ifreq *ifr;
363
        mm_segment_t old_fs;
364
        unsigned int i, j;
365
        int err;
366
 
367
        if (copy_from_user(&ifc32, uifc32, sizeof(struct ifconf32)))
368
                return -EFAULT;
369
 
370
        if(ifc32.ifcbuf == 0) {
371
                ifc32.ifc_len = 0;
372
                ifc.ifc_len = 0;
373
                ifc.ifc_buf = NULL;
374
        } else {
375
                ifc.ifc_len = ((ifc32.ifc_len / sizeof (struct ifreq32))) *
376
                        sizeof (struct ifreq);
377
                ifc.ifc_buf = kmalloc (ifc.ifc_len, GFP_KERNEL);
378
                if (!ifc.ifc_buf)
379
                        return -ENOMEM;
380
        }
381
        ifr = ifc.ifc_req;
382
        ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
383
        for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
384
                if (copy_from_user(ifr++, ifr32++, sizeof (struct ifreq32))) {
385
                        kfree (ifc.ifc_buf);
386
                        return -EFAULT;
387
                }
388
        }
389
 
390
        old_fs = get_fs(); set_fs (KERNEL_DS);
391
        err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)&ifc);
392
        set_fs (old_fs);
393
        if (err)
394
                goto out;
395
 
396
        ifr = ifc.ifc_req;
397
        ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf);
398
        for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len;
399
             i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
400
                if (copy_to_user(ifr32++, ifr++, sizeof (struct ifreq32))) {
401
                        err = -EFAULT;
402
                        goto out;
403
                }
404
        }
405
        if (ifc32.ifcbuf == 0) {
406
                /* Translate from 64-bit structure multiple to
407
                 * a 32-bit one.
408
                 */
409
                i = ifc.ifc_len;
410
                i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
411
                ifc32.ifc_len = i;
412
        } else {
413
                if (i <= ifc32.ifc_len)
414
                        ifc32.ifc_len = i;
415
                else
416
                        ifc32.ifc_len = i - sizeof (struct ifreq32);
417
        }
418
        if (copy_to_user(uifc32, &ifc32, sizeof(struct ifconf32))) {
419
                err = -EFAULT;
420
                goto out;
421
        }
422
out:
423
        if(ifc.ifc_buf != NULL)
424
                kfree (ifc.ifc_buf);
425
        return err;
426
}
427
 
428
static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
429
{
430
        struct ifreq ifr;
431
        mm_segment_t old_fs;
432
        int err;
433
 
434
        switch (cmd) {
435
        case SIOCSIFMAP:
436
                err = copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(ifr.ifr_name));
437
                err |= __get_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
438
                err |= __get_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
439
                err |= __get_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
440
                err |= __get_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
441
                err |= __get_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
442
                err |= __get_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
443
                if (err)
444
                        return -EFAULT;
445
                break;
446
        default:
447
                if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
448
                        return -EFAULT;
449
                break;
450
        }
451
        old_fs = get_fs();
452
        set_fs (KERNEL_DS);
453
        err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
454
        set_fs (old_fs);
455
        if (!err) {
456
                switch (cmd) {
457
                case SIOCGIFFLAGS:
458
                case SIOCGIFMETRIC:
459
                case SIOCGIFMTU:
460
                case SIOCGIFMEM:
461
                case SIOCGIFHWADDR:
462
                case SIOCGIFINDEX:
463
                case SIOCGIFADDR:
464
                case SIOCGIFBRDADDR:
465
                case SIOCGIFDSTADDR:
466
                case SIOCGIFNETMASK:
467
                case SIOCGIFTXQLEN:
468
                        if (copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(struct ifreq32)))
469
                                return -EFAULT;
470
                        break;
471
                case SIOCGIFMAP:
472
                        err = copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(ifr.ifr_name));
473
                        err |= __put_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
474
                        err |= __put_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
475
                        err |= __put_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
476
                        err |= __put_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
477
                        err |= __put_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
478
                        err |= __put_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
479
                        if (err)
480
                                err = -EFAULT;
481
                        break;
482
                }
483
        }
484
        return err;
485
}
486
 
487
struct rtentry32
488
{
489
        unsigned int    rt_pad1;
490
        struct sockaddr rt_dst;         /* target address               */
491
        struct sockaddr rt_gateway;     /* gateway addr (RTF_GATEWAY)   */
492
        struct sockaddr rt_genmask;     /* target network mask (IP)     */
493
        unsigned short  rt_flags;
494
        short           rt_pad2;
495
        unsigned int    rt_pad3;
496
        unsigned int    rt_pad4;
497
        short           rt_metric;      /* +1 for binary compatibility! */
498
        unsigned int    rt_dev;         /* forcing the device at add    */
499
        unsigned int    rt_mtu;         /* per route MTU/Window         */
500
#ifndef __KERNEL__
501
#define rt_mss  rt_mtu                  /* Compatibility :-(            */
502
#endif
503
        unsigned int    rt_window;      /* Window clamping              */
504
        unsigned short  rt_irtt;        /* Initial RTT                  */
505
};
506
 
507
static inline int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
508
{
509
        struct rtentry32 *ur = (struct rtentry32 *)arg;
510
        struct rtentry r;
511
        char devname[16];
512
        u32 rtdev;
513
        int ret;
514
        mm_segment_t old_fs = get_fs();
515
 
516
        ret = copy_from_user (&r.rt_dst, &(ur->rt_dst), 3 * sizeof(struct sockaddr));
517
        ret |= __get_user (r.rt_flags, &(ur->rt_flags));
518
        ret |= __get_user (r.rt_metric, &(ur->rt_metric));
519
        ret |= __get_user (r.rt_mtu, &(ur->rt_mtu));
520
        ret |= __get_user (r.rt_window, &(ur->rt_window));
521
        ret |= __get_user (r.rt_irtt, &(ur->rt_irtt));
522
        ret |= __get_user (rtdev, &(ur->rt_dev));
523
        if (rtdev) {
524
                ret |= copy_from_user (devname, (char *)A(rtdev), 15);
525
                r.rt_dev = devname; devname[15] = 0;
526
        } else
527
                r.rt_dev = 0;
528
        if (ret)
529
                return -EFAULT;
530
        set_fs (KERNEL_DS);
531
        ret = sys_ioctl (fd, cmd, (long)&r);
532
        set_fs (old_fs);
533
        return ret;
534
}
535
 
536
#endif /* CONFIG_NET */
537
 
538
static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
539
{
540
        /* These are just misnamed, they actually get/put from/to user an int */
541
        switch (cmd) {
542
        case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
543
        case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
544
        case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
545
        case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
546
        }
547
        return sys_ioctl(fd, cmd, arg);
548
}
549
 
550
struct video_tuner32 {
551
        s32 tuner;
552
        u8 name[32];
553
        u32 rangelow, rangehigh;
554
        u32 flags;
555
        u16 mode, signal;
556
};
557
 
558
static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 *up)
559
{
560
        int i;
561
 
562
        if(get_user(kp->tuner, &up->tuner))
563
                return -EFAULT;
564
        for(i = 0; i < 32; i++)
565
                __get_user(kp->name[i], &up->name[i]);
566
        __get_user(kp->rangelow, &up->rangelow);
567
        __get_user(kp->rangehigh, &up->rangehigh);
568
        __get_user(kp->flags, &up->flags);
569
        __get_user(kp->mode, &up->mode);
570
        __get_user(kp->signal, &up->signal);
571
        return 0;
572
}
573
 
574
static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 *up)
575
{
576
        int i;
577
 
578
        if(put_user(kp->tuner, &up->tuner))
579
                return -EFAULT;
580
        for(i = 0; i < 32; i++)
581
                __put_user(kp->name[i], &up->name[i]);
582
        __put_user(kp->rangelow, &up->rangelow);
583
        __put_user(kp->rangehigh, &up->rangehigh);
584
        __put_user(kp->flags, &up->flags);
585
        __put_user(kp->mode, &up->mode);
586
        __put_user(kp->signal, &up->signal);
587
        return 0;
588
}
589
 
590
struct video_buffer32 {
591
        /* void * */ u32 base;
592
        s32 height, width, depth, bytesperline;
593
};
594
 
595
static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 *up)
596
{
597
        u32 tmp;
598
 
599
        if(get_user(tmp, &up->base))
600
                return -EFAULT;
601
        kp->base = (void *) ((unsigned long)tmp);
602
        __get_user(kp->height, &up->height);
603
        __get_user(kp->width, &up->width);
604
        __get_user(kp->depth, &up->depth);
605
        __get_user(kp->bytesperline, &up->bytesperline);
606
        return 0;
607
}
608
 
609
static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 *up)
610
{
611
        u32 tmp = (u32)((unsigned long)kp->base);
612
 
613
        if(put_user(tmp, &up->base))
614
                return -EFAULT;
615
        __put_user(kp->height, &up->height);
616
        __put_user(kp->width, &up->width);
617
        __put_user(kp->depth, &up->depth);
618
        __put_user(kp->bytesperline, &up->bytesperline);
619
        return 0;
620
}
621
 
622
struct video_clip32 {
623
        s32 x, y, width, height;
624
        /* struct video_clip32 * */ u32 next;
625
};
626
 
627
struct video_window32 {
628
        u32 x, y, width, height, chromakey, flags;
629
        /* struct video_clip32 * */ u32 clips;
630
        s32 clipcount;
631
};
632
 
633
static void free_kvideo_clips(struct video_window *kp)
634
{
635
        struct video_clip *cp;
636
 
637
        cp = kp->clips;
638
        if(cp != NULL)
639
                kfree(cp);
640
}
641
 
642
static int get_video_window32(struct video_window *kp, struct video_window32 *up)
643
{
644
        struct video_clip32 *ucp;
645
        struct video_clip *kcp;
646
        int nclips, err, i;
647
        u32 tmp;
648
 
649
        if(get_user(kp->x, &up->x))
650
                return -EFAULT;
651
        __get_user(kp->y, &up->y);
652
        __get_user(kp->width, &up->width);
653
        __get_user(kp->height, &up->height);
654
        __get_user(kp->chromakey, &up->chromakey);
655
        __get_user(kp->flags, &up->flags);
656
        __get_user(kp->clipcount, &up->clipcount);
657
        __get_user(tmp, &up->clips);
658
        ucp = (struct video_clip32 *)A(tmp);
659
        kp->clips = NULL;
660
 
661
        nclips = kp->clipcount;
662
        if(nclips == 0)
663
                return 0;
664
 
665
        if(ucp == 0)
666
                return -EINVAL;
667
 
668
        /* Peculiar interface... */
669
        if(nclips < 0)
670
                nclips = VIDEO_CLIPMAP_SIZE;
671
 
672
        kcp = kmalloc(nclips * sizeof(struct video_clip), GFP_KERNEL);
673
        err = -ENOMEM;
674
        if(kcp == NULL)
675
                goto cleanup_and_err;
676
 
677
        kp->clips = kcp;
678
        for(i = 0; i < nclips; i++) {
679
                __get_user(kcp[i].x, &ucp[i].x);
680
                __get_user(kcp[i].y, &ucp[i].y);
681
                __get_user(kcp[i].width, &ucp[i].width);
682
                __get_user(kcp[i].height, &ucp[i].height);
683
                kcp[nclips].next = NULL;
684
        }
685
 
686
        return 0;
687
 
688
cleanup_and_err:
689
        free_kvideo_clips(kp);
690
        return err;
691
}
692
 
693
/* You get back everything except the clips... */
694
static int put_video_window32(struct video_window *kp, struct video_window32 *up)
695
{
696
        if(put_user(kp->x, &up->x))
697
                return -EFAULT;
698
        __put_user(kp->y, &up->y);
699
        __put_user(kp->width, &up->width);
700
        __put_user(kp->height, &up->height);
701
        __put_user(kp->chromakey, &up->chromakey);
702
        __put_user(kp->flags, &up->flags);
703
        __put_user(kp->clipcount, &up->clipcount);
704
        return 0;
705
}
706
 
707
#define VIDIOCGTUNER32          _IOWR('v',4, struct video_tuner32)
708
#define VIDIOCSTUNER32          _IOW('v',5, struct video_tuner32)
709
#define VIDIOCGWIN32            _IOR('v',9, struct video_window32)
710
#define VIDIOCSWIN32            _IOW('v',10, struct video_window32)
711
#define VIDIOCGFBUF32           _IOR('v',11, struct video_buffer32)
712
#define VIDIOCSFBUF32           _IOW('v',12, struct video_buffer32)
713
#define VIDIOCGFREQ32           _IOR('v',14, u32)
714
#define VIDIOCSFREQ32           _IOW('v',15, u32)
715
 
716
static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
717
{
718
        union {
719
                struct video_tuner vt;
720
                struct video_buffer vb;
721
                struct video_window vw;
722
                unsigned long vx;
723
        } karg;
724
        mm_segment_t old_fs = get_fs();
725
        void *up = (void *)arg;
726
        int err = 0;
727
 
728
        /* First, convert the command. */
729
        switch(cmd) {
730
        case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
731
        case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
732
        case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
733
        case VIDIOCSWIN32: cmd = VIDIOCSWIN; break;
734
        case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
735
        case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
736
        case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
737
        case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
738
        };
739
 
740
        switch(cmd) {
741
        case VIDIOCSTUNER:
742
        case VIDIOCGTUNER:
743
                err = get_video_tuner32(&karg.vt, up);
744
                break;
745
 
746
        case VIDIOCSWIN:
747
                err = get_video_window32(&karg.vw, up);
748
                break;
749
 
750
        case VIDIOCSFBUF:
751
                err = get_video_buffer32(&karg.vb, up);
752
                break;
753
 
754
        case VIDIOCSFREQ:
755
                err = get_user(karg.vx, (u32 *)up);
756
                break;
757
        };
758
        if(err)
759
                goto out;
760
 
761
        set_fs(KERNEL_DS);
762
        err = sys_ioctl(fd, cmd, (unsigned long)&karg);
763
        set_fs(old_fs);
764
 
765
        if(cmd == VIDIOCSWIN)
766
                free_kvideo_clips(&karg.vw);
767
 
768
        if(err == 0) {
769
                switch(cmd) {
770
                case VIDIOCGTUNER:
771
                        err = put_video_tuner32(&karg.vt, up);
772
                        break;
773
 
774
                case VIDIOCGWIN:
775
                        err = put_video_window32(&karg.vw, up);
776
                        break;
777
 
778
                case VIDIOCGFBUF:
779
                        err = put_video_buffer32(&karg.vb, up);
780
                        break;
781
 
782
                case VIDIOCGFREQ:
783
                        err = put_user(((u32)karg.vx), (u32 *)up);
784
                        break;
785
                };
786
        }
787
out:
788
        return err;
789
}
790
struct hd_geometry32 {
791
        unsigned char heads;
792
        unsigned char sectors;
793
        unsigned short cylinders;
794
        u32 start;
795
};
796
 
797
static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg)
798
{
799
        mm_segment_t old_fs = get_fs();
800
        struct hd_geometry geo;
801
        int err;
802
 
803
        set_fs (KERNEL_DS);
804
        err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
805
        set_fs (old_fs);
806
        if (!err) {
807
                err = copy_to_user ((struct hd_geometry32 *)arg, &geo, 4);
808
                err |= __put_user (geo.start, &(((struct hd_geometry32 *)arg)->start));
809
        }
810
 
811
        return err ? -EFAULT : 0;
812
}
813
 
814
static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
815
{
816
        mm_segment_t old_fs = get_fs();
817
        unsigned long kval;
818
        unsigned int *uvp;
819
        int error;
820
 
821
        set_fs(KERNEL_DS);
822
        error = sys_ioctl(fd, cmd, (long)&kval);
823
        set_fs(old_fs);
824
 
825
        if (error == 0) {
826
                uvp = (unsigned int *)arg;
827
                if (put_user(kval, uvp))
828
                        error = -EFAULT;
829
        }
830
 
831
        return error;
832
}
833
 
834
static int ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
835
{
836
        return -EINVAL;
837
}
838
 
839
static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg)
840
{
841
        /* The mkswap binary hard codes it to Intel value :-((( */
842
        return w_long(fd, BLKGETSIZE, arg);
843
}
844
 
845
struct blkpg_ioctl_arg32 {
846
        int op;
847
        int flags;
848
        int datalen;
849
        u32 data;
850
};
851
 
852
static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd,
853
                             struct blkpg_ioctl_arg32 *arg)
854
{
855
        struct blkpg_ioctl_arg a;
856
        struct blkpg_partition p;
857
        int err;
858
        mm_segment_t old_fs = get_fs();
859
 
860
        err = get_user(a.op, &arg->op);
861
        err |= __get_user(a.flags, &arg->flags);
862
        err |= __get_user(a.datalen, &arg->datalen);
863
        err |= __get_user((long)a.data, &arg->data);
864
        if (err) return err;
865
        switch (a.op) {
866
        case BLKPG_ADD_PARTITION:
867
        case BLKPG_DEL_PARTITION:
868
                if (a.datalen < sizeof(struct blkpg_partition))
869
                        return -EINVAL;
870
                if (copy_from_user(&p, a.data, sizeof(struct blkpg_partition)))
871
                        return -EFAULT;
872
                a.data = &p;
873
                set_fs (KERNEL_DS);
874
                err = sys_ioctl(fd, cmd, (unsigned long)&a);
875
                set_fs (old_fs);
876
        default:
877
                return -EINVAL;
878
        }
879
        return err;
880
}
881
 
882
/* Fix sizeof(sizeof()) breakage */
883
#define BLKELVGET_32    _IOR(0x12,106,int)
884
#define BLKELVSET_32    _IOW(0x12,107,int)
885
#define BLKBSZGET_32    _IOR(0x12,112,int)
886
#define BLKBSZSET_32    _IOW(0x12,113,int)
887
#define BLKGETSIZE64_32 _IOR(0x12,114,int)
888
 
889
static int do_blkelvget(unsigned int fd, unsigned int cmd, unsigned long arg)
890
{
891
        return sys_ioctl(fd, BLKELVGET, arg);
892
}
893
 
894
static int do_blkelvset(unsigned int fd, unsigned int cmd, unsigned long arg)
895
{
896
        return sys_ioctl(fd, BLKELVSET, arg);
897
}
898
 
899
static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
900
{
901
        return sys_ioctl(fd, BLKBSZGET, arg);
902
}
903
 
904
static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
905
{
906
        return sys_ioctl(fd, BLKBSZSET, arg);
907
}
908
 
909
static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
910
                           unsigned long arg)
911
{
912
        return sys_ioctl(fd, BLKGETSIZE64, arg);
913
}
914
 
915
struct mtget32 {
916
        __u32   mt_type;
917
        __u32   mt_resid;
918
        __u32   mt_dsreg;
919
        __u32   mt_gstat;
920
        __u32   mt_erreg;
921
        __kernel_daddr_t32      mt_fileno;
922
        __kernel_daddr_t32      mt_blkno;
923
};
924
#define MTIOCGET32      _IOR('m', 2, struct mtget32)
925
 
926
struct mtpos32 {
927
        __u32   mt_blkno;
928
};
929
#define MTIOCPOS32      _IOR('m', 3, struct mtpos32)
930
 
931
struct mtconfiginfo32 {
932
        __u32   mt_type;
933
        __u32   ifc_type;
934
        __u16   irqnr;
935
        __u16   dmanr;
936
        __u16   port;
937
        __u32   debug;
938
        __u32   have_dens:1;
939
        __u32   have_bsf:1;
940
        __u32   have_fsr:1;
941
        __u32   have_bsr:1;
942
        __u32   have_eod:1;
943
        __u32   have_seek:1;
944
        __u32   have_tell:1;
945
        __u32   have_ras1:1;
946
        __u32   have_ras2:1;
947
        __u32   have_ras3:1;
948
        __u32   have_qfa:1;
949
        __u32   pad1:5;
950
        char    reserved[10];
951
};
952
#define MTIOCGETCONFIG32        _IOR('m', 4, struct mtconfiginfo32)
953
#define MTIOCSETCONFIG32        _IOW('m', 5, struct mtconfiginfo32)
954
 
955
static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
956
{
957
        mm_segment_t old_fs = get_fs();
958
        struct mtconfiginfo info;
959
        struct mtget get;
960
        struct mtpos pos;
961
        unsigned long kcmd;
962
        void *karg;
963
        int err = 0;
964
 
965
        switch(cmd) {
966
        case MTIOCPOS32:
967
                kcmd = MTIOCPOS;
968
                karg = &pos;
969
                break;
970
        case MTIOCGET32:
971
                kcmd = MTIOCGET;
972
                karg = &get;
973
                break;
974
        case MTIOCGETCONFIG32:
975
                kcmd = MTIOCGETCONFIG;
976
                karg = &info;
977
                break;
978
        case MTIOCSETCONFIG32:
979
                kcmd = MTIOCSETCONFIG;
980
                karg = &info;
981
                err = __get_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
982
                err |= __get_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
983
                err |= __get_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
984
                err |= __get_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
985
                err |= __get_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
986
                err |= __get_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
987
                err |= __copy_from_user((char *)&info.debug + sizeof(info.debug),
988
                                     (char *)&((struct mtconfiginfo32 *)arg)->debug
989
                                     + sizeof(((struct mtconfiginfo32 *)arg)->debug), sizeof(__u32));
990
                if (err)
991
                        return -EFAULT;
992
                break;
993
        default:
994
                do {
995
                        static int count = 0;
996
                        if (++count <= 20)
997
                                printk("mt_ioctl: Unknown cmd fd(%d) "
998
                                       "cmd(%08x) arg(%08x)\n",
999
                                       (int)fd, (unsigned int)cmd, (unsigned int)arg);
1000
                } while(0);
1001
                return -EINVAL;
1002
        }
1003
        set_fs (KERNEL_DS);
1004
        err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1005
        set_fs (old_fs);
1006
        if (err)
1007
                return err;
1008
        switch (cmd) {
1009
        case MTIOCPOS32:
1010
                err = __put_user(pos.mt_blkno, &((struct mtpos32 *)arg)->mt_blkno);
1011
                break;
1012
        case MTIOCGET32:
1013
                err = __put_user(get.mt_type, &((struct mtget32 *)arg)->mt_type);
1014
                err |= __put_user(get.mt_resid, &((struct mtget32 *)arg)->mt_resid);
1015
                err |= __put_user(get.mt_dsreg, &((struct mtget32 *)arg)->mt_dsreg);
1016
                err |= __put_user(get.mt_gstat, &((struct mtget32 *)arg)->mt_gstat);
1017
                err |= __put_user(get.mt_erreg, &((struct mtget32 *)arg)->mt_erreg);
1018
                err |= __put_user(get.mt_fileno, &((struct mtget32 *)arg)->mt_fileno);
1019
                err |= __put_user(get.mt_blkno, &((struct mtget32 *)arg)->mt_blkno);
1020
                break;
1021
        case MTIOCGETCONFIG32:
1022
                err = __put_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
1023
                err |= __put_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
1024
                err |= __put_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
1025
                err |= __put_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
1026
                err |= __put_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
1027
                err |= __put_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
1028
                err |= __copy_to_user((char *)&((struct mtconfiginfo32 *)arg)->debug
1029
                                           + sizeof(((struct mtconfiginfo32 *)arg)->debug),
1030
                                           (char *)&info.debug + sizeof(info.debug), sizeof(__u32));
1031
                break;
1032
        case MTIOCSETCONFIG32:
1033
                break;
1034
        }
1035
        return err ? -EFAULT: 0;
1036
}
1037
 
1038
#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
1039
 
1040
static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1041
{
1042
        return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
1043
}
1044
 
1045
/* serial_struct_ioctl was taken from x86_64/ia32/ia32_ioctl.c and
1046
 * slightly modified for mips */
1047
/* iomem_base is unsigned char * in linux/serial.h (reserved in sgiserial.h) */
1048
struct serial_struct32 {
1049
        int     type;
1050
        int     line;
1051
        unsigned int    port;
1052
        int     irq;
1053
        int     flags;
1054
        int     xmit_fifo_size;
1055
        int     custom_divisor;
1056
        int     baud_base;
1057
        unsigned short  close_delay;
1058
        char    io_type;
1059
        char    reserved_char[1];
1060
        int     hub6;
1061
        unsigned short  closing_wait; /* time to wait before closing */
1062
        unsigned short  closing_wait2; /* no longer used... */
1063
        __u32 iomem_base;
1064
        unsigned short  iomem_reg_shift;
1065
        unsigned int    port_high;
1066
        int     reserved[1];
1067
};
1068
 
1069
static int serial_struct_ioctl(unsigned fd, unsigned cmd,  void *ptr)
1070
{
1071
        typedef struct serial_struct SS;
1072
        struct serial_struct32 *ss32 = ptr;
1073
        int err = 0;
1074
        struct serial_struct ss;
1075
        mm_segment_t oldseg = get_fs();
1076
        set_fs(KERNEL_DS);
1077
        if (cmd == TIOCSSERIAL) {
1078
                err = -EFAULT;
1079
                if (copy_from_user(&ss, ss32, sizeof(struct serial_struct32)))
1080
                        goto out;
1081
                memmove(&ss.iomem_reg_shift, ((char*)&ss.iomem_base)+4,
1082
                        sizeof(SS)-offsetof(SS,iomem_reg_shift));
1083
                ss.iomem_base = (void *)(long)ss.iomem_base; /* sign extend */
1084
        }
1085
        if (!err)
1086
                err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
1087
        if (cmd == TIOCGSERIAL && err >= 0) {
1088
                __u32 base;
1089
                if (__copy_to_user(ss32,&ss,offsetof(SS,iomem_base)) ||
1090
                    __copy_to_user(&ss32->iomem_reg_shift,
1091
                                   &ss.iomem_reg_shift,
1092
                                   sizeof(SS) - offsetof(SS, iomem_reg_shift)))
1093
                        err = -EFAULT;
1094
                base = (unsigned long)ss.iomem_base;
1095
                err |= __put_user(base, &ss32->iomem_base);
1096
        }
1097
 out:
1098
        set_fs(oldseg);
1099
        return err;
1100
}
1101
 
1102
/* loop_status was taken from sparc64/kernel/ioctl32.c */
1103
struct loop_info32 {
1104
        int                     lo_number;      /* ioctl r/o */
1105
        __kernel_dev_t32        lo_device;      /* ioctl r/o */
1106
        unsigned int            lo_inode;       /* ioctl r/o */
1107
        __kernel_dev_t32        lo_rdevice;     /* ioctl r/o */
1108
        int                     lo_offset;
1109
        int                     lo_encrypt_type;
1110
        int                     lo_encrypt_key_size;    /* ioctl w/o */
1111
        int                     lo_flags;       /* ioctl r/o */
1112
        char                    lo_name[LO_NAME_SIZE];
1113
        unsigned char           lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
1114
        unsigned int            lo_init[2];
1115
        char                    reserved[4];
1116
};
1117
 
1118
static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg)
1119
{
1120
        mm_segment_t old_fs = get_fs();
1121
        struct loop_info l;
1122
        int err = -EINVAL;
1123
 
1124
        switch(cmd) {
1125
        case LOOP_SET_STATUS:
1126
                err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1127
                err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1128
                err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1129
                err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1130
                err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
1131
                                           8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1132
                if (err) {
1133
                        err = -EFAULT;
1134
                } else {
1135
                        set_fs (KERNEL_DS);
1136
                        err = sys_ioctl (fd, cmd, (unsigned long)&l);
1137
                        set_fs (old_fs);
1138
                }
1139
                break;
1140
        case LOOP_GET_STATUS:
1141
                set_fs (KERNEL_DS);
1142
                err = sys_ioctl (fd, cmd, (unsigned long)&l);
1143
                set_fs (old_fs);
1144
                if (!err) {
1145
                        err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
1146
                        err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
1147
                        err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
1148
                        err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
1149
                        err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
1150
                                           (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
1151
                        if (err)
1152
                                err = -EFAULT;
1153
                }
1154
                break;
1155
        default: {
1156
                static int count;
1157
                if (++count <= 20)
1158
                        printk("%s: Unknown loop ioctl cmd, fd(%d) "
1159
                               "cmd(%08x) arg(%08lx)\n",
1160
                               __FUNCTION__, fd, cmd, arg);
1161
        }
1162
        }
1163
        return err;
1164
}
1165
 
1166
#ifdef CONFIG_VT
1167
 
1168
extern int tty_ioctl(struct inode * inode, struct file * file,
1169
        unsigned int cmd, unsigned long arg);
1170
 
1171
static int vt_check(struct file *file)
1172
{
1173
        struct tty_struct *tty;
1174
        struct inode *inode = file->f_dentry->d_inode;
1175
 
1176
        if (file->f_op->ioctl != tty_ioctl)
1177
                return -EINVAL;
1178
 
1179
        tty = (struct tty_struct *)file->private_data;
1180
        if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
1181
                return -EINVAL;
1182
 
1183
        if (tty->driver.ioctl != vt_ioctl)
1184
                return -EINVAL;
1185
 
1186
        /*
1187
         * To have permissions to do most of the vt ioctls, we either have
1188
         * to be the owner of the tty, or super-user.
1189
         */
1190
        if (current->tty == tty || suser())
1191
                return 1;
1192
        return 0;
1193
}
1194
 
1195
struct consolefontdesc32 {
1196
        unsigned short charcount;       /* characters in font (256 or 512) */
1197
        unsigned short charheight;      /* scan lines per character (1-32) */
1198
        u32 chardata;                   /* font data in expanded form */
1199
};
1200
 
1201
static int do_fontx_ioctl(unsigned int fd, int cmd, struct consolefontdesc32 *user_cfd, struct file *file)
1202
{
1203
        struct consolefontdesc cfdarg;
1204
        struct console_font_op op;
1205
        int i, perm;
1206
 
1207
        perm = vt_check(file);
1208
        if (perm < 0) return perm;
1209
 
1210
        if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc32)))
1211
                return -EFAULT;
1212
 
1213
        cfdarg.chardata = (unsigned char *)A(((struct consolefontdesc32 *)&cfdarg)->chardata);
1214
 
1215
        switch (cmd) {
1216
        case PIO_FONTX:
1217
                if (!perm)
1218
                        return -EPERM;
1219
                op.op = KD_FONT_OP_SET;
1220
                op.flags = 0;
1221
                op.width = 8;
1222
                op.height = cfdarg.charheight;
1223
                op.charcount = cfdarg.charcount;
1224
                op.data = cfdarg.chardata;
1225
                return con_font_op(fg_console, &op);
1226
        case GIO_FONTX:
1227
                if (!cfdarg.chardata)
1228
                        return 0;
1229
                op.op = KD_FONT_OP_GET;
1230
                op.flags = 0;
1231
                op.width = 8;
1232
                op.height = cfdarg.charheight;
1233
                op.charcount = cfdarg.charcount;
1234
                op.data = cfdarg.chardata;
1235
                i = con_font_op(fg_console, &op);
1236
                if (i)
1237
                        return i;
1238
                cfdarg.charheight = op.height;
1239
                cfdarg.charcount = op.charcount;
1240
                ((struct consolefontdesc32 *)&cfdarg)->chardata = (unsigned long)cfdarg.chardata;
1241
                if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc32)))
1242
                        return -EFAULT;
1243
                return 0;
1244
        }
1245
        return -EINVAL;
1246
}
1247
 
1248
struct console_font_op32 {
1249
        unsigned int op;        /* operation code KD_FONT_OP_* */
1250
        unsigned int flags;     /* KD_FONT_FLAG_* */
1251
        unsigned int width, height;     /* font size */
1252
        unsigned int charcount;
1253
        u32 data;    /* font data with height fixed to 32 */
1254
};
1255
 
1256
static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, struct console_font_op32 *fontop, struct file *file)
1257
{
1258
        struct console_font_op op;
1259
        int perm = vt_check(file), i;
1260
        struct vt_struct *vt;
1261
 
1262
        if (perm < 0) return perm;
1263
 
1264
        if (copy_from_user(&op, (void *) fontop, sizeof(struct console_font_op32)))
1265
                return -EFAULT;
1266
        if (!perm && op.op != KD_FONT_OP_GET)
1267
                return -EPERM;
1268
        op.data = (unsigned char *)A(((struct console_font_op32 *)&op)->data);
1269
        op.flags |= KD_FONT_FLAG_OLD;
1270
        vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data;
1271
        i = con_font_op(vt->vc_num, &op);
1272
        if (i) return i;
1273
        ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
1274
        if (copy_to_user((void *) fontop, &op, sizeof(struct console_font_op32)))
1275
                return -EFAULT;
1276
        return 0;
1277
}
1278
 
1279
#endif /* CONFIG_VT */
1280
 
1281
#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
1282
/* Ugh, LVM. Pitty it was not cleaned up before accepted :((. */
1283
typedef struct {
1284
        uint8_t vg_name[NAME_LEN];
1285
        uint32_t vg_number;
1286
        uint32_t vg_access;
1287
        uint32_t vg_status;
1288
        uint32_t lv_max;
1289
        uint32_t lv_cur;
1290
        uint32_t lv_open;
1291
        uint32_t pv_max;
1292
        uint32_t pv_cur;
1293
        uint32_t pv_act;
1294
        uint32_t dummy;
1295
        uint32_t vgda;
1296
        uint32_t pe_size;
1297
        uint32_t pe_total;
1298
        uint32_t pe_allocated;
1299
        uint32_t pvg_total;
1300
        u32 proc;
1301
        u32 pv[ABS_MAX_PV + 1];
1302
        u32 lv[ABS_MAX_LV + 1];
1303
        uint8_t vg_uuid[UUID_LEN+1];    /* volume group UUID */
1304
        uint8_t dummy1[200];
1305
} vg32_t;
1306
 
1307
typedef struct {
1308
        uint8_t id[2];
1309
        uint16_t version;
1310
        lvm_disk_data_t pv_on_disk;
1311
        lvm_disk_data_t vg_on_disk;
1312
        lvm_disk_data_t pv_namelist_on_disk;
1313
        lvm_disk_data_t lv_on_disk;
1314
        lvm_disk_data_t pe_on_disk;
1315
        uint8_t pv_name[NAME_LEN];
1316
        uint8_t vg_name[NAME_LEN];
1317
        uint8_t system_id[NAME_LEN];
1318
        kdev_t pv_dev;
1319
        uint32_t pv_number;
1320
        uint32_t pv_status;
1321
        uint32_t pv_allocatable;
1322
        uint32_t pv_size;
1323
        uint32_t lv_cur;
1324
        uint32_t pe_size;
1325
        uint32_t pe_total;
1326
        uint32_t pe_allocated;
1327
        uint32_t pe_stale;
1328
        u32 pe;
1329
        u32 inode;
1330
        uint8_t pv_uuid[UUID_LEN+1];
1331
} pv32_t;
1332
 
1333
typedef struct {
1334
        char lv_name[NAME_LEN];
1335
        u32 lv;
1336
} lv_req32_t;
1337
 
1338
typedef struct {
1339
        u32 lv_index;
1340
        u32 lv;
1341
        /* Transfer size because user space and kernel space differ */
1342
        uint16_t size;
1343
} lv_status_byindex_req32_t;
1344
 
1345
typedef struct {
1346
        __kernel_dev_t32 dev;
1347
        u32   lv;
1348
} lv_status_bydev_req32_t;
1349
 
1350
typedef struct {
1351
        uint8_t lv_name[NAME_LEN];
1352
        kdev_t old_dev;
1353
        kdev_t new_dev;
1354
        u32 old_pe;
1355
        u32 new_pe;
1356
} le_remap_req32_t;
1357
 
1358
typedef struct {
1359
        char pv_name[NAME_LEN];
1360
        u32 pv;
1361
} pv_status_req32_t;
1362
 
1363
typedef struct {
1364
        uint8_t lv_name[NAME_LEN];
1365
        uint8_t vg_name[NAME_LEN];
1366
        uint32_t lv_access;
1367
        uint32_t lv_status;
1368
        uint32_t lv_open;
1369
        kdev_t lv_dev;
1370
        uint32_t lv_number;
1371
        uint32_t lv_mirror_copies;
1372
        uint32_t lv_recovery;
1373
        uint32_t lv_schedule;
1374
        uint32_t lv_size;
1375
        u32 lv_current_pe;
1376
        uint32_t lv_current_le;
1377
        uint32_t lv_allocated_le;
1378
        uint32_t lv_stripes;
1379
        uint32_t lv_stripesize;
1380
        uint32_t lv_badblock;
1381
        uint32_t lv_allocation;
1382
        uint32_t lv_io_timeout;
1383
        uint32_t lv_read_ahead;
1384
        /* delta to version 1 starts here */
1385
        u32 lv_snapshot_org;
1386
        u32 lv_snapshot_prev;
1387
        u32 lv_snapshot_next;
1388
        u32 lv_block_exception;
1389
        uint32_t lv_remap_ptr;
1390
        uint32_t lv_remap_end;
1391
        uint32_t lv_chunk_size;
1392
        uint32_t lv_snapshot_minor;
1393
        char dummy[200];
1394
} lv32_t;
1395
 
1396
typedef struct {
1397
        u32 hash[2];
1398
        u32 rsector_org;
1399
        kdev_t rdev_org;
1400
        u32 rsector_new;
1401
        kdev_t rdev_new;
1402
} lv_block_exception32_t;
1403
 
1404
static void put_lv_t(lv_t *l)
1405
{
1406
        if (l->lv_current_pe) vfree(l->lv_current_pe);
1407
        if (l->lv_block_exception) vfree(l->lv_block_exception);
1408
        kfree(l);
1409
}
1410
 
1411
static lv_t *get_lv_t(u32 p, int *errp)
1412
{
1413
        int err, i;
1414
        u32 ptr1, ptr2;
1415
        size_t size;
1416
        lv_block_exception32_t *lbe32;
1417
        lv_block_exception_t *lbe;
1418
        lv32_t *ul = (lv32_t *)A(p);
1419
        lv_t *l = (lv_t *) kmalloc(sizeof(lv_t), GFP_KERNEL);
1420
 
1421
        if (!l) {
1422
                *errp = -ENOMEM;
1423
                return NULL;
1424
        }
1425
        memset(l, 0, sizeof(lv_t));
1426
        err = copy_from_user(l, ul, (long)&((lv32_t *)0)->lv_current_pe);
1427
        err |= __copy_from_user(&l->lv_current_le, &ul->lv_current_le,
1428
                                ((long)&ul->lv_snapshot_org) - ((long)&ul->lv_current_le));
1429
        err |= __copy_from_user(&l->lv_remap_ptr, &ul->lv_remap_ptr,
1430
                                ((long)&ul->dummy[0]) - ((long)&ul->lv_remap_ptr));
1431
        err |= __get_user(ptr1, &ul->lv_current_pe);
1432
        err |= __get_user(ptr2, &ul->lv_block_exception);
1433
        if (err) {
1434
                kfree(l);
1435
                *errp = -EFAULT;
1436
                return NULL;
1437
        }
1438
        if (ptr1) {
1439
                size = l->lv_allocated_le * sizeof(pe_t);
1440
                l->lv_current_pe = vmalloc(size);
1441
                if (l->lv_current_pe)
1442
                        err = copy_from_user(l->lv_current_pe, (void *)A(ptr1), size);
1443
        }
1444
        if (!err && ptr2) {
1445
                size = l->lv_remap_end * sizeof(lv_block_exception_t);
1446
                l->lv_block_exception = lbe = vmalloc(size);
1447
                if (l->lv_block_exception) {
1448
                        lbe32 = (lv_block_exception32_t *)A(ptr2);
1449
                        memset(lbe, 0, size);
1450
                        for (i = 0; i < l->lv_remap_end; i++, lbe++, lbe32++) {
1451
                                err |= get_user(lbe->rsector_org, &lbe32->rsector_org);
1452
                                err |= __get_user(lbe->rdev_org, &lbe32->rdev_org);
1453
                                err |= __get_user(lbe->rsector_new, &lbe32->rsector_new);
1454
                                err |= __get_user(lbe->rdev_new, &lbe32->rdev_new);
1455
                        }
1456
                }
1457
        }
1458
        if (err || (ptr1 && !l->lv_current_pe) || (ptr2 && !l->lv_block_exception)) {
1459
                if (!err)
1460
                        *errp = -ENOMEM;
1461
                else
1462
                        *errp = -EFAULT;
1463
                put_lv_t(l);
1464
                return NULL;
1465
        }
1466
        return l;
1467
}
1468
 
1469
static int copy_lv_t(u32 ptr, lv_t *l)
1470
{
1471
        int err;
1472
        lv32_t *ul = (lv32_t *)A(ptr);
1473
        u32 ptr1;
1474
        size_t size;
1475
 
1476
        err = get_user(ptr1, &ul->lv_current_pe);
1477
        if (err)
1478
                return -EFAULT;
1479
        err = copy_to_user(ul, l, (long)&((lv32_t *)0)->lv_current_pe);
1480
        err |= __copy_to_user(&ul->lv_current_le, &l->lv_current_le,
1481
                                ((long)&ul->lv_snapshot_org) - ((long)&ul->lv_current_le));
1482
        err |= __copy_to_user(&ul->lv_remap_ptr, &l->lv_remap_ptr,
1483
                                ((long)&ul->dummy[0]) - ((long)&ul->lv_remap_ptr));
1484
        size = l->lv_allocated_le * sizeof(pe_t);
1485
        if (ptr1)
1486
                err |= __copy_to_user((void *)A(ptr1), l->lv_current_pe, size);
1487
        return err ? -EFAULT : 0;
1488
}
1489
 
1490
static int do_lvm_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1491
{
1492
        vg_t *v = NULL;
1493
        union {
1494
                lv_req_t lv_req;
1495
                le_remap_req_t le_remap;
1496
                lv_status_byindex_req_t lv_byindex;
1497
                lv_status_bydev_req_t lv_bydev;
1498
                pv_status_req_t pv_status;
1499
        } u;
1500
        pv_t p;
1501
        int err;
1502
        u32 ptr = 0;
1503
        int i;
1504
        mm_segment_t old_fs;
1505
        void *karg = &u;
1506
 
1507
        switch (cmd) {
1508
        case VG_STATUS:
1509
                v = kmalloc(sizeof(vg_t), GFP_KERNEL);
1510
                if (!v)
1511
                        return -ENOMEM;
1512
                karg = v;
1513
                break;
1514
 
1515
        case VG_CREATE_OLD:
1516
        case VG_CREATE:
1517
                v = kmalloc(sizeof(vg_t), GFP_KERNEL);
1518
                if (!v)
1519
                        return -ENOMEM;
1520
                if (copy_from_user(v, (void *)arg, (long)&((vg32_t *)0)->proc)) {
1521
                        kfree(v);
1522
                        return -EFAULT;
1523
                }
1524
                /* 'proc' field is unused, just NULL it out. */
1525
                v->proc = NULL;
1526
                if (copy_from_user(v->vg_uuid, ((vg32_t *)arg)->vg_uuid, UUID_LEN+1)) {
1527
                        kfree(v);
1528
                        return -EFAULT;
1529
                }
1530
 
1531
                karg = v;
1532
                memset(v->pv, 0, sizeof(v->pv) + sizeof(v->lv));
1533
                if (v->pv_max > ABS_MAX_PV || v->lv_max > ABS_MAX_LV)
1534
                        return -EPERM;
1535
                for (i = 0; i < v->pv_max; i++) {
1536
                        err = __get_user(ptr, &((vg32_t *)arg)->pv[i]);
1537
                        if (err)
1538
                                break;
1539
                        if (ptr) {
1540
                                v->pv[i] = kmalloc(sizeof(pv_t), GFP_KERNEL);
1541
                                if (!v->pv[i]) {
1542
                                        err = -ENOMEM;
1543
                                        break;
1544
                                }
1545
                                err = copy_from_user(v->pv[i], (void *)A(ptr),
1546
                                                     sizeof(pv32_t) - 8 - UUID_LEN+1);
1547
                                if (err) {
1548
                                        err = -EFAULT;
1549
                                        break;
1550
                                }
1551
                                err = copy_from_user(v->pv[i]->pv_uuid,
1552
                                                     ((pv32_t *)A(ptr))->pv_uuid,
1553
                                                     UUID_LEN+1);
1554
                                if (err) {
1555
                                        err = -EFAULT;
1556
                                        break;
1557
                                }
1558
 
1559
                                v->pv[i]->pe = NULL;
1560
                                v->pv[i]->bd = NULL;
1561
                        }
1562
                }
1563
                if (!err) {
1564
                        for (i = 0; i < v->lv_max; i++) {
1565
                                err = __get_user(ptr, &((vg32_t *)arg)->lv[i]);
1566
                                if (err)
1567
                                        break;
1568
                                if (ptr) {
1569
                                        v->lv[i] = get_lv_t(ptr, &err);
1570
                                        if (err)
1571
                                                break;
1572
                                }
1573
                        }
1574
                }
1575
                break;
1576
 
1577
        case LV_CREATE:
1578
        case LV_EXTEND:
1579
        case LV_REDUCE:
1580
        case LV_REMOVE:
1581
        case LV_RENAME:
1582
        case LV_STATUS_BYNAME:
1583
                err = copy_from_user(&u.pv_status, arg, sizeof(u.pv_status.pv_name));
1584
                if (err)
1585
                        return -EFAULT;
1586
                if (cmd != LV_REMOVE) {
1587
                        err = __get_user(ptr, &((lv_req32_t *)arg)->lv);
1588
                        if (err)
1589
                                return err;
1590
                        u.lv_req.lv = get_lv_t(ptr, &err);
1591
                } else
1592
                        u.lv_req.lv = NULL;
1593
                break;
1594
 
1595
        case LV_STATUS_BYINDEX:
1596
                err = get_user(u.lv_byindex.lv_index,
1597
                               &((lv_status_byindex_req32_t *)arg)->lv_index);
1598
                err |= __get_user(ptr, &((lv_status_byindex_req32_t *)arg)->lv);
1599
                if (err)
1600
                        return err;
1601
                u.lv_byindex.lv = get_lv_t(ptr, &err);
1602
                break;
1603
 
1604
        case LV_STATUS_BYDEV:
1605
                err = get_user(u.lv_bydev.dev, &((lv_status_bydev_req32_t *)arg)->dev);
1606
                err |= __get_user(ptr, &((lv_status_bydev_req32_t *)arg)->lv);
1607
                if (err)
1608
                        return err;
1609
                u.lv_bydev.lv = get_lv_t(ptr, &err);
1610
                break;
1611
 
1612
        case VG_EXTEND:
1613
                err = copy_from_user(&p, (void *)arg, sizeof(pv32_t) - 8 - UUID_LEN+1);
1614
                if (err)
1615
                        return -EFAULT;
1616
                err = copy_from_user(p.pv_uuid, ((pv32_t *)arg)->pv_uuid, UUID_LEN+1);
1617
                if (err)
1618
                        return -EFAULT;
1619
                p.pe = NULL;
1620
                p.bd = NULL;
1621
                karg = &p;
1622
                break;
1623
 
1624
        case PV_CHANGE:
1625
        case PV_STATUS:
1626
                err = copy_from_user(&u.pv_status, arg, sizeof(u.lv_req.lv_name));
1627
                if (err)
1628
                        return -EFAULT;
1629
                err = __get_user(ptr, &((pv_status_req32_t *)arg)->pv);
1630
                if (err)
1631
                        return err;
1632
                u.pv_status.pv = &p;
1633
                if (cmd == PV_CHANGE) {
1634
                        err = copy_from_user(&p, (void *)A(ptr),
1635
                                             sizeof(pv32_t) - 8 - UUID_LEN+1);
1636
                        if (err)
1637
                                return -EFAULT;
1638
                        p.pe = NULL;
1639
                        p.bd = NULL;
1640
                }
1641
                break;
1642
        };
1643
 
1644
        old_fs = get_fs(); set_fs (KERNEL_DS);
1645
        err = sys_ioctl (fd, cmd, (unsigned long)karg);
1646
        set_fs (old_fs);
1647
 
1648
        switch (cmd) {
1649
        case VG_STATUS:
1650
                if (!err) {
1651
                        if (copy_to_user((void *)arg, v, (long)&((vg32_t *)0)->proc) ||
1652
                            clear_user(&((vg32_t *)arg)->proc, sizeof(vg32_t) - (long)&((vg32_t *)0)->proc))
1653
                                err = -EFAULT;
1654
                }
1655
                if (copy_to_user(((vg32_t *)arg)->vg_uuid, v->vg_uuid, UUID_LEN+1)) {
1656
                        err = -EFAULT;
1657
                }
1658
                kfree(v);
1659
                break;
1660
 
1661
        case VG_CREATE_OLD:
1662
        case VG_CREATE:
1663
                for (i = 0; i < v->pv_max; i++) {
1664
                        if (v->pv[i])
1665
                                kfree(v->pv[i]);
1666
                }
1667
                for (i = 0; i < v->lv_max; i++) {
1668
                        if (v->lv[i])
1669
                                put_lv_t(v->lv[i]);
1670
                }
1671
                kfree(v);
1672
                break;
1673
 
1674
        case LV_STATUS_BYNAME:
1675
                if (!err && u.lv_req.lv)
1676
                        err = copy_lv_t(ptr, u.lv_req.lv);
1677
                /* Fall through */
1678
 
1679
        case LV_CREATE:
1680
        case LV_EXTEND:
1681
        case LV_REDUCE:
1682
                if (u.lv_req.lv)
1683
                        put_lv_t(u.lv_req.lv);
1684
                break;
1685
 
1686
        case LV_STATUS_BYINDEX:
1687
                if (u.lv_byindex.lv) {
1688
                        if (!err)
1689
                                err = copy_lv_t(ptr, u.lv_byindex.lv);
1690
                        put_lv_t(u.lv_byindex.lv);
1691
                }
1692
                break;
1693
 
1694
        case LV_STATUS_BYDEV:
1695
                if (u.lv_bydev.lv) {
1696
                        if (!err)
1697
                                err = copy_lv_t(ptr, u.lv_bydev.lv);
1698
                        put_lv_t(u.lv_byindex.lv);
1699
                }
1700
                break;
1701
 
1702
        case PV_STATUS:
1703
                if (!err) {
1704
                        err = copy_to_user((void *)A(ptr), &p, sizeof(pv32_t) - 8 - UUID_LEN+1);
1705
                        if (err)
1706
                                return -EFAULT;
1707
                        err = copy_to_user(((pv_t *)A(ptr))->pv_uuid, p.pv_uuid, UUID_LEN + 1);
1708
                        if (err)
1709
                                return -EFAULT;
1710
                }
1711
                break;
1712
        };
1713
 
1714
        return err;
1715
}
1716
#endif /* CONFIG_BLK_DEV_LVM */
1717
 
1718
struct ioctl32_handler {
1719
        unsigned int cmd;
1720
        int (*function)(unsigned int, unsigned int, unsigned long);
1721
};
1722
 
1723
struct ioctl32_list {
1724
        struct ioctl32_handler handler;
1725
        struct ioctl32_list *next;
1726
};
1727
 
1728
#define IOCTL32_DEFAULT(cmd)            { { cmd, (void *) sys_ioctl }, 0 }
1729
#define IOCTL32_HANDLER(cmd, handler)   { { cmd, (void *) handler }, 0 }
1730
 
1731
static struct ioctl32_list ioctl32_handler_table[] = {
1732
        IOCTL32_DEFAULT(TCGETA),
1733
        IOCTL32_DEFAULT(TCSETA),
1734
        IOCTL32_DEFAULT(TCSETAW),
1735
        IOCTL32_DEFAULT(TCSETAF),
1736
        IOCTL32_DEFAULT(TCSBRK),
1737
        IOCTL32_DEFAULT(TCSBRKP),
1738
        IOCTL32_DEFAULT(TCXONC),
1739
        IOCTL32_DEFAULT(TCFLSH),
1740
        IOCTL32_DEFAULT(TCGETS),
1741
        IOCTL32_DEFAULT(TCSETS),
1742
        IOCTL32_DEFAULT(TCSETSW),
1743
        IOCTL32_DEFAULT(TCSETSF),
1744
        IOCTL32_DEFAULT(TIOCLINUX),
1745
 
1746
        IOCTL32_DEFAULT(TIOCGETD),
1747
        IOCTL32_DEFAULT(TIOCSETD),
1748
        IOCTL32_DEFAULT(TIOCEXCL),
1749
        IOCTL32_DEFAULT(TIOCNXCL),
1750
        IOCTL32_DEFAULT(TIOCCONS),
1751
        IOCTL32_DEFAULT(TIOCGSOFTCAR),
1752
        IOCTL32_DEFAULT(TIOCSSOFTCAR),
1753
        IOCTL32_DEFAULT(TIOCSWINSZ),
1754
        IOCTL32_DEFAULT(TIOCGWINSZ),
1755
        IOCTL32_DEFAULT(TIOCMGET),
1756
        IOCTL32_DEFAULT(TIOCMBIC),
1757
        IOCTL32_DEFAULT(TIOCMBIS),
1758
        IOCTL32_DEFAULT(TIOCMSET),
1759
        IOCTL32_DEFAULT(TIOCPKT),
1760
        IOCTL32_DEFAULT(TIOCNOTTY),
1761
        IOCTL32_DEFAULT(TIOCSTI),
1762
        IOCTL32_DEFAULT(TIOCOUTQ),
1763
        IOCTL32_DEFAULT(TIOCSPGRP),
1764
        IOCTL32_DEFAULT(TIOCGPGRP),
1765
        IOCTL32_DEFAULT(TIOCSCTTY),
1766
        IOCTL32_DEFAULT(TIOCGPTN),
1767
        IOCTL32_DEFAULT(TIOCSPTLCK),
1768
        IOCTL32_HANDLER(TIOCGSERIAL, serial_struct_ioctl),
1769
        IOCTL32_HANDLER(TIOCSSERIAL, serial_struct_ioctl),
1770
        IOCTL32_DEFAULT(TIOCSERGETLSR),
1771
 
1772
        IOCTL32_DEFAULT(FIOCLEX),
1773
        IOCTL32_DEFAULT(FIONCLEX),
1774
        IOCTL32_DEFAULT(FIOASYNC),
1775
        IOCTL32_DEFAULT(FIONBIO),
1776
        IOCTL32_DEFAULT(FIONREAD),
1777
 
1778
#ifdef CONFIG_FB
1779
        /* Big F */
1780
        IOCTL32_DEFAULT(FBIOGET_VSCREENINFO),
1781
        IOCTL32_DEFAULT(FBIOPUT_VSCREENINFO),
1782
        IOCTL32_HANDLER(FBIOGET_FSCREENINFO, do_fbioget_fscreeninfo_ioctl),
1783
        IOCTL32_HANDLER(FBIOGETCMAP, do_fbiocmap_ioctl),
1784
        IOCTL32_HANDLER(FBIOPUTCMAP, do_fbiocmap_ioctl),
1785
        IOCTL32_DEFAULT(FBIOPAN_DISPLAY),
1786
#endif /* CONFIG_FB */
1787
 
1788
        /* Little v, the video4linux ioctls */
1789
        IOCTL32_DEFAULT(VIDIOCGCAP),
1790
        IOCTL32_DEFAULT(VIDIOCGCHAN),
1791
        IOCTL32_DEFAULT(VIDIOCSCHAN),
1792
        IOCTL32_DEFAULT(VIDIOCGPICT),
1793
        IOCTL32_DEFAULT(VIDIOCSPICT),
1794
        IOCTL32_DEFAULT(VIDIOCCAPTURE),
1795
 
1796
        IOCTL32_DEFAULT(VIDIOCGWIN),
1797
        IOCTL32_DEFAULT(VIDIOCSWIN),
1798
        IOCTL32_DEFAULT(VIDIOCGFBUF),
1799
        IOCTL32_DEFAULT(VIDIOCSFBUF),
1800
 
1801
        IOCTL32_DEFAULT(VIDIOCKEY),
1802
        IOCTL32_DEFAULT(VIDIOCGAUDIO),
1803
        IOCTL32_DEFAULT(VIDIOCSAUDIO),
1804
        IOCTL32_DEFAULT(VIDIOCSYNC),
1805
        IOCTL32_DEFAULT(VIDIOCMCAPTURE),
1806
        IOCTL32_DEFAULT(VIDIOCGMBUF),
1807
        IOCTL32_DEFAULT(VIDIOCGUNIT),
1808
        IOCTL32_DEFAULT(VIDIOCGCAPTURE),
1809
        IOCTL32_DEFAULT(VIDIOCSCAPTURE),
1810
        /* BTTV specific... */
1811
        IOCTL32_DEFAULT(_IOW('v',  BASE_VIDIOCPRIVATE+0, char [256])),
1812
        IOCTL32_DEFAULT(_IOR('v',  BASE_VIDIOCPRIVATE+1, char [256])),
1813
        IOCTL32_DEFAULT(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)),
1814
        IOCTL32_DEFAULT(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])), /* struct bttv_pll_info */
1815
        IOCTL32_DEFAULT(_IOR('v' , BASE_VIDIOCPRIVATE+4, int)),
1816
        IOCTL32_DEFAULT(_IOR('v' , BASE_VIDIOCPRIVATE+5, int)),
1817
        IOCTL32_DEFAULT(_IOR('v' , BASE_VIDIOCPRIVATE+6, int)),
1818
        IOCTL32_DEFAULT(_IOR('v' , BASE_VIDIOCPRIVATE+7, int)),
1819
 
1820
#ifdef CONFIG_NET
1821
        /* Socket level stuff */
1822
        IOCTL32_DEFAULT(FIOSETOWN),
1823
        IOCTL32_DEFAULT(SIOCSPGRP),
1824
        IOCTL32_DEFAULT(FIOGETOWN),
1825
        IOCTL32_DEFAULT(SIOCGPGRP),
1826
        IOCTL32_DEFAULT(SIOCATMARK),
1827
        IOCTL32_DEFAULT(SIOCSIFLINK),
1828
        IOCTL32_DEFAULT(SIOCSIFENCAP),
1829
        IOCTL32_DEFAULT(SIOCGIFENCAP),
1830
        IOCTL32_DEFAULT(SIOCSIFBR),
1831
        IOCTL32_DEFAULT(SIOCGIFBR),
1832
        IOCTL32_DEFAULT(SIOCSARP),
1833
        IOCTL32_DEFAULT(SIOCGARP),
1834
        IOCTL32_DEFAULT(SIOCDARP),
1835
        IOCTL32_DEFAULT(SIOCSRARP),
1836
        IOCTL32_DEFAULT(SIOCGRARP),
1837
        IOCTL32_DEFAULT(SIOCDRARP),
1838
        IOCTL32_DEFAULT(SIOCADDDLCI),
1839
        IOCTL32_DEFAULT(SIOCDELDLCI),
1840
        /* SG stuff */
1841
        IOCTL32_DEFAULT(SG_SET_TIMEOUT),
1842
        IOCTL32_DEFAULT(SG_GET_TIMEOUT),
1843
        IOCTL32_DEFAULT(SG_EMULATED_HOST),
1844
        IOCTL32_DEFAULT(SG_SET_TRANSFORM),
1845
        IOCTL32_DEFAULT(SG_GET_TRANSFORM),
1846
        IOCTL32_DEFAULT(SG_SET_RESERVED_SIZE),
1847
        IOCTL32_DEFAULT(SG_GET_RESERVED_SIZE),
1848
        IOCTL32_DEFAULT(SG_GET_SCSI_ID),
1849
        IOCTL32_DEFAULT(SG_SET_FORCE_LOW_DMA),
1850
        IOCTL32_DEFAULT(SG_GET_LOW_DMA),
1851
        IOCTL32_DEFAULT(SG_SET_FORCE_PACK_ID),
1852
        IOCTL32_DEFAULT(SG_GET_PACK_ID),
1853
        IOCTL32_DEFAULT(SG_GET_NUM_WAITING),
1854
        IOCTL32_DEFAULT(SG_SET_DEBUG),
1855
        IOCTL32_DEFAULT(SG_GET_SG_TABLESIZE),
1856
        IOCTL32_DEFAULT(SG_GET_COMMAND_Q),
1857
        IOCTL32_DEFAULT(SG_SET_COMMAND_Q),
1858
        IOCTL32_DEFAULT(SG_GET_VERSION_NUM),
1859
        IOCTL32_DEFAULT(SG_NEXT_CMD_LEN),
1860
        IOCTL32_DEFAULT(SG_SCSI_RESET),
1861
        IOCTL32_DEFAULT(SG_IO),
1862
        IOCTL32_DEFAULT(SG_GET_REQUEST_TABLE),
1863
        IOCTL32_DEFAULT(SG_SET_KEEP_ORPHAN),
1864
        IOCTL32_DEFAULT(SG_GET_KEEP_ORPHAN),
1865
        /* PPP stuff */
1866
        IOCTL32_DEFAULT(PPPIOCGFLAGS),
1867
        IOCTL32_DEFAULT(PPPIOCSFLAGS),
1868
        IOCTL32_DEFAULT(PPPIOCGASYNCMAP),
1869
        IOCTL32_DEFAULT(PPPIOCSASYNCMAP),
1870
        IOCTL32_DEFAULT(PPPIOCGUNIT),
1871
        IOCTL32_DEFAULT(PPPIOCGRASYNCMAP),
1872
        IOCTL32_DEFAULT(PPPIOCSRASYNCMAP),
1873
        IOCTL32_DEFAULT(PPPIOCGMRU),
1874
        IOCTL32_DEFAULT(PPPIOCSMRU),
1875
        IOCTL32_DEFAULT(PPPIOCSMAXCID),
1876
        IOCTL32_DEFAULT(PPPIOCGXASYNCMAP),
1877
        IOCTL32_DEFAULT(PPPIOCSXASYNCMAP),
1878
        IOCTL32_DEFAULT(PPPIOCXFERUNIT),
1879
        IOCTL32_DEFAULT(PPPIOCGNPMODE),
1880
        IOCTL32_DEFAULT(PPPIOCSNPMODE),
1881
        IOCTL32_DEFAULT(PPPIOCGDEBUG),
1882
        IOCTL32_DEFAULT(PPPIOCSDEBUG),
1883
        IOCTL32_DEFAULT(PPPIOCNEWUNIT),
1884
        IOCTL32_DEFAULT(PPPIOCATTACH),
1885
        IOCTL32_DEFAULT(PPPIOCGCHAN),
1886
        /* PPPOX */
1887
        IOCTL32_DEFAULT(PPPOEIOCSFWD),
1888
        IOCTL32_DEFAULT(PPPOEIOCDFWD),
1889
        /* CDROM stuff */
1890
        IOCTL32_DEFAULT(CDROMPAUSE),
1891
        IOCTL32_DEFAULT(CDROMRESUME),
1892
        IOCTL32_DEFAULT(CDROMPLAYMSF),
1893
        IOCTL32_DEFAULT(CDROMPLAYTRKIND),
1894
        IOCTL32_DEFAULT(CDROMREADTOCHDR),
1895
        IOCTL32_DEFAULT(CDROMREADTOCENTRY),
1896
        IOCTL32_DEFAULT(CDROMSTOP),
1897
        IOCTL32_DEFAULT(CDROMSTART),
1898
        IOCTL32_DEFAULT(CDROMEJECT),
1899
        IOCTL32_DEFAULT(CDROMVOLCTRL),
1900
        IOCTL32_DEFAULT(CDROMSUBCHNL),
1901
        IOCTL32_DEFAULT(CDROMEJECT_SW),
1902
        IOCTL32_DEFAULT(CDROMMULTISESSION),
1903
        IOCTL32_DEFAULT(CDROM_GET_MCN),
1904
        IOCTL32_DEFAULT(CDROMRESET),
1905
        IOCTL32_DEFAULT(CDROMVOLREAD),
1906
        IOCTL32_DEFAULT(CDROMSEEK),
1907
        IOCTL32_DEFAULT(CDROMPLAYBLK),
1908
        IOCTL32_DEFAULT(CDROMCLOSETRAY),
1909
        IOCTL32_DEFAULT(CDROM_SET_OPTIONS),
1910
        IOCTL32_DEFAULT(CDROM_CLEAR_OPTIONS),
1911
        IOCTL32_DEFAULT(CDROM_SELECT_SPEED),
1912
        IOCTL32_DEFAULT(CDROM_SELECT_DISC),
1913
        IOCTL32_DEFAULT(CDROM_MEDIA_CHANGED),
1914
        IOCTL32_DEFAULT(CDROM_DRIVE_STATUS),
1915
        IOCTL32_DEFAULT(CDROM_DISC_STATUS),
1916
        IOCTL32_DEFAULT(CDROM_CHANGER_NSLOTS),
1917
        IOCTL32_DEFAULT(CDROM_LOCKDOOR),
1918
        IOCTL32_DEFAULT(CDROM_DEBUG),
1919
        IOCTL32_DEFAULT(CDROM_GET_CAPABILITY),
1920
        /* DVD ioctls */
1921
        IOCTL32_DEFAULT(DVD_READ_STRUCT),
1922
        IOCTL32_DEFAULT(DVD_WRITE_STRUCT),
1923
        IOCTL32_DEFAULT(DVD_AUTH),
1924
        /* Big L */
1925
        IOCTL32_DEFAULT(LOOP_SET_FD),
1926
        IOCTL32_DEFAULT(LOOP_CLR_FD),
1927
        IOCTL32_HANDLER(LOOP_SET_STATUS, loop_status),
1928
        IOCTL32_HANDLER(LOOP_GET_STATUS, loop_status),
1929
        /* Big Q for sound/OSS */
1930
        IOCTL32_DEFAULT(SNDCTL_SEQ_RESET),
1931
        IOCTL32_DEFAULT(SNDCTL_SEQ_SYNC),
1932
        IOCTL32_DEFAULT(SNDCTL_SYNTH_INFO),
1933
        IOCTL32_DEFAULT(SNDCTL_SEQ_CTRLRATE),
1934
        IOCTL32_DEFAULT(SNDCTL_SEQ_GETOUTCOUNT),
1935
        IOCTL32_DEFAULT(SNDCTL_SEQ_GETINCOUNT),
1936
        IOCTL32_DEFAULT(SNDCTL_SEQ_PERCMODE),
1937
        IOCTL32_DEFAULT(SNDCTL_FM_LOAD_INSTR),
1938
        IOCTL32_DEFAULT(SNDCTL_SEQ_TESTMIDI),
1939
        IOCTL32_DEFAULT(SNDCTL_SEQ_RESETSAMPLES),
1940
        IOCTL32_DEFAULT(SNDCTL_SEQ_NRSYNTHS),
1941
        IOCTL32_DEFAULT(SNDCTL_SEQ_NRMIDIS),
1942
        IOCTL32_DEFAULT(SNDCTL_MIDI_INFO),
1943
        IOCTL32_DEFAULT(SNDCTL_SEQ_THRESHOLD),
1944
        IOCTL32_DEFAULT(SNDCTL_SYNTH_MEMAVL),
1945
        IOCTL32_DEFAULT(SNDCTL_FM_4OP_ENABLE),
1946
        IOCTL32_DEFAULT(SNDCTL_SEQ_PANIC),
1947
        IOCTL32_DEFAULT(SNDCTL_SEQ_OUTOFBAND),
1948
        IOCTL32_DEFAULT(SNDCTL_SEQ_GETTIME),
1949
        IOCTL32_DEFAULT(SNDCTL_SYNTH_ID),
1950
        IOCTL32_DEFAULT(SNDCTL_SYNTH_CONTROL),
1951
        IOCTL32_DEFAULT(SNDCTL_SYNTH_REMOVESAMPLE),
1952
        /* Big T for sound/OSS */
1953
        IOCTL32_DEFAULT(SNDCTL_TMR_TIMEBASE),
1954
        IOCTL32_DEFAULT(SNDCTL_TMR_START),
1955
        IOCTL32_DEFAULT(SNDCTL_TMR_STOP),
1956
        IOCTL32_DEFAULT(SNDCTL_TMR_CONTINUE),
1957
        IOCTL32_DEFAULT(SNDCTL_TMR_TEMPO),
1958
        IOCTL32_DEFAULT(SNDCTL_TMR_SOURCE),
1959
        IOCTL32_DEFAULT(SNDCTL_TMR_METRONOME),
1960
        IOCTL32_DEFAULT(SNDCTL_TMR_SELECT),
1961
        /* Little m for sound/OSS */
1962
        IOCTL32_DEFAULT(SNDCTL_MIDI_PRETIME),
1963
        IOCTL32_DEFAULT(SNDCTL_MIDI_MPUMODE),
1964
        IOCTL32_DEFAULT(SNDCTL_MIDI_MPUCMD),
1965
        /* Big P for sound/OSS */
1966
        IOCTL32_DEFAULT(SNDCTL_DSP_RESET),
1967
        IOCTL32_DEFAULT(SNDCTL_DSP_SYNC),
1968
        IOCTL32_DEFAULT(SNDCTL_DSP_SPEED),
1969
        IOCTL32_DEFAULT(SNDCTL_DSP_STEREO),
1970
        IOCTL32_DEFAULT(SNDCTL_DSP_GETBLKSIZE),
1971
        IOCTL32_DEFAULT(SNDCTL_DSP_CHANNELS),
1972
        IOCTL32_DEFAULT(SOUND_PCM_WRITE_FILTER),
1973
        IOCTL32_DEFAULT(SNDCTL_DSP_POST),
1974
        IOCTL32_DEFAULT(SNDCTL_DSP_SUBDIVIDE),
1975
        IOCTL32_DEFAULT(SNDCTL_DSP_SETFRAGMENT),
1976
        IOCTL32_DEFAULT(SNDCTL_DSP_GETFMTS),
1977
        IOCTL32_DEFAULT(SNDCTL_DSP_SETFMT),
1978
        IOCTL32_DEFAULT(SNDCTL_DSP_GETOSPACE),
1979
        IOCTL32_DEFAULT(SNDCTL_DSP_GETISPACE),
1980
        IOCTL32_DEFAULT(SNDCTL_DSP_NONBLOCK),
1981
        IOCTL32_DEFAULT(SNDCTL_DSP_GETCAPS),
1982
        IOCTL32_DEFAULT(SNDCTL_DSP_GETTRIGGER),
1983
        IOCTL32_DEFAULT(SNDCTL_DSP_SETTRIGGER),
1984
        IOCTL32_DEFAULT(SNDCTL_DSP_GETIPTR),
1985
        IOCTL32_DEFAULT(SNDCTL_DSP_GETOPTR),
1986
        /* SNDCTL_DSP_MAPINBUF,  XXX needs translation */
1987
        /* SNDCTL_DSP_MAPOUTBUF,  XXX needs translation */
1988
        IOCTL32_DEFAULT(SNDCTL_DSP_SETSYNCRO),
1989
        IOCTL32_DEFAULT(SNDCTL_DSP_SETDUPLEX),
1990
        IOCTL32_DEFAULT(SNDCTL_DSP_GETODELAY),
1991
        IOCTL32_DEFAULT(SNDCTL_DSP_PROFILE),
1992
        IOCTL32_DEFAULT(SOUND_PCM_READ_RATE),
1993
        IOCTL32_DEFAULT(SOUND_PCM_READ_CHANNELS),
1994
        IOCTL32_DEFAULT(SOUND_PCM_READ_BITS),
1995
        IOCTL32_DEFAULT(SOUND_PCM_READ_FILTER),
1996
        /* Big C for sound/OSS */
1997
        IOCTL32_DEFAULT(SNDCTL_COPR_RESET),
1998
        IOCTL32_DEFAULT(SNDCTL_COPR_LOAD),
1999
        IOCTL32_DEFAULT(SNDCTL_COPR_RDATA),
2000
        IOCTL32_DEFAULT(SNDCTL_COPR_RCODE),
2001
        IOCTL32_DEFAULT(SNDCTL_COPR_WDATA),
2002
        IOCTL32_DEFAULT(SNDCTL_COPR_WCODE),
2003
        IOCTL32_DEFAULT(SNDCTL_COPR_RUN),
2004
        IOCTL32_DEFAULT(SNDCTL_COPR_HALT),
2005
        IOCTL32_DEFAULT(SNDCTL_COPR_SENDMSG),
2006
        IOCTL32_DEFAULT(SNDCTL_COPR_RCVMSG),
2007
        /* Big M for sound/OSS */
2008
        IOCTL32_DEFAULT(SOUND_MIXER_READ_VOLUME),
2009
        IOCTL32_DEFAULT(SOUND_MIXER_READ_BASS),
2010
        IOCTL32_DEFAULT(SOUND_MIXER_READ_TREBLE),
2011
        IOCTL32_DEFAULT(SOUND_MIXER_READ_SYNTH),
2012
        IOCTL32_DEFAULT(SOUND_MIXER_READ_PCM),
2013
        IOCTL32_DEFAULT(SOUND_MIXER_READ_SPEAKER),
2014
        IOCTL32_DEFAULT(SOUND_MIXER_READ_LINE),
2015
        IOCTL32_DEFAULT(SOUND_MIXER_READ_MIC),
2016
        IOCTL32_DEFAULT(SOUND_MIXER_READ_CD),
2017
        IOCTL32_DEFAULT(SOUND_MIXER_READ_IMIX),
2018
        IOCTL32_DEFAULT(SOUND_MIXER_READ_ALTPCM),
2019
        IOCTL32_DEFAULT(SOUND_MIXER_READ_RECLEV),
2020
        IOCTL32_DEFAULT(SOUND_MIXER_READ_IGAIN),
2021
        IOCTL32_DEFAULT(SOUND_MIXER_READ_OGAIN),
2022
        IOCTL32_DEFAULT(SOUND_MIXER_READ_LINE1),
2023
        IOCTL32_DEFAULT(SOUND_MIXER_READ_LINE2),
2024
        IOCTL32_DEFAULT(SOUND_MIXER_READ_LINE3),
2025
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_DIGITAL1)),
2026
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_DIGITAL2)),
2027
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_DIGITAL3)),
2028
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_PHONEIN)),
2029
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_PHONEOUT)),
2030
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_VIDEO)),
2031
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_RADIO)),
2032
        IOCTL32_DEFAULT(MIXER_READ(SOUND_MIXER_MONITOR)),
2033
        IOCTL32_DEFAULT(SOUND_MIXER_READ_MUTE),
2034
        /* SOUND_MIXER_READ_ENHANCE,  same value as READ_MUTE */
2035
        /* SOUND_MIXER_READ_LOUD,  same value as READ_MUTE */
2036
        IOCTL32_DEFAULT(SOUND_MIXER_READ_RECSRC),
2037
        IOCTL32_DEFAULT(SOUND_MIXER_READ_DEVMASK),
2038
        IOCTL32_DEFAULT(SOUND_MIXER_READ_RECMASK),
2039
        IOCTL32_DEFAULT(SOUND_MIXER_READ_STEREODEVS),
2040
        IOCTL32_DEFAULT(SOUND_MIXER_READ_CAPS),
2041
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_VOLUME),
2042
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_BASS),
2043
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_TREBLE),
2044
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_SYNTH),
2045
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_PCM),
2046
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_SPEAKER),
2047
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_LINE),
2048
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_MIC),
2049
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_CD),
2050
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_IMIX),
2051
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_ALTPCM),
2052
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_RECLEV),
2053
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_IGAIN),
2054
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_OGAIN),
2055
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_LINE1),
2056
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_LINE2),
2057
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_LINE3),
2058
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_DIGITAL1)),
2059
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_DIGITAL2)),
2060
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_DIGITAL3)),
2061
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_PHONEIN)),
2062
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_PHONEOUT)),
2063
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_VIDEO)),
2064
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_RADIO)),
2065
        IOCTL32_DEFAULT(MIXER_WRITE(SOUND_MIXER_MONITOR)),
2066
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_MUTE),
2067
        /* SOUND_MIXER_WRITE_ENHANCE,  same value as WRITE_MUTE */
2068
        /* SOUND_MIXER_WRITE_LOUD,  same value as WRITE_MUTE */
2069
        IOCTL32_DEFAULT(SOUND_MIXER_WRITE_RECSRC),
2070
        IOCTL32_DEFAULT(SOUND_MIXER_INFO),
2071
        IOCTL32_DEFAULT(SOUND_OLD_MIXER_INFO),
2072
        IOCTL32_DEFAULT(SOUND_MIXER_ACCESS),
2073
        IOCTL32_DEFAULT(SOUND_MIXER_PRIVATE1),
2074
        IOCTL32_DEFAULT(SOUND_MIXER_PRIVATE2),
2075
        IOCTL32_DEFAULT(SOUND_MIXER_PRIVATE3),
2076
        IOCTL32_DEFAULT(SOUND_MIXER_PRIVATE4),
2077
        IOCTL32_DEFAULT(SOUND_MIXER_PRIVATE5),
2078
        IOCTL32_DEFAULT(SOUND_MIXER_GETLEVELS),
2079
        IOCTL32_DEFAULT(SOUND_MIXER_SETLEVELS),
2080
        IOCTL32_DEFAULT(OSS_GETVERSION),
2081
 
2082
        /* And these ioctls need translation */
2083
        IOCTL32_HANDLER(SIOCGIFNAME, dev_ifname32),
2084
        IOCTL32_HANDLER(SIOCGIFCONF, dev_ifconf),
2085
        IOCTL32_HANDLER(SIOCGIFFLAGS, dev_ifsioc),
2086
        IOCTL32_HANDLER(SIOCSIFFLAGS, dev_ifsioc),
2087
        IOCTL32_HANDLER(SIOCGIFMETRIC, dev_ifsioc),
2088
        IOCTL32_HANDLER(SIOCSIFMETRIC, dev_ifsioc),
2089
        IOCTL32_HANDLER(SIOCGIFMTU, dev_ifsioc),
2090
        IOCTL32_HANDLER(SIOCSIFMTU, dev_ifsioc),
2091
        IOCTL32_HANDLER(SIOCGIFMEM, dev_ifsioc),
2092
        IOCTL32_HANDLER(SIOCSIFMEM, dev_ifsioc),
2093
        IOCTL32_HANDLER(SIOCGIFHWADDR, dev_ifsioc),
2094
        IOCTL32_HANDLER(SIOCSIFHWADDR, dev_ifsioc),
2095
        IOCTL32_HANDLER(SIOCADDMULTI, dev_ifsioc),
2096
        IOCTL32_HANDLER(SIOCDELMULTI, dev_ifsioc),
2097
        IOCTL32_HANDLER(SIOCGIFINDEX, dev_ifsioc),
2098
        IOCTL32_HANDLER(SIOCGIFMAP, dev_ifsioc),
2099
        IOCTL32_HANDLER(SIOCSIFMAP, dev_ifsioc),
2100
        IOCTL32_HANDLER(SIOCGIFADDR, dev_ifsioc),
2101
        IOCTL32_HANDLER(SIOCSIFADDR, dev_ifsioc),
2102
        IOCTL32_HANDLER(SIOCGIFBRDADDR, dev_ifsioc),
2103
        IOCTL32_HANDLER(SIOCSIFBRDADDR, dev_ifsioc),
2104
        IOCTL32_HANDLER(SIOCGIFDSTADDR, dev_ifsioc),
2105
        IOCTL32_HANDLER(SIOCSIFDSTADDR, dev_ifsioc),
2106
        IOCTL32_HANDLER(SIOCGIFNETMASK, dev_ifsioc),
2107
        IOCTL32_HANDLER(SIOCSIFNETMASK, dev_ifsioc),
2108
        IOCTL32_HANDLER(SIOCSIFPFLAGS, dev_ifsioc),
2109
        IOCTL32_HANDLER(SIOCGIFPFLAGS, dev_ifsioc),
2110
        IOCTL32_HANDLER(SIOCGPPPSTATS, dev_ifsioc),
2111
        IOCTL32_HANDLER(SIOCGPPPCSTATS, dev_ifsioc),
2112
        IOCTL32_HANDLER(SIOCGPPPVER, dev_ifsioc),
2113
        IOCTL32_HANDLER(SIOCGIFTXQLEN, dev_ifsioc),
2114
        IOCTL32_HANDLER(SIOCSIFTXQLEN, dev_ifsioc),
2115
        IOCTL32_HANDLER(SIOCADDRT, routing_ioctl),
2116
        IOCTL32_HANDLER(SIOCDELRT, routing_ioctl),
2117
        /*
2118
         * Note SIOCRTMSG is no longer, so this is safe and * the user would
2119
         * have seen just an -EINVAL anyways.
2120
         */
2121
        IOCTL32_HANDLER(SIOCRTMSG, ret_einval),
2122
        IOCTL32_HANDLER(SIOCGSTAMP, do_siocgstamp),
2123
 
2124
#endif /* CONFIG_NET */
2125
 
2126
        IOCTL32_HANDLER(BLKRAGET, w_long),
2127
        IOCTL32_HANDLER(BLKGETSIZE, w_long),
2128
        // IOCTL32_HANDLER(0x1260, broken_blkgetsize),
2129
        IOCTL32_HANDLER(BLKFRAGET, w_long),
2130
        IOCTL32_HANDLER(BLKSECTGET, w_long),
2131
        IOCTL32_HANDLER(BLKPG, blkpg_ioctl_trans),
2132
 
2133
        IOCTL32_HANDLER(EXT2_IOC32_GETFLAGS, do_ext2_ioctl),
2134
        IOCTL32_HANDLER(EXT2_IOC32_SETFLAGS, do_ext2_ioctl),
2135
        IOCTL32_HANDLER(EXT2_IOC32_GETVERSION, do_ext2_ioctl),
2136
        IOCTL32_HANDLER(EXT2_IOC32_SETVERSION, do_ext2_ioctl),
2137
 
2138
        IOCTL32_HANDLER(VIDIOCGTUNER32, do_video_ioctl),
2139
        IOCTL32_HANDLER(VIDIOCSTUNER32, do_video_ioctl),
2140
        IOCTL32_HANDLER(VIDIOCGWIN32, do_video_ioctl),
2141
        IOCTL32_HANDLER(VIDIOCSWIN32, do_video_ioctl),
2142
        IOCTL32_HANDLER(VIDIOCGFBUF32, do_video_ioctl),
2143
        IOCTL32_HANDLER(VIDIOCSFBUF32, do_video_ioctl),
2144
        IOCTL32_HANDLER(VIDIOCGFREQ32, do_video_ioctl),
2145
        IOCTL32_HANDLER(VIDIOCSFREQ32, do_video_ioctl),
2146
 
2147
#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
2148
        IOCTL32_HANDLER(VG_STATUS, do_lvm_ioctl),
2149
        IOCTL32_HANDLER(VG_CREATE_OLD, do_lvm_ioctl),
2150
        IOCTL32_HANDLER(VG_CREATE, do_lvm_ioctl),
2151
        IOCTL32_HANDLER(VG_EXTEND, do_lvm_ioctl),
2152
        IOCTL32_HANDLER(LV_CREATE, do_lvm_ioctl),
2153
        IOCTL32_HANDLER(LV_REMOVE, do_lvm_ioctl),
2154
        IOCTL32_HANDLER(LV_EXTEND, do_lvm_ioctl),
2155
        IOCTL32_HANDLER(LV_REDUCE, do_lvm_ioctl),
2156
        IOCTL32_HANDLER(LV_RENAME, do_lvm_ioctl),
2157
        IOCTL32_HANDLER(LV_STATUS_BYNAME, do_lvm_ioctl),
2158
        IOCTL32_HANDLER(LV_STATUS_BYINDEX, do_lvm_ioctl),
2159
        IOCTL32_HANDLER(LV_STATUS_BYDEV, do_lvm_ioctl),
2160
        IOCTL32_HANDLER(PV_CHANGE, do_lvm_ioctl),
2161
        IOCTL32_HANDLER(PV_STATUS, do_lvm_ioctl),
2162
#endif /* LVM */
2163
 
2164
        /* take care of sizeof(sizeof()) breakage */
2165
        /* elevator */
2166
        IOCTL32_HANDLER(BLKELVGET_32, do_blkelvget),
2167
        IOCTL32_HANDLER(BLKELVSET_32, do_blkelvset),
2168
        /* block stuff */
2169
        IOCTL32_HANDLER(BLKBSZGET_32, do_blkbszget),
2170
        IOCTL32_HANDLER(BLKBSZSET_32, do_blkbszset),
2171
        IOCTL32_HANDLER(BLKGETSIZE64_32, do_blkgetsize64),
2172
 
2173
        IOCTL32_HANDLER(HDIO_GETGEO, hdio_getgeo),      /* hdreg.h ioctls  */
2174
        IOCTL32_HANDLER(HDIO_GET_UNMASKINTR, hdio_ioctl_trans),
2175
        IOCTL32_HANDLER(HDIO_GET_MULTCOUNT, hdio_ioctl_trans),
2176
        // HDIO_OBSOLETE_IDENTITY
2177
        IOCTL32_HANDLER(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans),
2178
        IOCTL32_HANDLER(HDIO_GET_32BIT, hdio_ioctl_trans),
2179
        IOCTL32_HANDLER(HDIO_GET_NOWERR, hdio_ioctl_trans),
2180
        IOCTL32_HANDLER(HDIO_GET_DMA, hdio_ioctl_trans),
2181
        IOCTL32_HANDLER(HDIO_GET_NICE, hdio_ioctl_trans),
2182
        IOCTL32_DEFAULT(HDIO_GET_IDENTITY),
2183
        IOCTL32_DEFAULT(HDIO_DRIVE_RESET),
2184
        // HDIO_TRISTATE_HWIF                           /* not implemented */
2185
        // HDIO_DRIVE_TASK                              /* To do, need specs */
2186
        IOCTL32_DEFAULT(HDIO_DRIVE_CMD),
2187
        IOCTL32_DEFAULT(HDIO_SET_MULTCOUNT),
2188
        IOCTL32_DEFAULT(HDIO_SET_UNMASKINTR),
2189
        IOCTL32_DEFAULT(HDIO_SET_KEEPSETTINGS),
2190
        IOCTL32_DEFAULT(HDIO_SET_32BIT),
2191
        IOCTL32_DEFAULT(HDIO_SET_NOWERR),
2192
        IOCTL32_DEFAULT(HDIO_SET_DMA),
2193
        IOCTL32_DEFAULT(HDIO_SET_PIO_MODE),
2194
        IOCTL32_DEFAULT(HDIO_SCAN_HWIF),
2195
        IOCTL32_DEFAULT(HDIO_SET_NICE),
2196
        //HDIO_UNREGISTER_HWIF
2197
 
2198
        IOCTL32_DEFAULT(BLKROSET),                      /* fs.h ioctls  */
2199
        IOCTL32_DEFAULT(BLKROGET),
2200
        IOCTL32_DEFAULT(BLKRRPART),
2201
        IOCTL32_DEFAULT(BLKFLSBUF),
2202
        IOCTL32_DEFAULT(BLKRASET),
2203
        IOCTL32_DEFAULT(BLKFRASET),
2204
        IOCTL32_DEFAULT(BLKSECTSET),
2205
        IOCTL32_DEFAULT(BLKSSZGET),
2206
 
2207
        /* RAID */
2208
        IOCTL32_DEFAULT(RAID_VERSION),
2209
        IOCTL32_DEFAULT(GET_ARRAY_INFO),
2210
        IOCTL32_DEFAULT(GET_DISK_INFO),
2211
        IOCTL32_DEFAULT(PRINT_RAID_DEBUG),
2212
        IOCTL32_DEFAULT(CLEAR_ARRAY),
2213
        IOCTL32_DEFAULT(ADD_NEW_DISK),
2214
        IOCTL32_DEFAULT(HOT_REMOVE_DISK),
2215
        IOCTL32_DEFAULT(SET_ARRAY_INFO),
2216
        IOCTL32_DEFAULT(SET_DISK_INFO),
2217
        IOCTL32_DEFAULT(WRITE_RAID_INFO),
2218
        IOCTL32_DEFAULT(UNPROTECT_ARRAY),
2219
        IOCTL32_DEFAULT(PROTECT_ARRAY),
2220
        IOCTL32_DEFAULT(HOT_ADD_DISK),
2221
        IOCTL32_DEFAULT(SET_DISK_FAULTY),
2222
        IOCTL32_DEFAULT(RUN_ARRAY),
2223
        IOCTL32_DEFAULT(START_ARRAY),
2224
        IOCTL32_DEFAULT(STOP_ARRAY),
2225
        IOCTL32_DEFAULT(STOP_ARRAY_RO),
2226
        IOCTL32_DEFAULT(RESTART_ARRAY_RW),
2227
        IOCTL32_DEFAULT(RAID_AUTORUN),
2228
 
2229
        /* Big K */
2230
        IOCTL32_DEFAULT(PIO_FONT),
2231
        IOCTL32_DEFAULT(GIO_FONT),
2232
#ifdef CONFIG_VT
2233
        IOCTL32_HANDLER(GIO_FONTX, do_fontx_ioctl),
2234
        IOCTL32_HANDLER(PIO_FONTX, do_fontx_ioctl),
2235
#endif
2236
        IOCTL32_DEFAULT(KDSIGACCEPT),
2237
        IOCTL32_DEFAULT(KDGETKEYCODE),
2238
        IOCTL32_DEFAULT(KDSETKEYCODE),
2239
        IOCTL32_DEFAULT(KIOCSOUND),
2240
        IOCTL32_DEFAULT(KDMKTONE),
2241
        IOCTL32_DEFAULT(KDGKBTYPE),
2242
        IOCTL32_DEFAULT(KDSETMODE),
2243
        IOCTL32_DEFAULT(KDGETMODE),
2244
        IOCTL32_DEFAULT(KDSKBMODE),
2245
        IOCTL32_DEFAULT(KDGKBMODE),
2246
        IOCTL32_DEFAULT(KDSKBMETA),
2247
        IOCTL32_DEFAULT(KDGKBMETA),
2248
        IOCTL32_DEFAULT(KDGKBENT),
2249
        IOCTL32_DEFAULT(KDSKBENT),
2250
        IOCTL32_DEFAULT(KDGKBSENT),
2251
        IOCTL32_DEFAULT(KDSKBSENT),
2252
        IOCTL32_DEFAULT(KDGKBDIACR),
2253
        IOCTL32_DEFAULT(KDKBDREP),
2254
#ifdef CONFIG_VT
2255
        IOCTL32_HANDLER(KDFONTOP, do_kdfontop_ioctl),
2256
#endif
2257
        IOCTL32_DEFAULT(KDSKBDIACR),
2258
        IOCTL32_DEFAULT(KDGKBLED),
2259
        IOCTL32_DEFAULT(KDSKBLED),
2260
        IOCTL32_DEFAULT(KDGETLED),
2261
        IOCTL32_DEFAULT(KDSETLED),
2262
        IOCTL32_DEFAULT(GIO_SCRNMAP),
2263
        IOCTL32_DEFAULT(PIO_SCRNMAP),
2264
        IOCTL32_DEFAULT(GIO_UNISCRNMAP),
2265
        IOCTL32_DEFAULT(PIO_UNISCRNMAP),
2266
        IOCTL32_DEFAULT(PIO_FONTRESET),
2267
        IOCTL32_DEFAULT(PIO_UNIMAPCLR),
2268
 
2269
        /* Big S */
2270
        IOCTL32_DEFAULT(SCSI_IOCTL_GET_IDLUN),
2271
        IOCTL32_DEFAULT(SCSI_IOCTL_PROBE_HOST),
2272
        IOCTL32_DEFAULT(SCSI_IOCTL_GET_PCI),
2273
        IOCTL32_DEFAULT(SCSI_IOCTL_DOORLOCK),
2274
        IOCTL32_DEFAULT(SCSI_IOCTL_DOORUNLOCK),
2275
        IOCTL32_DEFAULT(SCSI_IOCTL_TEST_UNIT_READY),
2276
        IOCTL32_DEFAULT(SCSI_IOCTL_TAGGED_ENABLE),
2277
        IOCTL32_DEFAULT(SCSI_IOCTL_TAGGED_DISABLE),
2278
        IOCTL32_DEFAULT(SCSI_IOCTL_GET_BUS_NUMBER),
2279
        IOCTL32_DEFAULT(SCSI_IOCTL_SEND_COMMAND),
2280
 
2281
        /* Big T */
2282
        IOCTL32_DEFAULT(TUNSETNOCSUM),
2283
        IOCTL32_DEFAULT(TUNSETDEBUG),
2284
        IOCTL32_DEFAULT(TUNSETIFF),
2285
        IOCTL32_DEFAULT(TUNSETPERSIST),
2286
        IOCTL32_DEFAULT(TUNSETOWNER),
2287
 
2288
        /* Big V */
2289
        IOCTL32_DEFAULT(VT_SETMODE),
2290
        IOCTL32_DEFAULT(VT_GETMODE),
2291
        IOCTL32_DEFAULT(VT_GETSTATE),
2292
        IOCTL32_DEFAULT(VT_OPENQRY),
2293
        IOCTL32_DEFAULT(VT_ACTIVATE),
2294
        IOCTL32_DEFAULT(VT_WAITACTIVE),
2295
        IOCTL32_DEFAULT(VT_RELDISP),
2296
        IOCTL32_DEFAULT(VT_DISALLOCATE),
2297
        IOCTL32_DEFAULT(VT_RESIZE),
2298
        IOCTL32_DEFAULT(VT_RESIZEX),
2299
        IOCTL32_DEFAULT(VT_LOCKSWITCH),
2300
        IOCTL32_DEFAULT(VT_UNLOCKSWITCH),
2301
 
2302
#ifdef CONFIG_MD
2303
        /* status */
2304
        IOCTL32_DEFAULT(RAID_VERSION),
2305
        IOCTL32_DEFAULT(GET_ARRAY_INFO),
2306
        IOCTL32_DEFAULT(GET_DISK_INFO),
2307
        IOCTL32_DEFAULT(PRINT_RAID_DEBUG),
2308
        IOCTL32_DEFAULT(RAID_AUTORUN),
2309
 
2310
        /* configuration */
2311
        IOCTL32_DEFAULT(CLEAR_ARRAY),
2312
        IOCTL32_DEFAULT(ADD_NEW_DISK),
2313
        IOCTL32_DEFAULT(HOT_REMOVE_DISK),
2314
        IOCTL32_DEFAULT(SET_ARRAY_INFO),
2315
        IOCTL32_DEFAULT(SET_DISK_INFO),
2316
        IOCTL32_DEFAULT(WRITE_RAID_INFO),
2317
        IOCTL32_DEFAULT(UNPROTECT_ARRAY),
2318
        IOCTL32_DEFAULT(PROTECT_ARRAY),
2319
        IOCTL32_DEFAULT(HOT_ADD_DISK),
2320
        IOCTL32_DEFAULT(SET_DISK_FAULTY),
2321
 
2322
        /* usage */
2323
        IOCTL32_DEFAULT(RUN_ARRAY),
2324
        IOCTL32_DEFAULT(START_ARRAY),
2325
        IOCTL32_DEFAULT(STOP_ARRAY),
2326
        IOCTL32_DEFAULT(STOP_ARRAY_RO),
2327
        IOCTL32_DEFAULT(RESTART_ARRAY_RW),
2328
#endif /* CONFIG_MD */
2329
 
2330
#ifdef CONFIG_SIBYTE_TBPROF
2331
        IOCTL32_DEFAULT(SBPROF_ZBSTART),
2332
        IOCTL32_DEFAULT(SBPROF_ZBSTOP),
2333
        IOCTL32_DEFAULT(SBPROF_ZBWAITFULL),
2334
#endif /* CONFIG_SIBYTE_TBPROF */
2335
 
2336
        IOCTL32_DEFAULT(MTIOCTOP),                      /* mtio.h ioctls  */
2337
        IOCTL32_HANDLER(MTIOCGET32, mt_ioctl_trans),
2338
        IOCTL32_HANDLER(MTIOCPOS32, mt_ioctl_trans),
2339
        IOCTL32_HANDLER(MTIOCGETCONFIG32, mt_ioctl_trans),
2340
        IOCTL32_HANDLER(MTIOCSETCONFIG32, mt_ioctl_trans),
2341
        // MTIOCRDFTSEG
2342
        // MTIOCWRFTSEG
2343
        // MTIOCVOLINFO
2344
        // MTIOCGETSIZE
2345
        // MTIOCFTFORMAT
2346
        // MTIOCFTCMD
2347
 
2348
        IOCTL32_DEFAULT(AUTOFS_IOC_READY),              /* auto_fs.h ioctls */
2349
        IOCTL32_DEFAULT(AUTOFS_IOC_FAIL),
2350
        IOCTL32_DEFAULT(AUTOFS_IOC_CATATONIC),
2351
        IOCTL32_DEFAULT(AUTOFS_IOC_PROTOVER),
2352
        IOCTL32_HANDLER(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout),
2353
        IOCTL32_DEFAULT(AUTOFS_IOC_EXPIRE),
2354
        IOCTL32_DEFAULT(AUTOFS_IOC_EXPIRE_MULTI),
2355
 
2356
        /* DEVFS */
2357
        IOCTL32_DEFAULT(DEVFSDIOC_GET_PROTO_REV),
2358
        IOCTL32_DEFAULT(DEVFSDIOC_SET_EVENT_MASK),
2359
        IOCTL32_DEFAULT(DEVFSDIOC_RELEASE_EVENT_QUEUE),
2360
        IOCTL32_DEFAULT(DEVFSDIOC_SET_DEBUG_MASK),
2361
 
2362
        /* Raw devices */
2363
        IOCTL32_DEFAULT(RAW_SETBIND),
2364
        IOCTL32_DEFAULT(RAW_GETBIND),
2365
 
2366
#if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
2367
        /* 0xfe - lvm */
2368
        IOCTL32_DEFAULT(VG_SET_EXTENDABLE),
2369
        IOCTL32_DEFAULT(VG_STATUS_GET_COUNT),
2370
        IOCTL32_DEFAULT(VG_STATUS_GET_NAMELIST),
2371
        IOCTL32_DEFAULT(VG_REMOVE),
2372
        IOCTL32_DEFAULT(VG_RENAME),
2373
        IOCTL32_DEFAULT(VG_REDUCE),
2374
        IOCTL32_DEFAULT(PE_LOCK_UNLOCK),
2375
        IOCTL32_DEFAULT(PV_FLUSH),
2376
        IOCTL32_DEFAULT(LVM_LOCK_LVM),
2377
        IOCTL32_DEFAULT(LVM_GET_IOP_VERSION),
2378
#ifdef LVM_TOTAL_RESET
2379
        IOCTL32_DEFAULT(LVM_RESET),
2380
#endif
2381
        IOCTL32_DEFAULT(LV_SET_ACCESS),
2382
        IOCTL32_DEFAULT(LV_SET_STATUS),
2383
        IOCTL32_DEFAULT(LV_SET_ALLOCATION),
2384
        IOCTL32_DEFAULT(LE_REMAP),
2385
        IOCTL32_DEFAULT(LV_BMAP),
2386
        IOCTL32_DEFAULT(LV_SNAPSHOT_USE_RATE),
2387
#endif /* LVM */
2388
 
2389
        /* Little p (/dev/rtc, /dev/envctrl, etc.) */
2390
        IOCTL32_DEFAULT(_IOR('p', 20, int[7])), /* RTCGET */
2391
        IOCTL32_DEFAULT(_IOW('p', 21, int[7])), /* RTCSET */
2392
        IOCTL32_DEFAULT(RTC_AIE_ON),
2393
        IOCTL32_DEFAULT(RTC_AIE_OFF),
2394
        IOCTL32_DEFAULT(RTC_UIE_ON),
2395
        IOCTL32_DEFAULT(RTC_UIE_OFF),
2396
        IOCTL32_DEFAULT(RTC_PIE_ON),
2397
        IOCTL32_DEFAULT(RTC_PIE_OFF),
2398
        IOCTL32_DEFAULT(RTC_WIE_ON),
2399
        IOCTL32_DEFAULT(RTC_WIE_OFF),
2400
        IOCTL32_DEFAULT(RTC_ALM_SET),
2401
        IOCTL32_DEFAULT(RTC_ALM_READ),
2402
        IOCTL32_DEFAULT(RTC_RD_TIME),
2403
        IOCTL32_DEFAULT(RTC_SET_TIME),
2404
        IOCTL32_DEFAULT(RTC_WKALM_SET),
2405
        IOCTL32_DEFAULT(RTC_WKALM_RD),
2406
 
2407
#ifdef CONFIG_MTD_CHAR
2408
        /* Big M */
2409
        IOCTL32_DEFAULT(MEMGETINFO),
2410
        IOCTL32_DEFAULT(MEMERASE),
2411
        // IOCTL32_DEFAULT(MEMWRITEOOB32, mtd_rw_oob),
2412
        // IOCTL32_DEFAULT(MEMREADOOB32, mtd_rw_oob),
2413
        IOCTL32_DEFAULT(MEMLOCK),
2414
        IOCTL32_DEFAULT(MEMUNLOCK),
2415
        IOCTL32_DEFAULT(MEMGETREGIONCOUNT),
2416
        IOCTL32_DEFAULT(MEMGETREGIONINFO),
2417
#endif
2418
};
2419
 
2420
#define NR_IOCTL32_HANDLERS     (sizeof(ioctl32_handler_table) /        \
2421
                                 sizeof(ioctl32_handler_table[0]))
2422
 
2423
static struct ioctl32_list *ioctl32_hash_table[1024];
2424
 
2425
static inline int ioctl32_hash(unsigned int cmd)
2426
{
2427
        return ((cmd >> 6) ^ (cmd >> 4) ^ cmd) & 0x3ff;
2428
}
2429
 
2430
int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned int arg)
2431
{
2432
        int (*handler)(unsigned int, unsigned int, unsigned long, struct file * filp);
2433
        struct file *filp;
2434
        struct ioctl32_list *l;
2435
        int error;
2436
 
2437
        l = ioctl32_hash_table[ioctl32_hash(cmd)];
2438
 
2439
        error = -EBADF;
2440
 
2441
        filp = fget(fd);
2442
        if (!filp)
2443
                return error;
2444
 
2445
        if (!filp->f_op || !filp->f_op->ioctl) {
2446
                error = sys_ioctl (fd, cmd, arg);
2447
                goto out;
2448
        }
2449
 
2450
        while (l && l->handler.cmd != cmd)
2451
                l = l->next;
2452
 
2453
        if (l) {
2454
                handler = (void *)l->handler.function;
2455
                error = handler(fd, cmd, arg, filp);
2456
        } else {
2457
                error = -EINVAL;
2458
                printk("unknown ioctl: %08x\n", cmd);
2459
        }
2460
out:
2461
        fput(filp);
2462
        return error;
2463
}
2464
 
2465
static void ioctl32_insert(struct ioctl32_list *entry)
2466
{
2467
        int hash = ioctl32_hash(entry->handler.cmd);
2468
        if (!ioctl32_hash_table[hash])
2469
                ioctl32_hash_table[hash] = entry;
2470
        else {
2471
                struct ioctl32_list *l;
2472
                l = ioctl32_hash_table[hash];
2473
                while (l->next)
2474
                        l = l->next;
2475
                l->next = entry;
2476
                entry->next = 0;
2477
        }
2478
}
2479
 
2480
static int __init init_ioctl32(void)
2481
{
2482
        int i;
2483
        for (i = 0; i < NR_IOCTL32_HANDLERS; i++)
2484
                ioctl32_insert(&ioctl32_handler_table[i]);
2485
        return 0;
2486
}
2487
 
2488
__initcall(init_ioctl32);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.