ReactOS 0.4.16-dev-889-g9563c07
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 */
105
107{
115
116typedef struct _Ext4ExtentHeader
117{
124
125typedef struct _Ext4ExtentIdx
126{
132
133typedef struct _Ext4Extent
134{
140
141typedef struct _ExtInode
142{
155 union
156 {
158 struct
159 {
166 };
173
174typedef struct _ExtDirEntry
175{
182
183#include <poppack.h>
184
185/* Special inode numbers. */
186#define EXT_ROOT_INODE 2
187
188/* The revision level. */
189#define EXT_REVISION(sb) (sb->RevisionLevel)
190
191/* The inode size. */
192#define EXT_INODE_SIZE(sb) \
193 (EXT_REVISION(sb) < EXT_DYNAMIC_REVISION ? EXT_DEFAULT_INODE_SIZE : sb->InodeSize)
194
195/* The group descriptor size. */
196#define EXT_GROUP_DESC_SIZE(sb) \
197 ((EXT_REVISION(sb) >= EXT_DYNAMIC_REVISION && sb->GroupDescSize) ? sb->GroupDescSize : EXT_DEFAULT_GROUP_DESC_SIZE)
198
199/* The inode extents flag. */
200#define EXT4_INODE_FLAG_EXTENTS 0x80000
201
202/* The extent header magic value. */
203#define EXT4_EXTENT_HEADER_MAGIC 0xF30A
204
205/* The maximum extent level. */
206#define EXT4_EXTENT_MAX_LEVEL 5
207
208/* The maximum extent length used to check for sparse extents. */
209#define EXT4_EXTENT_MAX_LENGTH 32768
210
211// EXT_INODE::mode values
212#define EXT_S_IRWXO 0x0007 // Other mask
213#define EXT_S_IXOTH 0x0001 // ---------x execute
214#define EXT_S_IWOTH 0x0002 // --------w- write
215#define EXT_S_IROTH 0x0004 // -------r-- read
216
217#define EXT_S_IRWXG 0x0038 // Group mask
218#define EXT_S_IXGRP 0x0008 // ------x--- execute
219#define EXT_S_IWGRP 0x0010 // -----w---- write
220#define EXT_S_IRGRP 0x0020 // ----r----- read
221
222#define EXT_S_IRWXU 0x01C0 // User mask
223#define EXT_S_IXUSR 0x0040 // ---x------ execute
224#define EXT_S_IWUSR 0x0080 // --w------- write
225#define EXT_S_IRUSR 0x0100 // -r-------- read
226
227#define EXT_S_ISVTX 0x0200 // Sticky bit
228#define EXT_S_ISGID 0x0400 // SGID
229#define EXT_S_ISUID 0x0800 // SUID
230
231#define EXT_S_IFMT 0xF000 // Format mask
232#define EXT_S_IFIFO 0x1000 // FIFO buffer
233#define EXT_S_IFCHR 0x2000 // Character device
234#define EXT_S_IFDIR 0x4000 // Directory
235#define EXT_S_IFBLK 0x6000 // Block device
236#define EXT_S_IFREG 0x8000 // Regular file
237#define EXT_S_IFLNK 0xA000 // Symbolic link
238#define EXT_S_IFSOCK 0xC000 // Socket
239
240#define FAST_SYMLINK_MAX_NAME_SIZE 60
241
243
244typedef struct _EXT_FILE_INFO
245{
246 ULONGLONG FileSize; // File size
247 ULONGLONG FilePointer; // File pointer
248 PULONG FileBlockList; // File block list
249 EXT_INODE Inode; // File's inode
252
253const 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:242
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:1380
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
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
EXT_INODE Inode
Definition: ext.h:249
PEXT_VOLUME_INFO Volume
Definition: ext.h:250
PULONG FileBlockList
Definition: ext.h:248
ULONGLONG FilePointer
Definition: ext.h:247
ULONGLONG FileSize
Definition: ext.h:246
ULONG Generation
Definition: ext.h:122
USHORT Magic
Definition: ext.h:118
USHORT Max
Definition: ext.h:120
USHORT Depth
Definition: ext.h:121
USHORT Entries
Definition: ext.h:119
ULONG Leaf
Definition: ext.h:128
USHORT Unused
Definition: ext.h:130
ULONG Block
Definition: ext.h:127
USHORT LeafHigh
Definition: ext.h:129
ULONG Block
Definition: ext.h:135
USHORT StartHigh
Definition: ext.h:137
USHORT Length
Definition: ext.h:136
ULONG Start
Definition: ext.h:138
USHORT EntryLen
Definition: ext.h:177
ULONG Inode
Definition: ext.h:176
UCHAR FileType
Definition: ext.h:179
UCHAR NameLen
Definition: ext.h:178
USHORT FreeBlocksCount
Definition: ext.h:111
ULONG InodeBitmap
Definition: ext.h:109
ULONG InodeTable
Definition: ext.h:110
ULONG BlockBitmap
Definition: ext.h:108
USHORT FreeInodesCount
Definition: ext.h:112
USHORT UsedDirsCount
Definition: ext.h:113
Definition: ext.h:142
ULONG Dtime
Definition: ext.h:149
ULONG DirACL
Definition: ext.h:169
USHORT LinksCount
Definition: ext.h:151
ULONG IndirectBlock
Definition: ext.h:161
EXT4_EXTENT_HEADER ExtentHeader
Definition: ext.h:165
CHAR SymLink[60]
Definition: ext.h:157
ULONG FragAddress
Definition: ext.h:170
ULONG Flags
Definition: ext.h:153
ULONG TripleIndirectBlock
Definition: ext.h:163
USHORT GID
Definition: ext.h:150
ULONG Generation
Definition: ext.h:167
ULONG Ctime
Definition: ext.h:147
USHORT Mode
Definition: ext.h:143
USHORT UID
Definition: ext.h:144
ULONG OSD1
Definition: ext.h:154
ULONG FileACL
Definition: ext.h:168
struct _ExtInode::@185::@187 Blocks
ULONG Size
Definition: ext.h:145
ULONG DirectBlocks[12]
Definition: ext.h:160
ULONG Mtime
Definition: ext.h:148
ULONG OSD2[3]
Definition: ext.h:171
ULONG BlocksCount
Definition: ext.h:152
ULONG Atime
Definition: ext.h:146
ULONG DoubleIndirectBlock
Definition: ext.h:162
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 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 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
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