ReactOS
0.4.16-dev-306-g647d351
ext2.h
Go to the documentation of this file.
1
/*
2
* FreeLoader
3
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
*/
19
20
#pragma once
21
22
/*
23
* grub/fs/ext2.c
24
*
25
* GRUB -- GRand Unified Bootloader
26
* Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc.
27
*
28
* This program is free software; you can redistribute it and/or modify
29
* it under the terms of the GNU General Public License as published by
30
* the Free Software Foundation; either version 2 of the License, or
31
* (at your option) any later version.
32
*
33
* This program is distributed in the hope that it will be useful,
34
* but WITHOUT ANY WARRANTY; without even the implied warranty of
35
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36
* GNU General Public License for more details.
37
*
38
* You should have received a copy of the GNU General Public License
39
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
40
*/
41
42
/* Magic value used to identify an ext2 filesystem. */
43
#define EXT2_MAGIC 0xEF53
44
/* Amount of indirect blocks in an inode. */
45
#define INDIRECT_BLOCKS 12
46
/* Maximum length of a pathname. */
47
#define EXT2_PATH_MAX 4096
48
/* Maximum nesting of symlinks, used to prevent a loop. */
49
#define EXT2_MAX_SYMLINKCNT 8
50
51
/* The good old revision and the default inode size. */
52
#define EXT2_GOOD_OLD_REVISION 0
53
#define EXT2_DYNAMIC_REVISION 1
54
#define EXT2_GOOD_OLD_INODE_SIZE 128
55
56
/* Filetype used in directory entry. */
57
#define FILETYPE_UNKNOWN 0
58
#define FILETYPE_REG 1
59
#define FILETYPE_DIRECTORY 2
60
#define FILETYPE_SYMLINK 7
61
62
/* Filetype information as used in inodes. */
63
#define FILETYPE_INO_MASK 0170000
64
#define FILETYPE_INO_REG 0100000
65
#define FILETYPE_INO_DIRECTORY 0040000
66
#define FILETYPE_INO_SYMLINK 0120000
67
68
/* The ext2 superblock. */
69
struct
ext2_sblock
70
{
71
ULONG
total_inodes
;
72
ULONG
total_blocks
;
73
ULONG
reserved_blocks
;
74
ULONG
free_blocks
;
75
ULONG
free_inodes
;
76
ULONG
first_data_block
;
77
ULONG
log2_block_size
;
78
LONG
log2_fragment_size
;
79
ULONG
blocks_per_group
;
80
ULONG
fragments_per_group
;
81
ULONG
inodes_per_group
;
82
ULONG
mtime
;
83
ULONG
utime
;
84
USHORT
mnt_count
;
85
USHORT
max_mnt_count
;
86
USHORT
magic
;
87
USHORT
fs_state
;
88
USHORT
error_handling
;
89
USHORT
minor_revision_level
;
90
ULONG
lastcheck
;
91
ULONG
checkinterval
;
92
ULONG
creator_os
;
93
ULONG
revision_level
;
94
USHORT
uid_reserved
;
95
USHORT
gid_reserved
;
96
ULONG
first_inode
;
97
USHORT
inode_size
;
98
USHORT
block_group_number
;
99
ULONG
feature_compatibility
;
100
ULONG
feature_incompat
;
101
ULONG
feature_ro_compat
;
102
ULONG
unique_id
[4];
103
char
volume_name
[16];
104
char
last_mounted_on
[64];
105
ULONG
compression_info
;
106
ULONG
padding
[77];
107
};
108
109
/* The ext2 blockgroup. */
110
struct
ext2_block_group
111
{
112
ULONG
block_id
;
113
ULONG
inode_id
;
114
ULONG
inode_table_id
;
115
USHORT
free_blocks
;
116
USHORT
free_inodes
;
117
USHORT
used_dirs
;
118
USHORT
pad
;
119
ULONG
reserved
[3];
120
};
121
122
/* The ext2 inode. */
123
struct
ext2_inode
124
{
125
USHORT
mode
;
126
USHORT
uid
;
127
ULONG
size
;
128
ULONG
atime
;
129
ULONG
ctime
;
130
ULONG
mtime
;
131
ULONG
dtime
;
132
USHORT
gid
;
133
USHORT
nlinks
;
134
ULONG
blockcnt
;
/* Blocks of 512 bytes!! */
135
ULONG
flags
;
136
ULONG
osd1
;
137
union
138
{
139
struct
datablocks
140
{
141
ULONG
dir_blocks[
INDIRECT_BLOCKS
];
142
ULONG
indir_block
;
143
ULONG
double_indir_block
;
144
ULONG
tripple_indir_block
;
145
}
blocks
;
146
char
symlink
[60];
147
};
148
ULONG
version
;
149
ULONG
acl
;
150
ULONG
dir_acl
;
151
ULONG
fragment_addr
;
152
ULONG
osd2
[3];
153
};
154
155
/* The header of an ext2 directory entry. */
156
#define EXT2_NAME_LEN 255
157
158
struct
ext2_dirent
159
{
160
ULONG
inode
;
161
USHORT
direntlen
;
162
UCHAR
namelen
;
163
UCHAR
filetype
;
164
CHAR
name
[
EXT2_NAME_LEN
];
165
};
166
167
/*
168
* End of code from grub/fs/ext2.c
169
*/
170
171
typedef
struct
ext2_sblock
EXT2_SUPER_BLOCK
, *
PEXT2_SUPER_BLOCK
;
172
typedef
struct
ext2_inode
EXT2_INODE
, *
PEXT2_INODE
;
173
typedef
struct
ext2_block_group
EXT2_GROUP_DESC
, *
PEXT2_GROUP_DESC
;
174
typedef
struct
ext2_dirent
EXT2_DIR_ENTRY
, *
PEXT2_DIR_ENTRY
;
175
176
/* Special inode numbers. */
177
#define EXT2_ROOT_INO 2
178
179
/* Feature set definitions. */
180
#define EXT3_FEATURE_INCOMPAT_SUPP 0x0002
181
182
/* Log2 size of ext2 block in bytes. */
183
#define LOG2_BLOCK_SIZE(sb) (sb->log2_block_size + 10)
184
185
/* The size of an ext2 block in bytes. */
186
#define EXT2_BLOCK_SIZE(sb) (((SIZE_T)1) << LOG2_BLOCK_SIZE(sb))
187
188
/* The revision level. */
189
#define EXT2_REVISION(sb) (sb->revision_level)
190
191
/* The inode size. */
192
#define EXT2_INODE_SIZE(sb) (EXT2_REVISION(sb) == EXT2_GOOD_OLD_REVISION \
193
? EXT2_GOOD_OLD_INODE_SIZE \
194
: sb->inode_size)
195
196
#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(struct ext2_block_group))
197
198
// EXT2_INODE::mode values
199
#define EXT2_S_IRWXO 0x0007
// Other mask
200
#define EXT2_S_IXOTH 0x0001
// ---------x execute
201
#define EXT2_S_IWOTH 0x0002
// --------w- write
202
#define EXT2_S_IROTH 0x0004
// -------r-- read
203
204
#define EXT2_S_IRWXG 0x0038
// Group mask
205
#define EXT2_S_IXGRP 0x0008
// ------x--- execute
206
#define EXT2_S_IWGRP 0x0010
// -----w---- write
207
#define EXT2_S_IRGRP 0x0020
// ----r----- read
208
209
#define EXT2_S_IRWXU 0x01C0
// User mask
210
#define EXT2_S_IXUSR 0x0040
// ---x------ execute
211
#define EXT2_S_IWUSR 0x0080
// --w------- write
212
#define EXT2_S_IRUSR 0x0100
// -r-------- read
213
214
#define EXT2_S_ISVTX 0x0200
// Sticky bit
215
#define EXT2_S_ISGID 0x0400
// SGID
216
#define EXT2_S_ISUID 0x0800
// SUID
217
218
#define EXT2_S_IFMT 0xF000
// Format mask
219
#define EXT2_S_IFIFO 0x1000
// FIFO buffer
220
#define EXT2_S_IFCHR 0x2000
// Character device
221
#define EXT2_S_IFDIR 0x4000
// Directory
222
#define EXT2_S_IFBLK 0x6000
// Block device
223
#define EXT2_S_IFREG 0x8000
// Regular file
224
#define EXT2_S_IFLNK 0xA000
// Symbolic link
225
#define EXT2_S_IFSOCK 0xC000
// Socket
226
227
#define FAST_SYMLINK_MAX_NAME_SIZE 60
228
229
typedef
struct
_EXT2_VOLUME_INFO
*
PEXT2_VOLUME_INFO
;
230
231
typedef
struct
232
{
233
ULONGLONG
FileSize
;
// File size
234
ULONGLONG
FilePointer
;
// File pointer
235
ULONG
*
FileBlockList
;
// File block list
236
EXT2_INODE
Inode
;
// File's inode
237
PEXT2_VOLUME_INFO
Volume
;
238
}
EXT2_FILE_INFO
, *
PEXT2_FILE_INFO
;
239
240
const
DEVVTBL
*
Ext2Mount
(
ULONG
DeviceId
);
EXT2_NAME_LEN
#define EXT2_NAME_LEN
Definition:
ext2.h:156
PEXT2_INODE
struct ext2_inode * PEXT2_INODE
Definition:
ext2.h:172
PEXT2_VOLUME_INFO
struct _EXT2_VOLUME_INFO * PEXT2_VOLUME_INFO
Definition:
ext2.h:229
PEXT2_DIR_ENTRY
struct ext2_dirent * PEXT2_DIR_ENTRY
Definition:
ext2.h:174
PEXT2_FILE_INFO
struct EXT2_FILE_INFO * PEXT2_FILE_INFO
PEXT2_GROUP_DESC
struct ext2_block_group * PEXT2_GROUP_DESC
Definition:
ext2.h:173
INDIRECT_BLOCKS
#define INDIRECT_BLOCKS
Definition:
ext2.h:45
PEXT2_SUPER_BLOCK
struct ext2_sblock * PEXT2_SUPER_BLOCK
Definition:
ext2.h:171
Ext2Mount
const DEVVTBL * Ext2Mount(ULONG DeviceId)
Definition:
ext2.c:1298
LONG
long LONG
Definition:
pedump.c:60
USHORT
unsigned short USHORT
Definition:
pedump.c:61
EXT2_FILE_INFO
Definition:
ext2.h:232
EXT2_FILE_INFO::FileBlockList
ULONG * FileBlockList
Definition:
ext2.h:235
EXT2_FILE_INFO::Volume
PEXT2_VOLUME_INFO Volume
Definition:
ext2.h:237
EXT2_FILE_INFO::FilePointer
ULONGLONG FilePointer
Definition:
ext2.h:234
EXT2_FILE_INFO::FileSize
ULONGLONG FileSize
Definition:
ext2.h:233
EXT2_FILE_INFO::Inode
EXT2_INODE Inode
Definition:
ext2.h:236
_EXT2_VOLUME_INFO
Definition:
ext2.c:47
_EXT2_VOLUME_INFO::DeviceId
ULONG DeviceId
Definition:
ext2.c:61
ext2_block_group
Definition:
ext2.h:111
ext2_block_group::inode_table_id
ULONG inode_table_id
Definition:
ext2.h:114
ext2_block_group::free_inodes
USHORT free_inodes
Definition:
ext2.h:116
ext2_block_group::used_dirs
USHORT used_dirs
Definition:
ext2.h:117
ext2_block_group::inode_id
ULONG inode_id
Definition:
ext2.h:113
ext2_block_group::reserved
ULONG reserved[3]
Definition:
ext2.h:119
ext2_block_group::free_blocks
USHORT free_blocks
Definition:
ext2.h:115
ext2_block_group::block_id
ULONG block_id
Definition:
ext2.h:112
ext2_block_group::pad
USHORT pad
Definition:
ext2.h:118
ext2_dirent
Definition:
ext2.h:159
ext2_dirent::namelen
UCHAR namelen
Definition:
ext2.h:162
ext2_dirent::inode
ULONG inode
Definition:
ext2.h:160
ext2_dirent::filetype
UCHAR filetype
Definition:
ext2.h:163
ext2_dirent::direntlen
USHORT direntlen
Definition:
ext2.h:161
ext2_inode
Definition:
ext2.h:124
ext2_inode::osd2
ULONG osd2[3]
Definition:
ext2.h:152
ext2_inode::ctime
ULONG ctime
Definition:
ext2.h:129
ext2_inode::size
ULONG size
Definition:
ext2.h:127
ext2_inode::nlinks
USHORT nlinks
Definition:
ext2.h:133
ext2_inode::version
ULONG version
Definition:
ext2.h:148
ext2_inode::acl
ULONG acl
Definition:
ext2.h:149
ext2_inode::indir_block
ULONG indir_block
Definition:
ext2.h:142
ext2_inode::symlink
char symlink[60]
Definition:
ext2.h:146
ext2_inode::mtime
ULONG mtime
Definition:
ext2.h:130
ext2_inode::flags
ULONG flags
Definition:
ext2.h:135
ext2_inode::gid
USHORT gid
Definition:
ext2.h:132
ext2_inode::dir_acl
ULONG dir_acl
Definition:
ext2.h:150
ext2_inode::tripple_indir_block
ULONG tripple_indir_block
Definition:
ext2.h:144
ext2_inode::blocks
struct ext2_inode::@167::datablocks blocks
ext2_inode::mode
USHORT mode
Definition:
ext2.h:125
ext2_inode::blockcnt
ULONG blockcnt
Definition:
ext2.h:134
ext2_inode::osd1
ULONG osd1
Definition:
ext2.h:136
ext2_inode::fragment_addr
ULONG fragment_addr
Definition:
ext2.h:151
ext2_inode::double_indir_block
ULONG double_indir_block
Definition:
ext2.h:143
ext2_inode::uid
USHORT uid
Definition:
ext2.h:126
ext2_inode::atime
ULONG atime
Definition:
ext2.h:128
ext2_inode::dtime
ULONG dtime
Definition:
ext2.h:131
ext2_sblock
Definition:
ext2.h:70
ext2_sblock::revision_level
ULONG revision_level
Definition:
ext2.h:93
ext2_sblock::max_mnt_count
USHORT max_mnt_count
Definition:
ext2.h:85
ext2_sblock::feature_ro_compat
ULONG feature_ro_compat
Definition:
ext2.h:101
ext2_sblock::last_mounted_on
char last_mounted_on[64]
Definition:
ext2.h:104
ext2_sblock::compression_info
ULONG compression_info
Definition:
ext2.h:105
ext2_sblock::feature_compatibility
ULONG feature_compatibility
Definition:
ext2.h:99
ext2_sblock::free_blocks
ULONG free_blocks
Definition:
ext2.h:74
ext2_sblock::reserved_blocks
ULONG reserved_blocks
Definition:
ext2.h:73
ext2_sblock::block_group_number
USHORT block_group_number
Definition:
ext2.h:98
ext2_sblock::mtime
ULONG mtime
Definition:
ext2.h:82
ext2_sblock::utime
ULONG utime
Definition:
ext2.h:83
ext2_sblock::error_handling
USHORT error_handling
Definition:
ext2.h:88
ext2_sblock::first_inode
ULONG first_inode
Definition:
ext2.h:96
ext2_sblock::log2_block_size
ULONG log2_block_size
Definition:
ext2.h:77
ext2_sblock::fs_state
USHORT fs_state
Definition:
ext2.h:87
ext2_sblock::volume_name
char volume_name[16]
Definition:
ext2.h:103
ext2_sblock::total_inodes
ULONG total_inodes
Definition:
ext2.h:71
ext2_sblock::inode_size
USHORT inode_size
Definition:
ext2.h:97
ext2_sblock::log2_fragment_size
LONG log2_fragment_size
Definition:
ext2.h:78
ext2_sblock::padding
ULONG padding[77]
Definition:
ext2.h:106
ext2_sblock::free_inodes
ULONG free_inodes
Definition:
ext2.h:75
ext2_sblock::inodes_per_group
ULONG inodes_per_group
Definition:
ext2.h:81
ext2_sblock::magic
USHORT magic
Definition:
ext2.h:86
ext2_sblock::gid_reserved
USHORT gid_reserved
Definition:
ext2.h:95
ext2_sblock::minor_revision_level
USHORT minor_revision_level
Definition:
ext2.h:89
ext2_sblock::total_blocks
ULONG total_blocks
Definition:
ext2.h:72
ext2_sblock::uid_reserved
USHORT uid_reserved
Definition:
ext2.h:94
ext2_sblock::fragments_per_group
ULONG fragments_per_group
Definition:
ext2.h:80
ext2_sblock::checkinterval
ULONG checkinterval
Definition:
ext2.h:91
ext2_sblock::unique_id
ULONG unique_id[4]
Definition:
ext2.h:102
ext2_sblock::feature_incompat
ULONG feature_incompat
Definition:
ext2.h:100
ext2_sblock::blocks_per_group
ULONG blocks_per_group
Definition:
ext2.h:79
ext2_sblock::mnt_count
USHORT mnt_count
Definition:
ext2.h:84
ext2_sblock::lastcheck
ULONG lastcheck
Definition:
ext2.h:90
ext2_sblock::creator_os
ULONG creator_os
Definition:
ext2.h:92
ext2_sblock::first_data_block
ULONG first_data_block
Definition:
ext2.h:76
name
Definition:
name.c:39
tagDEVVTBL
Definition:
fs.h:25
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
ULONGLONG
uint64_t ULONGLONG
Definition:
typedefs.h:67
UCHAR
unsigned char UCHAR
Definition:
xmlstorage.h:181
CHAR
char CHAR
Definition:
xmlstorage.h:175
boot
freeldr
freeldr
include
fs
ext2.h
Generated on Mon Dec 2 2024 06:04:49 for ReactOS by
1.9.6