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