ReactOS  0.4.14-dev-323-g6fe6a88
Mke2fs.h File Reference
#include <ndk/kefuncs.h>
#include <ndk/rtlfuncs.h>
#include "ext2_fs.h"
Include dependency graph for Mke2fs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GUID
 
struct  _ext2fs_bitmap
 
struct  ext2_struct_badblocks_list
 
struct  _ext2_filesys
 
struct  _EXT2_BDL
 

Macros

#define NTOS_MODE_USER
 
#define SECTOR_SIZE   (Ext2Sys->DiskGeometry.BytesPerSector)
 
#define GUID_DEFINED
 
#define UUID_DEFINED
 
#define uuid_t   UUID
 
#define bool   BOOLEAN
 
#define true   TRUE
 
#define false   FALSE
 
#define EXT2_CHECK_MAGIC(struct, code)   if ((struct)->magic != (code)) return (code)
 
#define EXT2_SF_CHK_BADBLOCKS   0x0001
 
#define EXT2_SF_BAD_INODE_BLK   0x0002
 
#define EXT2_SF_BAD_EXTRA_BYTES   0x0004
 
#define EXT2_SF_SKIP_MISSING_ITABLE   0x0008
 
#define EXT2_MF_MOUNTED   1
 
#define EXT2_MF_ISROOT   2
 
#define EXT2_MF_READONLY   4
 
#define EXT2_MF_SWAP   8
 
#define LINUX_S_IFMT   00170000
 
#define LINUX_S_IFSOCK   0140000
 
#define LINUX_S_IFLNK   0120000
 
#define LINUX_S_IFREG   0100000
 
#define LINUX_S_IFBLK   0060000
 
#define LINUX_S_IFDIR   0040000
 
#define LINUX_S_IFCHR   0020000
 
#define LINUX_S_IFIFO   0010000
 
#define LINUX_S_ISUID   0004000
 
#define LINUX_S_ISGID   0002000
 
#define LINUX_S_ISVTX   0001000
 
#define LINUX_S_IRWXU   00700
 
#define LINUX_S_IRUSR   00400
 
#define LINUX_S_IWUSR   00200
 
#define LINUX_S_IXUSR   00100
 
#define LINUX_S_IRWXG   00070
 
#define LINUX_S_IRGRP   00040
 
#define LINUX_S_IWGRP   00020
 
#define LINUX_S_IXGRP   00010
 
#define LINUX_S_IRWXO   00007
 
#define LINUX_S_IROTH   00004
 
#define LINUX_S_IWOTH   00002
 
#define LINUX_S_IXOTH   00001
 
#define LINUX_S_ISLNK(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
 
#define LINUX_S_ISREG(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
 
#define LINUX_S_ISDIR(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
 
#define LINUX_S_ISCHR(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
 
#define LINUX_S_ISBLK(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
 
#define LINUX_S_ISFIFO(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
 
#define LINUX_S_ISSOCK(m)   (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
 
#define EXT2_FIRST_INODE(s)   EXT2_FIRST_INO(s)
 
#define SUPERBLOCK_OFFSET   1024
 
#define SUPERBLOCK_SIZE   1024
 
#define ext2_mark_block_bitmap   ext2_mark_bitmap
 
#define ext2_mark_inode_bitmap   ext2_mark_bitmap
 
#define ext2_unmark_block_bitmap   ext2_unmark_bitmap
 
#define ext2_unmark_inode_bitmap   ext2_unmark_bitmap
 

Typedefs

typedef struct _GUID GUID
 
typedef GUID UUID
 
typedef struct _ext2fs_bitmap EXT2_BITMAP
 
typedef struct _ext2fs_bitmapPEXT2_BITMAP
 
typedef EXT2_BITMAP EXT2_GENERIC_BITMAP
 
typedef EXT2_BITMAPPEXT2_GENERIC_BITMAP
 
typedef EXT2_BITMAP EXT2_INODE_BITMAP
 
typedef EXT2_BITMAPPEXT2_INODE_BITMAP
 
typedef EXT2_BITMAP EXT2_BLOCK_BITMAP
 
typedef EXT2_BITMAPPEXT2_BLOCK_BITMAP
 
typedef struct ext2_acl_entry EXT2_ACL_ENTRY
 
typedef struct ext2_acl_entryPEXT2_ACL_ENTRY
 
typedef struct ext2_acl_header EXT2_ACL_HEADER
 
typedef struct ext2_acl_headerPEXT2_ACL_HEADER
 
typedef struct ext2_dir_entry EXT2_DIR_ENTRY
 
typedef struct ext2_dir_entryPEXT2_DIR_ENTRY
 
typedef struct ext2_dir_entry_2 EXT2_DIR_ENTRY2
 
typedef struct ext2_dir_entry_2PEXT2_DIR_ENTRY2
 
typedef struct ext2_dx_countlimit EXT2_DX_CL
 
typedef struct ext2_dx_countlimitPEXT2_DX_CL
 
typedef struct ext2_dx_entry EXT2_DX_ENTRY
 
typedef struct ext2_dx_entryPEXT2_DX_ENTRY
 
typedef struct ext2_dx_root_info EXT2_DX_RI
 
typedef struct ext2_dx_root_infoPEXT2_DX_RI
 
typedef struct ext2_inode EXT2_INODE
 
typedef struct ext2_inodePEXT2_INODE
 
typedef struct ext2_group_desc EXT2_GROUP_DESC
 
typedef struct ext2_group_descPEXT2_GROUP_DESC
 
typedef struct ext2_super_block EXT2_SUPER_BLOCK
 
typedef struct ext2_super_blockPEXT2_SUPER_BLOCK
 
typedef struct ext2_struct_badblocks_list EXT2_BADBLK_LIST
 
typedef struct ext2_struct_badblocks_listPEXT2_BADBLK_LIST
 
typedef struct _ext2_filesys EXT2_FILESYS
 
typedef struct _ext2_filesysPEXT2_FILESYS
 
typedef struct _EXT2_BDL EXT2_BDL
 
typedef struct _EXT2_BDLPEXT2_BDL
 

Functions

bool create_bad_block_inode (PEXT2_FILESYS fs, PEXT2_BADBLK_LIST bb_list)
 
bool ext2_set_bit (int nr, void *addr)
 
bool ext2_clear_bit (int nr, void *addr)
 
bool ext2_test_bit (int nr, void *addr)
 
bool ext2_mark_bitmap (PEXT2_BITMAP bitmap, ULONG bitno)
 
bool ext2_unmark_bitmap (PEXT2_BITMAP bitmap, ULONG bitno)
 
bool ext2_test_block_bitmap (PEXT2_BLOCK_BITMAP bitmap, ULONG block)
 
bool ext2_test_block_bitmap_range (PEXT2_BLOCK_BITMAP bitmap, ULONG block, int num)
 
bool ext2_test_inode_bitmap (PEXT2_BLOCK_BITMAP bitmap, ULONG inode)
 
bool ext2_allocate_block_bitmap (PEXT2_FILESYS pExt2Sys)
 
bool ext2_allocate_inode_bitmap (PEXT2_FILESYS pExt2Sys)
 
void ext2_free_inode_bitmap (PEXT2_FILESYS pExt2Sys)
 
void ext2_free_block_bitmap (PEXT2_FILESYS pExt2Sys)
 
bool ext2_write_block_bitmap (PEXT2_FILESYS fs)
 
bool ext2_write_inode_bitmap (PEXT2_FILESYS fs)
 
bool ext2_write_bitmaps (PEXT2_FILESYS fs)
 
bool ext2_read_inode_bitmap (PEXT2_FILESYS fs)
 
bool ext2_read_block_bitmap (PEXT2_FILESYS fs)
 
bool ext2_read_bitmaps (PEXT2_FILESYS fs)
 
NTSTATUS Ext2OpenDevice (PEXT2_FILESYS Ext2Sys, PUNICODE_STRING DeviceName)
 
NTSTATUS Ext2CloseDevice (PEXT2_FILESYS Ext2Sys)
 
