4 BOOLEAN
Ext2ReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
9 #define BLOCKSIZE (1024)
11 struct ext2_super_block
{
12 ULONG s_inodes_count
; /* Inodes count */
13 ULONG s_blocks_count
; /* Blocks count */
14 ULONG s_r_blocks_count
; /* Reserved blocks count */
15 ULONG s_free_blocks_count
; /* Free blocks count */
16 ULONG s_free_inodes_count
; /* Free inodes count */
17 ULONG s_first_data_block
; /* First Data Block */
18 ULONG s_log_block_size
; /* Block size */
19 LONG s_log_frag_size
; /* Fragment size */
20 ULONG s_blocks_per_group
; /* # Blocks per group */
21 ULONG s_frags_per_group
; /* # Fragments per group */
22 ULONG s_inodes_per_group
; /* # Inodes per group */
23 ULONG s_mtime
; /* Mount time */
24 ULONG s_wtime
; /* Write time */
25 USHORT s_mnt_count
; /* Mount count */
26 SHORT s_max_mnt_count
; /* Maximal mount count */
27 USHORT s_magic
; /* Magic signature */
28 USHORT s_state
; /* File system state */
29 USHORT s_errors
; /* Behaviour when detecting errors */
30 USHORT s_minor_rev_level
; /* minor revision level */
31 ULONG s_lastcheck
; /* time of last check */
32 ULONG s_checkinterval
; /* max. time between checks */
33 ULONG s_creator_os
; /* OS */
34 ULONG s_rev_level
; /* Revision level */
35 USHORT s_def_resuid
; /* Default uid for reserved blocks */
36 USHORT s_def_resgid
; /* Default gid for reserved blocks */
38 * These fields are for EXT2_DYNAMIC_REV superblocks only.
40 * Note: the difference between the compatible feature set and
41 * the incompatible feature set is that if there is a bit set
42 * in the incompatible feature set that the kernel doesn't
43 * know about, it should refuse to mount the filesystem.
45 * e2fsck's requirements are more strict; if it doesn't know
46 * about a feature in either the compatible or incompatible
47 * feature set, it must abort and not try to meddle with
48 * things it doesn't understand...
50 ULONG s_first_ino
; /* First non-reserved inode */
51 USHORT s_inode_size
; /* size of inode structure */
52 USHORT s_block_group_nr
; /* block group # of this superblock */
53 ULONG s_feature_compat
; /* compatible feature set */
54 ULONG s_feature_incompat
; /* incompatible feature set */
55 ULONG s_feature_ro_compat
; /* readonly-compatible feature set */
56 ULONG s_reserved
[230]; /* Padding to the end of the block */
60 * Codes for operating systems
62 #define EXT2_OS_LINUX 0
63 #define EXT2_OS_HURD 1
64 #define EXT2_OS_MASIX 2
65 #define EXT2_OS_FREEBSD 3
66 #define EXT2_OS_LITES 4
71 #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
72 #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
74 #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
75 #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
78 * The second extended file system magic number
80 #define EXT2_SUPER_MAGIC 0xEF53
83 * Constants relative to the data blocks
85 #define EXT2_NDIR_BLOCKS 12
86 #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
87 #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
88 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
89 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
93 * Structure of an inode on the disk
96 USHORT i_mode
; /* File mode */
97 USHORT i_uid
; /* Owner Uid */
98 ULONG i_size
; /* Size in bytes */
99 ULONG i_atime
; /* Access time */
100 ULONG i_ctime
; /* Creation time */
101 ULONG i_mtime
; /* Modification time */
102 ULONG i_dtime
; /* Deletion Time */
103 USHORT i_gid
; /* Group Id */
104 USHORT i_links_count
; /* Links count */
105 ULONG i_blocks
; /* Blocks count */
106 ULONG i_flags
; /* File flags */
112 ULONG h_i_translator
;
117 } osd1
; /* OS dependent 1 */
118 ULONG i_block
[EXT2_N_BLOCKS
];/* Pointers to blocks */
119 ULONG i_version
; /* File version (for NFS) */
120 ULONG i_file_acl
; /* File ACL */
121 ULONG i_dir_acl
; /* Directory ACL */
122 ULONG i_faddr
; /* Fragment address */
125 UCHAR l_i_frag
; /* Fragment number */
126 UCHAR l_i_fsize
; /* Fragment size */
128 ULONG l_i_reserved2
[2];
131 UCHAR h_i_frag
; /* Fragment number */
132 UCHAR h_i_fsize
; /* Fragment size */
133 USHORT h_i_mode_high
;
139 UCHAR m_i_frag
; /* Fragment number */
140 UCHAR m_i_fsize
; /* Fragment size */
142 ULONG m_i_reserved2
[2];
144 } osd2
; /* OS dependent 2 */
147 #if defined(__KERNEL__) || defined(__linux__)
148 #define i_reserved1 osd1.linux1.l_i_reserved1
149 #define i_frag osd2.linux2.l_i_frag
150 #define i_fsize osd2.linux2.l_i_fsize
151 #define i_reserved2 osd2.linux2.l_i_reserved2
155 #define i_translator osd1.hurd1.h_i_translator
156 #define i_frag osd2.hurd2.h_i_frag;
157 #define i_fsize osd2.hurd2.h_i_fsize;
158 #define i_uid_high osd2.hurd2.h_i_uid_high
159 #define i_gid_high osd2.hurd2.h_i_gid_high
160 #define i_author osd2.hurd2.h_i_author
164 #define i_reserved1 osd1.masix1.m_i_reserved1
165 #define i_frag osd2.masix2.m_i_frag
166 #define i_fsize osd2.masix2.m_i_fsize
167 #define i_reserved2 osd2.masix2.m_i_reserved2
171 * Constants relative to the data blocks
173 #define EXT2_NDIR_BLOCKS 12
174 #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
175 #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
176 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
177 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
182 #define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
183 #define EXT2_UNRM_FL 0x00000002 /* Undelete */
184 #define EXT2_COMPR_FL 0x00000004 /* Compress file */
185 #define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
186 #define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
187 #define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
188 #define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
189 #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
193 * Structure of a blocks group descriptor
195 struct ext2_group_desc
197 ULONG bg_block_bitmap
; /* Blocks bitmap block */
198 ULONG bg_inode_bitmap
; /* Inodes bitmap block */
199 ULONG bg_inode_table
; /* Inodes table block */
200 USHORT bg_free_blocks_count
; /* Free blocks count */
201 USHORT bg_free_inodes_count
; /* Free inodes count */
202 USHORT bg_used_dirs_count
; /* Directories count */
204 ULONG bg_reserved
[3];
207 #define EXT2_NAME_LEN 255
209 struct ext2_dir_entry
{
210 ULONG inode
; /* Inode number */
211 USHORT rec_len
; /* Directory entry length */
212 USHORT name_len
; /* Name length */
213 char name
[EXT2_NAME_LEN
]; /* File name */
218 PDEVICE_OBJECT StorageDevice
;
219 struct ext2_super_block
* superblock
;
220 PFILE_OBJECT FileObject
;
222 } DEVICE_EXTENSION
, *PDEVICE_EXTENSION
;
224 typedef struct _EXT2_GROUP_DESC
227 struct ext2_group_desc
* desc
;
228 PCACHE_SEGMENT CacheSeg
;
230 } EXT2_GROUP_DESC
, *PEXT2_GROUP_DESC
;
232 PEXT2_GROUP_DESC
Ext2LoadGroup(PDEVICE_EXTENSION DeviceExt
,
234 VOID
Ext2ReleaseGroup(PDEVICE_EXTENSION DeviceExt
,
235 PEXT2_GROUP_DESC GrpDesc
);
237 VOID
Ext2ReadInode(PDEVICE_EXTENSION DeviceExt
,
239 struct ext2_inode
* inode
);
240 struct ext2_group_desc
* Ext2LoadGroupDesc(PDEVICE_EXTENSION DeviceExt
,
243 typedef struct _EXT2_INODE
245 struct ext2_inode
* inode
;
247 PCACHE_SEGMENT CacheSeg
;
248 } EXT2_INODE
, *PEXT2_INODE
;
250 typedef struct _EXT2_FCB
255 } EXT2_FCB
, *PEXT2_FCB
;
257 ULONG
Ext2BlockMap(PDEVICE_EXTENSION DeviceExt
,
258 struct ext2_inode
* inode
,
260 NTSTATUS
Ext2OpenFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
262 NTSTATUS
Ext2ReadFile(PDEVICE_EXTENSION DeviceExt
,
263 PFILE_OBJECT FileObject
,
266 LARGE_INTEGER Offset
);
267 NTSTATUS STDCALL
Ext2Create(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
268 NTSTATUS STDCALL
Ext2DirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
269 NTSTATUS STDCALL
Ext2QueryQuota(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
270 NTSTATUS STDCALL
Ext2SetQuota(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
271 NTSTATUS STDCALL
Ext2SetSecurity(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
272 NTSTATUS STDCALL
Ext2QuerySecurity(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
273 NTSTATUS STDCALL
Ext2SetInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
274 NTSTATUS STDCALL
Ext2QueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
275 NTSTATUS STDCALL
Ext2Read(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
276 NTSTATUS STDCALL
Ext2Write(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
277 NTSTATUS STDCALL
Ext2Cleanup(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
278 NTSTATUS STDCALL
Ext2FlushBuffers(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
279 NTSTATUS STDCALL
Ext2Shutdown(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
280 NTSTATUS
Ext2ReadPage(PDEVICE_EXTENSION DeviceExt
,
284 VOID
Ext2LoadInode(PDEVICE_EXTENSION DeviceExt
,
287 VOID
Ext2ReleaseInode(PDEVICE_EXTENSION DeviceExt
,