[UDFS] Fix an include. CORE-9774
[reactos.git] / reactos / drivers / filesystems / udfs / udffs.h
1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3 // All rights reserved
4 ////////////////////////////////////////////////////////////////////
5 /*************************************************************************
6 *
7 * File: UDF.h
8 *
9 * Module: UDF File System Driver (Kernel mode execution only)
10 *
11 * Description:
12 * The main include file for the UDF file system driver.
13 *
14 *************************************************************************/
15
16 #ifndef _UDF_UDF_H_
17 #define _UDF_UDF_H_
18
19 /**************** OPTIONS *****************/
20
21 //#define UDF_TRACK_UNICODE_STR
22
23 //#define DEMO
24
25 //#define UDF_LIMIT_NAME_LEN
26
27 //#define UDF_LIMIT_DIR_SIZE
28
29 #ifdef UDF_LIMIT_NAME_LEN
30 #define UDF_X_NAME_LEN (20)
31 #define UDF_X_PATH_LEN (25)
32 #else //UDF_LIMIT_NAME_LEN
33 #define UDF_X_NAME_LEN UDF_NAME_LEN
34 #define UDF_X_PATH_LEN UDF_PATH_LEN
35 #endif //UDF_LIMIT_NAME_LEN
36
37 #define IFS_40
38 //#define PRETEND_NTFS
39
40 //#define UDF_ASYNC_IO
41
42 //#define UDF_ENABLE_SECURITY
43
44 #define UDF_HANDLE_EAS
45
46 #define UDF_HDD_SUPPORT
47
48 #define UDF_ALLOW_FRAG_AD
49
50 #ifndef UDF_LIMIT_DIR_SIZE
51 #define UDF_DEFAULT_DIR_PACK_THRESHOLD (128)
52 #else // UDF_LIMIT_DIR_SIZE
53 #define UDF_DEFAULT_DIR_PACK_THRESHOLD (16)
54 #endif // UDF_LIMIT_DIR_SIZE
55
56 #ifdef DEMO
57 #define UDF_DEMO_VOLUME_LABEL L"UDF Demo"
58 #endif //DEMO
59
60 #define UDF_DEFAULT_READAHEAD_GRAN 0x10000
61 #define UDF_DEFAULT_SPARSE_THRESHOLD (256*PACKETSIZE_UDF)
62
63 #define ALLOW_SPARSE
64
65 #define UDF_PACK_DIRS
66
67 #define MOUNT_ERR_THRESHOLD 256
68
69 #define UDF_VALID_FILE_ATTRIBUTES \
70 (FILE_ATTRIBUTE_READONLY | \
71 FILE_ATTRIBUTE_HIDDEN | \
72 FILE_ATTRIBUTE_SYSTEM | \
73 FILE_ATTRIBUTE_DIRECTORY | \
74 FILE_ATTRIBUTE_ARCHIVE | \
75 /*FILE_ATTRIBUTE_DEVICE | */ \
76 FILE_ATTRIBUTE_NORMAL | \
77 FILE_ATTRIBUTE_TEMPORARY | \
78 FILE_ATTRIBUTE_SPARSE_FILE)
79
80 //#define UDF_DISABLE_SYSTEM_CACHE_MANAGER
81
82 //#define UDF_CDRW_EMULATION_ON_ROM
83
84 #define UDF_DELAYED_CLOSE
85
86 #ifdef UDF_DELAYED_CLOSE
87 #define UDF_FE_ALLOCATION_CHARGE
88 #endif //UDF_DELAYED_CLOSE
89
90 #define UDF_ALLOW_RENAME_MOVE
91
92 #define UDF_ALLOW_HARD_LINKS
93
94 #ifdef UDF_ALLOW_HARD_LINKS
95 //#define UDF_ALLOW_LINKS_TO_STREAMS
96 #endif //UDF_ALLOW_HARD_LINKS
97
98 //#define UDF_ALLOW_PRETEND_DELETED
99
100 #define UDF_DEFAULT_BM_FLUSH_TIMEOUT 16 // seconds
101 #define UDF_DEFAULT_TREE_FLUSH_TIMEOUT 5 // seconds
102
103 #define UDF_DEFAULT_FSP_THREAD_PER_CPU (4)
104 #define UDF_FSP_THREAD_PER_CPU (Vcb->ThreadsPerCpu)
105 #define FSP_PER_DEVICE_THRESHOLD (UDFGlobalData.CPU_Count*UDF_FSP_THREAD_PER_CPU)
106
107 /************* END OF OPTIONS **************/
108
109 // some constant definitions
110 #define UDF_PANIC_IDENTIFIER (0x86427531)
111
112 // Common include files - should be in the include dir of the MS supplied IFS Kit
113 #ifndef _CONSOLE
114 extern "C" {
115 #pragma pack(push, 8)
116 #include "ntifs.h"
117 #include "ntifs_ex.h"
118 #pragma pack(pop)
119 }
120 #endif //_CONSOLE
121
122 #include <pseh/pseh2.h>
123
124 #include "..\Include\check_env.h"
125
126 #define PEXTENDED_IO_STACK_LOCATION PIO_STACK_LOCATION
127
128 #ifndef NDEBUG
129 #define UDF_DBG
130 #endif
131
132 #define VALIDATE_STRUCTURES
133 // the following include files should be in the inc sub-dir associated with this driver
134
135 #define OS_SUCCESS(a) NT_SUCCESS(a)
136 #define OSSTATUS NTSTATUS
137
138 #ifndef _CONSOLE
139 #include "ntdddisk.h"
140 #include <devioctl.h>
141 #include "..\include\crossnt\crossnt.h"
142 #endif //_CONSOLE
143
144 #include <stddef.h>
145 #include <string.h>
146 #include <stdio.h>
147 //#include "ecma_167.h"
148 //#include "osta_misc.h"
149 #include "wcache.h"
150 #include "..\CDRW\cdrw_usr.h"
151
152 #include "..\Include\regtools.h"
153
154 #ifdef _CONSOLE
155 #include "udf_info\udf_rel.h"
156 #include "..\include\udf_common.h"
157 #else
158 #include "struct.h"
159 #endif //_CONSOLE
160
161 // global variables - minimize these
162 extern UDFData UDFGlobalData;
163
164 #ifndef _CONSOLE
165 #include "env_spec.h"
166 #include "DLDetect.h"
167 #include "Udf_dbg.h"
168 #else
169 #include "..\include\env_spec_w32.h"
170 #endif //_CONSOLE
171
172 #include "sys_spec.h"
173
174 #include "Udf_info\Udf_info.h"
175
176 #ifndef _CONSOLE
177 #include "protos.h"
178 #endif //_CONSOLE
179
180 #include "..\Include\phys_lib.h"
181 #include "errmsg.h"
182 //#include "..\Include\tools.h"
183 #include "Include\protect.h"
184 #include "udfpubl.h"
185 //#include "ntifs.h"
186 #include "mem.h"
187 #include "..\Include\key_lib.h"
188
189 extern CCHAR DefLetter[];
190
191 // try-finally simulation
192 #define try_return(S) { S; goto try_exit; }
193 #define try_return1(S) { S; goto try_exit1; }
194 #define try_return2(S) { S; goto try_exit2; }
195
196 // some global (helpful) macros
197 #define UDFSetFlag(Flag, Value) ((Flag) |= (Value))
198 #define UDFClearFlag(Flag, Value) ((Flag) &= ~(Value))
199
200 #define PtrOffset(BASE,OFFSET) ((ULONG)((ULONG)(OFFSET) - (ULONG)(BASE)))
201
202 #define UDFQuadAlign(Value) ((((uint32)(Value)) + 7) & 0xfffffff8)
203
204 // to perform a bug-check (panic), the following macro is used
205 #define UDFPanic(arg1, arg2, arg3) \
206 (KeBugCheckEx(UDF_PANIC_IDENTIFIER, UDF_BUG_CHECK_ID | __LINE__, (uint32)(arg1), (uint32)(arg2), (uint32)(arg3)))
207 // small check for illegal open mode (desired access) if volume is
208 // read only (on standard CD-ROM device or another like this)
209 #define UdfIllegalFcbAccess(Vcb,DesiredAccess) (( \
210 (Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) && \
211 (FlagOn( (DesiredAccess), \
212 FILE_WRITE_DATA | \
213 FILE_ADD_FILE | \
214 FILE_APPEND_DATA | \
215 FILE_ADD_SUBDIRECTORY | \
216 FILE_WRITE_EA | \
217 FILE_DELETE_CHILD | \
218 FILE_WRITE_ATTRIBUTES | \
219 DELETE | \
220 WRITE_OWNER | \
221 WRITE_DAC )) \
222 ) || ( \
223 !(Vcb->WriteSecurity) && \
224 (FlagOn( (DesiredAccess), \
225 WRITE_OWNER | \
226 0 /*WRITE_DAC*/ )) \
227 ))
228
229
230 //
231 #if !defined(UDF_DBG) && !defined(PRINT_ALWAYS)
232
233 #ifndef _CONSOLE
234 #define UDFAcquireResourceExclusive(Resource,CanWait) \
235 (ExAcquireResourceExclusiveLite((Resource),(CanWait)))
236 #define UDFAcquireResourceShared(Resource,CanWait) \
237 (ExAcquireResourceSharedLite((Resource),(CanWait)))
238 // a convenient macro (must be invoked in the context of the thread that acquired the resource)
239 #define UDFReleaseResource(Resource) \
240 (ExReleaseResourceForThreadLite((Resource), ExGetCurrentResourceThread()))
241 #define UDFDeleteResource(Resource) \
242 (ExDeleteResourceLite((Resource)))
243 #define UDFConvertExclusiveToSharedLite(Resource) \
244 (ExConvertExclusiveToSharedLite((Resource)))
245 #define UDFInitializeResourceLite(Resource) \
246 (ExInitializeResourceLite((Resource)))
247 #define UDFAcquireSharedStarveExclusive(Resource,CanWait) \
248 (ExAcquireSharedStarveExclusive((Resource),(CanWait)))
249 #define UDFAcquireSharedWaitForExclusive(Resource,CanWait) \
250 (ExAcquireSharedWaitForExclusive((Resource),(CanWait)))
251
252 #define UDFInterlockedIncrement(addr) \
253 (InterlockedIncrement((addr)))
254 #define UDFInterlockedDecrement(addr) \
255 (InterlockedDecrement((addr)))
256 #define UDFInterlockedExchangeAdd(addr,i) \
257 (InterlockedExchangeAdd((addr),(i)))
258
259 #endif //_CONSOLE
260
261 #define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB)
262 #define UDF_CHECK_EXVCB_RESOURCE(Vcb)
263 #define UDF_CHECK_BITMAP_RESOURCE(Vcb)
264
265
266 #else //UDF_DBG
267
268 #ifndef _CONSOLE
269 #define UDFAcquireResourceExclusive(Resource,CanWait) \
270 (UDFDebugAcquireResourceExclusiveLite((Resource),(CanWait),UDF_BUG_CHECK_ID,__LINE__))
271
272 #define UDFAcquireResourceShared(Resource,CanWait) \
273 (UDFDebugAcquireResourceSharedLite((Resource),(CanWait),UDF_BUG_CHECK_ID,__LINE__))
274 // a convenient macro (must be invoked in the context of the thread that acquired the resource)
275 #define UDFReleaseResource(Resource) \
276 (UDFDebugReleaseResourceForThreadLite((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
277
278 #define UDFDeleteResource(Resource) \
279 (UDFDebugDeleteResource((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
280 #define UDFConvertExclusiveToSharedLite(Resource) \
281 (UDFDebugConvertExclusiveToSharedLite((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
282 #define UDFInitializeResourceLite(Resource) \
283 (UDFDebugInitializeResourceLite((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
284 #define UDFAcquireSharedStarveExclusive(Resource,CanWait) \
285 (UDFDebugAcquireSharedStarveExclusive((Resource), (CanWait), UDF_BUG_CHECK_ID,__LINE__))
286 #define UDFAcquireSharedWaitForExclusive(Resource,CanWait) \
287 (UDFDebugAcquireSharedWaitForExclusive((Resource), (CanWait), UDF_BUG_CHECK_ID,__LINE__))
288
289 #define UDFInterlockedIncrement(addr) \
290 (UDFDebugInterlockedIncrement((addr), UDF_BUG_CHECK_ID,__LINE__))
291 #define UDFInterlockedDecrement(addr) \
292 (UDFDebugInterlockedDecrement((addr), UDF_BUG_CHECK_ID,__LINE__))
293 #define UDFInterlockedExchangeAdd(addr,i) \
294 (UDFDebugInterlockedExchangeAdd((addr),(i), UDF_BUG_CHECK_ID,__LINE__))
295
296 #endif //_CONSOLE
297
298 #define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB) \
299 ASSERT(!ExIsResourceAcquiredExclusiveLite(&(NTReqFCB->PagingIoResource))); \
300 ASSERT(!ExIsResourceAcquiredSharedLite(&(NTReqFCB->PagingIoResource)));
301
302 #define UDF_CHECK_EXVCB_RESOURCE(Vcb) \
303 ASSERT( ExIsResourceAcquiredExclusiveLite(&(Vcb->VCBResource)) );
304
305 #define UDF_CHECK_BITMAP_RESOURCE(Vcb)
306 /* \
307 ASSERT( (ExIsResourceAcquiredExclusiveLite(&(Vcb->VCBResource)) || \
308 ExIsResourceAcquiredSharedLite(&(Vcb->VCBResource))) ); \
309 ASSERT(ExIsResourceAcquiredExclusiveLite(&(Vcb->BitMapResource1))); \
310 */
311 #endif //UDF_DBG
312
313 #define UDFRaiseStatus(IC,S) { \
314 (IC)->SavedExceptionCode = (S); \
315 ExRaiseStatus( (S) ); \
316 }
317
318 #define UDFNormalizeAndRaiseStatus(IC,S) { \
319 (IC)->SavedExceptionCode = FsRtlNormalizeNtstatus((S),STATUS_UNEXPECTED_IO_ERROR); \
320 ExRaiseStatus( (IC)->SavedExceptionCode ); \
321 }
322
323 #define UDFIsRawDevice(RC) ( \
324 ((RC) == STATUS_DEVICE_NOT_READY) || \
325 ((RC) == STATUS_NO_MEDIA_IN_DEVICE) \
326 )
327
328
329 // each file has a unique bug-check identifier associated with it.
330 // Here is a list of constant definitions for these identifiers
331 #define UDF_FILE_INIT (0x00000001)
332 #define UDF_FILE_FILTER (0x00000002)
333 #define UDF_FILE_CREATE (0x00000003)
334 #define UDF_FILE_CLEANUP (0x00000004)
335 #define UDF_FILE_CLOSE (0x00000005)
336 #define UDF_FILE_READ (0x00000006)
337 #define UDF_FILE_WRITE (0x00000007)
338 #define UDF_FILE_INFORMATION (0x00000008)
339 #define UDF_FILE_FLUSH (0x00000009)
340 #define UDF_FILE_VOL_INFORMATION (0x0000000A)
341 #define UDF_FILE_DIR_CONTROL (0x0000000B)
342 #define UDF_FILE_FILE_CONTROL (0x0000000C)
343 #define UDF_FILE_DEVICE_CONTROL (0x0000000D)
344 #define UDF_FILE_SHUTDOWN (0x0000000E)
345 #define UDF_FILE_LOCK_CONTROL (0x0000000F)
346 #define UDF_FILE_SECURITY (0x00000010)
347 #define UDF_FILE_EXT_ATTR (0x00000011)
348 #define UDF_FILE_MISC (0x00000012)
349 #define UDF_FILE_FAST_IO (0x00000013)
350 #define UDF_FILE_FS_CONTROL (0x00000014)
351 #define UDF_FILE_PHYSICAL (0x00000015)
352 #define UDF_FILE_PNP (0x00000016)
353 #define UDF_FILE_VERIFY_FS_CONTROL (0x00000017)
354 #define UDF_FILE_ENV_SPEC (0x00000018)
355 #define UDF_FILE_SYS_SPEC (0x00000019)
356 #define UDF_FILE_PHYS_EJECT (0x0000001A)
357
358 #define UDF_FILE_DLD (0x00000200)
359 #define UDF_FILE_MEM (0x00000201)
360 #define UDF_FILE_MEMH (0x00000202)
361 #define UDF_FILE_WCACHE (0x00000203)
362
363 #define UDF_FILE_UDF_INFO (0x00000100)
364 #define UDF_FILE_UDF_INFO_ALLOC (0x00000101)
365 #define UDF_FILE_UDF_INFO_DIR (0x00000102)
366 #define UDF_FILE_UDF_INFO_MOUNT (0x00000103)
367 #define UDF_FILE_UDF_INFO_EXTENT (0x00000104)
368 #define UDF_FILE_UDF_INFO_REMAP (0x00000105)
369 //#define UDF_FILE_UDF_INFO_ (0x0000010x)
370
371 #define UDF_FILE_PROTECT (0x00000300)
372 //#define UDF_FILE_PROTECT_ (0x0000030x)
373
374 #define SystemAllocatePool(hernya,size) ExAllocatePoolWithTag(hernya, size, 'Snwd')
375 #define SystemFreePool(addr) ExFreePool((PVOID)(addr))
376
377 //Device names
378
379 #include "../Include/udf_reg.h"
380
381 #include <ddk/mountmgr.h>
382
383 #endif // _UDF_UDF_H_
384