NTSTATUS Ext2ReadDisk (PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
 
NTSTATUS Ext2WriteDisk (PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
 
NTSTATUS Ext2GetMediaInfo (PEXT2_FILESYS Ext2Sys)
 
NTSTATUS Ext2LockVolume (PEXT2_FILESYS Ext2Sys)
 
NTSTATUS Ext2UnLockVolume (PEXT2_FILESYS Ext2Sys)
 
NTSTATUS Ext2DisMountVolume (PEXT2_FILESYS Ext2Sys)
 
bool ext2_allocate_group_desc (PEXT2_FILESYS pExt2Sys)
 
void ext2_free_group_desc (PEXT2_FILESYS pExt2Sys)
 
bool ext2_bg_has_super (PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
 
bool ext2_get_inode_lba (PEXT2_FILESYS pExt2Sys, ULONG no, LONGLONG *offset)
 
bool ext2_load_inode (PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode)
 
bool ext2_save_inode (PEXT2_FILESYS pExt2Sys, ULONG no, PEXT2_INODE pInode)
 
bool ext2_new_inode (PEXT2_FILESYS fs, ULONG dir, int mode, PEXT2_INODE_BITMAP map, ULONG *ret)
 
bool ext2_expand_inode (PEXT2_FILESYS pExt2Sys, PEXT2_INODE, ULONG newBlk)
 
bool ext2_read_inode (PEXT2_FILESYS pExt2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
 
bool ext2_write_inode (PEXT2_FILESYS pExt2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
 
bool ext2_add_entry (PEXT2_FILESYS pExt2Sys, ULONG parent, ULONG inode, int filetype, char *name)
 
bool ext2_reserve_inodes (PEXT2_FILESYS fs)
 
int ext2_group_of_ino (PEXT2_FILESYS fs, ULONG ino)
 
int ext2_group_of_blk (PEXT2_FILESYS fs, ULONG blk)
 
void ext2_inode_alloc_stats2 (PEXT2_FILESYS fs, ULONG ino, int inuse, int isdir)
 
void ext2_inode_alloc_stats (PEXT2_FILESYS fs, ULONG ino, int inuse)
 
void ext2_block_alloc_stats (PEXT2_FILESYS fs, ULONG blk, int inuse)
 
bool ext2_allocate_tables (PEXT2_FILESYS pExt2Sys)
 
bool ext2_allocate_group_table (PEXT2_FILESYS fs, ULONG group, PEXT2_BLOCK_BITMAP bmap)
 
bool ext2_get_free_blocks (PEXT2_FILESYS fs, ULONG start, ULONG finish, int num, PEXT2_BLOCK_BITMAP map, ULONG *ret)
 
bool write_inode_tables (PEXT2_FILESYS fs)
 
bool ext2_new_block (PEXT2_FILESYS fs, ULONG goal, PEXT2_BLOCK_BITMAP map, ULONG *ret)
 
bool ext2_alloc_block (PEXT2_FILESYS fs, ULONG goal, ULONG *ret)
 
bool ext2_new_dir_block (PEXT2_FILESYS fs, ULONG dir_ino, ULONG parent_ino, char **block)
 
bool ext2_write_block (PEXT2_FILESYS fs, ULONG block, void *inbuf)
 
bool ext2_read_block (PEXT2_FILESYS fs, ULONG block, void *inbuf)
 
bool parase_cmd (int argc, char *argv[], PEXT2_FILESYS pExt2Sys)
 
bool zero_blocks (PEXT2_FILESYS fs, ULONG blk, ULONG num, ULONG *ret_blk, ULONG *ret_count)
 
ULONG Ext2DataBlocks (PEXT2_FILESYS Ext2Sys, ULONG TotalBlocks)
 
ULONG Ext2TotalBlocks (PEXT2_FILESYS Ext2Sys, ULONG DataBlocks)
 
void ext2_print_super (PEXT2_SUPER_BLOCK pExt2Sb)
 
bool ext2_initialize_sb (PEXT2_FILESYS pExt2Sys)
 
LONGLONG ext2_nt_time (ULONG i_time)
 
ULONG ext2_unix_time (LONGLONG n_time)
 
void uuid_generate (__u8 *uuid)
 

Macro Definition Documentation

◆ bool

#define bool   BOOLEAN

Definition at line 43 of file Mke2fs.h.

◆ EXT2_CHECK_MAGIC

#define EXT2_CHECK_MAGIC (   struct,
  code 
)    if ((struct)->magic != (code)) return (code)

Definition at line 55 of file Mke2fs.h.

◆ EXT2_FIRST_INODE

#define EXT2_FIRST_INODE (   s)    EXT2_FIRST_INO(s)

Definition at line 116 of file Mke2fs.h.

◆ ext2_mark_block_bitmap

#define ext2_mark_block_bitmap   ext2_mark_bitmap

Definition at line 215 of file Mke2fs.h.

◆ ext2_mark_inode_bitmap

#define ext2_mark_inode_bitmap   ext2_mark_bitmap

Definition at line 216 of file Mke2fs.h.

◆ EXT2_MF_ISROOT

#define EXT2_MF_ISROOT   2

Definition at line 70 of file Mke2fs.h.

◆ EXT2_MF_MOUNTED

#define EXT2_MF_MOUNTED   1

Definition at line 69 of file Mke2fs.h.

◆ EXT2_MF_READONLY

#define EXT2_MF_READONLY   4

Definition at line 71 of file Mke2fs.h.

◆ EXT2_MF_SWAP

#define EXT2_MF_SWAP   8

Definition at line 72 of file Mke2fs.h.

◆ EXT2_SF_BAD_EXTRA_BYTES

#define EXT2_SF_BAD_EXTRA_BYTES   0x0004

Definition at line 63 of file Mke2fs.h.

◆ EXT2_SF_BAD_INODE_BLK

#define EXT2_SF_BAD_INODE_BLK   0x0002

Definition at line 62 of file Mke2fs.h.

◆ EXT2_SF_CHK_BADBLOCKS

#define EXT2_SF_CHK_BADBLOCKS   0x0001

Definition at line 61 of file Mke2fs.h.

◆ EXT2_SF_SKIP_MISSING_ITABLE

#define EXT2_SF_SKIP_MISSING_ITABLE   0x0008

Definition at line 64 of file Mke2fs.h.

◆ ext2_unmark_block_bitmap

#define ext2_unmark_block_bitmap   ext2_unmark_bitmap

Definition at line 217 of file Mke2fs.h.

◆ ext2_unmark_inode_bitmap

#define ext2_unmark_inode_bitmap   ext2_unmark_bitmap

Definition at line 218 of file Mke2fs.h.

◆ false

#define false   FALSE

Definition at line 51 of file Mke2fs.h.

◆ GUID_DEFINED

#define GUID_DEFINED

Definition at line 24 of file Mke2fs.h.

◆ LINUX_S_IFBLK

#define LINUX_S_IFBLK   0060000

Definition at line 84 of file Mke2fs.h.

◆ LINUX_S_IFCHR

#define LINUX_S_IFCHR   0020000

Definition at line 86 of file Mke2fs.h.

◆ LINUX_S_IFDIR

#define LINUX_S_IFDIR   0040000

Definition at line 85 of file Mke2fs.h.

◆ LINUX_S_IFIFO

#define LINUX_S_IFIFO   0010000

Definition at line 87 of file Mke2fs.h.

◆ LINUX_S_IFLNK

#define LINUX_S_IFLNK   0120000

Definition at line 82 of file Mke2fs.h.

◆ LINUX_S_IFMT

#define LINUX_S_IFMT   00170000

Definition at line 80 of file Mke2fs.h.

◆ LINUX_S_IFREG

#define LINUX_S_IFREG   0100000

Definition at line 83 of file Mke2fs.h.

◆ LINUX_S_IFSOCK

#define LINUX_S_IFSOCK   0140000

Definition at line 81 of file Mke2fs.h.

◆ LINUX_S_IRGRP

#define LINUX_S_IRGRP   00040

Definition at line 98 of file Mke2fs.h.

◆ LINUX_S_IROTH

#define LINUX_S_IROTH   00004

Definition at line 103 of file Mke2fs.h.

◆ LINUX_S_IRUSR

#define LINUX_S_IRUSR   00400

Definition at line 93 of file Mke2fs.h.

◆ LINUX_S_IRWXG

#define LINUX_S_IRWXG   00070

Definition at line 97 of file Mke2fs.h.

◆ LINUX_S_IRWXO

#define LINUX_S_IRWXO   00007

Definition at line 102 of file Mke2fs.h.

◆ LINUX_S_IRWXU

#define LINUX_S_IRWXU   00700

Definition at line 92 of file Mke2fs.h.

◆ LINUX_S_ISBLK

#define LINUX_S_ISBLK (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)

Definition at line 111 of file Mke2fs.h.

◆ LINUX_S_ISCHR

#define LINUX_S_ISCHR (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)

Definition at line 110 of file Mke2fs.h.

◆ LINUX_S_ISDIR

#define LINUX_S_ISDIR (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)

Definition at line 109 of file Mke2fs.h.

◆ LINUX_S_ISFIFO

#define LINUX_S_ISFIFO (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)

Definition at line 112 of file Mke2fs.h.

◆ LINUX_S_ISGID

#define LINUX_S_ISGID   0002000

Definition at line 89 of file Mke2fs.h.

◆ LINUX_S_ISLNK

#define LINUX_S_ISLNK (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)

Definition at line 107 of file Mke2fs.h.

◆ LINUX_S_ISREG

#define LINUX_S_ISREG (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)

Definition at line 108 of file Mke2fs.h.

◆ LINUX_S_ISSOCK

#define LINUX_S_ISSOCK (   m)    (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)

Definition at line 113 of file Mke2fs.h.

◆ LINUX_S_ISUID

#define LINUX_S_ISUID   0004000

Definition at line 88 of file Mke2fs.h.

◆ LINUX_S_ISVTX

#define LINUX_S_ISVTX   0001000

Definition at line 90 of file Mke2fs.h.

◆ LINUX_S_IWGRP

#define LINUX_S_IWGRP   00020

Definition at line 99 of file Mke2fs.h.

◆ LINUX_S_IWOTH

#define LINUX_S_IWOTH   00002

Definition at line 104 of file Mke2fs.h.

◆ LINUX_S_IWUSR

#define LINUX_S_IWUSR   00200

Definition at line 94 of file Mke2fs.h.

◆ LINUX_S_IXGRP

#define LINUX_S_IXGRP   00010

Definition at line 100 of file Mke2fs.h.

◆ LINUX_S_IXOTH

#define LINUX_S_IXOTH   00001

Definition at line 105 of file Mke2fs.h.

◆ LINUX_S_IXUSR

#define LINUX_S_IXUSR   00100

Definition at line 95 of file Mke2fs.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 13 of file Mke2fs.h.

◆ SECTOR_SIZE

#define SECTOR_SIZE   (Ext2Sys->DiskGeometry.BytesPerSector)

Definition at line 21 of file Mke2fs.h.

◆ SUPERBLOCK_OFFSET

#define SUPERBLOCK_OFFSET   1024

Definition at line 204 of file Mke2fs.h.

◆ SUPERBLOCK_SIZE

#define SUPERBLOCK_SIZE   1024

Definition at line 205 of file Mke2fs.h.

◆ true

#define true   TRUE

Definition at line 47 of file Mke2fs.h.

◆ UUID_DEFINED

#define UUID_DEFINED

Definition at line 35 of file Mke2fs.h.

◆ uuid_t

#define uuid_t   UUID

Definition at line 38 of file Mke2fs.h.

Typedef Documentation

◆ EXT2_ACL_ENTRY

Definition at line 128 of file Mke2fs.h.

◆ EXT2_ACL_HEADER

Definition at line 129 of file Mke2fs.h.

◆ EXT2_BADBLK_LIST

Definition at line 149 of file Mke2fs.h.

◆ EXT2_BDL

◆ EXT2_BITMAP

◆ EXT2_BLOCK_BITMAP

Definition at line 126 of file Mke2fs.h.

◆ EXT2_DIR_ENTRY

Definition at line 130 of file Mke2fs.h.

◆ EXT2_DIR_ENTRY2

Definition at line 131 of file Mke2fs.h.

◆ EXT2_DX_CL

Definition at line 132 of file Mke2fs.h.

◆ EXT2_DX_ENTRY

Definition at line 133 of file Mke2fs.h.

◆ EXT2_DX_RI

Definition at line 134 of file Mke2fs.h.

◆ EXT2_FILESYS

◆ EXT2_GENERIC_BITMAP

Definition at line 124 of file Mke2fs.h.

◆ EXT2_GROUP_DESC

Definition at line 136 of file Mke2fs.h.

◆ EXT2_INODE

Definition at line 135 of file Mke2fs.h.

◆ EXT2_INODE_BITMAP

Definition at line 125 of file Mke2fs.h.

◆ EXT2_SUPER_BLOCK

Definition at line 137 of file Mke2fs.h.

◆ GUID

typedef struct _GUID GUID

◆ PEXT2_ACL_ENTRY

Definition at line 128 of file Mke2fs.h.

◆ PEXT2_ACL_HEADER

Definition at line 129 of file Mke2fs.h.

◆ PEXT2_BADBLK_LIST

Definition at line 149 of file Mke2fs.h.

◆ PEXT2_BDL

◆ PEXT2_BITMAP

◆ PEXT2_BLOCK_BITMAP

Definition at line 126 of file Mke2fs.h.

◆ PEXT2_DIR_ENTRY

Definition at line 130 of file Mke2fs.h.

◆ PEXT2_DIR_ENTRY2

Definition at line 131 of file Mke2fs.h.

◆ PEXT2_DX_CL

Definition at line 132 of file Mke2fs.h.

◆ PEXT2_DX_ENTRY

Definition at line 133 of file Mke2fs.h.

◆ PEXT2_DX_RI

Definition at line 134 of file Mke2fs.h.

◆ PEXT2_FILESYS

◆ PEXT2_GENERIC_BITMAP

Definition at line 124 of file Mke2fs.h.

◆ PEXT2_GROUP_DESC

Definition at line 136 of file Mke2fs.h.

◆ PEXT2_INODE

Definition at line 135 of file Mke2fs.h.

◆ PEXT2_INODE_BITMAP

Definition at line 125 of file Mke2fs.h.

◆ PEXT2_SUPER_BLOCK

Definition at line 137 of file Mke2fs.h.

◆ UUID

typedef GUID UUID

Definition at line 36 of file Mke2fs.h.

Function Documentation

◆ create_bad_block_inode()

bool create_bad_block_inode ( PEXT2_FILESYS  fs,
PEXT2_BADBLK_LIST  bb_list 
)

Definition at line 16 of file Badblock.c.

18 {
19  bool retval;
21  LARGE_INTEGER SysTime;
22 
23  NtQuerySystemTime(&SysTime);
24 
25  ext2_mark_inode_bitmap(Ext2Sys->inode_map, EXT2_BAD_INO);
26 
27  Ext2Sys->group_desc[0].bg_free_inodes_count--;
28  Ext2Sys->ext2_sb->s_free_inodes_count--;
29 
30  memset(&inode, 0, sizeof(EXT2_INODE));
31  inode.i_mode = (USHORT)((0777 & ~Ext2Sys->umask));
32  inode.i_uid = inode.i_gid = 0;
33  inode.i_blocks = 0;
34  inode.i_block[0] = 0;
35  inode.i_links_count = 2;
38  inode.i_size = 0;
39 
40  retval = ext2_save_inode(Ext2Sys, EXT2_BAD_INO, &inode);
41 
42  return retval;
43 }
bool ext2_save_inode(PEXT2_FILESYS Ext2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:59
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)
umode_t i_mode
Definition: fs.h:87
__u32 i_atime
Definition: fs.h:81
__u32 i_mtime
Definition: fs.h:83
Definition: fs.h:78
__u32 i_block[15]
Definition: fs.h:86
gid_t i_gid
Definition: fs.h:89
#define EXT2_BAD_INO
Definition: ext2_fs.h:58
__u64 i_blocks
Definition: fs.h:85
__u32 i_ctime
Definition: fs.h:82
loff_t i_size
Definition: fs.h:80
uid_t i_uid
Definition: fs.h:88
#define ext2_mark_inode_bitmap
Definition: Mke2fs.h:216
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:417
#define memset(x, y, z)
Definition: compat.h:39

Referenced by Ext2Format().

◆ ext2_add_entry()

bool ext2_add_entry ( PEXT2_FILESYS  pExt2Sys,
ULONG  parent,
ULONG  inode,
int  filetype,
char name 
)

Definition at line 619 of file Inode.c.

622 {
623  PEXT2_DIR_ENTRY2 dir = NULL, newdir = NULL;
624  EXT2_INODE parent_inode;
625  ULONG dwRet;
626  char *buf;
627  int rec_len;
628  bool bRet = false;
629 
630  rec_len = EXT2_DIR_REC_LEN(strlen(name));
631 
632  if (!ext2_load_inode(Ext2Sys, parent, &parent_inode))
633  {
634  return false;
635  }
636 
637  buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, parent_inode.i_size);
638 
639  if (!ext2_read_inode(Ext2Sys, parent, 0, buf, parent_inode.i_size, &dwRet))
640  {
641  return false;
642  }
643 
645 
646  while ((char *)dir < buf + parent_inode.i_size)
647  {
648  if ((dir->inode == 0 && dir->rec_len >= rec_len) ||
649  (dir->rec_len >= dir->name_len + rec_len) )
650  {
651  if (dir->inode)
652  {
653  newdir = (PEXT2_DIR_ENTRY2) ((PUCHAR)dir + EXT2_DIR_REC_LEN(dir->name_len));
654  newdir->rec_len = dir->rec_len - EXT2_DIR_REC_LEN(dir->name_len);
655 
656  dir->rec_len = EXT2_DIR_REC_LEN(dir->name_len);
657 
658  dir = newdir;
659  }
660 
661  dir->file_type = filetype;
662  dir->inode = inode;
663  dir->name_len = strlen(name);
664  memcpy(dir->name, name, strlen(name));
665 
666  bRet = true;
667  break;
668  }
669 
670  dir = (PEXT2_DIR_ENTRY2) (dir->rec_len + (PUCHAR) dir);
671  }
672 
673 
674  if (bRet)
675  return ext2_write_inode(Ext2Sys, parent, 0, buf, parent_inode.i_size, &dwRet);
676 
677  return bRet;
678 }
__u32 i_size
Definition: ext2_fs.h:227
bool ext2_load_inode(PEXT2_FILESYS Ext2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:41
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: ext3_fs.h:774
unsigned char * PUCHAR
Definition: retypes.h:3
#define EXT2_DIR_REC_LEN(name_len)
Definition: ext2_fs.h:536
Definition: fs.h:78
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
bool ext2_write_inode(PEXT2_FILESYS Ext2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
Definition: Inode.c:541
r parent
Definition: btrfs.c:2869
struct ext3_dir_entry_2 * PEXT2_DIR_ENTRY2
Definition: ext2fs.h:109
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
bool ext2_read_inode(PEXT2_FILESYS Ext2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
Definition: Inode.c:494
Definition: name.c:36
unsigned int ULONG
Definition: retypes.h:1
LOCAL char * filetype(int t)
Definition: tree.c:114

Referenced by ext2_mkdir().

◆ ext2_alloc_block()

bool ext2_alloc_block ( PEXT2_FILESYS  fs,
ULONG  goal,
ULONG ret 
)

Definition at line 293 of file Memory.c.

294 {
295  bool retval;
296  ULONG block;
297  char *buf = NULL;
298 
299  buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, fs->blocksize);
300  if (!buf)
301  return false;
302 
303  if (!fs->block_map)
304  {
305  retval = ext2_read_block_bitmap(fs);
306  if (!retval)
307  goto fail;
308  }
309 
310  retval = ext2_new_block(fs, goal, 0, &block);
311 
312  if (!retval)
313  goto fail;
314 
315  retval = NT_SUCCESS(Ext2WriteDisk(
316  fs,
317  ((LONGLONG)block * fs->blocksize),
318  fs->blocksize, (unsigned char *)buf));
319 
320  if (!retval)
321  {
322  goto fail;
323  }
324 
326  *ret = block;
327 
328  if (buf)
329  {
330  RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
331  }
332 
333  return true;
334 
335 fail:
336 
337  if (buf)
338  {
339  RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
340  }
341 
342  return false;
343 }
static unsigned int block
Definition: xmlmemory.c:118
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
Definition: fs.h:235
void ext2_block_alloc_stats(PEXT2_FILESYS fs, ULONG blk, int inuse)
Definition: Memory.c:61
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
int ret
bool ext2_new_block(PEXT2_FILESYS fs, ULONG goal, PEXT2_BLOCK_BITMAP map, ULONG *ret)
Definition: Memory.c:254
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
bool ext2_read_block_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:487

Referenced by create_lost_and_found(), ext2_expand_block(), ext2_expand_inode(), and ext2_write_inode().

◆ ext2_allocate_block_bitmap()

bool ext2_allocate_block_bitmap ( PEXT2_FILESYS  pExt2Sys)

Definition at line 100 of file Bitmap.c.

101 {
102  ULONG size = 0;
103 
104  PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
105  Ext2Sys->block_map = (PEXT2_BLOCK_BITMAP)
106  RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(EXT2_BLOCK_BITMAP));
107 
108  if (!Ext2Sys->block_map)
109  {
110  DPRINT1("Mke2fs: error allocating block bitmap...\n");
111  return false;
112  }
113 
114  memset(Ext2Sys->block_map, 0, sizeof(EXT2_BLOCK_BITMAP));
115 
116  Ext2Sys->block_map->start = pExt2Sb->s_first_data_block;
117  Ext2Sys->block_map->end = pExt2Sb->s_blocks_count-1;
118  Ext2Sys->block_map->real_end = (EXT2_BLOCKS_PER_GROUP(pExt2Sb)
119  * Ext2Sys->group_desc_count) -1 + Ext2Sys->block_map->start;
120 
121  size = (((Ext2Sys->block_map->real_end - Ext2Sys->block_map->start) / 8) + 1);
122 
123  Ext2Sys->block_map->bitmap =
124  (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
125 
126  if (!Ext2Sys->block_map->bitmap)
127  {
128  RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->block_map);
129  Ext2Sys->block_map = NULL;
130  DPRINT1("Mke2fs: error allocating block bitmap...\n");
131  return false;
132  }
133 
134  memset(Ext2Sys->block_map->bitmap, 0, size);
135 
136  return true;
137 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
EXT2_BITMAP EXT2_BLOCK_BITMAP
Definition: Mke2fs.h:126
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
GLsizeiptr size
Definition: glext.h:5919
EXT2_BITMAP * PEXT2_BLOCK_BITMAP
Definition: Mke2fs.h:126
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define EXT2_BLOCKS_PER_GROUP(s)
Definition: ext2_fs.h:169
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ext2_initialize_sb(), and read_bitmaps().

◆ ext2_allocate_group_desc()

bool ext2_allocate_group_desc ( PEXT2_FILESYS  pExt2Sys)

Definition at line 43 of file Group.c.

44 {
45  ULONG size;
46 
47  size = Ext2Sys->desc_blocks * Ext2Sys->blocksize;
48 
49  Ext2Sys->group_desc =
50  (PEXT2_GROUP_DESC)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
51 
52  if (Ext2Sys->group_desc)
53  {
54  memset(Ext2Sys->group_desc, 0, size);
55  return true;
56  }
57 
58  return false;
59 }
struct ext2_block_group * PEXT2_GROUP_DESC
Definition: ext2.h:173
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
GLsizeiptr size
Definition: glext.h:5919
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ext2_initialize_sb().

◆ ext2_allocate_group_table()

bool ext2_allocate_group_table ( PEXT2_FILESYS  fs,
ULONG  group,
PEXT2_BLOCK_BITMAP  bmap 
)

Definition at line 92 of file Memory.c.

94 {
95  bool retval;
96  ULONG group_blk, start_blk, last_blk, new_blk, blk, j;
97 
98  group_blk = fs->ext2_sb->s_first_data_block +
99  (group * fs->ext2_sb->s_blocks_per_group);
100 
101  last_blk = group_blk + fs->ext2_sb->s_blocks_per_group;
102  if (last_blk >= fs->ext2_sb->s_blocks_count)
103  last_blk = fs->ext2_sb->s_blocks_count - 1;
104 
105  start_blk = group_blk + 3 + fs->desc_blocks;
106  if (start_blk > last_blk)
107  start_blk = group_blk;
108 
109  if (!bmap)
110  bmap = fs->block_map;
111 
112  /*
113  * Allocate the inode table
114  */
115  if (!fs->group_desc[group].bg_inode_table)
116  {
117  retval = ext2_get_free_blocks(fs, start_blk, last_blk,
118  fs->inode_blocks_per_group,
119  bmap, &new_blk);
120  if (!retval)
121  return retval;
122 
123  for (j=0, blk = new_blk;
124  j < fs->inode_blocks_per_group;
125  j++, blk++)
127 
128  fs->group_desc[group].bg_inode_table = new_blk;
129  }
130 
131  /*
132  * Allocate the block and inode bitmaps, if necessary
133  */
134  if (fs->stride)
135  {
136  start_blk += fs->inode_blocks_per_group;
137  start_blk += ((fs->stride * group) %
138  (last_blk - start_blk));
139  if (start_blk > last_blk)
140  /* should never happen */
141  start_blk = group_blk;
142  }
143  else
144  {
145  start_blk = group_blk;
146  }
147 
148  if (!fs->group_desc[group].bg_block_bitmap)
149  {
150  retval = ext2_get_free_blocks(fs, start_blk, last_blk,
151  1, bmap, &new_blk);
152 
153  if (!retval)
154  retval = ext2_get_free_blocks(fs, group_blk,
155  last_blk, 1, bmap, &new_blk);
156 
157  if (!retval)
158  return retval;
159 
160  ext2_mark_block_bitmap(bmap, new_blk);
161  fs->group_desc[group].bg_block_bitmap = new_blk;
162  }
163 
164  if (!fs->group_desc[group].bg_inode_bitmap)
165  {
166  retval = ext2_get_free_blocks(fs, start_blk, last_blk,
167  1, bmap, &new_blk);
168  if (!retval)
169  retval = ext2_get_free_blocks(fs, group_blk,
170  last_blk, 1, bmap, &new_blk);
171  if (!retval)
172  return retval;
173 
174  ext2_mark_block_bitmap(bmap, new_blk);
175  fs->group_desc[group].bg_inode_bitmap = new_blk;
176  }
177 
178  return true;
179 }
bool ext2_get_free_blocks(PEXT2_FILESYS fs, ULONG start, ULONG finish, int num, PEXT2_BLOCK_BITMAP map, ULONG *ret)
Definition: Memory.c:182
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLboolean GLuint group
Definition: glext.h:11120
ULONGLONG bmap(struct inode *i, ULONGLONG b)
Definition: linux.c:934
#define blk
Definition: linetest.c:70
unsigned int ULONG
Definition: retypes.h:1
#define ext2_mark_block_bitmap
Definition: Mke2fs.h:215

Referenced by ext2_allocate_tables().

◆ ext2_allocate_inode_bitmap()

bool ext2_allocate_inode_bitmap ( PEXT2_FILESYS  pExt2Sys)

Definition at line 140 of file Bitmap.c.

141 {
142  ULONG size = 0;
143 
144  PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
145 
146  Ext2Sys->inode_map = (PEXT2_INODE_BITMAP)
147  RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(EXT2_INODE_BITMAP));
148 
149  if (!Ext2Sys->inode_map)
150  {
151  DPRINT1("Mke2fs: error allocating inode bitmap...\n");
152  return false;
153  }
154 
155  memset(Ext2Sys->inode_map, 0, sizeof(EXT2_INODE_BITMAP));
156 
157  Ext2Sys->inode_map->start = 1;
158  Ext2Sys->inode_map->end = pExt2Sb->s_inodes_count;
159  Ext2Sys->inode_map->real_end = (EXT2_INODES_PER_GROUP(pExt2Sb)
160  * Ext2Sys->group_desc_count);
161 
162  size = (((Ext2Sys->inode_map->real_end - Ext2Sys->inode_map->start) / 8) + 1);
163 
164  Ext2Sys->inode_map->bitmap =
165  (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
166 
167  if (!Ext2Sys->inode_map->bitmap)
168  {
169  RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->inode_map);
170  Ext2Sys->inode_map = NULL;
171  DPRINT1("Mke2fs: error allocating block bitmap...\n");
172  return false;
173  }
174 
175  memset(Ext2Sys->inode_map->bitmap, 0, size);
176 
177  return true;
178 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
smooth NULL
Definition: ftsmooth.c:416
#define EXT2_INODES_PER_GROUP(s)
Definition: ext2_fs.h:171
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
GLsizeiptr size
Definition: glext.h:5919
#define DPRINT1
Definition: precomp.h:8
EXT2_BITMAP * PEXT2_INODE_BITMAP
Definition: Mke2fs.h:125
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
EXT2_BITMAP EXT2_INODE_BITMAP
Definition: Mke2fs.h:125

Referenced by ext2_initialize_sb(), and read_bitmaps().

◆ ext2_allocate_tables()

bool ext2_allocate_tables ( PEXT2_FILESYS  pExt2Sys)

Definition at line 75 of file Memory.c.

76 {
77  bool retval;
78  ULONG i;
79 
80  for (i = 0; i < Ext2Sys->group_desc_count; i++)
81  {
82  retval = ext2_allocate_group_table(Ext2Sys, i, Ext2Sys->block_map);
83 
84  if (!retval)
85  return retval;
86  }
87 
88  return true;
89 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
bool ext2_allocate_group_table(PEXT2_FILESYS fs, ULONG group, PEXT2_BLOCK_BITMAP bmap)
Definition: Memory.c:92
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2Format().

◆ ext2_bg_has_super()

bool ext2_bg_has_super ( PEXT2_SUPER_BLOCK  pExt2Sb,
int  group_block 
)

Definition at line 30 of file Group.c.

31 {
32  if (!(pExt2Sb->s_feature_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
33  return true;
34 
35  if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
36  test_root(group_block, 7))
37  return true;
38 
39  return false;
40 }
int test_root(int a, int b)
Definition: Group.c:16
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
Definition: ext2_fs.h:465

Referenced by ext2_flush(), and ext2_initialize_sb().

◆ ext2_block_alloc_stats()

void ext2_block_alloc_stats ( PEXT2_FILESYS  fs,
ULONG  blk,
int  inuse 
)

Definition at line 61 of file Memory.c.

62 {
63  int group = ext2_group_of_blk(fs, blk);
64 
65  if (inuse > 0)
66  ext2_mark_block_bitmap(fs->block_map, blk);
67  else
68  ext2_unmark_block_bitmap(fs->block_map, blk);
69 
70  fs->group_desc[group].bg_free_blocks_count -= inuse;
71  fs->ext2_sb->s_free_blocks_count -= inuse;
72 }
int ext2_group_of_blk(PEXT2_FILESYS fs, ULONG blk)
Definition: Memory.c:31
Definition: fs.h:235
GLboolean GLuint group
Definition: glext.h:11120
#define blk
Definition: linetest.c:70
#define ext2_unmark_block_bitmap
Definition: Mke2fs.h:217
#define ext2_mark_block_bitmap
Definition: Mke2fs.h:215

Referenced by ext2_alloc_block(), and ext2_mkdir().

◆ ext2_clear_bit()

bool ext2_clear_bit ( int  nr,
void addr 
)

Definition at line 30 of file Bitmap.c.

31 {
32  int mask;
33  unsigned char *ADDR = (unsigned char *) addr;
34 
35  ADDR += nr >> 3;
36  mask = 1 << (nr & 0x07);
37  *ADDR &= ~mask;
38  return true;
39 }
ULONG nr
Definition: thread.c:7
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by ext2_unmark_bitmap().

◆ ext2_expand_inode()

bool ext2_expand_inode ( PEXT2_FILESYS  pExt2Sys,
PEXT2_INODE  ,
ULONG  newBlk 
)

Definition at line 212 of file Inode.c.

215 {
216  ULONG dwSizes[4] = {12, 1, 1, 1};
217  ULONG Index = 0;
218  ULONG dwTotal = 0;
219  ULONG dwBlk = 0, dwNewBlk = 0, Offset = 0;
220  PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
221  int i = 0;
222  bool bRet = true;
223  ULONG TotalBlocks;
224 
225  TotalBlocks = Inode->i_blocks / (Ext2Sys->blocksize / SECTOR_SIZE);
226  Index = Ext2DataBlocks(Ext2Sys, TotalBlocks);
227 
228  for (i = 0; i < 4; i++)
229  {
230  dwSizes[i] = dwSizes[i] << ((10 + pExt2Sb->s_log_block_size - 2) * i);
231  dwTotal += dwSizes[i];
232  }
233 
234  if (Index >= dwTotal)
235  {
236  DPRINT1("Mke2fs: ext2_expand_inode: beyond the maxinum size of an inode.\n");
237  return false;
238  }
239 
240  for (i = 0; i < 4; i++)
241  {
242  if (Index < dwSizes[i])
243  {
244  if (i == 0)
245  {
246  Inode->i_block[Index] = newBlk;
247  }
248  else
249  {
250  dwBlk = Inode->i_block[(i + 12 - 1)];
251 
252  if (dwBlk == 0)
253  {
254  if (ext2_alloc_block(Ext2Sys, 0, &dwBlk))
255  {
256  Inode->i_block[(i + 12 - 1)] = dwBlk;
257 
258  Inode->i_blocks += (Ext2Sys->blocksize / SECTOR_SIZE);
259  }
260  else
261  {
262  break;
263  }
264  }
265 
266  dwNewBlk = 0;
267  bRet = ext2_expand_block(
268  Ext2Sys,
269  Inode,
270  dwBlk,
271  Index,
272  i,
273  newBlk,
274  &dwNewBlk,
275  &Offset );
276  }
277 
278  break;
279  }
280 
281  Index -= dwSizes[i];
282  }
283 
284  return bRet;
285 }
ULONG Ext2DataBlocks(PEXT2_FILESYS Ext2Sys, ULONG TotalBlocks)
Definition: Mke2fs.c:698
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static const UCHAR Index[8]
Definition: usbohci.c:18
bool ext2_expand_block(PEXT2_FILESYS Ext2Sys, PEXT2_INODE Inode, ULONG dwContent, ULONG Index, int layer, ULONG newBlk, ULONG *dwRet, ULONG *off)
Definition: Inode.c:128
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define SECTOR_SIZE
Definition: fs.h:22
bool ext2_alloc_block(PEXT2_FILESYS fs, ULONG goal, ULONG *ret)
Definition: Memory.c:293

Referenced by create_lost_and_found(), and ext2_write_inode().

◆ ext2_free_block_bitmap()

void ext2_free_block_bitmap ( PEXT2_FILESYS  pExt2Sys)

Definition at line 205 of file Bitmap.c.

206 {
207  PEXT2_BLOCK_BITMAP bitmap = Ext2Sys->block_map;
208  if (!bitmap)
209  return;
210 
212 
213  Ext2Sys->block_map = NULL;
214 }
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
void ext2_free_generic_bitmap(PEXT2_GENERIC_BITMAP bitmap)
Definition: Bitmap.c:180

Referenced by ext2_initialize_sb(), Ext2Format(), and read_bitmaps().

◆ ext2_free_group_desc()

void ext2_free_group_desc ( PEXT2_FILESYS  pExt2Sys)

Definition at line 61 of file Group.c.

62 {
63  if (Ext2Sys->group_desc)
64  {
65  RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->group_desc);
66  Ext2Sys->group_desc = NULL;
67  }
68 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
smooth NULL
Definition: ftsmooth.c:416

Referenced by ext2_initialize_sb(), and Ext2Format().

◆ ext2_free_inode_bitmap()

void ext2_free_inode_bitmap ( PEXT2_FILESYS  pExt2Sys)

Definition at line 194 of file Bitmap.c.

195 {
196  PEXT2_INODE_BITMAP bitmap = Ext2Sys->inode_map;
197  if (!bitmap)
198  return;
199 
201 
202  Ext2Sys->inode_map = NULL;
203 }
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
void ext2_free_generic_bitmap(PEXT2_GENERIC_BITMAP bitmap)
Definition: Bitmap.c:180

Referenced by ext2_initialize_sb(), Ext2Format(), and read_bitmaps().

◆ ext2_get_free_blocks()

bool ext2_get_free_blocks ( PEXT2_FILESYS  fs,
ULONG  start,
ULONG  finish,
int  num,
PEXT2_BLOCK_BITMAP  map,
ULONG ret 
)

Definition at line 182 of file Memory.c.

184 {
185  ULONG b = start;
186 
187  if (!map)
188  map = fs->block_map;
189 
190  if (!map)
191  return false;
192 
193  if (!b)
194  b = fs->ext2_sb->s_first_data_block;
195 
196  if (!finish)
197  finish = start;
198 
199  if (!num)
200  num = 1;
201 
202  do
203  {
204  if (b+num-1 > fs->ext2_sb->s_blocks_count)
205  b = fs->ext2_sb->s_first_data_block;
206 
208  {
209  *ret = b;
210  return true;
211  }
212 
213  b++;
214 
215  } while (b != finish);
216 
217  return false;
218 }
Definition: fs.h:235
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint GLuint num
Definition: glext.h:9618
Definition: _map.h:44
int ret
bool ext2_test_block_bitmap_range(PEXT2_BLOCK_BITMAP bitmap, ULONG block, int num)
Definition: Bitmap.c:80
GLuint start
Definition: gl.h:1545
unsigned int ULONG
Definition: retypes.h:1

Referenced by ext2_allocate_group_table().

◆ ext2_get_inode_lba()

bool ext2_get_inode_lba ( PEXT2_FILESYS  pExt2Sys,
ULONG  no,
LONGLONG offset 
)

Definition at line 20 of file Inode.c.

21 {
22  LONGLONG loc = 0;
23  PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
24 
25  if (no < 1 || no > pExt2Sb->s_inodes_count)
26  {
27  DPRINT1("Mke2fs: Inode value %lu was out of range in load_inode.(1-%ld)\n",
28  no, pExt2Sb->s_inodes_count);
29  *offset = 0;
30  return false;
31  }
32 
33  loc = (LONGLONG)(Ext2Sys->blocksize) * Ext2Sys->group_desc[(no - 1) / pExt2Sb->s_inodes_per_group].bg_inode_table +
34  ((no - 1) % pExt2Sb->s_inodes_per_group) * sizeof(EXT2_INODE);
35 
36  *offset = loc;
37 
38  return true;
39 }
GLintptr offset
Definition: glext.h:5920
int64_t LONGLONG
Definition: typedefs.h:66
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
#define DPRINT1
Definition: precomp.h:8

Referenced by ext2_load_inode(), and ext2_save_inode().

◆ ext2_group_of_blk()

int ext2_group_of_blk ( PEXT2_FILESYS  fs,
ULONG  blk 
)

Definition at line 31 of file Memory.c.

32 {
33  return (blk - fs->ext2_sb->s_first_data_block) /
34  fs->ext2_sb->s_blocks_per_group;
35 }
Definition: fs.h:235
#define blk
Definition: linetest.c:70

Referenced by ext2_block_alloc_stats().

◆ ext2_group_of_ino()

int ext2_group_of_ino ( PEXT2_FILESYS  fs,
ULONG  ino 
)

Definition at line 23 of file Memory.c.

24 {
25  return (ino - 1) / fs->ext2_sb->s_inodes_per_group;
26 }
Definition: fs.h:235

Referenced by ext2_inode_alloc_stats2(), and ext2_reserve_inodes().

◆ ext2_initialize_sb()

bool ext2_initialize_sb ( PEXT2_FILESYS  pExt2Sys)

Definition at line 74 of file Super.c.

75 {
76  int frags_per_block = 0;
77  ULONG overhead = 0;
78  ULONG rem = 0;
79  ULONG i = 0;
80  ULONG group_block = 0;
81  ULONG numblocks = 0;
82  PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
83  LARGE_INTEGER SysTime;
84 
85  NtQuerySystemTime(&SysTime);
86 
87  Ext2Sys->blocksize = EXT2_BLOCK_SIZE(pExt2Sb);
88  Ext2Sys->fragsize = EXT2_FRAG_SIZE(pExt2Sb);
89  frags_per_block = Ext2Sys->blocksize / Ext2Sys->fragsize;
90 
91  pExt2Sb->s_magic = EXT2_SUPER_MAGIC;
92  pExt2Sb->s_state = EXT2_VALID_FS;
93 
94  pExt2Sb->s_first_data_block = (pExt2Sb->s_log_block_size) ? 0 : 1;
95  pExt2Sb->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT;
96 
97  pExt2Sb->s_errors = EXT2_ERRORS_DEFAULT;
98 
99  pExt2Sb->s_checkinterval = EXT2_DFL_CHECKINTERVAL;
100 
101  if (!pExt2Sb->s_rev_level)
102  pExt2Sb->s_rev_level = EXT2_GOOD_OLD_REV;
103 
104  if (pExt2Sb->s_rev_level >= EXT2_DYNAMIC_REV)
105  {
106  set_field(s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
107  set_field(s_inode_size, EXT2_GOOD_OLD_INODE_SIZE);
108  }
109 
110  RtlTimeToSecondsSince1970(&SysTime, &pExt2Sb->s_wtime);
111  pExt2Sb->s_lastcheck = pExt2Sb->s_mtime = pExt2Sb->s_wtime;
112 
113  if (!pExt2Sb->s_blocks_per_group)
114  pExt2Sb->s_blocks_per_group = Ext2Sys->blocksize * 8;
115 
116  pExt2Sb->s_frags_per_group = pExt2Sb->s_blocks_per_group * frags_per_block;
117  pExt2Sb->s_creator_os = EXT2_OS_WINNT;
118 
119  if (pExt2Sb->s_r_blocks_count >= pExt2Sb->s_blocks_count)
120  {
121  goto cleanup;
122  }
123 
124  /*
125  * If we're creating an external journal device, we don't need
126  * to bother with the rest.
127  */
128  if (pExt2Sb->s_feature_incompat &
130  {
131  Ext2Sys->group_desc_count = 0;
132  // ext2fs_mark_super_dirty(fs);
133  return true;
134  }
135 
136 retry:
137 
138  Ext2Sys->group_desc_count = (pExt2Sb->s_blocks_count - pExt2Sb->s_first_data_block
139  + EXT2_BLOCKS_PER_GROUP(pExt2Sb) - 1) / EXT2_BLOCKS_PER_GROUP(pExt2Sb);
140 
141  if (Ext2Sys->group_desc_count == 0)
142  return false;
143 
144  Ext2Sys->desc_blocks = (Ext2Sys->group_desc_count + EXT2_DESC_PER_BLOCK(pExt2Sb)
145  - 1) / EXT2_DESC_PER_BLOCK(pExt2Sb);
146 
147  if (!pExt2Sb->s_inodes_count)
148  pExt2Sb->s_inodes_count = pExt2Sb->s_blocks_count / ( inode_ratio /Ext2Sys->blocksize);
149 
150  /*
151  * Make sure we have at least EXT2_FIRST_INO + 1 inodes, so
152  * that we have enough inodes for the filesystem(!)
153  */
154  if (pExt2Sb->s_inodes_count < EXT2_FIRST_INODE(pExt2Sb)+1)
155  pExt2Sb->s_inodes_count = EXT2_FIRST_INODE(pExt2Sb)+1;
156 
157  /*
158  * There should be at least as many inodes as the user
159  * requested. Figure out how many inodes per group that
160  * should be. But make sure that we don't allocate more than
161  * one bitmap's worth of inodes
162  */
163  pExt2Sb->s_inodes_per_group = (pExt2Sb->s_inodes_count + Ext2Sys->group_desc_count - 1)
164  /Ext2Sys->group_desc_count;
165 
166  if (pExt2Sb->s_inodes_per_group > (ULONG)(Ext2Sys->blocksize*8))
167  pExt2Sb->s_inodes_per_group = Ext2Sys->blocksize*8;
168 
169  /*
170  * Make sure the number of inodes per group completely fills
171  * the inode table blocks in the descriptor. If not, add some
172  * additional inodes/group. Waste not, want not...
173  */
174  Ext2Sys->inode_blocks_per_group = (((pExt2Sb->s_inodes_per_group * EXT2_INODE_SIZE(pExt2Sb))
175  + EXT2_BLOCK_SIZE(pExt2Sb) - 1) / EXT2_BLOCK_SIZE(pExt2Sb));
176 
177  pExt2Sb->s_inodes_per_group = ((Ext2Sys->inode_blocks_per_group * EXT2_BLOCK_SIZE(pExt2Sb))
178  / EXT2_INODE_SIZE(pExt2Sb));
179 
180  /*
181  * Finally, make sure the number of inodes per group is a
182  * multiple of 8. This is needed to simplify the bitmap
183  * splicing code.
184  */
185  pExt2Sb->s_inodes_per_group &= ~7;
186  Ext2Sys->inode_blocks_per_group = (((pExt2Sb->s_inodes_per_group * EXT2_INODE_SIZE(pExt2Sb))
187  + EXT2_BLOCK_SIZE(pExt2Sb) - 1) / EXT2_BLOCK_SIZE(pExt2Sb));
188 
189  /*
190  * adjust inode count to reflect the adjusted inodes_per_group
191  */
192  pExt2Sb->s_inodes_count = pExt2Sb->s_inodes_per_group * Ext2Sys->group_desc_count;
193  pExt2Sb->s_free_inodes_count = pExt2Sb->s_inodes_count;
194 
195  /*
196  * Overhead is the number of bookkeeping blocks per group. It
197  * includes the superblock backup, the group descriptor
198  * backups, the inode bitmap, the block bitmap, and the inode
199  * table.
200  *
201  * XXX Not all block groups need the descriptor blocks, but
202  * being clever is tricky...
203  */
204  overhead = (3 + Ext2Sys->desc_blocks + Ext2Sys->inode_blocks_per_group);
205 
206  /*
207  * See if the last group is big enough to support the
208  * necessary data structures. If not, we need to get rid of
209  * it.
210  */
211  rem = ((pExt2Sb->s_blocks_count - pExt2Sb->s_first_data_block) %
212  pExt2Sb->s_blocks_per_group);
213 
214  if ((Ext2Sys->group_desc_count == 1) && rem && (rem < overhead))
215  return false;
216 
217  if (rem && (rem < overhead+50))
218  {
219  pExt2Sb->s_blocks_count -= rem;
220  goto retry;
221  }
222 
223  /*
224  * At this point we know how big the filesystem will be. So we can do
225  * any and all allocations that depend on the block count.
226  */
227 
228  // Allocate block bitmap
229  if(!ext2_allocate_block_bitmap(Ext2Sys))
230  {
231  goto cleanup;
232  }
233 
234  // Allocate inode bitmap
235  if(!ext2_allocate_inode_bitmap(Ext2Sys))
236  {
237  goto cleanup;
238  }
239 
240  // Allocate gourp desc
241  if(!ext2_allocate_group_desc(Ext2Sys))
242  {
243  goto cleanup;
244  }
245 
246  /*
247  * Reserve the superblock and group descriptors for each
248  * group, and fill in the correct group statistics for group.
249  * Note that although the block bitmap, inode bitmap, and
250  * inode table have not been allocated (and in fact won't be
251  * by this routine), they are accounted for nevertheless.
252  */
253  group_block = pExt2Sb->s_first_data_block;
254  numblocks = 0;
255 
256  pExt2Sb->s_free_blocks_count = 0;
257 
258  for (i = 0; i < Ext2Sys->group_desc_count; i++)
259  {
260  if (i == Ext2Sys->group_desc_count-1)
261  {
262  numblocks = (pExt2Sb->s_blocks_count - pExt2Sb->s_first_data_block)
263  % pExt2Sb->s_blocks_per_group;
264 
265  if (!numblocks)
266  numblocks = pExt2Sb->s_blocks_per_group;
267  }
268  else
269  {
270  numblocks = pExt2Sb->s_blocks_per_group;
271  }
272 
273  if (ext2_bg_has_super(pExt2Sb, i))
274  {
275  ULONG j;
276 
277  for (j=0; j < Ext2Sys->desc_blocks+1; j++)
278  ext2_mark_bitmap(Ext2Sys->block_map, group_block + j);
279 
280  numblocks -= 1 + Ext2Sys->desc_blocks;
281  }
282 
283  numblocks -= 2 + Ext2Sys->inode_blocks_per_group;
284 
285  pExt2Sb->s_free_blocks_count += numblocks;
286  Ext2Sys->group_desc[i].bg_free_blocks_count = (__u16)numblocks;
287  Ext2Sys->group_desc[i].bg_free_inodes_count = (__u16)pExt2Sb->s_inodes_per_group;
288  Ext2Sys->group_desc[i].bg_used_dirs_count = 0;
289 
290  group_block += pExt2Sb->s_blocks_per_group;
291  }
292 
293  return true;
294 
295 cleanup:
296 
297  ext2_free_group_desc(Ext2Sys);
298  ext2_free_block_bitmap(Ext2Sys);
299  ext2_free_inode_bitmap(Ext2Sys);
300 
301  return false;
302 }
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV
Definition: ext3_fs.h:681
#define EXT2_OS_WINNT
Definition: ext2_fs.h:447
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)
bool ext2_allocate_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:43
bool ext2_allocate_block_bitmap(PEXT2_FILESYS Ext2Sys)
Definition: Bitmap.c:100
#define EXT2_GOOD_OLD_REV
Definition: ext2_fs.h:426
void ext2_free_inode_bitmap(PEXT2_FILESYS Ext2Sys)
Definition: Bitmap.c:194
#define EXT2_DFL_MAX_MNT_COUNT
Definition: ext2_fs.h:332
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXT2_SUPER_MAGIC
Definition: ext2fs.h:344
#define EXT2_VALID_FS
Definition: ext2_fs.h:310
bool ext2_allocate_inode_bitmap(PEXT2_FILESYS Ext2Sys)
Definition: Bitmap.c:140
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define EXT2_INODE_SIZE(sb)
Definition: ext2.h:192
unsigned short __u16
Definition: compat.h:89
void ext2_free_block_bitmap(PEXT2_FILESYS Ext2Sys)
Definition: Bitmap.c:205
#define EXT2_DYNAMIC_REV
Definition: ext2_fs.h:427
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define EXT2_DESC_PER_BLOCK(s)
Definition: ext2.h:196
bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
Definition: Group.c:30
#define EXT2_ERRORS_DEFAULT
Definition: ext2_fs.h:341
#define EXT2_FIRST_INODE(s)
Definition: Mke2fs.h:116
void ext2_free_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:61
bool ext2_mark_bitmap(PEXT2_BITMAP bitmap, ULONG bitno)
Definition: Bitmap.c:52
#define EXT2_BLOCK_SIZE(sb)
Definition: ext2.h:186
#define set_field(field, default)
Definition: Super.c:68
#define EXT2_GOOD_OLD_INODE_SIZE
Definition: ext2.h:54
#define EXT2_GOOD_OLD_FIRST_INO
Definition: ext2_fs.h:66
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:417
char * cleanup(char *str)
Definition: wpickclick.c:99
#define EXT2_FRAG_SIZE(s)
Definition: ext2_fs.h:119
#define EXT2_DFL_CHECKINTERVAL
Definition: ext2_fs.h:333
int inode_ratio
Definition: Mke2fs.c:17
#define EXT2_BLOCKS_PER_GROUP(s)
Definition: ext2_fs.h:169

Referenced by Ext2Format().

◆ ext2_inode_alloc_stats()

void ext2_inode_alloc_stats ( PEXT2_FILESYS  fs,
ULONG  ino,
int  inuse 
)

Definition at line 56 of file Memory.c.

57 {
58  ext2_inode_alloc_stats2(fs, ino, inuse, 0);
59 }
void ext2_inode_alloc_stats2(PEXT2_FILESYS fs, ULONG ino, int inuse, int isdir)
Definition: Memory.c:37
Definition: fs.h:235

◆ ext2_inode_alloc_stats2()

void ext2_inode_alloc_stats2 ( PEXT2_FILESYS  fs,
ULONG  ino,
int  inuse,
int  isdir 
)

Definition at line 37 of file Memory.c.

39 {
40  int group = ext2_group_of_ino(fs, ino);
41 
42  if (inuse > 0)
43  ext2_mark_inode_bitmap(fs->inode_map, ino);
44  else
45  ext2_unmark_inode_bitmap(fs->inode_map, ino);
46 
47  fs->group_desc[group].bg_free_inodes_count -= inuse;
48 
49  if (isdir)
50  fs->group_desc[group].bg_used_dirs_count += inuse;
51 
52  fs->ext2_sb->s_free_inodes_count -= inuse;
53 }
Definition: fs.h:235
GLboolean GLuint group
Definition: glext.h:11120
#define ext2_unmark_inode_bitmap
Definition: Mke2fs.h:218
#define ext2_mark_inode_bitmap
Definition: Mke2fs.h:216
int ext2_group_of_ino(PEXT2_FILESYS fs, ULONG ino)
Definition: Memory.c:23

Referenced by ext2_inode_alloc_stats(), and ext2_mkdir().

◆ ext2_load_inode()

bool ext2_load_inode ( PEXT2_FILESYS  pExt2Sys,
ULONG  no,
PEXT2_INODE  pInode 
)

Definition at line 41 of file Inode.c.

42 {
44  bool bRet = false;
45 
46  if (ext2_get_inode_lba(Ext2Sys, no, &Offset))
47  {
48  bRet = NT_SUCCESS(Ext2ReadDisk(
49  Ext2Sys,
50  Offset,
51  sizeof(EXT2_INODE),
52  (unsigned char *)pInode));
53  }
54 
55  return bRet;
56 }
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:539
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
int64_t LONGLONG
Definition: typedefs.h:66
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
bool ext2_get_inode_lba(PEXT2_FILESYS Ext2Sys, ULONG no, LONGLONG *offset)
Definition: Inode.c:20

Referenced by ext2_add_entry(), ext2_mkdir(), ext2_read_inode(), and ext2_write_inode().

◆ ext2_mark_bitmap()

bool ext2_mark_bitmap ( PEXT2_BITMAP  bitmap,
ULONG  bitno 
)

Definition at line 52 of file Bitmap.c.

53 {
54  if ((bitno < bitmap->start) || (bitno > bitmap->end))
55  {
56  return false;
57  }
58 
59  return ext2_set_bit(bitno - bitmap->start, bitmap->bitmap);
60 }
Definition: uimain.c:88
bool ext2_set_bit(int nr, void *addr)
Definition: Bitmap.c:18
GLuint start
Definition: gl.h:1545

Referenced by ext2_initialize_sb().

◆ ext2_new_block()

bool ext2_new_block ( PEXT2_FILESYS  fs,
ULONG  goal,
PEXT2_BLOCK_BITMAP  map,
ULONG ret 
)

Definition at line 254 of file Memory.c.

256 {
257  ULONG i;
258 
259  if (!map)
260  map = fs->block_map;
261 
262  if (!map)
263  return false;
264 
265  if (!goal || (goal >= fs->ext2_sb->s_blocks_count))
266  goal = fs->ext2_sb->s_first_data_block;
267 
268  i = goal;
269 
270  do
271  {
273  {
274  *ret = i;
275  return true;
276  }
277 
278  i++;
279 
280  if (i >= fs->ext2_sb->s_blocks_count)
281  i = fs->ext2_sb->s_first_data_block;
282 
283  } while (i != goal);
284 
285  return false;
286 }
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
bool ext2_test_block_bitmap(PEXT2_BLOCK_BITMAP bitmap, ULONG block)
Definition: Bitmap.c:73
Definition: _map.h:44
int ret
unsigned int ULONG
Definition: retypes.h:1

Referenced by ext2_alloc_block(), and ext2_mkdir().

◆ ext2_new_dir_block()

bool ext2_new_dir_block ( PEXT2_FILESYS  fs,
ULONG  dir_ino,
ULONG  parent_ino,
char **  block 
)

Definition at line 349 of file Memory.c.

351 {
353  char *buf;
354  int rec_len;
355  int filetype = 0;
356 
357  buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, fs->blocksize);
358  if (!buf)
359  return false;
360 
361  dir = (PEXT2_DIR_ENTRY) buf;
362  dir->rec_len = fs->blocksize;
363 
364  if (dir_ino)
365  {
366  if (fs->ext2_sb->s_feature_incompat &
368  filetype = EXT2_FT_DIR << 8;
369  /*
370  * Set up entry for '.'
371  */
372  dir->inode = dir_ino;
373  dir->name_len = 1 | filetype;
374  dir->name[0] = '.';
375  rec_len = dir->rec_len - EXT2_DIR_REC_LEN(1);
376  dir->rec_len = EXT2_DIR_REC_LEN(1);
377 
378  /*
379  * Set up entry for '..'
380  */
381  dir = (struct ext2_dir_entry *) (buf + dir->rec_len);
382  dir->rec_len = rec_len;
383  dir->inode = parent_ino;
384  dir->name_len = 2 | filetype;
385  dir->name[0] = '.';
386  dir->name[1] = '.';
387  }
388 
389  *block = buf;
390 
391  return true;
392 }
static unsigned int block
Definition: xmlmemory.c:118
__u16 rec_len
Definition: ext2_fs.h:494
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define EXT2_DIR_REC_LEN(name_len)
Definition: ext2_fs.h:536
Definition: fs.h:235
Definition: ext2_fs.h:492
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
#define EXT2_FEATURE_INCOMPAT_FILETYPE
Definition: ext2_fs.h:471
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
struct ext2_dirent * PEXT2_DIR_ENTRY
Definition: ext2.h:174
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
LOCAL char * filetype(int t)
Definition: tree.c:114

Referenced by ext2_mkdir().

◆ ext2_new_inode()

bool ext2_new_inode ( PEXT2_FILESYS  fs,
ULONG  dir,
int  mode,
PEXT2_INODE_BITMAP  map,
ULONG ret 
)

Definition at line 84 of file Inode.c.

86 {
87  ULONG dir_group = 0;
88  ULONG i;
89  ULONG start_inode;
90 
91  if (!map)
92  map = fs->inode_map;
93 
94  if (!map)
95  return false;
96 
97  if (dir > 0)
98  dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->ext2_sb);
99 
100  start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->ext2_sb)) + 1;
101 
102  if (start_inode < EXT2_FIRST_INODE(fs->ext2_sb))
103  start_inode = EXT2_FIRST_INODE(fs->ext2_sb);
104 
105  i = start_inode;
106 
107  do
108  {
110  break;
111 
112  i++;
113 
114  if (i > fs->ext2_sb->s_inodes_count)
115  i = EXT2_FIRST_INODE(fs->ext2_sb);
116 
117  } while (i != start_inode);
118 
120  return false;
121 
122  *ret = i;
123 
124  return true;
125 }
bool ext2_test_inode_bitmap(PEXT2_BLOCK_BITMAP bitmap, ULONG inode)
Definition: Bitmap.c:93
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXT2_INODES_PER_GROUP(s)
Definition: ext2_fs.h:171
unsigned int dir
Definition: maze.c:112
Definition: _map.h:44
int ret
#define EXT2_FIRST_INODE(s)
Definition: Mke2fs.h:116
unsigned int ULONG
Definition: retypes.h:1

Referenced by ext2_mkdir().

◆ ext2_nt_time()

LONGLONG ext2_nt_time ( ULONG  i_time)

◆ ext2_print_super()

void ext2_print_super ( PEXT2_SUPER_BLOCK  pExt2Sb)

Definition at line 20 of file Super.c.

21 {
22  int i;
23 
24  DPRINT("\nExt2 Super Block Details ...\n\n");
25  DPRINT(" Inode Count: %lu\n", pExt2Sb->s_inodes_count);
26  DPRINT(" Block Count: %lu\n", pExt2Sb->s_blocks_count);
27  DPRINT(" Reserved Block Count: %lu\n", pExt2Sb->s_r_blocks_count);
28  DPRINT(" Free Blocks: %lu\n", pExt2Sb->s_free_blocks_count);
29  DPRINT(" Free Inodes: %lu\n", pExt2Sb->s_free_inodes_count);
30  DPRINT(" First Data Block: %lu\n", pExt2Sb->s_first_data_block);
31  DPRINT(" Log Block Size: %lu\n", pExt2Sb->s_log_block_size);
32  DPRINT(" Log Frag Size: %ld\n", pExt2Sb->s_log_frag_size);
33  DPRINT(" Blocks per Group: %lu\n", pExt2Sb->s_blocks_per_group);
34  DPRINT(" Fragments per Group: %lu\n", pExt2Sb->s_frags_per_group);
35  DPRINT(" Inodes per Group: %lu\n", pExt2Sb->s_inodes_per_group);
36 // DPRINT(" Mount Time: %s", ctime((time_t *) & (pExt2Sb->s_mtime)));
37 // DPRINT(" Write Time: %s", ctime((time_t *) & (pExt2Sb->s_wtime)));
38  DPRINT(" Mount Count: %u\n", pExt2Sb->s_mnt_count);
39  DPRINT(" Max Mount Count: %d\n", pExt2Sb->s_max_mnt_count);
40  DPRINT(" Magic Number: %X (%s)\n", pExt2Sb->s_magic,
41  pExt2Sb->s_magic == EXT2_SUPER_MAGIC ? "OK" : "BAD");
42  DPRINT(" File System State: %X\n", pExt2Sb->s_state);
43  DPRINT(" Error Behaviour: %X\n", pExt2Sb->s_errors);
44  DPRINT(" Minor rev: %u\n", pExt2Sb->s_minor_rev_level);
45 // DPRINT(" Last Check: %s", ctime((time_t *) & (pExt2Sb->s_lastcheck)));
46  DPRINT(" Check Interval: %lu\n", pExt2Sb->s_checkinterval);
47  DPRINT(" Creator OS: %lu\n", pExt2Sb->s_creator_os);
48  DPRINT(" Revision Level: %lu\n", pExt2Sb->s_rev_level);
49  DPRINT(" Reserved Block Default UID: %u\n", pExt2Sb->s_def_resuid);
50  DPRINT(" Reserved Block Default GID: %u\n", pExt2Sb->s_def_resgid);
51  DPRINT(" uuid = ");
52  for (i=0; i < 16; i++)
53  DbgPrint("%x ", pExt2Sb->s_uuid[i]);
54  DbgPrint("\n");
55 
56  DPRINT(" volume label name: ");
57  for (i=0; i < 16; i++)
58  {
59  if (pExt2Sb->s_volume_name[i] == 0)
60  break;
61  DbgPrint("%c", pExt2Sb->s_volume_name[i]);
62  }
63  DbgPrint("\n");
64 
65  DPRINT("\n\n");
66 }
#define DbgPrint
Definition: loader.c:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXT2_SUPER_MAGIC
Definition: ext2fs.h:344
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by Ext2Format().

◆ ext2_read_bitmaps()

bool ext2_read_bitmaps ( PEXT2_FILESYS  fs)

Definition at line 492 of file Bitmap.c.

493 {
494 
495  if (fs->inode_map && fs->block_map)
496  return 0;
497 
498  return read_bitmaps(fs, !fs->inode_map, !fs->block_map);
499 }
Definition: fs.h:235
bool read_bitmaps(PEXT2_FILESYS fs, int do_inode, int do_block)
Definition: Bitmap.c:364

◆ ext2_read_block()

bool ext2_read_block ( PEXT2_FILESYS  fs,
ULONG  block,
void inbuf 
)

Definition at line 406 of file Memory.c.

407 {
408  bool retval = false;
409 
410  retval = NT_SUCCESS(Ext2ReadDisk(
411  fs,
412  ((ULONGLONG)block * fs->blocksize),
413  fs->blocksize, (unsigned char *)inbuf));
414 
415  return retval;
416 }
static unsigned int block
Definition: xmlmemory.c:118
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:539
static int inbuf
Definition: adnsresfilter.c:73
Definition: fs.h:235
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65

Referenced by ext2_expand_block(), and ext2_get_block().

◆ ext2_read_block_bitmap()

bool ext2_read_block_bitmap ( PEXT2_FILESYS  fs)

Definition at line 487 of file Bitmap.c.

488 {
489  return read_bitmaps(fs, 0, 1);
490 }
Definition: fs.h:235
bool read_bitmaps(PEXT2_FILESYS fs, int do_inode, int do_block)
Definition: Bitmap.c:364

Referenced by ext2_alloc_block().

◆ ext2_read_inode()

bool ext2_read_inode ( PEXT2_FILESYS  pExt2Sys,
ULONG  ino,
ULONG  offset,
PVOID  Buffer,
ULONG  size,
PULONG  dwReturn 
)

Definition at line 494 of file Inode.c.

500 {
501  PEXT2_BDL ext2_bdl = NULL;
502  ULONG blocks, i;
503  bool bRet = true;
505  ULONG dwTotal = 0;
506 
507  if (!ext2_load_inode(Ext2Sys, ino, &ext2_inode))
508  {
509  return false;
510  }
511 
512  blocks = ext2_build_bdl(Ext2Sys, &ext2_inode, offset, size, &ext2_bdl);
513 
514  if (blocks <= 0)
515  return false;
516 
517 
518  for(i = 0; i < blocks; i++)
519  {
520  bRet = NT_SUCCESS(Ext2ReadDisk(
521  Ext2Sys,
522  ext2_bdl[i].Lba,
523  ext2_bdl[i].Length,
524  (PUCHAR)Buffer + ext2_bdl[i].Offset
525  ));
526 
527  if (!bRet)
528  break;
529  dwTotal += ext2_bdl[i].Length;
530  }
531 
532  *dwReturn = dwTotal;
533 
534  if (ext2_bdl)
535  RtlFreeHeap(RtlGetProcessHeap(), 0, ext2_bdl);
536 
537  return bRet;
538 }
bool ext2_load_inode(PEXT2_FILESYS Ext2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:41
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
GLintptr offset
Definition: glext.h:5920
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:539
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static int blocks
Definition: mkdosfs.c:527
ULONG Length
Definition: Mke2fs.h:194
GLsizeiptr size
Definition: glext.h:5919
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG ext2_build_bdl(PEXT2_FILESYS Ext2Sys, PEXT2_INODE ext2_inode, IN ULONG offset, IN ULONG size, OUT PEXT2_BDL *ext2_bdl)
Definition: Inode.c:392
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned int ULONG
Definition: retypes.h:1

Referenced by ext2_add_entry().

◆ ext2_read_inode_bitmap()

bool ext2_read_inode_bitmap ( PEXT2_FILESYS  fs)

Definition at line 482 of file Bitmap.c.

483 {
484  return read_bitmaps(fs, 1, 0);
485 }
Definition: fs.h:235
bool read_bitmaps(PEXT2_FILESYS fs, int do_inode, int do_block)
Definition: Bitmap.c:364

◆ ext2_reserve_inodes()

bool ext2_reserve_inodes ( PEXT2_FILESYS  fs)

Definition at line 681 of file Inode.c.

682 {
683  ULONG i;
684  int group;
685 
686  for (i = EXT2_ROOT_INO + 1; i < EXT2_FIRST_INODE(fs->ext2_sb); i++)
687  {
688  ext2_mark_inode_bitmap(fs->inode_map, i);
690  fs->group_desc[group].bg_free_inodes_count--;
691  fs->ext2_sb->s_free_inodes_count--;
692  }
693 
694  return true;
695 }
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXT2_ROOT_INO
Definition: ext2.h:177
GLboolean GLuint group
Definition: glext.h:11120
#define EXT2_FIRST_INODE(s)
Definition: Mke2fs.h:116
#define ext2_mark_inode_bitmap
Definition: Mke2fs.h:216
unsigned int ULONG
Definition: retypes.h:1
int ext2_group_of_ino(PEXT2_FILESYS fs, ULONG ino)
Definition: Memory.c:23

Referenced by Ext2Format().

◆ ext2_save_inode()

bool ext2_save_inode ( PEXT2_FILESYS  pExt2Sys,
ULONG  no,
PEXT2_INODE  pInode 
)

Definition at line 59 of file Inode.c.

60 {
62  bool bRet = false;
63 
64  if (ext2_get_inode_lba(Ext2Sys, no, &offset))
65  {
67  Ext2Sys,
68  offset,
69  sizeof(EXT2_INODE),
70  (unsigned char *)pInode));
71  }
72 
73  return bRet;
74 }
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
GLintptr offset
Definition: glext.h:5920
int64_t LONGLONG
Definition: typedefs.h:66
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
bool ext2_get_inode_lba(PEXT2_FILESYS Ext2Sys, ULONG no, LONGLONG *offset)
Definition: Inode.c:20

Referenced by create_bad_block_inode(), create_lost_and_found(), create_root_dir(), ext2_mkdir(), and ext2_write_inode().

◆ ext2_set_bit()

bool ext2_set_bit ( int  nr,
void addr 
)

Definition at line 18 of file Bitmap.c.

19 {
20  int mask;
21  unsigned char *ADDR = (unsigned char *) addr;
22 
23  ADDR += nr >> 3;
24  mask = 1 << (nr & 0x07);
25  *ADDR |= mask;
26 
27  return true;
28 }
ULONG nr
Definition: thread.c:7
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by ext2_mark_bitmap(), and ext2_write_block_bitmap().

◆ ext2_test_bit()

bool ext2_test_bit ( int  nr,
void addr 
)

Definition at line 41 of file Bitmap.c.

42 {
43  int mask;
44  const unsigned char *ADDR = (const unsigned char *) addr;
45 
46  ADDR += nr >> 3;
47  mask = 1 << (nr & 0x07);
48 
49  return ((mask & *ADDR) != 0);
50 }
ULONG nr
Definition: thread.c:7
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by ext2_test_block_bitmap(), and ext2_test_inode_bitmap().

◆ ext2_test_block_bitmap()

bool ext2_test_block_bitmap ( PEXT2_BLOCK_BITMAP  bitmap,
ULONG  block 
)

Definition at line 73 of file Bitmap.c.

75 {
76  return ext2_test_bit(block - bitmap->start, bitmap->bitmap);
77 }
static unsigned int block
Definition: xmlmemory.c:118
bool ext2_test_bit(int nr, void *addr)
Definition: Bitmap.c:41
Definition: uimain.c:88

Referenced by ext2_new_block(), and ext2_test_block_bitmap_range().

◆ ext2_test_block_bitmap_range()

bool ext2_test_block_bitmap_range ( PEXT2_BLOCK_BITMAP  bitmap,
ULONG  block,
int  num 
)

Definition at line 80 of file Bitmap.c.

82 {
83  int i;
84 
85  for (i=0; i < num; i++)
86  {
88  return false;
89  }
90  return true;
91 }
static unsigned int block
Definition: xmlmemory.c:118
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
bool ext2_test_block_bitmap(PEXT2_BLOCK_BITMAP bitmap, ULONG block)
Definition: Bitmap.c:73
Definition: uimain.c:88
GLuint GLuint num
Definition: glext.h:9618

Referenced by ext2_get_free_blocks().

◆ ext2_test_inode_bitmap()

bool ext2_test_inode_bitmap ( PEXT2_BLOCK_BITMAP  bitmap,
ULONG  inode 
)

Definition at line 93 of file Bitmap.c.

95 {
96  return ext2_test_bit(inode - bitmap->start, bitmap->bitmap);
97 }
bool ext2_test_bit(int nr, void *addr)
Definition: Bitmap.c:41
Definition: fs.h:78
Definition: uimain.c:88

Referenced by ext2_new_inode().

◆ ext2_unix_time()

ULONG ext2_unix_time ( LONGLONG  n_time)

◆ ext2_unmark_bitmap()

bool ext2_unmark_bitmap ( PEXT2_BITMAP  bitmap,
ULONG  bitno 
)

Definition at line 62 of file Bitmap.c.

63 {
64  if ((bitno < bitmap->start) || (bitno > bitmap->end))
65  {
66  return false;
67  }
68 
69  return ext2_clear_bit(bitno - bitmap->start, bitmap->bitmap);
70 }
bool ext2_clear_bit(int nr, void *addr)
Definition: Bitmap.c:30
Definition: uimain.c:88
GLuint start
Definition: gl.h:1545

◆ ext2_write_bitmaps()

bool ext2_write_bitmaps ( PEXT2_FILESYS  fs)

Definition at line 342 of file Bitmap.c.

343 {
344  bool retval;
345 
346  if (fs->block_map) // && ext2fs_test_bb_dirty(fs))
347  {
348  retval = ext2_write_block_bitmap(fs);
349  if (!retval)
350  return retval;
351  }
352 
353  if (fs->inode_map) // && ext2fs_test_ib_dirty(fs))
354  {
355  retval = ext2_write_inode_bitmap(fs);
356  if (!retval)
357  return retval;
358  }
359 
360  return true;
361 }
Definition: fs.h:235
bool ext2_write_block_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:270
bool ext2_write_inode_bitmap(PEXT2_FILESYS fs)
Definition: Bitmap.c:216

Referenced by ext2_flush().

◆ ext2_write_block()

bool ext2_write_block ( PEXT2_FILESYS  fs,
ULONG  block,
void inbuf 
)

Definition at line 394 of file Memory.c.

395 {
396  bool retval = false;
397 
398  retval = NT_SUCCESS(Ext2WriteDisk(
399  fs,
400  ((ULONGLONG)block * fs->blocksize),
401  fs->blocksize, (unsigned char *)inbuf));
402 
403  return retval;
404 }
static unsigned int block
Definition: xmlmemory.c:118
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
static int inbuf
Definition: adnsresfilter.c:73
Definition: fs.h:235
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65

Referenced by create_lost_and_found(), ext2_expand_block(), and ext2_mkdir().

◆ ext2_write_block_bitmap()

bool ext2_write_block_bitmap ( PEXT2_FILESYS  fs)

Definition at line 270 of file Bitmap.c.

271 {
272  ULONG i;
273  int j;
274  int nbytes;
275  int nbits;
276  bool retval;
277  char *block_bitmap = fs->block_map->bitmap;
278  char *bitmap_block = NULL;
279  ULONG blk;
280 
281  if (!block_bitmap)
282  return false;
283 
284  nbytes = EXT2_BLOCKS_PER_GROUP(fs->ext2_sb) / 8;
285 
286  bitmap_block = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, fs->blocksize);
287  if (!bitmap_block)
288  return false;
289 
290  memset(bitmap_block, 0xff, fs->blocksize);
291 
292  for (i = 0; i < fs->group_desc_count; i++)
293  {
294  memcpy(bitmap_block, block_bitmap, nbytes);
295 
296  if (i == fs->group_desc_count - 1)
297  {
298  /* Force bitmap padding for the last group */
299  nbits = (int) ((fs->ext2_sb->s_blocks_count
300  - fs->ext2_sb->s_first_data_block)
301  % EXT2_BLOCKS_PER_GROUP(fs->ext2_sb));
302 
303  if (nbits)
304  {
305  for (j = nbits; j < fs->blocksize * 8; j++)
306  {
307  ext2_set_bit(j, bitmap_block);
308  }
309  }
310  }
311 
312  blk = fs->group_desc[i].bg_block_bitmap;
313 
314  if (blk)
315  {
316 #ifdef EXT2_BIG_ENDIAN_BITMAPS
317  if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
318  (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)))
319  ext2_swap_bitmap(fs, bitmap_block, nbytes);
320 #endif
321  retval = NT_SUCCESS(Ext2WriteDisk(
322  fs,
323  ((ULONGLONG)blk * fs->blocksize),
324  fs->blocksize,
325  (unsigned char *)bitmap_block));
326 
327  if (!retval)
328  {
329  RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
330  return false;
331  }
332  }
333 
334  block_bitmap += nbytes;
335  }
336 
337  RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
338 
339  return true;
340 }
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define blk
Definition: linetest.c:70
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
bool ext2_set_bit(int nr, void *addr)
Definition: Bitmap.c:18
unsigned int ULONG
Definition: retypes.h:1
#define EXT2_BLOCKS_PER_GROUP(s)
Definition: ext2_fs.h:169
#define memset(x, y, z)
Definition: compat.h:39
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by ext2_write_bitmaps().

◆ ext2_write_inode()

bool ext2_write_inode ( PEXT2_FILESYS  pExt2Sys,
ULONG  ino,
ULONG  offset,
PVOID  Buffer,
ULONG  size,
PULONG  dwReturn 
)

Definition at line 541 of file Inode.c.

547 {
548  PEXT2_BDL ext2_bdl = NULL;
549  ULONG blocks, i;
550  bool bRet = true;
552  ULONG dwTotal = 0;
553  ULONG dwBlk = 0;
554  ULONG TotalBlks;
555 
556  blocks = (size + offset + Ext2Sys->blocksize - 1) / Ext2Sys->blocksize;
557 
558  if (!ext2_load_inode(Ext2Sys, ino, &inode))
559  {
560  return false;
561  }
562 
563  TotalBlks = inode.i_blocks / (Ext2Sys->blocksize / SECTOR_SIZE);
564  TotalBlks = Ext2DataBlocks(Ext2Sys, TotalBlks);
565 
566  if (blocks > TotalBlks)
567  {
568  for (i=0; i < (blocks - TotalBlks); i++)
569  {
570  if (ext2_alloc_block(Ext2Sys, 0, &dwBlk) )
571  {
572  ext2_expand_inode(Ext2Sys, &inode, dwBlk);
573  inode.i_blocks += (Ext2Sys->blocksize/SECTOR_SIZE);
574  }
575  }
576  }
577 
578  blocks = ext2_build_bdl(Ext2Sys, &inode, offset, size, &ext2_bdl);
579 
580  if (blocks <= 0)
581  return false;
582 
583  for(i = 0; i < blocks; i++)
584  {
585  bRet = NT_SUCCESS(Ext2WriteDisk(
586  Ext2Sys,
587  ext2_bdl[i].Lba,
588  ext2_bdl[i].Length,
589  (PUCHAR)Buffer + ext2_bdl[i].Offset
590  ));
591 
592  if (!bRet)
593  {
594  goto errorout;
595  }
596 
597  dwTotal += ext2_bdl[i].Length;
598  }
599 
600  *dwReturn = dwTotal;
601 
602  if (size + offset > inode.i_size)
603  {
604  inode.i_size = size + offset;
605  }
606 
607  ext2_save_inode(Ext2Sys, ino, &inode);
608 
609 
610 errorout:
611 
612  if (ext2_bdl)
613  RtlFreeHeap(RtlGetProcessHeap(), 0, ext2_bdl);
614 
615  return bRet;
616 }
bool ext2_save_inode(PEXT2_FILESYS Ext2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:59
ULONG Ext2DataBlocks(PEXT2_FILESYS Ext2Sys, ULONG TotalBlocks)
Definition: Mke2fs.c:698
bool ext2_load_inode(PEXT2_FILESYS Ext2Sys, ULONG no, PEXT2_INODE pInode)
Definition: Inode.c:41
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
GLintptr offset
Definition: glext.h:5920
Definition: fs.h:78
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
bool ext2_expand_inode(PEXT2_FILESYS Ext2Sys, PEXT2_INODE Inode, ULONG newBlk)
Definition: Inode.c:212
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static int blocks
Definition: mkdosfs.c:527
__u64 i_blocks
Definition: fs.h:85
ULONG Length
Definition: Mke2fs.h:194
GLsizeiptr size
Definition: glext.h:5919
__u32 inode
Definition: ext2_fs.h:493
loff_t i_size
Definition: fs.h:80
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG ext2_build_bdl(PEXT2_FILESYS Ext2Sys, PEXT2_INODE ext2_inode, IN ULONG offset, IN ULONG size, OUT PEXT2_BDL *ext2_bdl)
Definition: Inode.c:392
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned int ULONG
Definition: retypes.h:1
#define SECTOR_SIZE
Definition: fs.h:22
bool ext2_alloc_block(PEXT2_FILESYS fs, ULONG goal, ULONG *ret)
Definition: Memory.c:293

Referenced by ext2_add_entry().

◆ ext2_write_inode_bitmap()

bool ext2_write_inode_bitmap ( PEXT2_FILESYS  fs)

Definition at line 216 of file Bitmap.c.

217 {
218  ULONG i;
219  ULONG nbytes;
220  bool retval;
221  char *inode_bitmap = fs->inode_map->bitmap;
222  char *bitmap_block = NULL;
223  ULONG blk;
224 
225  if (!inode_bitmap)
226  return false;
227 
228  nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->ext2_sb)+7) / 8);
229 
230  bitmap_block = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, fs->blocksize);
231  if (!bitmap_block) return false;
232 
233  memset(bitmap_block, 0xff, fs->blocksize);
234 
235  for (i = 0; i < fs->group_desc_count; i++)
236  {
237  memcpy(bitmap_block, inode_bitmap, nbytes);
238  blk = fs->group_desc[i].bg_inode_bitmap;
239 
240  if (blk)
241  {
242 /*
243 #ifdef EXT2_BIG_ENDIAN_BITMAPS
244  if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
245  (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)))
246  ext2_swap_bitmap(fs, bitmap_block, nbytes);
247 #endif
248 */
249  retval = NT_SUCCESS(Ext2WriteDisk(
250  fs,
251  ((ULONGLONG)blk * fs->blocksize),
252  fs->blocksize,
253  (unsigned char *)bitmap_block));
254 
255  if (!retval)
256  {
257  RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
258  return false;
259  }
260  }
261 
262  inode_bitmap += nbytes;
263  }
264 
265  RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
266 
267  return true;
268 }
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define EXT2_INODES_PER_GROUP(s)
Definition: ext2_fs.h:171
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__kernel_size_t size_t
Definition: linux.h:237
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define blk
Definition: linetest.c:70
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ext2_write_bitmaps().

