Rev 2404 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2404 | konopa | 1 | /* |
2 | * Copyright (c) 1987,1997, Prentice Hall |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use of the MINIX operating system in source and |
||
6 | * binary forms, with or without modification, are permitted provided |
||
7 | * that the following conditions are met: |
||
8 | |||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | |||
12 | * - Redistributions in binary form must reproduce the above |
||
13 | * copyright notice, this list of conditions and the following |
||
14 | * disclaimer in the documentation and/or other materials provided |
||
15 | * with the distribution. |
||
16 | |||
17 | * - Neither the name of Prentice Hall nor the names of the software |
||
18 | * authors or contributors may be used to endorse or promote |
||
19 | * products derived from this software without specific prior |
||
20 | * written permission. |
||
21 | |||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
||
23 | * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||
24 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||
25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
26 | * IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
||
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||
30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
||
31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
||
32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||
33 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
34 | */ |
||
2435 | jelen | 35 | |
36 | /** @addtogroup FileSystemImpl |
||
37 | * @{ |
||
38 | */ |
||
2404 | konopa | 39 | |
2435 | jelen | 40 | /** |
41 | * @file const.h |
||
42 | * @brief Constants of all file system. Some of them are not used here in |
||
43 | * current version, but will be used in later versions probably. |
||
2364 | konopa | 44 | */ |
45 | |||
46 | #ifndef _CONST_H |
||
47 | #define _CONST_H |
||
48 | |||
2435 | jelen | 49 | #define BLOCK_SIZE 1024 /**< # bytes in a disk block */ |
50 | #define MAJOR 8 /**< major device = (dev>>MAJOR) & 0377 */ |
||
51 | #define MINOR 0 /**< minor device = (dev>>MINOR) & 0377 */ |
||
52 | #define BYTE 0377 /**< mask for 8 bits */ |
||
53 | #define NO_NUM 0x8000 /**< used as numerical argument to panic() */ |
||
2364 | konopa | 54 | |
55 | /* Not used here. */ |
||
2435 | jelen | 56 | #define NR_SEGS 3 /**< # segments per process */ |
57 | #define T 0 /**< proc[i].mem_map[T] is for text */ |
||
58 | #define D 1 /**< proc[i].mem_map[D] is for data */ |
||
59 | #define S 2 /**< proc[i].mem_map[S] is for stack */ |
||
2364 | konopa | 60 | |
61 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
||
62 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
||
63 | |||
2435 | jelen | 64 | #define I_NOT_ALLOC 0000000 /**< this inode is free */ |
2364 | konopa | 65 | |
2435 | jelen | 66 | #define I_TYPE 0170000 /**< this field gives inode type */ |
67 | #define I_REGULAR 0100000 /**< regular file, not dir or special */ |
||
68 | #define I_DIRECTORY 0040000 /**< file is a directory */ |
||
69 | #define I_BLOCK_SPECIAL 0060000 /**< block special file */ |
||
70 | #define I_CHAR_SPECIAL 0020000 /**< character special file */ |
||
2364 | konopa | 71 | |
2435 | jelen | 72 | #define MAX_FILE_POS ((off_t) 037777777777) /**< largest legal file offset */ |
2364 | konopa | 73 | |
2435 | jelen | 74 | #define R_BIT 0000004 /**< Rwx protection bit */ |
75 | #define W_BIT 0000002 /**< rWx protection bit */ |
||
76 | #define X_BIT 0000001 /**< rwX protection bit */ |
||
2364 | konopa | 77 | |
2435 | jelen | 78 | #define NO_BLOCK ((block_num_t) 0) /**< absence of a block number */ |
79 | #define NO_ZONE ((zone_t) 0) /**< absence of a zone number */ |
||
80 | #define NO_DEV ((dev_t) 0) /**< absence of a device numb */ |
||
2364 | konopa | 81 | |
82 | |||
83 | /* Tables sizes. */ |
||
2435 | jelen | 84 | #define V1_NR_DZONES 7 /**< # direct zone numbers in a V1 inode */ |
85 | #define V1_NR_TZONES 9 /**< total # zone numbers in a V1 inode */ |
||
86 | #define V2_NR_DZONES 7 /**< # direct zone numbers in a V2 inode */ |
||
87 | #define V2_NR_TZONES 10 /**< total # zone numbers in a V2 inode */ |
||
2364 | konopa | 88 | |
2435 | jelen | 89 | #define NR_FILPS 128 /**< # slots in filp table */ |
90 | #define NR_INODES 64 /**< # slots in "in core" inode table */ |
||
2364 | konopa | 91 | |
92 | |||
2435 | jelen | 93 | /** |
94 | * The type of sizeof may be (unsigned) long. Use the following macro for |
||
2364 | konopa | 95 | * taking the sizes of small objects so that there are no surprises like |
96 | * (small) long constants being passed to routines expecting an int. |
||
97 | */ |
||
98 | #define usizeof(t) ((unsigned) sizeof(t)) |
||
99 | |||
100 | |||
101 | /* File system macros corresponding with given versions. */ |
||
2435 | jelen | 102 | #define SUPER_MAGIC 0x137F /**< magic number for V1 file systems */ |
103 | #define SUPER_MAGIC2 0x138F /**< magic number for V1 file systems - 30 char names */ |
||
104 | #define SUPER_V2 0x2468 /**< magic number for V2 file systems */ |
||
105 | #define SUPER_V2E 0x2478 /**< magic number for V2 file systems - 30 char names */ |
||
2364 | konopa | 106 | |
2435 | jelen | 107 | #define TOTAL_VERSIONS 2 /**< number of versions of file system */ |
2364 | konopa | 108 | |
2435 | jelen | 109 | #define V1 1 /**< version number of V2 file systems */ |
110 | #define V2 2 /**< version number of V2 file systems */ |
||
2364 | konopa | 111 | |
2435 | jelen | 112 | #define LOOK_UP 0 /**< tells search_dir to lookup string */ |
113 | #define IS_EMPTY 3 /**< tells search_dir to ret. OK or ENOTEMPTY */ |
||
2364 | konopa | 114 | |
2435 | jelen | 115 | #define BYTE_SWAP 0 /**< tells conv2/conv4 to swap bytes */ |
116 | #define DONT_SWAP 1 /**< tells conv2/conv4 not to swap bytes */ |
||
2364 | konopa | 117 | |
2435 | jelen | 118 | #define END_OF_FILE (-104) /**< eof detected */ |
2364 | konopa | 119 | |
2435 | jelen | 120 | #define ROOT_INODE 1 /**< inode number for root directory */ |
121 | #define BOOT_BLOCK ((block_num_t) 0) /**< block number of boot block */ |
||
122 | #define SUPER_BLOCK ((block_num_t) 1) /**< block number of super block */ |
||
2364 | konopa | 123 | |
124 | /* For normal version. */ |
||
2435 | jelen | 125 | #define DIR_ENTRY_SIZE usizeof (direct_t) /**< # bytes/dir entry */ |
126 | #define NR_DIR_ENTRIES (BLOCK_SIZE/DIR_ENTRY_SIZE) /**< # dir entries/blk */ |
||
2364 | konopa | 127 | |
128 | /* For extended version. */ |
||
2435 | jelen | 129 | #define DIR_ENTRY_SIZE_EX usizeof (directex_t) /**< # bytes/dir entry */ |
130 | #define NR_DIR_ENTRIES_EX (BLOCK_SIZE/DIR_ENTRY_SIZE_EX) /**< # dir entries/blk */ |
||
2364 | konopa | 131 | |
2435 | jelen | 132 | #define SUPER_SIZE usizeof (super_block_t) /**< super_block size */ |
2364 | konopa | 133 | |
134 | |||
135 | /* Derived sizes pertaining to the V1 file system. */ |
||
2435 | jelen | 136 | #define V1_ZONE_NUM_SIZE usizeof (zone1_t) /**< # bytes in V1 zone */ |
137 | #define V1_INODE_SIZE usizeof (d1_inode_t) /**< bytes in V1 dsk ino */ |
||
138 | #define V1_INDIRECTS (BLOCK_SIZE/V1_ZONE_NUM_SIZE) /**< # zones/indir block */ |
||
139 | #define V1_INODES_PER_BLOCK (BLOCK_SIZE/V1_INODE_SIZE)/**< # V1 dsk inodes/blk */ |
||
2364 | konopa | 140 | |
141 | /* Derived sizes pertaining to the V2 file system. */ |
||
2435 | jelen | 142 | #define V2_ZONE_NUM_SIZE usizeof (zone_t) /**< # bytes in V2 zone */ |
143 | #define V2_INODE_SIZE usizeof (d2_inode_t) /**< bytes in V2 dsk ino */ |
||
144 | #define V2_INDIRECTS (BLOCK_SIZE/V2_ZONE_NUM_SIZE) /**< # zones/indir block */ |
||
145 | #define V2_INODES_PER_BLOCK (BLOCK_SIZE/V2_INODE_SIZE)/**< # V2 dsk inodes/blk */ |
||
2364 | konopa | 146 | |
147 | |||
148 | /* Filesystem supported operations. */ |
||
2435 | jelen | 149 | #define FS_NEW_CONSUMER (FIRST_USER_METHOD + 50) /**< this is not file system system call */ |
150 | #define FS_DROP_CONSUMER (FS_NEW_CONSUMER + 1) /**< drops connected consument */ |
||
2364 | konopa | 151 | |
2435 | jelen | 152 | #define FS_BASE FIRST_USER_METHOD /**> Index of the first FS method */ |
153 | #define FS_NOSYS (0 + FS_BASE) /**> */ |
||
154 | #define FS_OPEN (1 + FS_BASE) /**> Open file method */ |
||
155 | #define FS_SEEK (2 + FS_BASE) /**> Seek in file method */ |
||
156 | #define FS_READ (3 + FS_BASE) /**> File read method */ |
||
157 | #define FS_CLOSE (4 + FS_BASE) /**> File close method */ |
||
158 | #define FS_CHDIR (5 + FS_BASE) /**> Change current directory method */ |
||
159 | #define FS_STAT (6 + FS_BASE) /**> Stat method */ |
||
160 | #define FS_FSTAT (7 + FS_BASE) /**> File stat method */ |
||
161 | #define FS_DSUM (8 + FS_BASE) /**> Directory entry count method */ |
||
162 | #define FS_READENTRY (9 + FS_BASE) /**> Read directory entry method */ |
||
2364 | konopa | 163 | |
2435 | jelen | 164 | #define FS_CALLS 10 /**> The number of File system calls */ |
2364 | konopa | 165 | |
166 | #define FS_MIN (FS_BASE) |
||
167 | #define FS_MAX (FS_BASE + FS_CALLS) |
||
168 | |||
169 | #define FS_IN_RANGE(VAL) ((FS_MIN <= VAL && VAL < FS_MAX)? TRUE:FALSE) |
||
170 | |||
2435 | jelen | 171 | #define CON_CONN_ATTEMPTS 1000 /**< Number of attempts the FS will try to connect to the console services. */ |
172 | #define RD_CONN_ATTEMPTS 1000 /**< Number of attempts the FS will try to connect to the RAM disk services. */ |
||
2364 | konopa | 173 | |
174 | #endif /* _CONST_H */ |
||
2435 | jelen | 175 | |
176 | /** |
||
177 | * } |
||
178 | */ |
||
179 |