|
|
1.1 root 1: #include <string.h>
2: #include <errno.h>
3: #include <sys/stat.h>
4:
5: #include <linux/sched.h>
6:
7: extern int tty_ioctl(int dev, int cmd, int arg);
8:
9: typedef int (*ioctl_ptr)(int dev,int cmd,int arg);
10:
11: #define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr)))
12:
13: static ioctl_ptr ioctl_table[]={
14: NULL, /* nodev */
15: NULL, /* /dev/mem */
16: NULL, /* /dev/fd */
17: NULL, /* /dev/hd */
18: tty_ioctl, /* /dev/ttyx */
19: tty_ioctl, /* /dev/tty */
20: NULL, /* /dev/lp */
21: NULL}; /* named pipes */
22:
23:
24: int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
25: {
26: struct file * filp;
27: int dev,mode;
28:
29: if (fd >= NR_OPEN || !(filp = current->filp[fd]))
30: return -EBADF;
31: mode=filp->f_inode->i_mode;
32: if (!S_ISCHR(mode) && !S_ISBLK(mode))
33: return -EINVAL;
34: dev = filp->f_inode->i_zone[0];
35: if (MAJOR(dev) >= NRDEVS)
36: panic("unknown device for ioctl");
37: if (!ioctl_table[MAJOR(dev)])
38: return -ENOTTY;
39: return ioctl_table[MAJOR(dev)](dev,cmd,arg);
40: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.