◆ Ext2CloseDevice()

NTSTATUS Ext2CloseDevice ( PEXT2_FILESYS  Ext2Sys)

Definition at line 1342 of file Disk.c.

1343 {
1345 
1346  if(Ext2Sys->MediaHandle)
1347  {
1348  Status = NtClose(Ext2Sys->MediaHandle);
1349  }
1350 
1351  return Status;
1352 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by Ext2Format().

◆ Ext2DataBlocks()

ULONG Ext2DataBlocks ( PEXT2_FILESYS  Ext2Sys,
ULONG  TotalBlocks 
)

Definition at line 698 of file Mke2fs.c.

699 {
700  ULONG dwData[4] = {1, 1, 1, 1};
701  ULONG dwMeta[4] = {0, 0, 0, 0};
702  ULONG DataBlocks = 0;
703  ULONG i, j;
704 
705  if (TotalBlocks <= EXT2_NDIR_BLOCKS)
706  {
707  return TotalBlocks;
708  }
709 
710  TotalBlocks -= EXT2_NDIR_BLOCKS;
711 
712  for (i = 0; i < 4; i++)
713  {
714  dwData[i] = dwData[i] << ((BLOCK_BITS - 2) * i);
715 
716  if (i > 0)
717  {
718  dwMeta[i] = 1 + (dwMeta[i - 1] << (BLOCK_BITS - 2));
719  }
720  }
721 
722  for( i=1; (i < 4) && (TotalBlocks > 0); i++)
723  {
724  if (TotalBlocks >= (dwData[i] + dwMeta[i]))
725  {
726  TotalBlocks -= (dwData[i] + dwMeta[i]);
727  DataBlocks += dwData[i];
728  }
729  else
730  {
731  ULONG dwDivide = 0;
732  ULONG dwRemain = 0;
733 
734  for (j=i; (j > 0) && (TotalBlocks > 0); j--)
735  {
736  dwDivide = (TotalBlocks - 1) / (dwData[j-1] + dwMeta[j-1]);
737  dwRemain = (TotalBlocks - 1) % (dwData[j-1] + dwMeta[j-1]);
738 
739  DataBlocks += (dwDivide * dwData[j-1]);
740  TotalBlocks = dwRemain;
741  }
742  }
743  }
744 
745  return (DataBlocks + EXT2_NDIR_BLOCKS);
746 }
static HANDLE ULONG_PTR dwData
Definition: file.c:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define EXT2_NDIR_BLOCKS
Definition: ext2_fs.h:177
#define BLOCK_BITS
Definition: Mke2fs.c:695
unsigned int ULONG
Definition: retypes.h:1

Referenced by create_lost_and_found(), ext2_expand_inode(), and ext2_write_inode().

◆ Ext2DisMountVolume()

NTSTATUS Ext2DisMountVolume ( PEXT2_FILESYS  Ext2Sys)

Definition at line 1260 of file Disk.c.

1261 {
1262  NTSTATUS Status;
1263  IO_STATUS_BLOCK IoSb;
1264 
1265  Status = NtFsControlFile( Ext2Sys->MediaHandle,
1266  NULL, NULL, NULL, &IoSb,
1268  NULL, 0, NULL, 0 );
1269 
1270  if (!NT_SUCCESS(Status))
1271  {
1272  DPRINT1("Mke2fs: Error when dismounting volume ...\n");
1273  goto errorout;
1274  }
1275 
1276 errorout:
1277 
1278  return Status;
1279 }
LONG NTSTATUS
Definition: precomp.h:26
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
smooth NULL
Definition: ftsmooth.c:416
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8

Referenced by Ext2Format().

◆ Ext2GetMediaInfo()

NTSTATUS Ext2GetMediaInfo ( PEXT2_FILESYS  Ext2Sys)

Definition at line 1162 of file Disk.c.

1163 {
1164  NTSTATUS Status;
1165  IO_STATUS_BLOCK IoSb;
1166 
1168  NULL, NULL, NULL, &IoSb,
1170  &(Ext2Sys->DiskGeometry), sizeof(DISK_GEOMETRY),
1171  &(Ext2Sys->DiskGeometry), sizeof(DISK_GEOMETRY));
1172 
1173 
1174  if (!NT_SUCCESS(Status))
1175  {
1176  goto errorout;
1177  }
1178 
1180  NULL, NULL, NULL, &IoSb,
1182  &(Ext2Sys->PartInfo), sizeof(PARTITION_INFORMATION),
1183  &(Ext2Sys->PartInfo), sizeof(PARTITION_INFORMATION));
1184 
1185  if (!NT_SUCCESS(Status))
1186  {
1187  goto errorout;
1188  }
1189 
1190 errorout:
1191 
1192  return Status;
1193 }
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:88
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
PARTITION_INFORMATION PartInfo
Definition: Mke2fs.h:186
DISK_GEOMETRY DiskGeometry
Definition: Mke2fs.h:184
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169

