Subversion Repositories HelenOS

Rev

Rev 2401 | 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
 */
35
 
36
 
2364 konopa 37
/* Constants of all file system. Some of them are not used here in
38
 * current version, but will be used in later versions probably.  
39
 */
40
 
41
#ifndef _CONST_H
42
#define _CONST_H
43
 
44
/* Defined in ../share/base_const.h */
45
/*
46
#define FALSE              0    
47
#define TRUE           1
48
#define OK         0
49
*/
50
 
51
#define BLOCK_SIZE      1024    /* # bytes in a disk block */
52
#define MAJOR              8    /* major device = (dev>>MAJOR) & 0377 */
53
#define MINOR              0    /* minor device = (dev>>MINOR) & 0377 */
54
#define BYTE            0377    /* mask for 8 bits */
55
#define NO_NUM        0x8000    /* used as numerical argument to panic() */
56
 
57
/* Not used here. */
58
#define NR_SEGS            3    /* # segments per process */
59
#define T                  0    /* proc[i].mem_map[T] is for text */
60
#define D                  1    /* proc[i].mem_map[D] is for data */
61
#define S                  2    /* proc[i].mem_map[S] is for stack */
62
 
63
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
64
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
65
 
66
#define I_NOT_ALLOC     0000000 /* this inode is free */
67
 
68
#define I_TYPE          0170000 /* this field gives inode type */
69
#define I_REGULAR       0100000 /* regular file, not dir or special */
70
#define I_DIRECTORY     0040000 /* file is a directory */
71
#define I_BLOCK_SPECIAL 0060000 /* block special file */
72
#define I_CHAR_SPECIAL  0020000 /* character special file */
73
 
74
#define MAX_FILE_POS ((off_t) 037777777777)     /* largest legal file offset */
75
 
76
#define R_BIT           0000004     /* Rwx protection bit */
77
#define W_BIT           0000002     /* rWx protection bit */
78
#define X_BIT           0000001     /* rwX protection bit */
79
 
80
#define NO_BLOCK        ((block_num_t) 0)   /* absence of a block number */
81
#define NO_ZONE     ((zone_t) 0)    /* absence of a zone number */
82
#define NO_DEV      ((dev_t) 0)     /* absence of a device numb */
83
 
84
 
85
/* Tables sizes. */
86
#define V1_NR_DZONES       7    /* # direct zone numbers in a V1 inode */
87
#define V1_NR_TZONES       9    /* total # zone numbers in a V1 inode */
88
#define V2_NR_DZONES       7    /* # direct zone numbers in a V2 inode */
89
#define V2_NR_TZONES      10    /* total # zone numbers in a V2 inode */
90
 
91
#define NR_FILPS         128    /* # slots in filp table */
92
#define NR_INODES         64    /* # slots in "in core" inode table */
93
 
94
 
95
/* The type of sizeof may be (unsigned) long.  Use the following macro for
96
* taking the sizes of small objects so that there are no surprises like
97
* (small) long constants being passed to routines expecting an int.
98
*/
99
#define usizeof(t) ((unsigned) sizeof(t))
100
 
101
 
102
/* File system macros corresponding with given versions. */
103
#define SUPER_MAGIC 0x137F  /* magic number for V1 file systems */
104
#define SUPER_MAGIC2    0x138F  /* magic number for V1 file systems - 30 char names */
105
#define SUPER_V2    0x2468  /* magic number for V2 file systems */
106
#define SUPER_V2E   0x2478  /* magic number for V2 file systems - 30 char names */
107
 
108
#define TOTAL_VERSIONS  2   /* number of versions of file system */
109
 
110
#define V1      1   /* version number of V2 file systems */
111
#define V2      2   /* version number of V2 file systems */
112
 
113
#define LOOK_UP     0       /* tells search_dir to lookup string */
114
#define IS_EMPTY    3       /* tells search_dir to ret. OK or ENOTEMPTY */  
115
 
