1 /*
2 * linux/fs/ext/chrdev.c
3 *
4 * Copyright (C) 1992 Remy Card (card@masi.ibp.fr)
5 *
6 * from
7 *
8 * linux/fs/minix/chrdev.c
9 *
10 * Copyright (C) 1991, 1992 Linus Torvalds
11 */
12
13 #include <linux/sched.h>
14 #include <linux/ext_fs.h>
15 #include <linux/tty.h>
16 #include <linux/stat.h>
17 #include <linux/fcntl.h>
18 #include <linux/errno.h>
19
20 /*
21 * Called every time an ext character special file is opened
22 */
23 static int chrdev_open(struct inode * inode, struct file * filp)
/* ![[previous]](../icons/n_left.png)
![[next]](../icons/n_right.png)
![[first]](../icons/n_first.png)
![[last]](../icons/n_last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
24 {
25 int i;
26
27 i = MAJOR(inode->i_rdev);
28 if (i < MAX_CHRDEV) {
29 filp->f_op = chrdev_fops[i];
30 if (filp->f_op && filp->f_op->open)
31 return filp->f_op->open(inode,filp);
32 }
33 return 0;
34 }
35
36 /*
37 * Dummy default file-operations: the only thing this does
38 * is contain the open that then fills in the correct operations
39 * depending on the special file...
40 */
41 static struct file_operations def_chr_fops = {
42 NULL, /* lseek */
43 NULL, /* read */
44 NULL, /* write */
45 NULL, /* readdir */
46 NULL, /* select */
47 NULL, /* ioctl */
48 chrdev_open, /* open */
49 NULL, /* release */
50 };
51
52 struct inode_operations ext_chrdev_inode_operations = {
53 &def_chr_fops, /* default file operations */
54 NULL, /* create */
55 NULL, /* lookup */
56 NULL, /* link */
57 NULL, /* unlink */
58 NULL, /* symlink */
59 NULL, /* mkdir */
60 NULL, /* rmdir */
61 NULL, /* mknod */
62 NULL, /* rename */
63 NULL, /* readlink */
64 NULL, /* follow_link */
65 ext_bmap, /* bmap */
66 ext_truncate /* truncate */
67 };
68