ReactOS 0.4.15-dev-7842-g558ab78
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#pragma pack(push, 8)
111#include "ntifs.h"
112#include "ntifs_ex.h"
113#pragma pack(pop)
114}
115#endif //_CONSOLE
116
117#include <pseh/pseh2.h>
118
119#include "Include/check_env.h"
120
121#define PEXTENDED_IO_STACK_LOCATION PIO_STACK_LOCATION
122
123#define NDEBUG
124#ifndef NDEBUG
125#define UDF_DBG
126#endif
127
128#define VALIDATE_STRUCTURES
129// the following include files should be in the inc sub-dir associated with this driver
130
131#define OS_SUCCESS(a) NT_SUCCESS(a)
132#define OSSTATUS NTSTATUS
133
134#ifndef _CONSOLE
135#include "ntdddisk.h"
136#include <devioctl.h>
138#endif //_CONSOLE
139
140#include <stddef.h>
141#include <string.h>
142#include <stdio.h>
143//#include "ecma_167.h"
144//#include "osta_misc.h"
145#include "wcache.h"
146#include "CDRW/cdrw_usr.h"
147
148#include "Include/regtools.h"
149
150#ifdef _CONSOLE
151#include "udf_info/udf_rel.h"
152#include "Include/udf_common.h"
153#else
154#include "struct.h"
155#endif //_CONSOLE
156
157// global variables - minimize these
159
160#ifndef _CONSOLE
161#include "env_spec.h"
162#include "dldetect.h"
163#include "udf_dbg.h"
164#else
165#include "Include/env_spec_w32.h"
166#endif //_CONSOLE
167
168#include "sys_spec.h"
169
170#include "udf_info/udf_info.h"
171
172#ifndef _CONSOLE
173#include "protos.h"
174#endif //_CONSOLE
175
176#include "Include/phys_lib.h"
177#include "errmsg.h"
178//#include "Include/tools.h"
179#include "udfpubl.h"
180//#include "ntifs.h"
181#include "mem.h"
182
183extern CCHAR DefLetter[];
184
185// try-finally simulation
186#define try_return(S) { S; goto try_exit; }
187#define try_return1(S) { S; goto try_exit1; }
188#define try_return2(S) { S; goto try_exit2; }
189
190// some global (helpful) macros
191#define UDFSetFlag(Flag, Value) ((Flag) |= (Value))
192#define UDFClearFlag(Flag, Value) ((Flag) &= ~(Value))
193
194#define PtrOffset(BASE,OFFSET) ((ULONG)((ULONG)(OFFSET) - (ULONG)(BASE)))
195
196#define UDFQuadAlign(Value) ((((uint32)(Value)) + 7) & 0xfffffff8)
197
198// to perform a bug-check (panic), the following macro is used
199#define UDFPanic(arg1, arg2, arg3) \
200 (KeBugCheckEx(UDF_PANIC_IDENTIFIER, UDF_BUG_CHECK_ID | __LINE__, (uint32)(arg1), (uint32)(arg2), (uint32)(arg3)))
201// small check for illegal open mode (desired access) if volume is
202// read only (on standard CD-ROM device or another like this)
203#define UdfIllegalFcbAccess(Vcb,DesiredAccess) (( \
204 (Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) && \
205 (FlagOn( (DesiredAccess), \
206 FILE_WRITE_DATA | \
207 FILE_ADD_FILE | \
208 FILE_APPEND_DATA | \
209 FILE_ADD_SUBDIRECTORY | \
210 FILE_WRITE_EA | \
211 FILE_DELETE_CHILD | \
212 FILE_WRITE_ATTRIBUTES | \
213 DELETE | \
214 WRITE_OWNER | \
215 WRITE_DAC )) \
216 ) || ( \
217 !(Vcb->WriteSecurity) && \
218 (FlagOn( (DesiredAccess), \
219 WRITE_OWNER | \
220 0 /*WRITE_DAC*/ )) \
221))
222
223
224#if !defined(UDF_DBG) && !defined(PRINT_ALWAYS)
225#define UDFPrint(Args)
226#else
227#define UDFPrint(Args) KdPrint(Args)
228#endif
229#define UDFPrintErr(Args) KdPrint(Args)
230
231//
232#if !defined(UDF_DBG) && !defined(PRINT_ALWAYS)
233
234#ifndef _CONSOLE
235#define UDFAcquireResourceExclusive(Resource,CanWait) \
236 (ExAcquireResourceExclusiveLite((Resource),(CanWait)))
237#define UDFAcquireResourceShared(Resource,CanWait) \
238 (ExAcquireResourceSharedLite((Resource),(CanWait)))
239// a convenient macro (must be invoked in the context of the thread that acquired the resource)
240#define UDFReleaseResource(Resource) \
241 (ExReleaseResourceForThreadLite((Resource), ExGetCurrentResourceThread()))
242#define UDFDeleteResource(Resource) \
243 (ExDeleteResourceLite((Resource)))
244#define UDFConvertExclusiveToSharedLite(Resource) \
245 (ExConvertExclusiveToSharedLite((Resource)))
246#define UDFInitializeResourceLite(Resource) \
247 (ExInitializeResourceLite((Resource)))
248#define UDFAcquireSharedStarveExclusive(Resource,CanWait) \
249 (ExAcquireSharedStarveExclusive((Resource),(CanWait)))
250#define UDFAcquireSharedWaitForExclusive(Resource,CanWait) \
251 (ExAcquireSharedWaitForExclusive((Resource),(CanWait)))
252
253#define UDFInterlockedIncrement(addr) \
254 (InterlockedIncrement((addr)))
255#define UDFInterlockedDecrement(addr) \
256 (InterlockedDecrement((addr)))
257#define UDFInterlockedExchangeAdd(addr,i) \
258 (InterlockedExchangeAdd((addr),(i)))
259
260#endif //_CONSOLE
261
262#define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB)
263#define UDF_CHECK_EXVCB_RESOURCE(Vcb)
264#define UDF_CHECK_BITMAP_RESOURCE(Vcb)
265
266
267#else //UDF_DBG
268
269#ifndef _CONSOLE
270#define UDFAcquireResourceExclusive(Resource,CanWait) \
271 (UDFDebugAcquireResourceExclusiveLite((Resource),(CanWait),UDF_BUG_CHECK_ID,__LINE__))
272
273#define UDFAcquireResourceShared(Resource,CanWait) \
274 (UDFDebugAcquireResourceSharedLite((Resource),(CanWait),UDF_BUG_CHECK_ID,__LINE__))
275// a convenient macro (must be invoked in the context of the thread that acquired the resource)
276#define UDFReleaseResource(Resource) \
277 (UDFDebugReleaseResourceForThreadLite((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
278
279#define UDFDeleteResource(Resource) \
280 (UDFDebugDeleteResource((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
281#define UDFConvertExclusiveToSharedLite(Resource) \
282 (UDFDebugConvertExclusiveToSharedLite((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
283#define UDFInitializeResourceLite(Resource) \
284 (UDFDebugInitializeResourceLite((Resource), ExGetCurrentResourceThread(),UDF_BUG_CHECK_ID,__LINE__))
285#define UDFAcquireSharedStarveExclusive(Resource,CanWait) \
286 (UDFDebugAcquireSharedStarveExclusive((Resource), (CanWait), UDF_BUG_CHECK_ID,__LINE__))
287#define UDFAcquireSharedWaitForExclusive(Resource,CanWait) \
288 (UDFDebugAcquireSharedWaitForExclusive((Resource), (CanWait), UDF_BUG_CHECK_ID,__LINE__))
289
290#define UDFInterlockedIncrement(addr) \
291 (UDFDebugInterlockedIncrement((addr), UDF_BUG_CHECK_ID,__LINE__))
292#define UDFInterlockedDecrement(addr) \
293 (UDFDebugInterlockedDecrement((addr), UDF_BUG_CHECK_ID,__LINE__))
294#define UDFInterlockedExchangeAdd(addr,i) \
295 (UDFDebugInterlockedExchangeAdd((addr),(i), UDF_BUG_CHECK_ID,__LINE__))
296
297#endif //_CONSOLE
298
299#define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB) \
300 ASSERT(!ExIsResourceAcquiredExclusiveLite(&(NTReqFCB->PagingIoResource))); \
301 ASSERT(!ExIsResourceAcquiredSharedLite(&(NTReqFCB->PagingIoResource)));
302
303#define UDF_CHECK_EXVCB_RESOURCE(Vcb) \
304 ASSERT( ExIsResourceAcquiredExclusiveLite(&(Vcb->VCBResource)) );
305
306#define UDF_CHECK_BITMAP_RESOURCE(Vcb)
307/* \
308 ASSERT( (ExIsResourceAcquiredExclusiveLite(&(Vcb->VCBResource)) || \
309 ExIsResourceAcquiredSharedLite(&(Vcb->VCBResource))) ); \
310 ASSERT(ExIsResourceAcquiredExclusiveLite(&(Vcb->BitMapResource1))); \
311*/
312#endif //UDF_DBG
313
314#define UDFRaiseStatus(IC,S) { \
315 (IC)->SavedExceptionCode = (S); \
316 ExRaiseStatus( (S) ); \
317}
318
319#define UDFNormalizeAndRaiseStatus(IC,S) { \
320 (IC)->SavedExceptionCode = FsRtlNormalizeNtstatus((S),STATUS_UNEXPECTED_IO_ERROR); \
321 ExRaiseStatus( (IC)->SavedExceptionCode ); \
322}
323
324#define UDFIsRawDevice(RC) ( \
325 ((RC) == STATUS_DEVICE_NOT_READY) || \
326 ((RC) == STATUS_NO_MEDIA_IN_DEVICE) \
327)
328
329
330// each file has a unique bug-check identifier associated with it.
331// Here is a list of constant definitions for these identifiers
332#define UDF_FILE_INIT (0x00000001)
333#define UDF_FILE_FILTER (0x00000002)
334#define UDF_FILE_CREATE (0x00000003)
335#define UDF_FILE_CLEANUP (0x00000004)
336#define UDF_FILE_CLOSE (0x00000005)
337#define UDF_FILE_READ (0x00000006)
338#define UDF_FILE_WRITE (0x00000007)
339#define UDF_FILE_INFORMATION (0x00000008)
340#define UDF_FILE_FLUSH (0x00000009)
341#define UDF_FILE_VOL_INFORMATION (0x0000000A)
342#define UDF_FILE_DIR_CONTROL (0x0000000B)
343#define UDF_FILE_FILE_CONTROL (0x0000000C)
344#define UDF_FILE_DEVICE_CONTROL (0x0000000D)
345#define UDF_FILE_SHUTDOWN (0x0000000E)
346#define UDF_FILE_LOCK_CONTROL (0x0000000F)
347#define UDF_FILE_SECURITY (0x00000010)
348#define UDF_FILE_EXT_ATTR (0x00000011)
349#define UDF_FILE_MISC (0x00000012)
350#define UDF_FILE_FAST_IO (0x00000013)
351#define UDF_FILE_FS_CONTROL (0x00000014)
352#define UDF_FILE_PHYSICAL (0x00000015)
353#define UDF_FILE_PNP (0x00000016)
354#define UDF_FILE_VERIFY_FS_CONTROL (0x00000017)
355#define UDF_FILE_ENV_SPEC (0x00000018)
356#define UDF_FILE_SYS_SPEC (0x00000019)
357#define UDF_FILE_PHYS_EJECT (0x0000001A)
358
359#define UDF_FILE_DLD (0x00000200)
360#define UDF_FILE_MEM (0x00000201)
361#define UDF_FILE_MEMH (0x00000202)
362#define UDF_FILE_WCACHE (0x00000203)
363
364#define UDF_FILE_UDF_INFO (0x00000100)
365#define UDF_FILE_UDF_INFO_ALLOC (0x00000101)
366#define UDF_FILE_UDF_INFO_DIR (0x00000102)
367#define UDF_FILE_UDF_INFO_MOUNT (0x00000103)
368#define UDF_FILE_UDF_INFO_EXTENT (0x00000104)
369#define UDF_FILE_UDF_INFO_REMAP (0x00000105)
370//#define UDF_FILE_UDF_INFO_ (0x0000010x)
371
372#define UDF_FILE_PROTECT (0x00000300)
373//#define UDF_FILE_PROTECT_ (0x0000030x)
374
375#define SystemAllocatePool(hernya,size) ExAllocatePoolWithTag(hernya, size, 'Snwd')
376#define SystemFreePool(addr) ExFreePool((PVOID)(addr))
377
378//Device names
379
380#include "Include/udf_reg.h"
381
382#include <ddk/mountmgr.h>
383
384#endif // _UDF_UDF_H_
385
char CCHAR
Definition: typedefs.h:51
CCHAR DefLetter[]
UDFData UDFGlobalData
Definition: udfinit.cpp:25