Referenced by Ext2Format().

◆ Ext2LockVolume()

NTSTATUS Ext2LockVolume ( PEXT2_FILESYS  Ext2Sys)

Definition at line 1212 of file Disk.c.

1213 {
1214  NTSTATUS Status;
1215  IO_STATUS_BLOCK IoSb;
1216 
1217  Status = NtFsControlFile( Ext2Sys->MediaHandle,
1218  NULL, NULL, NULL, &IoSb,
1220  NULL, 0, NULL, 0 );
1221 
1222  if (!NT_SUCCESS(Status))
1223  {
1224  DPRINT1("Mke2fs: Error when locking volume: Status = %lxh %s...\n",
1226 
1227  goto errorout;
1228  }
1229 
1230 errorout:
1231 
1232  return Status;
1233 }
LONG NTSTATUS
Definition: precomp.h:26
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
PCCH Ext2StatusToString(IN NTSTATUS Status)
Definition: Disk.c:19

◆ Ext2OpenDevice()

NTSTATUS Ext2OpenDevice ( PEXT2_FILESYS  Ext2Sys,
PUNICODE_STRING  DeviceName 
)

Definition at line 1282 of file Disk.c.

1284 {
1285  NTSTATUS Status;
1289 
1290  //
1291  // Setup the name in an object attributes structure.
1292  // Note that we create a name that is case INsensitive
1293  //
1294  InitializeObjectAttributes(&ObjectAttributes, // ptr to structure
1295  DeviceName, // ptr to file spec
1296  OBJ_CASE_INSENSITIVE, // attributes
1297  NULL, // root directory handle
1298  NULL ); // ptr to security descriptor
1299 
1300  //
1301  // Do the create. In this particular case, we'll have the I/O Manager
1302  // make our write requests syncrhonous for our convenience.
1303  //
1304  Status = NtCreateFile(&FileHandle, // returned file handle
1305  (GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE), // desired access
1306  &ObjectAttributes, // ptr to object attributes
1307  &Iosb, // ptr to I/O status block
1308  0, // allocation size
1309  FILE_ATTRIBUTE_NORMAL, // file attributes
1310  FILE_SHARE_WRITE | FILE_SHARE_READ, // share access
1311  FILE_OPEN /*FILE_SUPERSEDE*/, // create disposition
1312  FILE_SYNCHRONOUS_IO_NONALERT, // create options
1313  NULL, // ptr to extended attributes
1314  0); // length of ea buffer
1315 
1316  //
1317  // Check the system service status
1318  //
1319  if( !NT_SUCCESS(Status) )
1320  {
1321  DPRINT1("Mke2fs: Create system service failed status = 0x%lx\n", Status);
1322  return Status;
1323  }
1324 
1325 
1326  //
1327  // Check the returned status too...
1328  //
1329  if(!NT_SUCCESS(Iosb.Status) )
1330  {
1331  DPRINT1("Mke2fs: Create failed with status = 0x%lx\n",Iosb.Status);
1332  return Status;
1333  }
1334 
1335  Ext2Sys->MediaHandle = FileHandle;
1336 
1337  return Status;
1338 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE FileHandle
Definition: stats.c:38
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
HANDLE MediaHandle
Definition: Mke2fs.h:182
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

Referenced by Ext2Format().

◆ Ext2ReadDisk()

NTSTATUS Ext2ReadDisk ( PEXT2_FILESYS  Ext2Sys,
ULONGLONG  Offset,
ULONG  Length,
PVOID  Buffer 
)

Definition at line 964 of file Disk.c.

968 {
971  ULONG AlignedLength;
972 
974 
975  PVOID NonPagedBuffer = NULL;
976 
977  ASSERT(Buffer != NULL);
978 
979 #if 0
980  if (Ext2Sys->bFile)
981  {
982  Address.QuadPart = Offset;
983 
984  Status = NtReadFile( Ext2Sys->MediaHandle,
985  NULL,
986  NULL,
987  NULL,
988  &IoStatus,
989  Buffer,
990  Length,
991  &Address,
992  NULL );
993  }
994  else
995 #endif
996  {
997  Address.QuadPart = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
998 
999  AlignedLength = (Length + SECTOR_SIZE - 1)&(~(SECTOR_SIZE - 1));
1000 
1001  AlignedLength += ((ULONG)(Offset - Address.QuadPart) + SECTOR_SIZE - 1)
1002  & (~(SECTOR_SIZE - 1));
1003 
1004  NonPagedBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AlignedLength);
1005  if (!NonPagedBuffer)
1006  {
1008  goto errorout;
1009  }
1010 
1011  Status = NtReadFile( Ext2Sys->MediaHandle,
1012  NULL,
1013  NULL,
1014  NULL,
1015  &IoStatus,
1016  NonPagedBuffer,
1017  AlignedLength,
1018  &Address,
1019  NULL );
1020 
1021  if (!NT_SUCCESS(Status))
1022  {
1023  goto errorout;
1024  }
1025 
1027  (PUCHAR)NonPagedBuffer + (ULONG)(Offset - Address.QuadPart),
1028  Length );
1029  }
1030 
1031 errorout:
1032 
1033  if (NonPagedBuffer)
1034  RtlFreeHeap(RtlGetProcessHeap(), 0, NonPagedBuffer);
1035 
1036  return Status;
1037 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define SECTOR_SIZE
Definition: fs.h:22
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)

