* cormen book
[mascara-docs.git] / i86 / mtx-16-bit / mtx / samples / LAB5_FS / type.h
blob1d09abcb3b80abd48e69e12c9ee6b443afb83acc
1 typedef unsigned long u32;
2 typedef unsigned short u16;
3 typedef unsigned char u8;
5 typedef unsigned short ushort;
6 typedef unsigned long ulong;
8 #define NULL 0
9 #define NPROC 9
10 #define SSIZE 512
11 #define NQUEUE NPROC // at most NPROC ready queues
13 #define FREE 0 /* proc statuc */
14 #define READY 1
15 #define SLEEP 2
16 #define ZOMBIE 3
17 #define KILLED 4
18 #define BLOCK 5
20 typedef struct ext2_super_block {
21 u32 s_inodes_count; /* Inodes count */
22 u32 s_blocks_count; /* Blocks count */
23 u32 s_r_blocks_count; /* Reserved blocks count */
24 u32 s_free_blocks_count; /* Free blocks count */
25 u32 s_free_inodes_count; /* Free inodes count */
26 u32 s_first_data_block; /* First Data Block */
27 u32 s_log_block_size; /* Block size */
28 u32 s_log_frag_size; /* Fragment size */
29 u32 s_blocks_per_group; /* # Blocks per group */
30 u32 s_frags_per_group; /* # Fragments per group */
31 u32 s_inodes_per_group; /* # Inodes per group */
32 u32 s_mtime; /* Mount time */
33 u32 s_wtime; /* Write time */
34 u16 s_mnt_count; /* Mount count */
35 u16 s_max_mnt_count; /* Maximal mount count */
36 u16 s_magic; /* Magic signature */
37 u16 s_state; /* File system state */
38 u16 s_errors; /* Behaviour when detecting errors */
39 } SUPER;
41 typedef struct ext2_group_desc
43 u32 bg_block_bitmap; /* Blocks bitmap block */
44 u32 bg_inode_bitmap; /* Inodes bitmap block */
45 u32 bg_inode_table; /* Inodes table block */
46 u16 bg_free_blocks_count; /* Free blocks count */
47 u16 bg_free_inodes_count; /* Free inodes count */
48 u16 bg_used_dirs_count; /* Directories count */
49 u16 bg_pad;
50 u32 bg_reserved[3];
51 } GD;
53 typedef struct ext2_inode {
54 u16 i_mode; /* File mode */
55 u16 i_uid; /* Owner Uid */
56 u32 i_size; /* Size in bytes */
57 u32 i_atime; /* Access time */
58 u32 i_ctime; /* Creation time */
59 u32 i_mtime; /* Modification time */
60 u32 i_dtime; /* Deletion Time */
61 u16 i_gid; /* Group Id */
62 u16 i_links_count; /* Links count */
63 u32 i_blocks; /* Blocks count */
64 u32 i_flags; /* File flags */
65 u32 dummy;
66 u32 i_block[15]; /* Pointers to blocks */
67 u32 pad[7]; /* inode size MUST be 128 bytes */
68 } INODE;
70 typedef struct ext2_dir_entry_2 {
71 u32 inode; /* Inode number */
72 u16 rec_len; /* Directory entry length */
73 u8 name_len; /* Name length */
74 u8 file_type;
75 char name[255]; /* File name */
76 } DIR;
78 #define NMINODES 20
79 #define NMOUNT 4
80 #define NFD 10
81 #define NOFT 20
82 #define NPIPES 20
83 #define PSIZE 256
85 #define READ 0
86 #define WRITE 1
87 #define RW 2
88 #define APPEND 3
89 #define READ_PIPE 4
90 #define WRITE_PIPE 5
92 typedef struct Oft{
93 int mode;
94 int refCount;
95 struct Minode *inodeptr;
96 struct pipe *pipe_ptr;
97 long offset;
98 char name[32];
99 } OFT;
101 typedef struct Minode{
102 INODE INODE;
103 ushort dev, ino;
104 ushort refCount;
105 ushort dirty;
106 ushort mounted;
107 struct Mount *mountptr;
108 char name[32];
109 } MINODE;
112 typedef struct Mount{
113 int ninodes;
114 int nblocks;
115 int dev, busy;
116 struct Minode *mounted_inode;
117 char name[32];
118 char mount_name[32];
119 } MOUNT;
121 typedef struct pipe{
122 char buf[PSIZE];
123 int head, tail, hasData, hasRoom;
124 OFT *read, *write;
125 int busy;
126 }PIPE;
129 typedef struct stat {
130 ushort st_dev; /* major/minor device number */
131 ushort st_ino; /* i-node number */
132 ushort st_mode; /* file mode, protection bits, etc. */
133 ushort st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/
134 ushort st_uid; /* uid of the file's owner */
135 ushort st_gid; /* gid; TEMPORARY HACK: should be gid_t */
136 ushort st_rdev;
137 long st_size; /* file size */
138 long st_atime; /* time of last access */
139 long st_mtime; /* time of last data modification */
140 long st_ctime; /* time of last file status change */
141 } STAT;
143 typedef struct stty TTY;
145 #define SSIZE 512
147 typedef struct proc{
148 struct proc *next;
149 int *ksp;
150 int uss,usp;
152 int uid;
153 int gid;
154 int pid;
155 int ppid;
156 struct proc *parent;
158 int exitValue;
159 int status;
160 int pri; /* scheduling priority */
161 char name[16]; /* name string */
162 int event;
164 OFT *fd[NFD]; /* file descriptors */
165 MINODE *cwd; /* CWD */
166 char tty[16]; /* opened /dev/ttyXX */
167 int time;
168 int signal;
169 int sig[10];
170 struct semaphore *sem; // ptr to semaphore currently BLOCKed on
171 ushort segment, tsize, dsize, size; // memory image location & size
173 int kstack[SSIZE];
174 }PROC;
176 /* Default dir and regulsr file modes */
177 #define DIR_MODE 0040777
178 #define FILE_MODE 0100644
179 #define SUPER_MAGIC 0xEF53
180 #define SUPER_USER 0