116
|
1 typedef struct file {
|
|
2 enum { FD_NONE, FD_PIPE, FD_INODE } type;
|
|
3 int ref; // reference count
|
|
4 char readable;
|
|
5 char writable;
|
|
6 struct pipe *pipe;
|
|
7 struct inode *ip;
|
|
8 uint off;
|
|
9 } file;
|
0
|
10 // in-memory copy of an inode
|
|
11 struct inode {
|
|
12 uint dev; // Device number
|
|
13 uint inum; // Inode number
|
|
14 int ref; // Reference count
|
|
15 int flags; // I_BUSY, I_VALID
|
|
16
|
|
17 short type; // copy of disk inode
|
|
18 short major;
|
|
19 short minor;
|
|
20 short nlink;
|
|
21 uint size;
|
|
22 uint addrs[NDIRECT+1];
|
|
23 };
|
|
24 #define I_BUSY 0x1
|
|
25 #define I_VALID 0x2
|
|
26
|
|
27 // table mapping major device number to
|
|
28 // device functions
|
|
29 struct devsw {
|
|
30 int (*read) (struct inode*, char*, int);
|
|
31 int (*write)(struct inode*, char*, int);
|
|
32 };
|
|
33
|
27
|
34 struct cbc_devsw {
|
33
|
35 __code (*read) (struct inode*, char*, int, __code (*)(int));
|
29
|
36 //__code (*write)(struct inode*, char*, int, __code (*)(int));
|
27
|
37 };
|
|
38
|
0
|
39 extern struct devsw devsw[];
|
27
|
40 extern struct cbc_devsw cbc_devsw[];
|
0
|
41
|
|
42 #define CONSOLE 1
|