◆ Ext2TotalBlocks()

ULONG Ext2TotalBlocks ( PEXT2_FILESYS  Ext2Sys,
ULONG  DataBlocks 
)

Definition at line 750 of file Mke2fs.c.

751 {
752  ULONG dwData[4] = {1, 1, 1, 1};
753  ULONG dwMeta[4] = {0, 0, 0, 0};
754  ULONG TotalBlocks = 0;
755  ULONG i, j;
756 
757  if (DataBlocks <= EXT2_NDIR_BLOCKS)
758  {
759  return DataBlocks;
760  }
761 
762  DataBlocks -= EXT2_NDIR_BLOCKS;
763 
764  for (i = 0; i < 4; i++)
765  {
766  dwData[i] = dwData[i] << ((BLOCK_BITS - 2) * i);
767 
768  if (i > 0)
769  {
770  dwMeta[i] = 1 + (dwMeta[i - 1] << (BLOCK_BITS - 2));
771  }
772  }
773 
774  for( i=1; (i < 4) && (DataBlocks > 0); i++)
775  {
776  if (DataBlocks >= dwData[i])
777  {
778  DataBlocks -= dwData[i];
779  TotalBlocks += (dwData[i] + dwMeta[i]);
780  }
781  else
782  {
783  ULONG dwDivide = 0;
784  ULONG dwRemain = 0;
785 
786  for (j=i; (j > 0) && (DataBlocks > 0); j--)
787  {
788  dwDivide = (DataBlocks) / (dwData[j-1]);
789  dwRemain = (DataBlocks) % (dwData[j-1]);
790 
791  TotalBlocks += (dwDivide * (dwData[j-1] + dwMeta[j-1]) + 1);
792  DataBlocks = dwRemain;
793  }
794  }
795  }
796 
797  return (TotalBlocks + EXT2_NDIR_BLOCKS);
798 }
static HANDLE ULONG_PTR dwData
Definition: file.c:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define EXT2_NDIR_BLOCKS
Definition: ext2_fs.h:177
#define BLOCK_BITS
Definition: Mke2fs.c:695
unsigned int ULONG
Definition: retypes.h:1