116
#define BYTE_SWAP   0   /* tells conv2/conv4 to swap bytes */
117
#define DONT_SWAP   1   /* tells conv2/conv4 not to swap bytes */
118
 
119
#define END_OF_FILE   (-104)    /* eof detected */
120
 
121
#define ROOT_INODE         1    /* inode number for root directory */
122
#define BOOT_BLOCK  ((block_num_t) 0)       /* block number of boot block */
123
#define SUPER_BLOCK ((block_num_t) 1)       /* block number of super block */
124
 
125
/* For normal version. */
126
#define DIR_ENTRY_SIZE       usizeof (direct_t)  /* # bytes/dir entry   */
127
#define NR_DIR_ENTRIES   (BLOCK_SIZE/DIR_ENTRY_SIZE)  /* # dir entries/blk   */
128
 
129
/* For extended version. */
130
#define DIR_ENTRY_SIZE_EX   usizeof (directex_t)  /* # bytes/dir entry   */
131
#define NR_DIR_ENTRIES_EX   (BLOCK_SIZE/DIR_ENTRY_SIZE_EX)  /* # dir entries/blk   */
132
 
133
#define SUPER_SIZE      usizeof (super_block_t)       /* super_block size    */
134
 
135
 
136
/* Derived sizes pertaining to the V1 file system. */
137
#define V1_ZONE_NUM_SIZE           usizeof (zone1_t)  /* # bytes in V1 zone  */
138
#define V1_INODE_SIZE             usizeof (d1_inode_t)  /* bytes in V1 dsk ino */
139
#define V1_INDIRECTS   (BLOCK_SIZE/V1_ZONE_NUM_SIZE)  /* # zones/indir block */
140
#define V1_INODES_PER_BLOCK (BLOCK_SIZE/V1_INODE_SIZE)/* # V1 dsk inodes/blk */
141
 
142
/* Derived sizes pertaining to the V2 file system. */
143
#define V2_ZONE_NUM_SIZE            usizeof (zone_t)  /* # bytes in V2 zone  */
144
#define V2_INODE_SIZE             usizeof (d2_inode_t)  /* bytes in V2 dsk ino */
145
#define V2_INDIRECTS   (BLOCK_SIZE/V2_ZONE_NUM_SIZE)  /* # zones/indir block */
146
#define V2_INODES_PER_BLOCK (BLOCK_SIZE/V2_INODE_SIZE)/* # V2 dsk inodes/blk */
147
 
148
 
149
/* Filesystem supported operations. */
150
#define FS_NEW_CONSUMER (FIRST_USER_METHOD + 50)    /* this is not file system system call */
2401 konopa 151
#define FS_DROP_CONSUMER (FS_NEW_CONSUMER + 1)      /* drops connected consument */  
2364 konopa 152
 
153
#define FS_BASE     FIRST_USER_METHOD  
154
#define FS_NOSYS    (0 + FS_BASE)
155
#define FS_OPEN     (1 + FS_BASE)
156
#define FS_SEEK     (2 + FS_BASE)
157
#define FS_READ     (3 + FS_BASE)
158
#define FS_CLOSE    (4 + FS_BASE)
159
#define FS_CHDIR    (5 + FS_BASE)
160
#define FS_STAT     (6 + FS_BASE)
161
#define FS_FSTAT    (7 + FS_BASE)
162
#define FS_DSUM     (8 + FS_BASE)
163
#define FS_READENTRY    (9 + FS_BASE)
164
 
165
#define FS_CALLS    10
166
 
167
#define FS_MIN      (FS_BASE)
168
#define FS_MAX      (FS_BASE + FS_CALLS)
169
 
170
#define FS_IN_RANGE(VAL)    ((FS_MIN <= VAL && VAL < FS_MAX)? TRUE:FALSE)
171
 
172
/* Number of attempts the FS will try to connect to each defined services. */
173
#define CON_CONN_ATTEMPTS   1000
174
#define RD_CONN_ATTEMPTS    1000
175
 
176
#endif /* _CONST_H */