1 /* 2 * linux/fs/ioctl.c 3 * 4 * (C) 1991 Linus Torvalds 5 */ 6 7 #include <linux/string.h> 8 #include <errno.h> 9 #include <sys/stat.h> 10 11 #include <linux/sched.h> 12 13 int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) /* */ 14 { 15 struct file * filp; 16 17 if (fd >= NR_OPEN || !(filp = current->filp[fd])) 18 return -EBADF; 19 if (filp->f_op && filp->f_op->ioctl) 20 return filp->f_op->ioctl(filp->f_inode, filp, cmd,arg); 21 return -EINVAL; 22 }