Referenced by create_lost_and_found().

◆ Ext2UnLockVolume()

NTSTATUS Ext2UnLockVolume ( PEXT2_FILESYS  Ext2Sys)

Definition at line 1237 of file Disk.c.

1238 {
1239  NTSTATUS Status;
1240  IO_STATUS_BLOCK IoSb;
1241 
1242  Status = NtFsControlFile( Ext2Sys->MediaHandle,
1243  NULL, NULL, NULL, &IoSb,
1245  NULL, 0, NULL, 0 );
1246 
1247  if (!NT_SUCCESS(Status))
1248  {
1249  DPRINT1("Mke2fs: Error when unlocking volume ...\n");
1250  goto errorout;
1251  }
1252 
1253 errorout:
1254 
1255  return Status;
1256 }
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
LONG NTSTATUS
Definition: precomp.h:26
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8

Referenced by Ext2Format().

◆ Ext2WriteDisk()

NTSTATUS Ext2WriteDisk ( PEXT2_FILESYS  Ext2Sys,
ULONGLONG  Offset,
ULONG  Length,
PVOID  Buffer 
)

Definition at line 1059 of file Disk.c.

1063 {
1065  NTSTATUS Status;
1066  ULONG AlignedLength;
1067 
1069 
1070  PVOID NonPagedBuffer = NULL;
1071 
1072  ASSERT(Buffer != NULL);
1073 
1074 #if 0
1075  if (Ext2Sys->bFile)
1076  {
1077  Address.QuadPart = Offset;
1078 
1079  Status = NtWriteFile( Ext2Sys->MediaHandle,
1080  NULL,
1081  NULL,
1082  NULL,
1083  &IoStatus,
1084  Buffer,
1085  Length,
1086  &Address,
1087  NULL );
1088  }
1089  else
1090 #endif
1091  {
1092  Address.QuadPart = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
1093 
1094  AlignedLength = (Length + SECTOR_SIZE - 1)&(~(SECTOR_SIZE - 1));
1095 
1096  AlignedLength += ((ULONG)(Offset - Address.QuadPart) + SECTOR_SIZE - 1)
1097  & (~(SECTOR_SIZE - 1));
1098 
1099  NonPagedBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AlignedLength);
1100  if (!NonPagedBuffer)
1101  {
1103  goto errorout;
1104  }
1105 
1106  if ((AlignedLength != Length) || (Address.QuadPart != (LONGLONG)Offset))
1107  {
1108  Status = NtReadFile( Ext2Sys->MediaHandle,
1109  NULL,
1110  NULL,
1111  NULL,
1112  &IoStatus,
1113  NonPagedBuffer,
1114  AlignedLength,
1115  &Address,
1116  NULL );
1117 
1118  if (!NT_SUCCESS(Status))
1119  {
1120  goto errorout;
1121  }
1122  }
1123 
1124  RtlCopyMemory( (PUCHAR)NonPagedBuffer + (ULONG)(Offset - Address.QuadPart),
1125  Buffer, Length );
1126 
1127  Status = NtWriteFile( Ext2Sys->MediaHandle,
1128  NULL,
1129  NULL,
1130  NULL,
1131  &IoStatus,
1132  NonPagedBuffer,
1133  AlignedLength,
1134  &Address,
1135  NULL );
1136  }
1137 
1138 errorout:
1139 
1140  if (NonPagedBuffer)
1141  RtlFreeHeap(RtlGetProcessHeap(), 0, NonPagedBuffer);
1142 
1143  return Status;
1144 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
HANDLE MediaHandle
Definition: Mke2fs.h:182
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define SECTOR_SIZE
Definition: fs.h:22
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)

