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. */
70{
103 char volume_name[16];
107};
108
109/* The ext2 blockgroup. */
111{
120};
121
122/* The ext2 inode. */
124{
134 ULONG blockcnt; /* Blocks of 512 bytes!! */
137 union
138 {
139 struct datablocks
140 {
146 char symlink[60];
147 };
153};
154
155/* The header of an ext2 directory entry. */
156#define EXT2_NAME_LEN 255
157
159{
165};
166
167/*
168 * End of code from grub/fs/ext2.c
169 */
170
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
230
231typedef 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
239
#define EXT2_NAME_LEN
Definition: ext2.h:156
struct ext2_inode * PEXT2_INODE
Definition: ext2.h:172
struct _EXT2_VOLUME_INFO * PEXT2_VOLUME_INFO
Definition: ext2.h:229
struct ext2_dirent * PEXT2_DIR_ENTRY
Definition: ext2.h:174
struct EXT2_FILE_INFO * PEXT2_FILE_INFO
struct ext2_block_group * PEXT2_GROUP_DESC
Definition: ext2.h:173
#define INDIRECT_BLOCKS
Definition: ext2.h:45
struct ext2_sblock * PEXT2_SUPER_BLOCK
Definition: ext2.h:171
const DEVVTBL * Ext2Mount(ULONG DeviceId)
Definition: ext2.c:1298
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
ULONG * FileBlockList
Definition: ext2.h:235
PEXT2_VOLUME_INFO Volume
Definition: ext2.h:237
ULONGLONG FilePointer
Definition: ext2.h:234
ULONGLONG FileSize
Definition: ext2.h:233
EXT2_INODE Inode
Definition: ext2.h:236
ULONG DeviceId
Definition: ext2.c:61
ULONG inode_table_id
Definition: ext2.h:114
USHORT free_inodes
Definition: ext2.h:116
USHORT used_dirs
Definition: ext2.h:117
ULONG inode_id
Definition: ext2.h:113
ULONG reserved[3]
Definition: ext2.h:119
USHORT free_blocks
Definition: ext2.h:115
ULONG block_id
Definition: ext2.h:112
USHORT pad
Definition: ext2.h:118
UCHAR namelen
Definition: ext2.h:162
ULONG inode
Definition: ext2.h:160
UCHAR filetype
Definition: ext2.h:163
USHORT direntlen
Definition: ext2.h:161
ULONG osd2[3]
Definition: ext2.h:152
ULONG ctime
Definition: ext2.h:129
ULONG size
Definition: ext2.h:127
USHORT nlinks
Definition: ext2.h:133
ULONG version
Definition: ext2.h:148
ULONG acl
Definition: ext2.h:149
ULONG indir_block
Definition: ext2.h:142
char symlink[60]
Definition: ext2.h:146
ULONG mtime
Definition: ext2.h:130
ULONG flags
Definition: ext2.h:135
USHORT gid
Definition: ext2.h:132
ULONG dir_acl
Definition: ext2.h:150
ULONG tripple_indir_block
Definition: ext2.h:144
struct ext2_inode::@167::datablocks blocks
USHORT mode
Definition: ext2.h:125
ULONG blockcnt
Definition: ext2.h:134
ULONG osd1
Definition: ext2.h:136
ULONG fragment_addr
Definition: ext2.h:151
ULONG double_indir_block
Definition: ext2.h:143
USHORT uid
Definition: ext2.h:126
ULONG atime
Definition: ext2.h:128
ULONG dtime
Definition: ext2.h:131
ULONG revision_level
Definition: ext2.h:93
USHORT max_mnt_count
Definition: ext2.h:85
ULONG feature_ro_compat
Definition: ext2.h:101
char last_mounted_on[64]
Definition: ext2.h:104
ULONG compression_info
Definition: ext2.h:105
ULONG feature_compatibility
Definition: ext2.h:99
ULONG free_blocks
Definition: ext2.h:74
ULONG reserved_blocks
Definition: ext2.h:73
USHORT block_group_number
Definition: ext2.h:98
ULONG mtime
Definition: ext2.h:82
ULONG utime
Definition: ext2.h:83
USHORT error_handling
Definition: ext2.h:88
ULONG first_inode
Definition: ext2.h:96
ULONG log2_block_size
Definition: ext2.h:77
USHORT fs_state
Definition: ext2.h:87
char volume_name[16]
Definition: ext2.h:103
ULONG total_inodes
Definition: ext2.h:71
USHORT inode_size
Definition: ext2.h:97
LONG log2_fragment_size
Definition: ext2.h:78
ULONG padding[77]
Definition: ext2.h:106
ULONG free_inodes
Definition: ext2.h:75
ULONG inodes_per_group
Definition: ext2.h:81
USHORT magic
Definition: ext2.h:86
USHORT gid_reserved
Definition: ext2.h:95
USHORT minor_revision_level
Definition: ext2.h:89
ULONG total_blocks
Definition: ext2.h:72
USHORT uid_reserved
Definition: ext2.h:94
ULONG fragments_per_group
Definition: ext2.h:80
ULONG checkinterval
Definition: ext2.h:91
ULONG unique_id[4]
Definition: ext2.h:102
ULONG feature_incompat
Definition: ext2.h:100
ULONG blocks_per_group
Definition: ext2.h:79
USHORT mnt_count
Definition: ext2.h:84
ULONG lastcheck
Definition: ext2.h:90
ULONG creator_os
Definition: ext2.h:92
ULONG first_data_block
Definition: ext2.h:76
Definition: name.c:39
Definition: fs.h:25
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175