Subversion Repositories HelenOS

Rev

Rev 2364 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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