Referenced by create_journal_dev(), ext2_alloc_block(), ext2_flush(), ext2_save_inode(), ext2_write_block(), ext2_write_block_bitmap(), ext2_write_inode(), ext2_write_inode_bitmap(), write_primary_superblock(), zap_sector(), and zero_blocks().

◆ parase_cmd()

bool parase_cmd ( int  argc,
char argv[],
PEXT2_FILESYS  pExt2Sys 
)

◆ uuid_generate()

void uuid_generate ( __u8 uuid)

Definition at line 17 of file Uuid.c.

18 {
19 #if 0
20  UuidCreate((UUID *) uuid);
21 #else
22  RtlZeroMemory(uuid, 16);
23 #endif
24 }
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:306
Definition: msctf.idl:510
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by Ext2Format().

◆ write_inode_tables()

bool write_inode_tables ( PEXT2_FILESYS  fs)

Definition at line 221 of file Memory.c.

222 {
223  bool retval;
224  ULONG blk, num;
225  int i;
226 
227  for (i = 0; (ULONG)i < fs->group_desc_count; i++)
228  {
229  blk = fs->group_desc[i].bg_inode_table;
230  num = fs->inode_blocks_per_group;
231 
232  retval = zero_blocks(fs, blk, num, &blk, &num);
233  if (!retval)
234  {
235  DPRINT1("\nMke2fs: Could not write %lu blocks "
236  "in inode table starting at %lu.\n",
237  num, blk);
238 
239  zero_blocks(0, 0, 0, 0, 0);
240  return false;
241  }
242  }
243 
244  zero_blocks(0, 0, 0, 0, 0);
245 
246  return true;
247 }
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLuint GLuint num
Definition: glext.h:9618
#define blk
Definition: linetest.c:70
bool zero_blocks(PEXT2_FILESYS fs, ULONG blk, ULONG num, ULONG *ret_blk, ULONG *ret_count)
Definition: Mke2fs.c:122
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2Format().

