source: mainline/uspace/lib/minix/minix.h@ e80b1de

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

Fix V3 superblock structure

  • 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
40/*The following block sizes are valid only on V3 filesystem*/
41#define MFS_MIN_BLOCKSIZE 1024
42#define MFS_MAX_BLOCKSIZE 4096
43
44#define MFS_ROOT_INO 1
45#define MFS_SUPERBLOCK 1
46#define MFS_SUPERBLOCK_SIZE 1024
47
48#define V2_NR_DIRECT_ZONES 7
49#define V2_NR_INDIRECT_ZONES 3
50
51#define V1_NR_DIRECT_ZONES 7
52#define V1_NR_INDIRECT_ZONES 2
53
54#define V1_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs_inode))
55#define V2_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs2_inode))
56#define V3_INODES_PER_BLOCK(bs) ((bs) / sizeof(struct mfs2_inode))
57
58#define MFS_MAX_NAME_LEN 14
59#define MFS_L_MAX_NAME_LEN 30
60#define MFS3_MAX_NAME_LEN 60
61
62#define MFS_MAGIC_V1 0x137F
63#define MFS_MAGIC_V1R 0x7F13
64
65#define MFS_MAGIC_V1L 0x138F
66#define MFS_MAGIC_V1LR 0x8F13
67
68#define MFS_MAGIC_V2 0x2468
69#define MFS_MAGIC_V2R 0x6824
70
71#define MFS_MAGIC_V2L 0x2478
72#define MFS_MAGIC_V2LR 0x7824
73
74#define MFS_MAGIC_V3 0x4D5A
75#define MFS_MAGIC_V3R 0x5A4D
76
77/*MFS V1/V2 superblock data on disk*/
78struct mfs_superblock {
79 /*Total number of inodes on the device*/
80 uint16_t s_ninodes;
81 /*Total number of zones on the device*/
82 uint16_t s_nzones;
83 /*Number of inode bitmap blocks*/
84 uint16_t s_ibmap_blocks;
85 /*Number of zone bitmap blocks*/
86 uint16_t s_zbmap_blocks;
87 /*First data zone on device*/
88 uint16_t s_first_data_zone;
89 /*Base 2 logarithm of the zone to block ratio*/
90 uint16_t s_log2_zone_size;
91 /*Maximum file size expressed in bytes*/
92 uint32_t s_max_file_size;
93 /*
94 *Magic number used to recognize MinixFS
95 *and to detect on-disk endianness
96 */
97 uint16_t s_magic;
98 /*Flag used to detect FS errors*/
99 uint16_t s_state;
100 /*Total number of zones on the device (V2 only)*/
101 uint32_t s_nzones2;
102} __attribute__ ((packed));
103
104
105/*MFS V3 superblock data on disk*/
106struct mfs3_superblock {
107 /*Total number of inodes on the device*/
108 uint32_t s_ninodes;
109 uint16_t s_pad0;
110 /*Number of inode bitmap blocks*/
111 int16_t s_ibmap_blocks;
112 /*Number of zone bitmap blocks*/
113 int16_t s_zbmap_blocks;
114 /*First data zone on device*/
115 uint16_t s_first_data_zone;
116 /*Base 2 logarithm of the zone to block ratio*/
117 int16_t s_log2_zone_size;
118 int16_t s_pad1;
119 /*Maximum file size expressed in bytes*/
120 int32_t s_max_file_size;
121 /*Total number of zones on the device*/
122 uint32_t s_nzones;
123 /*
124 *Magic number used to recognize MinixFS
125 *and to detect on-disk endianness
126 */
127 int16_t s_magic;
128 int16_t s_pad2;
129 /*Filesystem block size expressed in bytes*/
130 uint16_t s_block_size;
131 /*Filesystem disk format version*/
132 int8_t s_disk_version;
133} __attribute__ ((packed));
134
135/*MinixFS V1 inode structure as it is on disk*/
136struct mfs_inode {
137 uint16_t i_mode;
138 int16_t i_uid;
139 int32_t i_size;
140 int32_t i_mtime;
141 uint8_t i_gid;
142 uint8_t i_nlinks;
143 /*Block numbers for direct zones*/
144 uint16_t i_dzone[V1_NR_DIRECT_ZONES];
145 /*Block numbers for indirect zones*/
146 uint16_t i_izone[V1_NR_INDIRECT_ZONES];
147} __attribute__ ((packed));
148
149/*MinixFS V2 inode structure as it is on disk (also valid for V3).*/
150struct mfs2_inode {
151 uint16_t i_mode;
152 uint16_t i_nlinks;
153 int16_t i_uid;
154 uint16_t i_gid;
155 int32_t i_size;
156 int32_t i_atime;
157 int32_t i_mtime;
158 int32_t i_ctime;
159 /*Block numbers for direct zones*/
160 uint32_t i_dzone[V2_NR_DIRECT_ZONES];
161 /*Block numbers for indirect zones*/
162 uint32_t i_izone[V2_NR_INDIRECT_ZONES];
163} __attribute__ ((packed));
164
165/*MinixFS V1/V2 directory entry on-disk structure*/
166struct mfs_dentry {
167 uint16_t d_inum;
168 char d_name[MFS_MAX_NAME_LEN];
169} __attribute__ ((packed));
170
171/*MinixFS V1/V2 with 30-char filenames (Linux variant)*/
172struct mfs_l_dentry {
173 uint16_t d_inum;
174 char d_name[MFS_L_MAX_NAME_LEN];
175} __attribute__ ((packed));
176
177/*MinixFS V3 directory entry on-disk structure*/
178struct mfs3_dentry {
179 uint32_t d_inum;
180 char d_name[MFS3_MAX_NAME_LEN];
181} __attribute__ ((packed));
182
183
184#endif
185
186/**
187 * @}
188 */
189
Note: See TracBrowser for help on using the repository browser.