ReactOS 0.4.15-dev-7674-gc0b4db1
Mke2fs.h
Go to the documentation of this file.
1/*
2 * PROJECT: Mke2fs
3 * FILE: Mke2fs.h
4 * PROGRAMMER: Matt Wu <mattwu@163.com>
5 * HOMEPAGE: http://ext2.yeah.net
6 */
7
8#ifndef _MKE2FS_H_
9#define _MKE2FS_H_
10
11/* INCLUDES **************************************************************/
12
13#define NTOS_MODE_USER
14#include <ndk/kefuncs.h>
15#include <ndk/rtlfuncs.h>
16
17#include "ext2_fs.h"
18
19/* DEFINITIONS ***********************************************************/
20
21#define SECTOR_SIZE (Ext2Sys->DiskGeometry.BytesPerSector)
22
23#ifndef GUID_DEFINED
24#define GUID_DEFINED
25typedef struct _GUID
26{
27 unsigned long Data1;
28 unsigned short Data2;
29 unsigned short Data3;
30 unsigned char Data4[8];
32#endif /* GUID_DEFINED */
33
34#ifndef UUID_DEFINED
35#define UUID_DEFINED
36typedef GUID UUID;
37#ifndef uuid_t
38#define uuid_t UUID
39#endif
40#endif
41
42#ifndef bool
43#define bool BOOLEAN
44#endif
45
46#ifndef true
47#define true TRUE
48#endif
49
50#ifndef false
51#define false FALSE
52#endif
53
54
55#define EXT2_CHECK_MAGIC(struct, code) \
56 if ((struct)->magic != (code)) return (code)
57
58/*
59 * ext2fs_scan flags
60 */
61#define EXT2_SF_CHK_BADBLOCKS 0x0001
62#define EXT2_SF_BAD_INODE_BLK 0x0002
63#define EXT2_SF_BAD_EXTRA_BYTES 0x0004
64#define EXT2_SF_SKIP_MISSING_ITABLE 0x0008
65
66/*
67 * ext2fs_check_if_mounted flags
68 */
69#define EXT2_MF_MOUNTED 1
70#define EXT2_MF_ISROOT 2
71#define EXT2_MF_READONLY 4
72#define EXT2_MF_SWAP 8
73
74/*
75 * Ext2/linux mode flags. We define them here so that we don't need
76 * to depend on the OS's sys/stat.h, since we may be compiling on a
77 * non-Linux system.
78 */
79
80#define LINUX_S_IFMT 00170000
81#define LINUX_S_IFSOCK 0140000
82#define LINUX_S_IFLNK 0120000
83#define LINUX_S_IFREG 0100000
84#define LINUX_S_IFBLK 0060000
85#define LINUX_S_IFDIR 0040000
86#define LINUX_S_IFCHR 0020000
87#define LINUX_S_IFIFO 0010000
88#define LINUX_S_ISUID 0004000
89#define LINUX_S_ISGID 0002000
90#define LINUX_S_ISVTX 0001000
91
92#define LINUX_S_IRWXU 00700
93#define LINUX_S_IRUSR 00400
94#define LINUX_S_IWUSR 00200
95#define LINUX_S_IXUSR 00100
96
97#define LINUX_S_IRWXG 00070
98#define LINUX_S_IRGRP 00040
99#define LINUX_S_IWGRP 00020
100#define LINUX_S_IXGRP 00010
101
102#define LINUX_S_IRWXO 00007
103#define LINUX_S_IROTH 00004
104#define LINUX_S_IWOTH 00002
105#define LINUX_S_IXOTH 00001
106
107#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
108#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
109#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
110#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
111#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
112#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
113#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
114
115
116#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
117
118typedef struct _ext2fs_bitmap {
121 char* bitmap;
123
127
138
139/*
140 * Badblocks list
141 */
143 int num;
144 int size;
147};
148
150
151typedef struct _ext2_filesys
152{
153 int flags;
157 unsigned long desc_blocks;
163
165/*
166 ext2_dblist dblist;
167*/
168 __u32 stride; /* for mke2fs */
169
171
172 /*
173 * Reserved for future expansion
174 */
176
177 /*
178 * Reserved for the use of the calling application.
179 */
180 void * priv_data;
181
183
185
187
189
190// Block Description List
191typedef struct _EXT2_BDL {
196
197/*
198 * Where the master copy of the superblock is located, and how big
199 * superblocks are supposed to be. We define SUPERBLOCK_SIZE because
200 * the size of the superblock structure is not necessarily trustworthy
201 * (some versions have the padding set up so that the superblock is
202 * 1032 bytes long).
203 */
204#define SUPERBLOCK_OFFSET 1024
205#define SUPERBLOCK_SIZE 1024
206
207
209
210
211/*
212 * Bitmap.c
213 */
214
215#define ext2_mark_block_bitmap ext2_mark_bitmap
216#define ext2_mark_inode_bitmap ext2_mark_bitmap
217#define ext2_unmark_block_bitmap ext2_unmark_bitmap
218#define ext2_unmark_inode_bitmap ext2_unmark_bitmap
219
220bool ext2_set_bit(int nr, void * addr);
221bool ext2_clear_bit(int nr, void * addr);
222bool ext2_test_bit(int nr, void * addr);
223
226
228 ULONG block);
229
231 ULONG block, int num);
232
234 ULONG inode);
235
236
241
244
246
247//bool read_bitmaps(PEXT2_FILESYS fs, int do_inode, int do_block);
251
252
253/*
254 * Disk.c
255 */
256
260
263
268 PVOID Buffer );
269
274 PVOID Buffer );
275
278
279
282
285
288
289
290/*
291 * Group.c
292 */
293
296bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block);
297
298/*
299 * Inode.c
300 */
301
303bool ext2_load_inode(PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode);
304bool ext2_save_inode(PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode);
307bool ext2_expand_inode(PEXT2_FILESYS pExt2Sys, PEXT2_INODE, ULONG newBlk);
308
309bool ext2_read_inode (PEXT2_FILESYS pExt2Sys,
310 ULONG ino,
313 ULONG size,
314 PULONG dwReturn );
315bool ext2_write_inode (PEXT2_FILESYS pExt2Sys,
316 ULONG ino,
319 ULONG size,
320 PULONG dwReturn );
321
322bool ext2_add_entry(PEXT2_FILESYS pExt2Sys, ULONG parent, ULONG inode, int filetype, char *name);
324/*
325 * Memory.c
326 */
327
328//
329// Return the group # of an inode number
330//
332
333//
334// Return the group # of a block
335//
337
338/*
339 * Badblock.c
340 */
341
342
343void ext2_inode_alloc_stats2(PEXT2_FILESYS fs, ULONG ino, int inuse, int isdir);
344void ext2_inode_alloc_stats(PEXT2_FILESYS fs, ULONG ino, int inuse);
346
353
358 ULONG parent_ino, char **block);
361
362/*
363 * Mke2fs.c
364 */
365
366bool parase_cmd(int argc, char *argv[], PEXT2_FILESYS pExt2Sys);
367
369 ULONG *ret_blk, ULONG *ret_count);
370
371ULONG
372Ext2DataBlocks(PEXT2_FILESYS Ext2Sys, ULONG TotalBlocks);
373
374ULONG
375Ext2TotalBlocks(PEXT2_FILESYS Ext2Sys, ULONG DataBlocks);
376
377
378
379/*
380 * Super.c
381 */
382
384bool ext2_initialize_sb(PEXT2_FILESYS pExt2Sys);
385
386
387/*
388 * Super.c
389 */
390
393
394/*
395 * Uuid.c
396 */
397
398void uuid_generate(__u8 * uuid);
399
400#endif /* _MKE2FS_H_ */
int ext2_group_of_ino(PEXT2_FILESYS fs, ULONG ino)
Definition: Memory.c:23
struct ext2_dx_root_info * PEXT2_DX_RI
Definition: Mke2fs.h:134
EXT2_BITMAP EXT2_BLOCK_BITMAP
Definition: Mke2fs.h:126
void ext2_print_super(PEXT2_SUPER_BLOCK pExt2Sb)
Definition: Super.c:20
bool ext2_test_bit(int nr, void *addr)
Definition: Bitmap.c:41
bool ext2_test_inode_bitmap(PEXT2_BLOCK_BITMAP bitmap, ULONG inode)
Definition: Bitmap.c:93
struct ext2_dir_entry * PEXT2_DIR_ENTRY
Definition: Mke2fs.h:130
NTSTATUS Ext2ReadDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:964
void uuid_generate(__u8 *uuid)
Definition: Uuid.c:17
void ext2_inode_alloc_stats2(PEXT2_FILESYS fs, ULONG ino, int inuse, int isdir)
Definition: Memory.c:37
bool ext2_allocate_group_table(PEXT2_FILESYS fs, ULONG group, PEXT2_BLOCK_BITMAP bmap)
Definition: Memory.c:92
bool ext2_test_block_bitmap(PEXT2_BLOCK_BITMAP bitmap, ULONG block)
Definition: Bitmap.c:73
NTSTATUS Ext2GetMediaInfo(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1162
bool zero_blocks(PEXT2_FILESYS fs, ULONG blk, ULONG num, ULONG *ret_blk, ULONG *ret_count)
Definition: Mke2fs.c:122
GUID UUID
Definition: Mke2fs.h:36
bool ext2_set_bit(int nr, void *addr)
Definition: Bitmap.c:18
struct ext2_inode * PEXT2_INODE
Definition: Mke2fs.h:135
bool ext2_test_block_bitmap_range(PEXT2_BLOCK_BITMAP bitmap, ULONG block, int num)
Definition: Bitmap.c:80
bool ext2_write_block_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:270
void ext2_block_alloc_stats(PEXT2_FILESYS fs, ULONG blk, int inuse)
Definition: Memory.c:61
NTSTATUS Ext2OpenDevice(PEXT2_FILESYS Ext2Sys, PUNICODE_STRING DeviceName)
Definition: Disk.c:1282
struct _ext2fs_bitmap * PEXT2_BITMAP
bool ext2_initialize_sb(PEXT2_FILESYS pExt2Sys)
Definition: Super.c:74
bool ext2_get_inode_lba(PEXT2_FILESYS pExt2Sys, ULONG no, LONGLONG *offset)
Definition: Inode.c:20
bool ext2_read_bitmaps(PEXT2_FILESYS fs)
Definition: Bitmap.c:492
bool ext2_write_inode(PEXT2_FILESYS pExt2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
Definition: Inode.c:541
int ext2_group_of_blk(PEXT2_FILESYS fs, ULONG blk)
Definition: Memory.c:31
struct ext2_dx_countlimit * PEXT2_DX_CL
Definition: Mke2fs.h:132
bool parase_cmd(int argc, char *argv[], PEXT2_FILESYS pExt2Sys)
bool ext2_new_block(PEXT2_FILESYS fs, ULONG goal, PEXT2_BLOCK_BITMAP map, ULONG *ret)
Definition: Memory.c:254
struct ext2_dir_entry_2 * PEXT2_DIR_ENTRY2
Definition: Mke2fs.h:131
bool create_bad_block_inode(PEXT2_FILESYS fs, PEXT2_BADBLK_LIST bb_list)
Definition: Badblock.c:16
struct _EXT2_BDL * PEXT2_BDL
void ext2_free_block_bitmap(PEXT2_FILESYS pExt2Sys)
Definition: Bitmap.c:205
NTSTATUS Ext2DisMountVolume(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1260
bool ext2_read_block_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:487
struct ext2_group_desc * PEXT2_GROUP_DESC
Definition: Mke2fs.h:136
EXT2_BITMAP EXT2_GENERIC_BITMAP
Definition: Mke2fs.h:124
EXT2_BITMAP * PEXT2_GENERIC_BITMAP
Definition: Mke2fs.h:124
bool ext2_allocate_block_bitmap(PEXT2_FILESYS pExt2Sys)
Definition: Bitmap.c:100
EXT2_BITMAP EXT2_INODE_BITMAP
Definition: Mke2fs.h:125
bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
Definition: Group.c:30
void ext2_free_group_desc(PEXT2_FILESYS pExt2Sys)
Definition: Group.c:61
bool ext2_add_entry(PEXT2_FILESYS pExt2Sys, ULONG parent, ULONG inode, int filetype, char *name)
Definition: Inode.c:619
struct _ext2_filesys EXT2_FILESYS
bool ext2_write_bitmaps(PEXT2_FILESYS fs)
Definition: Bitmap.c:342
bool ext2_read_inode_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:482
bool ext2_reserve_inodes(PEXT2_FILESYS fs)
Definition: Inode.c:681
bool ext2_read_block(PEXT2_FILESYS fs, ULONG block, void *inbuf)
Definition: Memory.c:406
EXT2_BITMAP * PEXT2_INODE_BITMAP
Definition: Mke2fs.h:125
bool ext2_expand_inode(PEXT2_FILESYS pExt2Sys, PEXT2_INODE, ULONG newBlk)
Definition: Inode.c:212
struct ext2_acl_entry * PEXT2_ACL_ENTRY
Definition: Mke2fs.h:128
struct ext2_super_block * PEXT2_SUPER_BLOCK
Definition: Mke2fs.h:137
bool ext2_mark_bitmap(PEXT2_BITMAP bitmap, ULONG bitno)
Definition: Bitmap.c:52
bool ext2_get_free_blocks(PEXT2_FILESYS fs, ULONG start, ULONG finish, int num, PEXT2_BLOCK_BITMAP map, ULONG *ret)
Definition: Memory.c:182
LONGLONG ext2_nt_time(ULONG i_time)
bool ext2_read_inode(PEXT2_FILESYS pExt2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
Definition: Inode.c:494
bool ext2_clear_bit(int nr, void *addr)
Definition: Bitmap.c:30
bool ext2_unmark_bitmap(PEXT2_BITMAP bitmap, ULONG bitno)
Definition: Bitmap.c:62
bool ext2_allocate_inode_bitmap(PEXT2_FILESYS pExt2Sys)
Definition: Bitmap.c:140
void ext2_inode_alloc_stats(PEXT2_FILESYS fs, ULONG ino, int inuse)
Definition: Memory.c:56
bool ext2_save_inode(PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:59
EXT2_BITMAP * PEXT2_BLOCK_BITMAP
Definition: Mke2fs.h:126
bool ext2_allocate_tables(PEXT2_FILESYS pExt2Sys)
Definition: Memory.c:75
struct ext2_acl_header * PEXT2_ACL_HEADER
Definition: Mke2fs.h:129
bool ext2_write_block(PEXT2_FILESYS fs, ULONG block, void *inbuf)
Definition: Memory.c:394
struct ext2_dx_entry * PEXT2_DX_ENTRY
Definition: Mke2fs.h:133
struct _EXT2_BDL EXT2_BDL
bool ext2_new_dir_block(PEXT2_FILESYS fs, ULONG dir_ino, ULONG parent_ino, char **block)
Definition: Memory.c:349
bool ext2_alloc_block(PEXT2_FILESYS fs, ULONG goal, ULONG *ret)
Definition: Memory.c:293
bool ext2_load_inode(PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:41
ULONG Ext2TotalBlocks(PEXT2_FILESYS Ext2Sys, ULONG DataBlocks)
Definition: Mke2fs.c:750
bool ext2_write_inode_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:216
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
struct _GUID GUID
struct _ext2_filesys * PEXT2_FILESYS
NTSTATUS Ext2UnLockVolume(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1237
void ext2_free_inode_bitmap(PEXT2_FILESYS pExt2Sys)
Definition: Bitmap.c:194
ULONG ext2_unix_time(LONGLONG n_time)
ULONG Ext2DataBlocks(PEXT2_FILESYS Ext2Sys, ULONG TotalBlocks)
Definition: Mke2fs.c:698
bool ext2_allocate_group_desc(PEXT2_FILESYS pExt2Sys)
Definition: Group.c:43
struct ext2_struct_badblocks_list * PEXT2_BADBLK_LIST
Definition: Mke2fs.h:149
bool ext2_new_inode(PEXT2_FILESYS fs, ULONG dir, int mode, PEXT2_INODE_BITMAP map, ULONG *ret)
Definition: Inode.c:84
NTSTATUS Ext2LockVolume(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1212
bool write_inode_tables(PEXT2_FILESYS fs)
Definition: Memory.c:221
NTSTATUS Ext2CloseDevice(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1342
struct _ext2fs_bitmap EXT2_BITMAP
static int argc
Definition: ServiceArgs.c:12
static int inbuf
Definition: adnsresfilter.c:73
unsigned int dir
Definition: maze.c:112
LONG NTSTATUS
Definition: precomp.h:26
u8 __u8
Definition: btrfs.h:17
u32 __u32
Definition: btrfs.h:19
Definition: bufpool.h:45
Definition: _map.h:48
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
r parent
Definition: btrfs.c:3010
ULONGLONG bmap(struct inode *i, ULONGLONG b)
Definition: linux.c:942
GLuint start
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLenum mode
Definition: glext.h:6217
GLboolean GLuint group
Definition: glext.h:11120
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint GLuint num
Definition: glext.h:9618
GLintptr offset
Definition: glext.h:5920
Definition: msctf.idl:550
#define blk
Definition: linetest.c:70
ULONG nr
Definition: thread.c:7
#define argv
Definition: mplay32.c:18
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
LOCAL char * filetype(int t)
Definition: tree.c:114
#define finish()
Definition: seh0024.c:15
ULONG Length
Definition: Mke2fs.h:194
ULONG Offset
Definition: Mke2fs.h:193
LONGLONG Lba
Definition: Mke2fs.h:192
Definition: scsiwmi.h:51
unsigned char Data4[8]
Definition: scsiwmi.h:55
unsigned long Data1
Definition: scsiwmi.h:52
unsigned short Data2
Definition: scsiwmi.h:53
unsigned short Data3
Definition: scsiwmi.h:54
PEXT2_SUPER_BLOCK ext2_sb
Definition: Mke2fs.h:159
DISK_GEOMETRY DiskGeometry
Definition: Mke2fs.h:184
__u32 umask
Definition: Mke2fs.h:170
void * priv_data
Definition: Mke2fs.h:180
unsigned long inode_blocks_per_group
Definition: Mke2fs.h:160
PARTITION_INFORMATION PartInfo
Definition: Mke2fs.h:186
PEXT2_BLOCK_BITMAP block_map
Definition: Mke2fs.h:162
PEXT2_INODE_BITMAP inode_map
Definition: Mke2fs.h:161
ULONG group_desc_count
Definition: Mke2fs.h:156
int blocksize
Definition: Mke2fs.h:154
EXT2_BADBLK_LIST badblocks
Definition: Mke2fs.h:164
__u32 stride
Definition: Mke2fs.h:168
unsigned long desc_blocks
Definition: Mke2fs.h:157
__u32 reserved[8]
Definition: Mke2fs.h:175
HANDLE MediaHandle
Definition: Mke2fs.h:182
int fragsize
Definition: Mke2fs.h:155
PEXT2_GROUP_DESC group_desc
Definition: Mke2fs.h:158
__u32 end
Definition: Mke2fs.h:119
__u32 real_end
Definition: Mke2fs.h:120
__u32 start
Definition: Mke2fs.h:119
char * bitmap
Definition: Mke2fs.h:121
Definition: uimain.c:89
Definition: ext2_fs.h:135
Definition: ext2_fs.h:505
Definition: ext2_fs.h:492
Definition: ext2_fs.h:168
Definition: ext3_fs.h:774
Definition: ffs.h:70
Definition: fs.h:78
Definition: name.c:39
uint32_t * PULONG
Definition: typedefs.h:59
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
int ret
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
static unsigned int block
Definition: xmlmemory.c:101