◆ zero_blocks()

bool zero_blocks ( PEXT2_FILESYS  fs,
ULONG  blk,
ULONG  num,
ULONG ret_blk,
ULONG ret_count 
)

Definition at line 122 of file Mke2fs.c.

124 {
125  ULONG j, count;
126  static unsigned char *buf;
127  bool retval;
128 
129  /* If fs is null, clean up the static buffer and return */
130  if (!fs)
131  {
132  if (buf)
133  {
134  RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
135  buf = 0;
136  }
137  return true;
138  }
139 
140 #define STRIDE_LENGTH 8
141 
142  /* Allocate the zeroizing buffer if necessary */
143  if (!buf)
144  {
145  buf = (unsigned char *)
146  RtlAllocateHeap(RtlGetProcessHeap(), 0, fs->blocksize * STRIDE_LENGTH);
147  if (!buf)
148  {
149  DPRINT1("Mke2fs: while allocating zeroizing buffer");
150  if (ret_blk)
151  *ret_blk = blk;
152  return false;
153  }
154  memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
155  }
156 
157  /* OK, do the write loop */
158  for (j=0; j < num; j += STRIDE_LENGTH, blk += STRIDE_LENGTH)
159  {
160  if (num-j > STRIDE_LENGTH)
162  else
163  count = num - j;
164 
165  retval = NT_SUCCESS(Ext2WriteDisk(
166  fs,
167  ((ULONGLONG)blk * fs->blocksize),
168  count * fs->blocksize,
169  buf));
170 
171  if (!retval)
172  {
173  if (ret_count)
174  *ret_count = count;
175 
176  if (ret_blk)
177  *ret_blk = blk;
178 
179  return retval;
180  }
181  }
182 
183  return true;
184 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
NTSTATUS Ext2WriteDisk(PEXT2_FILESYS Ext2Sys, ULONGLONG Offset, ULONG Length, PVOID Buffer)
Definition: Disk.c:1059
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
Definition: fs.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
GLuint GLuint num
Definition: glext.h:9618
#define blk
Definition: linetest.c:70
#define STRIDE_LENGTH
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39

Referenced by create_journal_dev(), Ext2Format(), and write_inode_tables().