- Check that all pins have been closed when the last filter reference is gone
[reactos.git] / reactos / drivers / filesystems / ext2 / inc / ext2fsd.h
1 /*************************************************************************
2 *
3 * File: ext2fsd.h
4 *
5 * Module: Ext2 File System Driver (Kernel mode execution only)
6 *
7 * Description:
8 * The main include file for the Ext2 file system driver.
9 *
10 * Author: Manoj Paul Joseph
11 *
12 *
13 *************************************************************************/
14
15
16 #ifndef _EXT2_FSD_H_
17 #define _EXT2_FSD_H_
18
19 #define EXT2_POOL_WITH_TAG
20
21
22 // some constant definitions
23 #define EXT2_PANIC_IDENTIFIER (0x86427531)
24
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
30
31 // Some type definitions...
32 // These are used later...
33
34 typedef unsigned int UINT;
35 typedef unsigned char BYTE;
36
37 // Common include files - should be in the include dir of the MS supplied IFS Kit
38 #include <ntifs.h>
39 #include <ntdddisk.h>
40
41
42 /* REACTOS FIXME */
43 #undef DeleteFile
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
47
48
49 // the following include files should be in the inc sub-dir associated with this driver
50 #include "ext2metadata.h"
51 #include "struct.h"
52 #include "protos.h"
53 #include "errmsg.h"
54
55
56 // global variables - minimize these
57 extern Ext2Data Ext2GlobalData;
58
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; }
63
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))
68
69 #define Ext2QuadAlign(Value) ((((uint32)(Value)) + 7) & 0xfffffff8)
70
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)))
74
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()))
78
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)
102
103
104
105 #if DBG
106 #define Ext2BreakPoint() DbgBreakPoint()
107 #else
108 #define Ext2BreakPoint()
109 #endif
110
111 #define Ext2RaiseStatus(IRPCONTEXT,STATUS) \
112 { \
113 (IRPCONTEXT)->ExceptionStatus = (STATUS); \
114 ExRaiseStatus( (STATUS) ); \
115 }
116
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' ) )
121 #else
122 #define Ext2AllocatePool(PoolType,NumberOfBytes) \
123 ExAllocatePool( PoolType, NumberOfBytes )
124 #endif
125
126
127 #if DBG
128
129 //
130 // Trace types...
131 // Any number of these may be enabled...
132 //
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)
155
156 #define DEBUG_TRACE_ALL (0xffffffff)
157 #define DEBUG_TRACE_NONE 0
158 //
159 // The permitted DebugTrace types...
160 //
161 #define PERMITTED_DEBUG_TRACE_TYPES DEBUG_TRACE_NONE
162 /*
163 #define PERMITTED_DEBUG_TRACE_TYPES DEBUG_TRACE_ERROR | DEBUG_TRACE_IRP_ENTRY | \
164 DEBUG_TRACE_FILE_NAME | DEBUG_TRACE_SPECIAL | \
165 DEBUG_TRACE_ASYNC
166
167 */
168
169
170 #define DebugTrace( TYPE, X, Y ) \
171 { \
172 if( ( TYPE ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
173 { \
174 if( ( DEBUG_TRACE_LINENO ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
175 { \
176 DbgPrint("(%s:%ld) ", __FILE__, __LINE__ ); \
177 } \
178 DbgPrint(X,Y); \
179 if( ( DEBUG_TRACE_IRQL ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
180 { \
181 DbgPrint( ",IRQL = %d ", KeGetCurrentIrql( ) ); \
182 } \
183 DbgPrint("\n"); \
184 } \
185 }
186
187
188 #define DebugTraceState( STR, X1, X2, X3) \
189 { \
190 if( ( DEBUG_TRACE_RESOURCE_STATE ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
191 { \
192 DbgPrint("\nState: "); \
193 DbgPrint( STR, X1, X2, X3 ); \
194 if( ( DEBUG_TRACE_IRQL ) & ( PERMITTED_DEBUG_TRACE_TYPES ) ) \
195 { \
196 DbgPrint( " IRQL = %d ", KeGetCurrentIrql( ) ); \
197 } \
198 } \
199 }
200
201 #define AssertFCB( PtrFCB ) \
202 { \
203 if( !(PtrFCB) || (PtrFCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) \
204 { \
205 Ext2BreakPoint(); \
206 } \
207 }
208
209 #define AssertVCB( PtrVCB ) \
210 { \
211 if( !(PtrVCB) || (PtrVCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_VCB ) \
212 { \
213 Ext2BreakPoint(); \
214 } \
215 }
216
217 #define AssertFCBorVCB( PtrVCBorFCB ) \
218 { \
219 if( !(PtrVCBorFCB) || \
220 ( (PtrVCBorFCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_VCB && \
221 (PtrVCBorFCB)->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) ) \
222 { \
223 Ext2BreakPoint(); \
224 } \
225 }
226
227 #else
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 )
233
234 #endif
235
236 #endif // _EXT2_FSD_H_