Import 2.1.42pre1
[davej-history.git] / arch / sparc64 / kernel / ioctl32.c
blob3db6fa94596fd326c819e6b8af57fd6da4a82724
1 /* $Id: ioctl32.c,v 1.3 1997/05/27 19:30:13 jj Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 * These routines maintain argument size conversion between 32bit and 64bit
7 * ioctls.
8 */
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <linux/smp.h>
13 #include <linux/smp_lock.h>
14 #include <linux/ioctl.h>
16 #include <asm/types.h>
17 #include <asm/uaccess.h>
19 /* As gcc will warn about casting u32 to some ptr, we have to cast it to unsigned long first, and that's what is A() for.
20 * You just do (void *)A(x), instead of having to type (void *)((unsigned long)x) or instead of just (void *)x, which will
21 * produce warnings */
22 #define A(x) ((unsigned long)x)
24 extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
26 asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, u32 arg)
28 struct file * filp;
29 int error = -EBADF;
31 lock_kernel();
32 if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
33 goto out;
34 if (!filp->f_op || !filp->f_op->ioctl) {
35 error = sys_ioctl (fd, cmd, (unsigned long)arg);
36 goto out;
38 error = 0;
39 switch (cmd) {
40 default:
41 error = sys_ioctl (fd, cmd, (unsigned long)arg);
42 goto out;
44 out:
45 if (error == -EINVAL) {
46 printk ("sys32_ioctl on %016lx's %08x returns EINVAL\n", filp->f_op ? (long)filp->f_op->ioctl : 0UL, cmd);
48 unlock_kernel();
49 return error;