[source navigation] [diff markup] [identifier search] [freetext search] [file search]

Oldlinux Cross Reference
Linux/fs/ioctl.c

Version: [1.0] [0.99.11] [0.99] [0.98] [0.97] [0.96a] [0.95] [0.12] [0.11] [0.01]
Architecture: [i386]

  1 /*
  2  *  linux/fs/ioctl.c
  3  *
  4  *  (C) 1991  Linus Torvalds
  5  */
  6 
  7 #include <string.h>
  8 #include <errno.h>
  9 #include <sys/stat.h>
 10 
 11 #include <linux/sched.h>
 12 
 13 extern int tty_ioctl(int dev, int cmd, int arg);
 14 
 15 typedef int (*ioctl_ptr)(int dev,int cmd,int arg);
 16 
 17 #define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr)))
 18 
 19 static ioctl_ptr ioctl_table[]={
 20         NULL,           /* nodev */
 21         NULL,           /* /dev/mem */
 22         NULL,           /* /dev/fd */
 23         NULL,           /* /dev/hd */
 24         tty_ioctl,      /* /dev/ttyx */
 25         tty_ioctl,      /* /dev/tty */
 26         NULL,           /* /dev/lp */
 27         NULL};          /* named pipes */
 28         
 29 
 30 int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 31 {       
 32         struct file * filp;
 33         int dev,mode;
 34 
 35         if (fd >= NR_OPEN || !(filp = current->filp[fd]))
 36                 return -EBADF;
 37         mode=filp->f_inode->i_mode;
 38         if (!S_ISCHR(mode) && !S_ISBLK(mode))
 39                 return -EINVAL;
 40         dev = filp->f_inode->i_zone[0];
 41         if (MAJOR(dev) >= NRDEVS)
 42                 return -ENODEV;
 43         if (!ioctl_table[MAJOR(dev)])
 44                 return -ENOTTY;
 45         return ioctl_table[MAJOR(dev)](dev,cmd,arg);
 46 }
 47 

[source navigation] [diff markup] [identifier search] [freetext search] [file search]

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.