source: mainline/uspace/lib/minix/minix.h@ 3c616f6

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

Fix directory entries structures

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