1 /*************************************************************************
5 * Module: Ext2 File System Driver (Kernel mode execution only)
8 * The main include file for the Ext2 file system driver.
10 * Author: Manoj Paul Joseph
13 *************************************************************************/
19 #define EXT2_POOL_WITH_TAG
22 // some constant definitions
23 #define EXT2_PANIC_IDENTIFIER (0x86427531)
25 // any directory information EXT2 obtains from the local file system
26 // will use a buffer of the following size ... (in KB)
27 #define EXT2_READ_DIR_BUFFER_LENGTH (512)
28 #define EXT2_MAXCLOSABLE_FCBS_UL 20
29 #define EXT2_MAXCLOSABLE_FCBS_LL 10
31 // Some type definitions...
32 // These are used later...
34 typedef unsigned int UINT
;
35 typedef unsigned char BYTE
;
37 // Common include files - should be in the include dir of the MS supplied IFS Kit
44 /* This is deprecated and should be changed in the EXT2FS driver. */
45 #define RtlLargeIntegerLessThan(a, b) (a).QuadPart < (b).QuadPart
46 #define RtlLargeIntegerGreaterThan(a, b) (a).QuadPart > (b).QuadPart
49 // the following include files should be in the inc sub-dir associated with this driver
50 #include "ext2metadata.h"
56 // global variables - minimize these
57 extern Ext2Data Ext2GlobalData
;
59 // try-finally simulation
60 #define try_return(S) { S; goto try_exit; }
61 #define try_return1(S) { S; goto try_exit1; }
62 #define try_return2(S) { S; goto try_exit2; }
64 // some global (helpful) macros
65 #define Ext2IsFlagOn(Flags,SingleFlag) ((BOOLEAN)((((Flags) & (SingleFlag)) != 0)))
66 #define Ext2SetFlag(Flag, Value) ((Flag) |= (Value))
67 #define Ext2ClearFlag(Flag, Value) ((Flag) &= ~(Value))
69 #define Ext2QuadAlign(Value) ((((uint32)(Value)) + 7) & 0xfffffff8)
71 // to perform a bug-check (panic), the following macro is used
72 #define Ext2Panic(arg1, arg2, arg3) \
73 (KeBugCheckEx(EXT2_PANIC_IDENTIFIER, EXT2_BUG_CHECK_ID | __LINE__, (uint32)(arg1), (uint32)(arg2), (uint32)(arg3)))
75 // a convenient macro (must be invoked in the context of the thread that acquired the resource)
76 #define Ext2ReleaseResource(Resource) \
77 (ExReleaseResourceForThreadLite((Resource), ExGetCurrentResourceThread()))
79 // each file has a unique bug-check identifier associated with it.
80 // Here is a list of constant definitions for these identifiers
81 #define EXT2_FILE_INIT (0x00000001)
82 #define EXT2_FILE_REGISTRY (0x00000002)
83 #define EXT2_FILE_CREATE (0x00000003)
84 #define EXT2_FILE_CLEANUP (0x00000004)
85 #define EXT2_FILE_CLOSE (0x00000005)
86 #define EXT2_FILE_READ (0x00000006)
87 #define EXT2_FILE_WRITE (0x00000007)
88 #define EXT2_FILE_INFORMATION (0x00000008)
89 #define EXT2_FILE_FLUSH (0x00000009)
90 #define EXT2_FILE_VOL_INFORMATION (0x0000000A)
91 #define EXT2_FILE_DIR_CONTROL (0x0000000B)
92 #define EXT2_FILE_FILE_CONTROL (0x0000000C)
93 #define EXT2_FILE_DEVICE_CONTROL (0x0000000D)
94 #define EXT2_FILE_SHUTDOWN (0x0000000E)
95 #define EXT2_FILE_LOCK_CONTROL (0x0000000F)
96 #define EXT2_FILE_SECURITY (0x00000010)
97 #define EXT2_FILE_EXT_ATTR (0x00000011)
98 #define EXT2_FILE_MISC (0x00000012)
99 #define EXT2_FILE_FAST_IO (0x00000013)
100 #define EXT2_FILE_IO (0x00000014)
101 #define EXT2_FILE_METADATA_IO (0x00000015)
106 #define Ext2BreakPoint() DbgBreakPoint()
108 #define Ext2BreakPoint()
111 #define Ext2RaiseStatus(IRPCONTEXT,STATUS) \
113 (IRPCONTEXT)->ExceptionStatus = (STATUS); \
114 ExRaiseStatus( (STATUS) ); \
117 #ifdef EXT2_POOL_WITH_TAG
118 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
119 #define Ext2AllocatePool(PoolType,NumberOfBytes) \
120 ExAllocatePoolWithTag( PoolType, NumberOfBytes, TAG ( 'E','x','t','2' ) )
122 #define Ext2AllocatePool(PoolType,NumberOfBytes) \
123 ExAllocatePool( PoolType, NumberOfBytes )
131 // Any number of these may be enabled...
133 #define DEBUG_TRACE_IRQL (0x00000001)
134 #define DEBUG_TRACE_IRP_ENTRY (0x00000002)
135 #define DEBUG_TRACE_RESOURCE_ACQUIRE (0x00000004)
136 #define DEBUG_TRACE_RESOURCE_RELEASE (0x00000008)
137 #define DEBUG_TRACE_RESOURCE_RETRY (0x00000010)
138 #define DEBUG_TRACE_ASYNC (0x00000020)
139 #define DEBUG_TRACE_MOUNT (0x00000040)
140 #define DEBUG_TRACE_RESOURCE_STATE (0x00000080)
141 #define DEBUG_TRACE_MISC (0x00000100)
142 #define DEBUG_TRACE_FILE_OBJ (0x00000200)
143 #define DEBUG_TRACE_FILE_NAME (0x00000400)
144 #define DEBUG_TRACE_SPECIAL (0x00000800)
145 #define DEBUG_TRACE_ERROR (0x00001000)
146 #define DEBUG_TRACE_READ_DETAILS (0x00002000)
147 #define DEBUG_TRACE_WRITE_DETAILS (0x00004000)
148 #define DEBUG_TRACE_FILEINFO (0x00008000)
149 #define DEBUG_TRACE_DIRINFO (0x00010000)
150 #define DEBUG_TRACE_REFERENCE (0x00020000)
151 #define DEBUG_TRACE_FSCTRL (0x00040000)
152 #define DEBUG_TRACE_FREE (0x00080000)
153 #define DEBUG_TRACE_LINENO (0x00100000)
154 #define DEBUG_TRACE_TRIPLE (0x00200000)
156 #define DEBUG_TRACE_ALL (0xffffffff)
157 #define DEBUG_TRACE_NONE 0
159 // The permitted DebugTrace types...
161 #define PERMITTED_DEBUG_TRACE_TYPES DEBUG_TRACE_NONE
163 #define PERMITTED_DEBUG_TRACE_TYPES DEBUG_TRACE_ERROR | DEBUG_TRACE_IRP_ENTRY | \
164 DEBUG_TRACE_FILE_NAME | DEBUG_TRACE_SPECIAL | \
170 #define DebugTrace( TYPE, X, Y ) \
172 if( ( TYPE ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
174 if( ( DEBUG_TRACE_LINENO ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
176 DbgPrint("(%s:%ld) ", __FILE__, __LINE__ ); \
179 if( ( DEBUG_TRACE_IRQL ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
181 DbgPrint( ",IRQL = %d ", KeGetCurrentIrql( ) ); \
188 #define DebugTraceState( STR, X1, X2, X3) \
190 if( ( DEBUG_TRACE_RESOURCE_STATE ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
192 DbgPrint("\nState: "); \
193 DbgPrint( STR, X1, X2, X3 ); \
194 if( ( DEBUG_TRACE_IRQL ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
196 DbgPrint( " IRQL = %d ", KeGetCurrentIrql( ) ); \
201 #define AssertFCB( PtrFCB ) \
203 if( !(PtrFCB) || (PtrFCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) \
209 #define AssertVCB( PtrVCB ) \
211 if( !(PtrVCB) || (PtrVCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_VCB ) \
217 #define AssertFCBorVCB( PtrVCBorFCB ) \
219 if( !(PtrVCBorFCB) || \
220 ( (PtrVCBorFCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_VCB && \
221 (PtrVCBorFCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) ) \
228 #define DebugTrace( TYPE, X, Y )
229 #define DebugTraceState( STR, X1, X2, X3 )
230 #define AssertFCB( PtrFCB )
231 #define AssertVCB( PtrVCB )
232 #define AssertFCBorVCB( PtrVCBorFCB )
236 #endif // _EXT2_FSD_H_