ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

Mke2fs.h
Go to the documentation of this file.
00001 /*
00002  * PROJECT:          Mke2fs
00003  * FILE:             Mke2fs.h
00004  * PROGRAMMER:       Matt Wu <mattwu@163.com>
00005  * HOMEPAGE:         http://ext2.yeah.net
00006  */
00007 
00008 /* INCLUDES **************************************************************/
00009 
00010 #define WIN32_NO_STATUS
00011 #include <windows.h>
00012 #define NTOS_MODE_USER
00013 #include <ndk/iofuncs.h>
00014 #include <ndk/kefuncs.h>
00015 #include <ndk/obfuncs.h>
00016 #include <ndk/rtlfuncs.h>
00017 #include <fmifs/fmifs.h>
00018 
00019 #include "string.h"
00020 #include "ctype.h"
00021 
00022 #include "types.h"
00023 #include "ext2_fs.h"
00024 
00025 #include "getopt.h"
00026 
00027 /* DEFINITIONS ***********************************************************/
00028 
00029 #define SECTOR_SIZE (Ext2Sys->DiskGeometry.BytesPerSector)
00030 
00031 #ifndef GUID_DEFINED
00032 #define GUID_DEFINED
00033 typedef struct _GUID
00034 {
00035     unsigned long  Data1;
00036     unsigned short Data2;
00037     unsigned short Data3;
00038     unsigned char  Data4[8];
00039 } GUID;
00040 #endif /* GUID_DEFINED */
00041 
00042 #ifndef UUID_DEFINED
00043 #define UUID_DEFINED
00044 typedef GUID UUID;
00045 #ifndef uuid_t
00046 #define uuid_t UUID
00047 #endif
00048 #endif
00049 
00050 #ifndef bool
00051 #define bool    BOOLEAN
00052 #endif
00053 
00054 #ifndef true
00055 #define true    TRUE
00056 #endif
00057 
00058 #ifndef false
00059 #define false   FALSE
00060 #endif
00061 
00062 
00063 #define EXT2_CHECK_MAGIC(struct, code) \
00064       if ((struct)->magic != (code)) return (code)
00065 
00066 /*
00067  * ext2fs_scan flags
00068  */
00069 #define EXT2_SF_CHK_BADBLOCKS   0x0001
00070 #define EXT2_SF_BAD_INODE_BLK   0x0002
00071 #define EXT2_SF_BAD_EXTRA_BYTES 0x0004
00072 #define EXT2_SF_SKIP_MISSING_ITABLE 0x0008
00073 
00074 /*
00075  * ext2fs_check_if_mounted flags
00076  */
00077 #define EXT2_MF_MOUNTED     1
00078 #define EXT2_MF_ISROOT      2
00079 #define EXT2_MF_READONLY    4
00080 #define EXT2_MF_SWAP        8
00081 
00082 /*
00083  * Ext2/linux mode flags.  We define them here so that we don't need
00084  * to depend on the OS's sys/stat.h, since we may be compiling on a
00085  * non-Linux system.
00086  */
00087 
00088 #define LINUX_S_IFMT  00170000
00089 #define LINUX_S_IFSOCK 0140000
00090 #define LINUX_S_IFLNK    0120000
00091 #define LINUX_S_IFREG  0100000
00092 #define LINUX_S_IFBLK  0060000
00093 #define LINUX_S_IFDIR  0040000
00094 #define LINUX_S_IFCHR  0020000
00095 #define LINUX_S_IFIFO  0010000
00096 #define LINUX_S_ISUID  0004000
00097 #define LINUX_S_ISGID  0002000
00098 #define LINUX_S_ISVTX  0001000
00099 
00100 #define LINUX_S_IRWXU 00700
00101 #define LINUX_S_IRUSR 00400
00102 #define LINUX_S_IWUSR 00200
00103 #define LINUX_S_IXUSR 00100
00104 
00105 #define LINUX_S_IRWXG 00070
00106 #define LINUX_S_IRGRP 00040
00107 #define LINUX_S_IWGRP 00020
00108 #define LINUX_S_IXGRP 00010
00109 
00110 #define LINUX_S_IRWXO 00007
00111 #define LINUX_S_IROTH 00004
00112 #define LINUX_S_IWOTH 00002
00113 #define LINUX_S_IXOTH 00001
00114 
00115 #define LINUX_S_ISLNK(m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
00116 #define LINUX_S_ISREG(m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
00117 #define LINUX_S_ISDIR(m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
00118 #define LINUX_S_ISCHR(m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
00119 #define LINUX_S_ISBLK(m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
00120 #define LINUX_S_ISFIFO(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
00121 #define LINUX_S_ISSOCK(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
00122 
00123 
00124 #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
00125 
00126 typedef struct _ext2fs_bitmap {
00127     __u32       start, end;
00128     __u32       real_end;
00129     char*       bitmap;
00130 } EXT2_BITMAP, *PEXT2_BITMAP;
00131 
00132 typedef EXT2_BITMAP EXT2_GENERIC_BITMAP, *PEXT2_GENERIC_BITMAP;
00133 typedef EXT2_BITMAP EXT2_INODE_BITMAP, *PEXT2_INODE_BITMAP;
00134 typedef EXT2_BITMAP EXT2_BLOCK_BITMAP, *PEXT2_BLOCK_BITMAP;
00135 
00136 typedef struct ext2_acl_entry   EXT2_ACL_ENTRY, *PEXT2_ACL_ENTRY;
00137 typedef struct ext2_acl_header  EXT2_ACL_HEADER, *PEXT2_ACL_HEADER;
00138 typedef struct ext2_dir_entry   EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
00139 typedef struct ext2_dir_entry_2 EXT2_DIR_ENTRY2, *PEXT2_DIR_ENTRY2;
00140 typedef struct ext2_dx_countlimit   EXT2_DX_CL, *PEXT2_DX_CL;
00141 typedef struct ext2_dx_entry    EXT2_DX_ENTRY, *PEXT2_DX_ENTRY;
00142 typedef struct ext2_dx_root_info    EXT2_DX_RI, *PEXT2_DX_RI;
00143 typedef struct ext2_inode   EXT2_INODE, *PEXT2_INODE;
00144 typedef struct ext2_group_desc  EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
00145 typedef struct ext2_super_block EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
00146 
00147 /*
00148  * Badblocks list
00149  */
00150 struct ext2_struct_badblocks_list {
00151     int     num;
00152     int     size;
00153     ULONG   *list;
00154     int     badblocks_flags;
00155 };
00156 
00157 typedef struct ext2_struct_badblocks_list EXT2_BADBLK_LIST, *PEXT2_BADBLK_LIST;
00158 
00159 typedef struct _ext2_filesys
00160 {
00161     int                 flags;
00162     int                 blocksize;
00163     int                 fragsize;
00164     ULONG               group_desc_count;
00165     unsigned long       desc_blocks;
00166     PEXT2_GROUP_DESC    group_desc;
00167     PEXT2_SUPER_BLOCK   ext2_sb;
00168     unsigned long       inode_blocks_per_group;
00169     PEXT2_INODE_BITMAP  inode_map;
00170     PEXT2_BLOCK_BITMAP  block_map;
00171 
00172     EXT2_BADBLK_LIST    badblocks;
00173 /*
00174     ext2_dblist         dblist;
00175 */
00176     __u32               stride; /* for mke2fs */
00177 
00178     __u32               umask;
00179 
00180     /*
00181      * Reserved for future expansion
00182      */
00183     __u32               reserved[8];
00184 
00185     /*
00186      * Reserved for the use of the calling application.
00187      */
00188     void *              priv_data;
00189 
00190     HANDLE              MediaHandle;
00191 
00192     DISK_GEOMETRY       DiskGeometry;
00193 
00194     PARTITION_INFORMATION   PartInfo;
00195 
00196 } EXT2_FILESYS, *PEXT2_FILESYS;
00197 
00198 // Block Description List
00199 typedef struct _EXT2_BDL {
00200     LONGLONG    Lba;
00201     ULONG       Offset;
00202     ULONG       Length;
00203 } EXT2_BDL, *PEXT2_BDL;
00204 
00205 /*
00206  * Where the master copy of the superblock is located, and how big
00207  * superblocks are supposed to be.  We define SUPERBLOCK_SIZE because
00208  * the size of the superblock structure is not necessarily trustworthy
00209  * (some versions have the padding set up so that the superblock is
00210  * 1032 bytes long).
00211  */
00212 #define SUPERBLOCK_OFFSET   1024
00213 #define SUPERBLOCK_SIZE     1024
00214 
00215 
00216 bool create_bad_block_inode(PEXT2_FILESYS fs, PEXT2_BADBLK_LIST bb_list);
00217 
00218 
00219 /*
00220  *  Bitmap.c
00221  */
00222 
00223 #define ext2_mark_block_bitmap ext2_mark_bitmap
00224 #define ext2_mark_inode_bitmap ext2_mark_bitmap
00225 #define ext2_unmark_block_bitmap ext2_unmark_bitmap
00226 #define ext2_unmark_inode_bitmap ext2_unmark_bitmap
00227 
00228 bool ext2_set_bit(int nr, void * addr);
00229 bool ext2_clear_bit(int nr, void * addr);
00230 bool ext2_test_bit(int nr, void * addr);
00231 
00232 bool ext2_mark_bitmap(PEXT2_BITMAP bitmap, ULONG bitno);
00233 bool ext2_unmark_bitmap(PEXT2_BITMAP bitmap, ULONG bitno);
00234 
00235 bool ext2_test_block_bitmap(PEXT2_BLOCK_BITMAP bitmap,
00236                         ULONG block);
00237 
00238 bool ext2_test_block_bitmap_range(PEXT2_BLOCK_BITMAP bitmap,
00239                         ULONG block, int num);
00240 
00241 bool ext2_test_inode_bitmap(PEXT2_BLOCK_BITMAP bitmap,
00242                         ULONG inode);
00243 
00244 
00245 bool ext2_allocate_block_bitmap(PEXT2_FILESYS pExt2Sys);
00246 bool ext2_allocate_inode_bitmap(PEXT2_FILESYS pExt2Sys);
00247 void ext2_free_inode_bitmap(PEXT2_FILESYS pExt2Sys);
00248 void ext2_free_block_bitmap(PEXT2_FILESYS pExt2Sys);
00249 
00250 bool ext2_write_block_bitmap (PEXT2_FILESYS fs);
00251 bool ext2_write_inode_bitmap (PEXT2_FILESYS fs);
00252 
00253 bool ext2_write_bitmaps(PEXT2_FILESYS fs);
00254 
00255 //bool read_bitmaps(PEXT2_FILESYS fs, int do_inode, int do_block);
00256 bool ext2_read_inode_bitmap (PEXT2_FILESYS fs);
00257 bool ext2_read_block_bitmap(PEXT2_FILESYS fs);
00258 bool ext2_read_bitmaps(PEXT2_FILESYS fs);
00259 
00260 
00261 /*
00262  *  Disk.c
00263  */
00264 
00265 NTSTATUS
00266 Ext2OpenDevice( PEXT2_FILESYS    Ext2Sys,
00267                 PUNICODE_STRING  DeviceName );
00268 
00269 NTSTATUS
00270 Ext2CloseDevice( PEXT2_FILESYS  Ext2Sys);
00271 
00272 NTSTATUS 
00273 Ext2ReadDisk( PEXT2_FILESYS  Ext2Sys,
00274               ULONGLONG      Offset,
00275               ULONG          Length,
00276               PVOID          Buffer     );
00277 
00278 NTSTATUS
00279 Ext2WriteDisk( PEXT2_FILESYS  Ext2Sys,
00280                ULONGLONG      Offset,
00281                ULONG          Length,
00282                PVOID          Buffer );
00283 
00284 NTSTATUS
00285 Ext2GetMediaInfo( PEXT2_FILESYS Ext2Sys );
00286 
00287 
00288 NTSTATUS
00289 Ext2LockVolume( PEXT2_FILESYS Ext2Sys );
00290 
00291 NTSTATUS
00292 Ext2UnLockVolume( PEXT2_FILESYS Ext2Sys );
00293 
00294 NTSTATUS
00295 Ext2DisMountVolume( PEXT2_FILESYS Ext2Sys );
00296 
00297 
00298 /*
00299  *  Group.c
00300  */
00301 
00302 bool ext2_allocate_group_desc(PEXT2_FILESYS pExt2Sys);
00303 void ext2_free_group_desc(PEXT2_FILESYS pExt2Sys);
00304 bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block);
00305 
00306 /*
00307  *  Inode.c
00308  */
00309 
00310 bool ext2_get_inode_lba(PEXT2_FILESYS pExt2Sys, ULONG no, LONGLONG *offset);
00311 bool ext2_load_inode(PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode);
00312 bool ext2_save_inode(PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode);
00313 bool ext2_new_inode(PEXT2_FILESYS fs, ULONG dir, int mode,
00314                       PEXT2_INODE_BITMAP map, ULONG *ret);
00315 bool ext2_expand_inode(PEXT2_FILESYS pExt2Sys, PEXT2_INODE, ULONG newBlk);
00316 
00317 bool ext2_read_inode (PEXT2_FILESYS pExt2Sys,
00318             ULONG               ino,
00319             ULONG               offset,
00320             PVOID               Buffer,
00321             ULONG               size,
00322             PULONG              dwReturn );
00323 bool ext2_write_inode (PEXT2_FILESYS pExt2Sys,
00324             ULONG               ino,
00325             ULONG               offset,
00326             PVOID               Buffer,
00327             ULONG               size,
00328             PULONG              dwReturn );
00329 
00330 bool ext2_add_entry(PEXT2_FILESYS pExt2Sys, ULONG parent, ULONG inode, int filetype, char *name);
00331 bool ext2_reserve_inodes(PEXT2_FILESYS fs);
00332 /*
00333  *  Memory.c
00334  */
00335 
00336 //
00337 // Return the group # of an inode number
00338 //
00339 int ext2_group_of_ino(PEXT2_FILESYS fs, ULONG ino);
00340 
00341 //
00342 // Return the group # of a block
00343 //
00344 int ext2_group_of_blk(PEXT2_FILESYS fs, ULONG blk);
00345 
00346 /*
00347  *  Badblock.c
00348  */
00349 
00350 
00351 void ext2_inode_alloc_stats2(PEXT2_FILESYS fs, ULONG ino, int inuse, int isdir);
00352 void ext2_inode_alloc_stats(PEXT2_FILESYS fs, ULONG ino, int inuse);
00353 void ext2_block_alloc_stats(PEXT2_FILESYS fs, ULONG blk, int inuse);
00354 
00355 bool ext2_allocate_tables(PEXT2_FILESYS pExt2Sys);
00356 bool ext2_allocate_group_table(PEXT2_FILESYS fs, ULONG group,
00357                       PEXT2_BLOCK_BITMAP bmap);
00358 bool ext2_get_free_blocks(PEXT2_FILESYS fs, ULONG start, ULONG finish,
00359                  int num, PEXT2_BLOCK_BITMAP map, ULONG *ret);
00360 bool write_inode_tables(PEXT2_FILESYS fs);
00361 
00362 bool ext2_new_block(PEXT2_FILESYS fs, ULONG goal,
00363                PEXT2_BLOCK_BITMAP map, ULONG *ret);
00364 bool ext2_alloc_block(PEXT2_FILESYS fs, ULONG goal, ULONG *ret);
00365 bool ext2_new_dir_block(PEXT2_FILESYS fs, ULONG dir_ino,
00366                    ULONG parent_ino, char **block);
00367 bool ext2_write_block(PEXT2_FILESYS fs, ULONG block, void *inbuf);
00368 bool ext2_read_block(PEXT2_FILESYS fs, ULONG block, void *inbuf);
00369 
00370 /*
00371  *  Mke2fs.c
00372  */
00373 
00374 bool parase_cmd(int argc, char *argv[], PEXT2_FILESYS pExt2Sys);
00375 
00376 bool zero_blocks(PEXT2_FILESYS fs, ULONG blk, ULONG num,
00377                  ULONG *ret_blk, ULONG *ret_count);
00378 
00379 ULONG
00380 Ext2DataBlocks(PEXT2_FILESYS Ext2Sys, ULONG TotalBlocks);
00381 
00382 ULONG
00383 Ext2TotalBlocks(PEXT2_FILESYS Ext2Sys, ULONG DataBlocks);
00384 
00385 
00386 
00387 /*
00388  *  Super.c
00389  */
00390 
00391 void ext2_print_super(PEXT2_SUPER_BLOCK pExt2Sb);
00392 bool ext2_initialize_sb(PEXT2_FILESYS pExt2Sys);
00393 
00394 
00395 /*
00396  *  Super.c
00397  */
00398 
00399 LONGLONG ext2_nt_time (ULONG i_time);
00400 ULONG ext2_unix_time (LONGLONG n_time);
00401 
00402 /*
00403  *  Uuid.c
00404  */
00405 
00406 void uuid_generate(__u8 * uuid);

Generated on Fri May 25 2012 04:34:40 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.