source: mainline/uspace/lib/minix/minix.h@ 340b5690

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 340b5690 was 340b5690, checked in by Maurizio Lombardi <m.lombardi85@…>, 15 years ago

Fix inode table initialization

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 * Copyright (c) 2011 Maurizio Lombardi
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup fs
30 * @{
31 */
32
33#ifndef _MINIX_FS_H_
34#define _MINIX_FS_H_
35
36#include <sys/types.h>
37
38#define MFS_BLOCKSIZE 1024
39#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
40#define S_IFDIR 0040000
41#define S_IFMT 00170000
42
43/*The following block sizes are valid only on V3 filesystem*/
44#define MFS_MIN_BLOCKSIZE 1024
45#define MFS_MAX_BLOCKSIZE 4096
46
47#define MFS_ROOT_INO 1
48#define MFS_SUPERBLOCK 1
49#define MFS_SUPERBLOCK_SIZE 1024
50#define MFS_BOOTBLOCK_SIZE 1024
51
52#define V2_NR_DIRECT_ZONES 7
53#define V2_NR_INDIRECT_ZONES 3
54
55#define V1_NR_DIRECT_ZONES 7
56#define V1_NR_INDIRECT_ZONES 2
57
58#define V1_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs_inode))
59#define V2_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs2_inode))
60#define V3_INODES_PER_BLOCK(bs) ((bs) / sizeof(struct mfs2_inode))
61
62#define MFS_DIRSIZE 16
63#define MFSL_DIRSIZE 32
64#define MFS3_DIRSIZE 64
65
66#define MFS_MAX_NAME_LEN 14
67#define MFS_L_MAX_NAME_LEN 30
68#define MFS3_MAX_NAME_LEN 60
69
70#define MFS_MAGIC_V1 0x137F
71#define MFS_MAGIC_V1R 0x7F13
72
73#define MFS_MAGIC_V1L 0x138F
74#define MFS_MAGIC_V1LR 0x8F13
75
76#define MFS_MAGIC_V2 0x2468
77#define MFS_MAGIC_V2R 0x6824
78
79#define MFS_MAGIC_V2L 0x2478
80#define MFS_MAGIC_V2LR 0x7824
81
82#define MFS_MAGIC_V3 0x4D5A
83#define MFS_MAGIC_V3R 0x5A4D
84
85#define MFS_VALID_FS 0x0001
86#define MFS_ERROR_FS 0x0002
87
88/*MFS V1/V2 superblock data on disk*/
89struct mfs_superblock {
90 /*Total number of inodes on the device*/
91 uint16_t s_ninodes;
92 /*Total number of zones on the device*/
93 uint16_t s_nzones;
94 /*Number of inode bitmap blocks*/
95 uint16_t s_ibmap_blocks;
96 /*Number of zone bitmap blocks*/
97 uint16_t s_zbmap_blocks;
98 /*First data zone on device*/
99 uint16_t s_first_data_zone;
100 /*Base 2 logarithm of the zone to block ratio*/
101 uint16_t s_log2_zone_size;
102 /*Maximum file size expressed in bytes*/
103 uint32_t s_max_file_size;
104 /*
105 *Magic number used to recognize MinixFS
106 *and to detect on-disk endianness
107 */
108 uint16_t s_magic;
109 /*Flag used to detect FS errors*/
110 uint16_t s_state;
111 /*Total number of zones on the device (V2 only)*/
112 uint32_t s_nzones2;
113} __attribute__ ((packed));
114
115
116/*MFS V3 superblock data on disk*/
117struct mfs3_superblock {
118 /*Total number of inodes on the device*/
119 uint32_t s_ninodes;
120 uint16_t s_pad0;
121 /*Number of inode bitmap blocks*/
122 int16_t s_ibmap_blocks;
123 /*Number of zone bitmap blocks*/
124 int16_t s_zbmap_blocks;
125 /*First data zone on device*/
126 uint16_t s_first_data_zone;
127 /*Base 2 logarithm of the zone to block ratio*/
128 int16_t s_log2_zone_size;
129 int16_t s_pad1;
130 /*Maximum file size expressed in bytes*/
131 uint32_t s_max_file_size;
132 /*Total number of zones on the device*/
133 uint32_t s_nzones;
134 /*
135 *Magic number used to recognize MinixFS
136 *and to detect on-disk endianness
137 */
138 int16_t s_magic;
139 int16_t s_pad2;
140 /*Filesystem block size expressed in bytes*/
141 uint16_t s_block_size;
142 /*Filesystem disk format version*/
143 int8_t s_disk_version;
144} __attribute__ ((packed));
145
146/*MinixFS V1 inode structure as it is on disk*/
147struct mfs_inode {
148 uint16_t i_mode;
149 int16_t i_uid;
150 int32_t i_size;
151 int32_t i_mtime;
152 uint8_t i_gid;
153 uint8_t i_nlinks;
154 /*Block numbers for direct zones*/
155 uint16_t i_dzone[V1_NR_DIRECT_ZONES];
156 /*Block numbers for indirect zones*/
157 uint16_t i_izone[V1_NR_INDIRECT_ZONES];
158} __attribute__ ((packed));
159
160/*MinixFS V2 inode structure as it is on disk (also valid for V3).*/
161struct mfs2_inode {
162 uint16_t i_mode;
163 uint16_t i_nlinks;
164 int16_t i_uid;
165 uint16_t i_gid;
166 int32_t i_size;
167 int32_t i_atime;
168 int32_t i_mtime;
169 int32_t i_ctime;
170 /*Block numbers for direct zones*/
171 uint32_t i_dzone[V2_NR_DIRECT_ZONES];
172 /*Block numbers for indirect zones*/
173 uint32_t i_izone[V2_NR_INDIRECT_ZONES];
174} __attribute__ ((packed));
175
176/*MinixFS V1/V2 directory entry on-disk structure*/
177struct mfs_dentry {
178 uint16_t d_inum;
179 char d_name[0];
180};
181
182/*MinixFS V3 directory entry on-disk structure*/
183struct mfs3_dentry {
184 uint32_t d_inum;
185 char d_name[0];
186};
187
188
189#endif
190
191/**
192 * @}
193 */
194
Note: See TracBrowser for help on using the repository browser.