?? ext2fs.h
字號:
/*
* COPYRIGHT: See COPYRIGHT.TXT
* PROJECT: Ext2 File System for NT
* FILE: Ext2fs.h
* PURPOSE: Header file: ext2 structures
* PROGRAMMER: Matt Wu <mattwu@163.com>
* HOMEPAGE: http://ext2.yeah.net
* UPDATE HISTORY:
*/
#ifndef _EXT2_HEADER_
#define _EXT2_HEADER_
/* INCLUDES *****************************************************************/
#include <ntdddisk.h>
/* DEBUG *****************************************************************/
#undef DBG
#define DBG 0
/* STRUCTS & CONSTS******************************************************/
#define EXT2_RO
/* Ext2 releated ******************************************************/
#pragma pack(1)
#define SECTOR_SIZE (512)
typedef struct ext2_super_block {
ULONG s_inodes_count; /* Inodes count */
ULONG s_blocks_count; /* Blocks count */
ULONG s_r_blocks_count; /* Reserved blocks count */
ULONG s_free_blocks_count; /* Free blocks count */
ULONG s_free_inodes_count; /* Free inodes count */
ULONG s_first_data_block; /* First Data Block */
ULONG s_log_block_size; /* Block size */
LONG s_log_frag_size; /* Fragment size */
ULONG s_blocks_per_group; /* # Blocks per group */
ULONG s_frags_per_group; /* # Fragments per group */
ULONG s_inodes_per_group; /* # Inodes per group */
ULONG s_mtime; /* Mount time */
ULONG s_wtime; /* Write time */
USHORT s_mnt_count; /* Mount count */
SHORT s_max_mnt_count; /* Maximal mount count */
USHORT s_magic; /* Magic signature */
USHORT s_state; /* File system state */
USHORT s_errors; /* Behaviour when detecting errors */
USHORT s_minor_rev_level; /* minor revision level */
ULONG s_lastcheck; /* time of last check */
ULONG s_checkinterval; /* max. time between checks */
ULONG s_creator_os; /* OS */
ULONG s_rev_level; /* Revision level */
USHORT s_def_resuid; /* Default uid for reserved blocks */
USHORT s_def_resgid; /* Default gid for reserved blocks */
/*
* These fields are for EXT2_DYNAMIC_REV superblocks only.
*
* Note: the difference between the compatible feature set and
* the incompatible feature set is that if there is a bit set
* in the incompatible feature set that the kernel doesn't
* know about, it should refuse to mount the filesystem.
*
* e2fsck's requirements are more strict; if it doesn't know
* about a feature in either the compatible or incompatible
* feature set, it must abort and not try to meddle with
* things it doesn't understand...
*/
ULONG s_first_ino; /* First non-reserved inode */
USHORT s_inode_size; /* size of inode structure */
USHORT s_block_group_nr; /* block group # of this superblock */
ULONG s_feature_compat; /* compatible feature set */
ULONG s_feature_incompat; /* incompatible feature set */
ULONG s_feature_ro_compat; /* readonly-compatible feature set */
ULONG s_reserved[230]; /* Padding to the end of the block */
} EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
/*
* Codes for operating systems
*/
#define EXT2_OS_LINUX 0
#define EXT2_OS_HURD 1
#define EXT2_OS_MASIX 2
#define EXT2_OS_FREEBSD 3
#define EXT2_OS_LITES 4
/*
* Revision levels
*/
#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
/*
* The second extended file system magic number
*/
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT2_MIN_BLOCK 1024
#define EXT2_MIN_FRAG 1024
/*
* (Your local time - GMT) *3600
*/
#define TIMEZONEDIFF 7200
#define TIMEZONE TIMEZONEDIFF+14400
/*
* Constants relative to the data blocks
*/
#define EXT2_NDIR_BLOCKS 12
#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
/*
* Structure of an inode on the disk
*/
typedef struct ext2_inode {
USHORT i_mode; /* File mode */
USHORT i_uid; /* Owner Uid */
ULONG i_size; /* Size in bytes */
ULONG i_atime; /* Access time */
ULONG i_ctime; /* Creation time */
ULONG i_mtime; /* Modification time */
ULONG i_dtime; /* Deletion Time */
USHORT i_gid; /* Group Id */
USHORT i_links_count; /* Links count */
ULONG i_blocks; /* Blocks count */
ULONG i_flags; /* File flags */
union {
struct {
ULONG l_i_reserved1;
} linux1;
struct {
ULONG h_i_translator;
} hurd1;
struct {
ULONG m_i_reserved1;
} masix1;
} osd1; /* OS dependent 1 */
ULONG i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
ULONG i_version; /* File version (for NFS) */
ULONG i_file_acl; /* File ACL */
ULONG i_dir_acl; /* Directory ACL */
ULONG i_faddr; /* Fragment address */
union {
struct {
UCHAR l_i_frag; /* Fragment number */
UCHAR l_i_fsize; /* Fragment size */
USHORT i_pad1;
ULONG l_i_reserved2[2];
} linux2;
struct {
UCHAR h_i_frag; /* Fragment number */
UCHAR h_i_fsize; /* Fragment size */
USHORT h_i_mode_high;
USHORT h_i_uid_high;
USHORT h_i_gid_high;
ULONG h_i_author;
} hurd2;
struct {
UCHAR m_i_frag; /* Fragment number */
UCHAR m_i_fsize; /* Fragment size */
USHORT m_pad1;
ULONG m_i_reserved2[2];
} masix2;
} osd2; /* OS dependent 2 */
} EXT2_INODE, *PEXT2_INODE;
#if defined(__KERNEL__) || defined(__linux__)
#define i_reserved1 osd1.linux1.l_i_reserved1
#define i_frag osd2.linux2.l_i_frag
#define i_fsize osd2.linux2.l_i_fsize
#define i_reserved2 osd2.linux2.l_i_reserved2
#endif
#ifdef __hurd__
#define i_translator osd1.hurd1.h_i_translator
#define i_frag osd2.hurd2.h_i_frag;
#define i_fsize osd2.hurd2.h_i_fsize;
#define i_uid_high osd2.hurd2.h_i_uid_high
#define i_gid_high osd2.hurd2.h_i_gid_high
#define i_author osd2.hurd2.h_i_author
#endif
#ifdef __masix__
#define i_reserved1 osd1.masix1.m_i_reserved1
#define i_frag osd2.masix2.m_i_frag
#define i_fsize osd2.masix2.m_i_fsize
#define i_reserved2 osd2.masix2.m_i_reserved2
#endif
/*
* Inode flags
*/
#define S_IFMT 0x0F000 /*017 0000 */
#define S_IFSOCK 0x0C000 /*014 0000 */
#define S_IFLNK 0x0A000 /*012 0000 */
#define S_IFFIL 0x08000 /*010 0000 */
#define S_IFBLK 0x06000 /*006 0000 */
#define S_IFDIR 0x04000 /*004 0000 */
#define S_IFCHR 0x02000 /*002 0000 */
#define S_IFIFO 0x01000 /*001 0000 */
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISFIL(m) (((m) & S_IFMT) == S_IFFIL)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
/*not yet supported: */
#define S_IFUID 0x00800 /*000 4000 */
#define S_IFGID 0x00400 /*000 2000 */
#define S_IFVTX 0x00200 /*000 1000 */
#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
#define EXT2_UNRM_FL 0x00000002 /* Undelete */
#define EXT2_COMPR_FL 0x00000004 /* Compress file */
#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
/*
* Structure of a blocks group descriptor
*/
typedef struct ext2_group_desc
{
ULONG bg_block_bitmap; /* Blocks bitmap block */
ULONG bg_inode_bitmap; /* Inodes bitmap block */
ULONG bg_inode_table; /* Inodes table block */
USHORT bg_free_blocks_count; /* Free blocks count */
USHORT bg_free_inodes_count; /* Free inodes count */
USHORT bg_used_dirs_count; /* Directories count */
USHORT bg_pad;
ULONG bg_reserved[3];
} EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
#define EXT2_NAME_LEN 255
typedef struct ext2_dir_entry {
ULONG inode; /* Inode number */
USHORT rec_len; /* Directory entry length */
USHORT name_len; /* Name length */
char name[EXT2_NAME_LEN]; /* File name */
} EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
/* File System releated ******************************************************/
#define DRIVER_NAME "Ext2fs"
#define DEVICE_NAME L"\\Ext2fs"
#if DBG
#define DOS_DEVICE_NAME L"\\DosDevices\\Ext2fs"
#endif
#define IOCTL_PREPARE_TO_UNLOAD \
CTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_NEITHER, FILE_WRITE_ACCESS)
//
// EXT2_IDENTIFIER_TYPE
//
// Identifiers used to mark the structures
//
typedef enum _EXT2_IDENTIFIER_TYPE {
FGD = ':DGF',
VCB = ':BCV',
FCB = ':BCF',
CCB = ':BCC',
ICX = ':XCI',
FSD = ':DSF'
} EXT2_IDENTIFIER_TYPE;
//
// EXT2_IDENTIFIER
//
// Header used to mark the structures
//
typedef struct _EXT2_IDENTIFIER {
EXT2_IDENTIFIER_TYPE Type;
ULONG Size;
} EXT2_IDENTIFIER, *PEXT2_IDENTIFIER;
//
// EXT2_GLOBAL_DATA
//
// Data that is not specific to a mounted volume
//
typedef struct _EXT2_GLOBAL {
// Identifier for this structure
EXT2_IDENTIFIER Identifier;
// Syncronization primitive for this structure
ERESOURCE Resource;
// Table of pointers to the fast I/O entry points
FAST_IO_DISPATCH FastIoDispatch;
// Table of pointers to the Cache Manager callbacks
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
// Pointer to the driver object
PDRIVER_OBJECT DriverObject;
// Pointer to the main device object
PDEVICE_OBJECT DeviceObject;
// List of mounted volumes
LIST_ENTRY VcbList;
// Global flags for the driver
ULONG Flags;
LARGE_INTEGER TimeZone;
} EXT2_GLOBAL, *PEXT2_GLOBAL;
//
// Flags for EXT2_GLOBAL_DATA
//
#define EXT2_UNLOAD_PENDING 0x00000001
//
// Driver Extension define
//
typedef struct {
EXT2_GLOBAL Ext2Global;
} EXT2FS_EXT, *PEXT2FS_EXT;
//
// EXT2_VCB Volume Control Block
//
// Data that represents a mounted logical volume
// It is allocated as the device extension of the volume device object
//
typedef struct _EXT2_VCB {
// FCB header required by NT
// The VCB is also used as an FCB for file objects
// that represents the volume itself
FSRTL_COMMON_FCB_HEADER CommonFCBHeader;
SECTION_OBJECT_POINTERS SectionObject;
ERESOURCE MainResource;
ERESOURCE PagingIoResource;
// end FCB header required by NT
// Identifier for this structure
EXT2_IDENTIFIER Identifier;
LIST_ENTRY Next;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
// for files on this volume.
ULONG OpenFileHandleCount;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
// for both files on this volume and open instances of the
// volume itself.
ULONG ReferenceCount;
// Pointer to the VPB in the target device object
PVPB Vpb;
#ifndef EXT2_RO
// If the volume is mounted read only
BOOLEAN ReadOnly;
#endif
// List of FCBs for open files on this volume
LIST_ENTRY FcbList;
// This volumes device object
PDEVICE_OBJECT DeviceObject;
// The physical device object (the disk)
PDEVICE_OBJECT TargetDeviceObject;
// Information about the physical device object
DISK_GEOMETRY DiskGeometry;
PARTITION_INFORMATION PartitionInformation;
// Pointer to the file system superblock
PEXT2_SUPER_BLOCK ext2_super_block;
PEXT2_GROUP_DESC ext2_group_desc;
// Number of Group Decsciptions
ULONG ext2_groups;
// Block and fragment size
ULONG ext2_block;
ULONG ext2_frag;
// Flags for the volume
ULONG Flags;
} EXT2_VCB, *PEXT2_VCB;
//
// Flags for EXT2_VCB
//
#define VCB_VOLUME_LOCKED 0x00000001
#define VCB_DISMOUNT_PENDING 0x00000002
//
// EXT2_FCB File Control Block
//
// Data that represents an open file
// There is a single instance of the FCB for every open file
//
typedef struct _EXT2_FCB {
// FCB header required by NT
FSRTL_COMMON_FCB_HEADER CommonFCBHeader;
SECTION_OBJECT_POINTERS SectionObject;
ERESOURCE MainResource;
ERESOURCE PagingIoResource;
// end FCB header required by NT
// Identifier for this structure
EXT2_IDENTIFIER Identifier;
// List of FCBs for this volume
LIST_ENTRY Next;
#ifndef EXT2_RO
// Share Access for the file object
SHARE_ACCESS ShareAccess;
#endif
// List of byte-range locks for this file
FILE_LOCK_ANCHOR FileLockAnchor;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
ULONG OpenHandleCount;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
ULONG ReferenceCount;
#ifndef EXT2_RO
// If the file is a page file
BOOLEAN IsPageFile;
// If the file is to be deleted
BOOLEAN DeletePending;
#endif
// The filename
UNICODE_STRING FileName;
#if DBG
// Non unicode filename for use in debug prints
PUCHAR DbgFileName;
#endif
// The file attributes
ULONG FileAttributes;
// The offset in it's directory
LARGE_INTEGER IndexNumber;
// Pointer to the inode
struct ext2_inode* ext2_inode;
// Inode number and it's directory's inode number
ULONG inode;
ULONG dir_inode;
} EXT2_FCB, *PEXT2_FCB;
//
// EXT2_CCB Context Control Block
//
// Data that represents one instance of an open file
// There is one instance of the CCB for every instance of an open file
//
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -