ReactOS 0.4.16-dev-1946-g52006dd
ext.h
Go to the documentation of this file.
1/*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 * Copyright (C) 2024-2025 Daniel Victor <ilauncherdeveloper@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#pragma once
22
23/*
24 * grub/fs/ext2.c
25 *
26 * GRUB -- GRand Unified Bootloader
27 * Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc.
28 *
29 * This program is free software; you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation; either version 2 of the License, or
32 * (at your option) any later version.
33 *
34 * This program is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details.
38 *
39 * You should have received a copy of the GNU General Public License
40 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
41 */
42
43#include <pshpack1.h>
44
45#define EXT_SUPERBLOCK_MAGIC 0xEF53
46#define EXT_DYNAMIC_REVISION 1
47#define EXT_DEFAULT_INODE_SIZE 128
48#define EXT_DEFAULT_GROUP_DESC_SIZE 32
49
50#define EXT_DIR_ENTRY_MAX_NAME_LENGTH 255
51
52typedef struct _ExtSuperBlock
53{
54 /* SuperBlock Information Ext2 */
80
81 /* SuperBlock Information Ext3 */
103
108
109 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
113
116C_ASSERT(sizeof(EXT_SUPER_BLOCK) == 0x400);
117
119{
127
128typedef struct _Ext4ExtentHeader
129{
136
137typedef struct _Ext4ExtentIdx
138{
144
145typedef struct _Ext4Extent
146{
152
153typedef struct _ExtInode
154{
155 USHORT Mode; // Combination of _S_IF* mode flags (FILETYPE_INO_* in grub/fs/ext2.c)
167 union
168 {
170 struct
171 {
178 };
185
186typedef struct _ExtDirEntry
187{
191 UCHAR FileType; // One of the FILETYPE_* values
194
195#include <poppack.h>
196
197/* Special inode numbers. */
198#define EXT_ROOT_INODE 2
199
200/* The revision level. */
201#define EXT_REVISION(sb) (sb->RevisionLevel)
202
203/* The inode size. */
204#define EXT_INODE_SIZE(sb) \
205 (EXT_REVISION(sb) < EXT_DYNAMIC_REVISION ? EXT_DEFAULT_INODE_SIZE : sb->InodeSize)
206
207/* The group descriptor size. */
208#define EXT_GROUP_DESC_SIZE(sb) \
209 ((EXT_REVISION(sb) >= EXT_DYNAMIC_REVISION && sb->GroupDescSize) ? sb->GroupDescSize : EXT_DEFAULT_GROUP_DESC_SIZE)
210
211/* The inode extents flag. */
212#define EXT4_INODE_FLAG_EXTENTS 0x80000
213
214/* The extent header magic value. */
215#define EXT4_EXTENT_HEADER_MAGIC 0xF30A
216
217/* The maximum extent level. */
218#define EXT4_EXTENT_MAX_LEVEL 5
219
220/* The maximum extent length used to check for sparse extents. */
221#define EXT4_EXTENT_MAX_LENGTH 32768
222
223/* Filetype used in directory entry. */
224#define FILETYPE_UNKNOWN 0
225#define FILETYPE_REG 1
226#define FILETYPE_DIRECTORY 2
227#define FILETYPE_SYMLINK 7
228
229#define FAST_SYMLINK_MAX_NAME_SIZE 60
230
232
233typedef struct _EXT_FILE_INFO
234{
236 PULONG FileBlockList; // File block list
237 EXT_INODE Inode; // File inode
238 ULONGLONG FileSize; // File size
239 ULONGLONG FilePointer; // File pointer
244
247 _In_ ULONG DeviceId);
248
249const DEVVTBL* ExtMount(ULONG DeviceId);
struct _Ext4Extent EXT4_EXTENT
struct _Ext4Extent * PEXT4_EXTENT
struct _ExtGroupDescriptor EXT_GROUP_DESC
struct _ExtInode EXT_INODE
struct _EXT_VOLUME_INFO * PEXT_VOLUME_INFO
Definition: ext.h:231
ULONGLONG ExtGetVolumeSize(_In_ ULONG DeviceId)
Returns the size of the EXT2/3/4 volume laid on the storage media device opened via DeviceId.
Definition: ext.c:1404
struct _ExtDirEntry EXT_DIR_ENTRY
struct _EXT_FILE_INFO EXT_FILE_INFO
struct _EXT_FILE_INFO * PEXT_FILE_INFO
struct _ExtSuperBlock * PEXT_SUPER_BLOCK
struct _Ext4ExtentIdx EXT4_EXTENT_IDX
struct _Ext4ExtentHeader EXT4_EXTENT_HEADER
struct _ExtDirEntry * PEXT_DIR_ENTRY
struct _ExtInode * PEXT_INODE
const DEVVTBL * ExtMount(ULONG DeviceId)
Definition: ext.c:1431
struct _Ext4ExtentHeader * PEXT4_EXTENT_HEADER
#define EXT_DIR_ENTRY_MAX_NAME_LENGTH
Definition: ext.h:50
struct _Ext4ExtentIdx * PEXT4_EXTENT_IDX
struct _ExtSuperBlock EXT_SUPER_BLOCK
struct _ExtGroupDescriptor * PEXT_GROUP_DESC
#define C_ASSERT(e)
Definition: intsafe.h:73
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
#define _In_
Definition: no_sal2.h:158
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
EXT_INODE Inode
Definition: ext.h:237
PEXT_VOLUME_INFO Volume
Definition: ext.h:235
UCHAR Attributes
Definition: ext.h:241
PULONG FileBlockList
Definition: ext.h:236
ULONG FileNameLength
Definition: ext.h:240
ULONGLONG FilePointer
Definition: ext.h:239
ULONGLONG FileSize
Definition: ext.h:238
ULONG Generation
Definition: ext.h:134
USHORT Magic
Definition: ext.h:130
USHORT Max
Definition: ext.h:132
USHORT Depth
Definition: ext.h:133
USHORT Entries
Definition: ext.h:131
ULONG Leaf
Definition: ext.h:140
USHORT Unused
Definition: ext.h:142
ULONG Block
Definition: ext.h:139
USHORT LeafHigh
Definition: ext.h:141
ULONG Block
Definition: ext.h:147
USHORT StartHigh
Definition: ext.h:149
USHORT Length
Definition: ext.h:148
ULONG Start
Definition: ext.h:150
USHORT EntryLen
Definition: ext.h:189
ULONG Inode
Definition: ext.h:188
UCHAR FileType
Definition: ext.h:191
CHAR Name[EXT_DIR_ENTRY_MAX_NAME_LENGTH]
Definition: ext.h:192
UCHAR NameLen
Definition: ext.h:190
USHORT FreeBlocksCount
Definition: ext.h:123
ULONG InodeBitmap
Definition: ext.h:121
ULONG InodeTable
Definition: ext.h:122
ULONG BlockBitmap
Definition: ext.h:120
USHORT FreeInodesCount
Definition: ext.h:124
USHORT UsedDirsCount
Definition: ext.h:125
Definition: ext.h:154
ULONG Dtime
Definition: ext.h:161
ULONG DirACL
Definition: ext.h:181
struct _ExtInode::@203::@205 Blocks
USHORT LinksCount
Definition: ext.h:163
ULONG IndirectBlock
Definition: ext.h:173
EXT4_EXTENT_HEADER ExtentHeader
Definition: ext.h:177
CHAR SymLink[60]
Definition: ext.h:169
ULONG FragAddress
Definition: ext.h:182
ULONG Flags
Definition: ext.h:165
ULONG TripleIndirectBlock
Definition: ext.h:175
USHORT GID
Definition: ext.h:162
ULONG Generation
Definition: ext.h:179
ULONG Ctime
Definition: ext.h:159
USHORT Mode
Definition: ext.h:155
USHORT UID
Definition: ext.h:156
ULONG OSD1
Definition: ext.h:166
ULONG FileACL
Definition: ext.h:180
ULONG Size
Definition: ext.h:157
ULONG DirectBlocks[12]
Definition: ext.h:172
ULONG Mtime
Definition: ext.h:160
ULONG OSD2[3]
Definition: ext.h:183
ULONG BlocksCount
Definition: ext.h:164
ULONG Atime
Definition: ext.h:158
ULONG DoubleIndirectBlock
Definition: ext.h:174
ULONG DefaultMountOpts
Definition: ext.h:104
ULONG FreeBlocksCountHi
Definition: ext.h:112
USHORT GroupDescSize
Definition: ext.h:102
ULONG FreeInodesCount
Definition: ext.h:59
UCHAR PreallocDirBlocks
Definition: ext.h:93
ULONG FeatureCompat
Definition: ext.h:85
ULONG HashSeed[4]
Definition: ext.h:99
ULONG MkfsTime
Definition: ext.h:106
ULONG FirstMetaBg
Definition: ext.h:105
ULONG FeatureIncompat
Definition: ext.h:86
UCHAR DefHashVersion
Definition: ext.h:100
ULONG InodesCount
Definition: ext.h:55
UCHAR JournalBackupType
Definition: ext.h:101
ULONG BlocksCountLo
Definition: ext.h:56
USHORT MaxMntCount
Definition: ext.h:69
USHORT DefResUID
Definition: ext.h:78
ULONG InodesPerGroup
Definition: ext.h:65
ULONG MTime
Definition: ext.h:66
ULONG CreatorOS
Definition: ext.h:76
USHORT Magic
Definition: ext.h:70
ULONG LogBlockSize
Definition: ext.h:61
ULONG LastCheck
Definition: ext.h:74
ULONG RevisionLevel
Definition: ext.h:77
USHORT BlockGroupNr
Definition: ext.h:84
ULONG CheckInterval
Definition: ext.h:75
ULONG AlgorithmUsageBitmap
Definition: ext.h:91
LONG LogFragSize
Definition: ext.h:62
ULONG FragsPerGroup
Definition: ext.h:64
USHORT DefResGID
Definition: ext.h:79
CHAR VolumeName[16]
Definition: ext.h:89
ULONG BlocksPerGroup
Definition: ext.h:63
ULONG FirstInode
Definition: ext.h:82
ULONG BlocksCountHi
Definition: ext.h:110
ULONG RBlocksCountHi
Definition: ext.h:111
ULONG WTime
Definition: ext.h:67
ULONG LastOrphan
Definition: ext.h:98
ULONG RBlocksCountLo
Definition: ext.h:57
ULONG FeatureROCompat
Definition: ext.h:87
USHORT MntCount
Definition: ext.h:68
USHORT InodeSize
Definition: ext.h:83
ULONG JnlBlocks[17]
Definition: ext.h:107
USHORT State
Definition: ext.h:71
UCHAR JournalUUID[16]
Definition: ext.h:95
CHAR LastMounted[64]
Definition: ext.h:90
USHORT Errors
Definition: ext.h:72
ULONG FreeBlocksCountLo
Definition: ext.h:58
USHORT ReservedGdtBlocks
Definition: ext.h:94
USHORT MinorRevisionLevel
Definition: ext.h:73
ULONG FirstDataBlock
Definition: ext.h:60
UCHAR PreallocBlocks
Definition: ext.h:92
ULONG JournalDev
Definition: ext.h:97
ULONG JournalInum
Definition: ext.h:96
Definition: fs.h:25
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175