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.
5 ////////////////////////////////////////////////////////////////////
6 #ifndef __UDF_COMMON_STRUCT__H__
7 #define __UDF_COMMON_STRUCT__H__
8 
9 typedef enum _UDFFSD_MEDIA_TYPE {
10     MediaUnknown = 0,
11     MediaHdd,
12     MediaCdr,
13     MediaCdrw,
14     MediaCdrom,
15     MediaZip,
16     MediaFloppy,
17     MediaDvdr,
18     MediaDvdrw
19 } UDFFSD_MEDIA_TYPE;
20 
21 #define MAX_UDFFSD_MEDIA_TYPE ((ULONG)MediaFloppy)
22 
23 typedef struct _UDF_KEY_LIST {
24     int32 d[4];
25 } UDF_KEY_LIST, *PUDF_KEY_LIST;
26 
27 struct UDF_MEDIA_CLASS_NAMES
28 {
29     UDFFSD_MEDIA_TYPE MediaClass;
30     PCWSTR ClassName;
31 };
32 
33 extern struct UDF_MEDIA_CLASS_NAMES UDFMediaClassName[];
34 
35 #define MAX_ANCHOR_LOCATIONS 11
36 #define MAX_SPARING_TABLE_LOCATIONS 32
37 
38 typedef struct _UDFVolumeControlBlock {
39 
40 #ifdef _UDF_STRUCTURES_H_
41 
42     //---------------
43     // Kernel-only data:
44     //---------------
45 
46     //---------------
47     // Fcb data
48     //---------------
49 
50     union {
51         struct {
52             UDFIdentifier                       NodeIdentifier;
53             //  compatibility field
54             PtrUDFNTRequiredFCB                 NTRequiredFCB;
55             // UDF related data (compatibility field)
56             PVOID                               Reserved0;
57             // this FCB belongs to some mounted logical volume
58             // (compatibility field - pointer to itself)
59             struct _UDFVolumeControlBlock*      Vcb;
60             // a global list of all FCB structures associated with the VCB
61             LIST_ENTRY                          NextFCB;
62             // some state information for the FCB is maintained using the
63             //  flags field
64             uint32                              FCBFlags;
65             // all CCB's for this particular FCB are linked off the following
66             //  list head.
67             // For volume open operations, we do not create a FCB (we use the VCB
68             //  directly instead). Therefore, all CCB structures for the volume
69             //  open operation are linked directly off the VCB
70             LIST_ENTRY                          VolumeOpenListHead; // CCB
71             // A count of the number of open files/directories
72             //  As long as the count is != 0, the volume cannot
73             //  be dismounted or locked.
74             uint32                              VolumeOpenCount;
75             uint32                              Reserved2;
76             uint32                              Reserved3;
77 
78             PVOID                               Reserved4;
79             ERESOURCE                           CcbListResource;
80 
81             struct _UDFFileControlBlock*        ParentFcb;
82             //  Pointer to IrpContextLite in delayed queue.
83             struct _UDFIrpContextLite*          IrpContextLite;
84             uint32                              CcbCount;
85         };
86         UDFFCB VcbAsFcb;
87     };
88 
89     //---------------
90     // Vcb-only data
91     //---------------
92 
93     uint32                              VCBOpenCount;
94     uint32                              VCBOpenCountRO;
95     uint32                              VCBHandleCount;
96     // a resource to protect the fields contained within the VCB
97     ERESOURCE                           FcbListResource;
98     ERESOURCE                           FlushResource;
99     // each VCB is accessible off a global linked list
100     LIST_ENTRY                          NextVCB;
101     // each VCB points to a VPB structure created by the NT I/O Manager
102     PVPB                                Vpb;
103     // we will maintain a global list of IRP's that are pending
104     //  because of a directory notify request.
105     LIST_ENTRY                          NextNotifyIRP;
106     // the above list is protected only by the mutex declared below
107     PNOTIFY_SYNC                        NotifyIRPMutex;
108     // for each mounted volume, we create a device object. Here then
109     //  is a back pointer to that device object
110     PDEVICE_OBJECT                      VCBDeviceObject;
111     BOOLEAN                             ShutdownRegistered;
112     // We also retain a pointer to the physical device object on which we
113     // have mounted ourselves. The I/O Manager passes us a pointer to this
114     // device object when requesting a mount operation.
115     PDEVICE_OBJECT                      TargetDeviceObject;
116     UNICODE_STRING                      TargetDevName;
117     PCWSTR                               DefaultRegName;
118     // the volume structure contains a pointer to the root directory FCB
119     PtrUDFFCB                           RootDirFCB;
120     // the complete name of the user visible drive letter we serve
121     PUCHAR                              PtrVolumePath;
122     // Pointer to a stream file object created for the volume information
123     // to be more easily read from secondary storage (with the support of
124     // the NT Cache Manager).
125 /*    PFILE_OBJECT                        PtrStreamFileObject;
126     // Required to use the Cache Manager.
127 */
128     struct _FILE_SYSTEM_STATISTICS*     Statistics;
129     // Volume lock file object - used in Lock/Unlock routines
130     ULONG                               VolumeLockPID;
131     PFILE_OBJECT                        VolumeLockFileObject;
132     DEVICE_TYPE                         FsDeviceType;
133 
134     //  The following field tells how many requests for this volume have
135     //  either been enqueued to ExWorker threads or are currently being
136     //  serviced by ExWorker threads.  If the number goes above
137     //  a certain threshold, put the request on the overflow queue to be
138     //  executed later.
139     ULONG PostedRequestCount;
140     ULONG ThreadsPerCpu;
141     //  The following field indicates the number of IRP's waiting
142     //  to be serviced in the overflow queue.
143     ULONG OverflowQueueCount;
144     //  The following field contains the queue header of the overflow queue.
145     //  The Overflow queue is a list of IRP's linked via the IRP's ListEntry
146     //  field.
147     LIST_ENTRY OverflowQueue;
148     //  The following spinlock protects access to all the above fields.
149     KSPIN_LOCK OverflowQueueSpinLock;
150     ULONG StopOverflowQueue;
151     ULONG SystemCacheGran;
152 
153     //---------------
154     //
155     //---------------
156 
157     // Eject Request waiter
158     struct _UDFEjectWaitContext*  EjectWaiter;
159     KEVENT          WaiterStopped;
160     ULONG           SoftEjectReq;
161 
162     ULONG           BM_FlushTime;
163     ULONG           BM_FlushPriod;
164     ULONG           Tree_FlushTime;
165     ULONG           Tree_FlushPriod;
166     ULONG           SkipCountLimit;
167     ULONG           SkipEjectCountLimit;
168 
169 /*    // XP CD Burner related data
170     UNICODE_STRING  CDBurnerVolume;
171     BOOLEAN         CDBurnerVolumeValid;
172 */
173     // Background writes counter
174     LONG            BGWriters;
175     // File Id cache
176     struct _UDFFileIDCacheItem* FileIdCache;
177     ULONG           FileIdCount;
178     //
179     ULONG           MediaLockCount;
180 
181     BOOLEAN         IsVolumeJustMounted;
182 #else
183 
184     //---------------
185     // Win32-only data:
186     //---------------
187 
188   #ifdef _BROWSE_UDF_
189     PUDF_FILE_INFO  RootFileInfo;
190   #endif
191 
192 
193   #ifdef UDF_FORMAT_MEDIA
194     struct _UDFFmtState* fms;
195   #endif //UDF_FORMAT_MEDIA
196 
197 
198     PDEVICE_OBJECT  TargetDeviceObject;
199     ULONG           FsDeviceType;
200     ULONG           PhDeviceType;
201 
202 #endif //_UDF_STRUCTURES_H_
203 
204     // FS size cache
205     LONGLONG        TotalAllocUnits;
206     LONGLONG        FreeAllocUnits;
207     LONGLONG        EstimatedFreeUnits;
208 
209     // a resource to protect the fields contained within the VCB
210     ERESOURCE                           VCBResource;
211     ERESOURCE                           BitMapResource1;
212     ERESOURCE                           FileIdResource;
213     ERESOURCE                           DlocResource;
214     ERESOURCE                           DlocResource2;
215     ERESOURCE                           PreallocResource;
216     ERESOURCE                           IoResource;
217 
218     //---------------
219     // Physical media parameters
220     //---------------
221 
222     ULONG           BlockSize;
223     ULONG           BlockSizeBits;
224     ULONG           WriteBlockSize;
225     ULONG           LBlockSize;
226     ULONG           LBlockSizeBits;
227     ULONG           LB2B_Bits;
228     // Number of last session
229     ULONG           LastSession;
230     ULONG           FirstTrackNum;
231     ULONG           FirstTrackNumLastSes;
232     ULONG           LastTrackNum;
233     // First & Last LBA of the last session
234     ULONG           FirstLBA;
235     ULONG           FirstLBALastSes;
236     ULONG           LastLBA;
237     // Last writable LBA
238     ULONG           LastPossibleLBA;
239     // First writable LBA
240     ULONG           NWA;
241     // sector type map
242     struct _UDFTrackMap*  TrackMap;
243     ULONG           LastModifiedTrack;
244     ULONG           LastReadTrack;
245     ULONG           CdrwBufferSize;
246     ULONG           CdrwBufferSizeCounter;
247     uint32          SavedFeatures;
248     // OPC info
249 //    PCHAR           OPC_buffer;
250     UCHAR           OPCNum;
251     BOOLEAN         OPCDone;
252     UCHAR           MediaType;
253     UCHAR           MediaClassEx;
254 
255     UCHAR           DiscStat;
256     UCHAR           PhErasable;
257     UCHAR           PhDiskType;
258     UCHAR           PhMediaCapFlags;
259 
260     UCHAR           MRWStatus;
261     UCHAR           UseEvent;
262     BOOLEAN         BlankCD;
263     UCHAR           Reserved;
264 
265     ULONG           PhSerialNumber;
266 
267     // Speed control
268     SET_CD_SPEED_EX_USER_IN SpeedBuf;
269     ULONG           MaxWriteSpeed;
270     ULONG           MaxReadSpeed;
271     ULONG           CurSpeed;
272 
273     BOOLEAN         CDR_Mode;
274     BOOLEAN         DVD_Mode;
275     BOOLEAN         WriteParamsReq;
276 
277 #define SYNC_CACHE_RECOVERY_NONE     0
278 #define SYNC_CACHE_RECOVERY_ATTEMPT  1
279 #define SYNC_CACHE_RECOVERY_RETRY    2
280 
281     UCHAR           SyncCacheState;
282 
283     // W-cache
284     W_CACHE         FastCache;
285     ULONG           WCacheMaxFrames;
286     ULONG           WCacheMaxBlocks;
287     ULONG           WCacheBlocksPerFrameSh;
288     ULONG           WCacheFramesToKeepFree;
289 
290     PCHAR           ZBuffer;
291     PCHAR           fZBuffer;
292     ULONG           fZBufferSize;
293     PSEND_OPC_INFO_HEADER_USER_IN OPCh;
294     PGET_WRITE_MODE_USER_OUT WParams;
295     PGET_LAST_ERROR_USER_OUT Error;
296 
297     ULONG           IoErrorCounter;
298     // Media change count (equal to the same field in CDFS VCB)
299     ULONG           MediaChangeCount;
300 
301 #define INCREMENTAL_SEEK_NONE        0
302 #define INCREMENTAL_SEEK_WORKAROUND  1
303 #define INCREMENTAL_SEEK_DONE        2
304 
305     UCHAR           IncrementalSeekState;
306 
307     BOOLEAN         VerifyOnWrite;
308     BOOLEAN         DoNotCompareBeforeWrite;
309     BOOLEAN         CacheChainedIo;
310 
311     ULONG           MountPhErrorCount;
312 
313     // a set of flags that might mean something useful
314     uint32          VCBFlags;
315     BOOLEAN         FP_disc;
316 
317     //---------------
318     // UDF related data
319     //---------------
320 
321 #ifdef _BROWSE_UDF_
322 
323     // Anchors LBA
324     ULONG           Anchor[MAX_ANCHOR_LOCATIONS];
325     ULONG           BadSeqLoc[MAX_ANCHOR_LOCATIONS*2];
326     OSSTATUS        BadSeqStatus[MAX_ANCHOR_LOCATIONS*2];
327     ULONG           BadSeqLocIndex;
328     // Volume label
329     UNICODE_STRING  VolIdent;
330     // Volume creation time
331     int64           VolCreationTime;
332     // Root & SystemStream lb_addr
333     lb_addr         RootLbAddr;
334     lb_addr         SysStreamLbAddr;
335     // Number of partition
336     ULONG           PartitionMaps;
337     // Pointer to partition structures
338     PUDFPartMap     Partitions;
339     LogicalVolIntegrityDesc *LVid;
340     uint32          IntegrityType;
341     uint32          origIntegrityType;
342     extent_ad       LVid_loc;
343     ULONG           SerialNumber;
344     // on-disk structure version control
345     uint16          CurrentUDFRev;
346     uint16          minUDFReadRev;
347     uint16          minUDFWriteRev;
348     uint16          maxUDFWriteRev;
349     // file/dir counters for Mac OS
350     uint32          numFiles;
351     uint32          numDirs;
352     // VAT
353     uint32          InitVatCount;
354     uint32          VatCount;
355     uint32*         Vat;
356     uint32          VatPartNdx;
357     PUDF_FILE_INFO  VatFileInfo;
358     // sparing table
359     ULONG           SparingCountFree;
360     ULONG           SparingCount;
361     ULONG           SparingBlockSize;
362     struct _SparingEntry*    SparingTable;
363     uint32          SparingTableLoc[MAX_SPARING_TABLE_LOCATIONS];
364     uint32          SparingTableCount;
365     uint32          SparingTableLength;
366     uint32          SparingTableModified;
367     // free space bitmap
368     ULONG           FSBM_ByteCount;
369     // the following 2 fields are equal to NTIFS's RTL_BITMAP structure
370     ULONG           FSBM_BitCount;
371     PCHAR           FSBM_Bitmap;     // 0 - free, 1 - used
372 #ifdef UDF_TRACK_ONDISK_ALLOCATION_OWNERS
373     PULONG          FSBM_Bitmap_owners; // 0 - free
374                                         // -1 - used by unknown
375                                         // other - owner's FE location
376 #ifdef UDF_TRACK_FS_STRUCTURES
377     PEXTENT_MAP     FsStructMap;
378     PULONG          FE_link_counts; // 0 - free
379 #endif //UDF_TRACK_FS_STRUCTURES
380 #endif //UDF_TRACK_ONDISK_ALLOCATION_OWNERS
381 
382     PCHAR           FSBM_OldBitmap;  // 0 - free, 1 - used
383     ULONG           BitmapModified;
384 
385     PCHAR           ZSBM_Bitmap;     // 0 - data, 1 - zero-filleld
386 #endif //_BROWSE_UDF_
387 
388     PCHAR           BSBM_Bitmap;     // 0 - normal, 1 - bad-block
389 
390 #ifdef _BROWSE_UDF_
391     // pointers to Volume Descriptor Sequences
392     ULONG VDS1;
393     ULONG VDS1_Len;
394     ULONG VDS2;
395     ULONG VDS2_Len;
396 
397     ULONG           Modified;
398 
399     // System Stream Dir
400     PUDF_FILE_INFO  SysSDirFileInfo;
401     // Non-alloc space
402     PUDF_FILE_INFO  NonAllocFileInfo;
403     // Unique ID Mapping
404     PUDF_FILE_INFO  UniqueIDMapFileInfo;
405     // Saved location of Primary Vol Descr (used for setting Label)
406     UDF_VDS_RECORD  PVolDescAddr;
407     UDF_VDS_RECORD  PVolDescAddr2;
408     // NSR flags
409     uint32          NSRDesc;
410     // File Id cache
411     ULONGLONG       NextUniqueId;
412     // FE location cache
413     PUDF_DATALOC_INDEX DlocList;
414     ULONG           DlocCount;
415     // FS compatibility
416     USHORT          DefaultAllocMode; // Default alloc mode (from registry)
417     BOOLEAN         UseExtendedFE;
418     BOOLEAN         LowFreeSpace;
419     UDFFSD_MEDIA_TYPE MediaTypeEx;
420     ULONG           DefaultUID;
421     ULONG           DefaultGID;
422     ULONG           DefaultAttr;      // Default file attributes (NT-style)
423 
424 
425     UCHAR           PartitialDamagedVolumeAction;
426     BOOLEAN         NoFreeRelocationSpaceVolumeAction;
427     BOOLEAN         WriteSecurity;
428     BOOLEAN         FlushMedia;
429     BOOLEAN         ForgetVolume;
430     UCHAR           Reserved5[3];
431 
432     //
433     ULONG           FECharge;
434     ULONG           FEChargeSDir;
435     ULONG           PackDirThreshold;
436     ULONG           SparseThreshold;  // in blocks
437 
438     PUDF_ALLOCATION_CACHE_ITEM    FEChargeCache;
439     ULONG                         FEChargeCacheMaxSize;
440 
441     PUDF_ALLOCATION_CACHE_ITEM    PreallocCache;
442     ULONG                         PreallocCacheMaxSize;
443 
444     UDF_VERIFY_CTX  VerifyCtx;
445 
446     PUCHAR          Cfg;
447     ULONG           CfgLength;
448     ULONG           CfgVersion;
449 
450 #endif //_BROWSE_UDF_
451     uint32          CompatFlags;
452     uint32          UserFSFlags;
453     UCHAR           ShowBlankCd;
454 
455 } VCB, *PVCB;
456 
457 
458 // some valid flags for the VCB
459 #define         UDF_VCB_FLAGS_VOLUME_MOUNTED        (0x00000001)
460 #define         UDF_VCB_FLAGS_VOLUME_LOCKED         (0x00000002)
461 #define         UDF_VCB_FLAGS_BEING_DISMOUNTED      (0x00000004)
462 #define         UDF_VCB_FLAGS_SHUTDOWN              (0x00000008)
463 #define         UDF_VCB_FLAGS_VOLUME_READ_ONLY      (0x00000010)
464 
465 #define         UDF_VCB_FLAGS_VCB_INITIALIZED       (0x00000020)
466 #define         UDF_VCB_FLAGS_OUR_DEVICE_DRIVER     (0x00000040)
467 #define         UDF_VCB_FLAGS_NO_SYNC_CACHE         (0x00000080)
468 #define         UDF_VCB_FLAGS_REMOVABLE_MEDIA       (0x00000100)
469 #define         UDF_VCB_FLAGS_MEDIA_LOCKED          (0x00000200)
470 #define         UDF_VCB_SKIP_EJECT_CHECK            (0x00000400)
471 //#define         UDF_VCB_FS_BITMAP_MODIFIED          (0x00000800)  // moved to separate flag
472 #define         UDF_VCB_LAST_WRITE                  (0x00001000)
473 #define         UDF_VCB_FLAGS_TRACKMAP              (0x00002000)
474 #define         UDF_VCB_ASSUME_ALL_USED             (0x00004000)
475 
476 #define         UDF_VCB_FLAGS_RAW_DISK              (0x00040000)
477 #define         UDF_VCB_FLAGS_USE_STD               (0x00080000)
478 
479 #define         UDF_VCB_FLAGS_STOP_WAITER_EVENT     (0x00100000)
480 #define         UDF_VCB_FLAGS_NO_DELAYED_CLOSE      (0x00200000)
481 #define         UDF_VCB_FLAGS_MEDIA_READ_ONLY       (0x00400000)
482 
483 #define         UDF_VCB_FLAGS_FLUSH_BREAK_REQ       (0x01000000)
484 #define         UDF_VCB_FLAGS_EJECT_REQ             (0x02000000)
485 #define         UDF_VCB_FLAGS_FORCE_SYNC_CACHE      (0x04000000)
486 
487 #define         UDF_VCB_FLAGS_USE_CAV               (0x08000000)
488 #define         UDF_VCB_FLAGS_UNSAFE_IOCTL          (0x10000000)
489 #define         UDF_VCB_FLAGS_DEAD                  (0x20000000)  // device unexpectedly disappeared
490 
491 
492 // flags for FS Interface Compatibility
493 #define         UDF_VCB_IC_UPDATE_ACCESS_TIME          (0x00000001)
494 #define         UDF_VCB_IC_UPDATE_MODIFY_TIME          (0x00000002)
495 #define         UDF_VCB_IC_UPDATE_ATTR_TIME            (0x00000004)
496 #define         UDF_VCB_IC_UPDATE_ARCH_BIT             (0x00000008)
497 #define         UDF_VCB_IC_UPDATE_DIR_WRITE            (0x00000010)
498 #define         UDF_VCB_IC_UPDATE_DIR_READ             (0x00000020)
499 #define         UDF_VCB_IC_WRITE_IN_RO_DIR             (0x00000040)
500 #define         UDF_VCB_IC_UPDATE_UCHG_DIR_ACCESS_TIME (0x00000080)
501 #define         UDF_VCB_IC_W2K_COMPAT_ALLOC_DESCS      (0x00000100)
502 #define         UDF_VCB_IC_HW_RO                       (0x00000200)
503 #define         UDF_VCB_IC_OS_NATIVE_DOS_NAME          (0x00000400)
504 #define         UDF_VCB_IC_FORCE_WRITE_THROUGH         (0x00000800)
505 #define         UDF_VCB_IC_FORCE_HW_RO                 (0x00001000)
506 #define         UDF_VCB_IC_IGNORE_SEQUENTIAL_IO        (0x00002000)
507 #define         UDF_VCB_IC_NO_SYNCCACHE_AFTER_WRITE    (0x00004000)
508 #define         UDF_VCB_IC_BAD_RW_SEEK                 (0x00008000)
509 #define         UDF_VCB_IC_FP_ADDR_PROBLEM             (0x00010000)
510 #define         UDF_VCB_IC_MRW_ADDR_PROBLEM            (0x00020000)
511 #define         UDF_VCB_IC_BAD_DVD_LAST_LBA            (0x00040000)
512 #define         UDF_VCB_IC_SYNCCACHE_BEFORE_READ       (0x00080000)
513 #define         UDF_VCB_IC_INSTANT_COMPAT_ALLOC_DESCS  (0x00100000)
514 #define         UDF_VCB_IC_SOFT_RO                     (0x00200000)
515 
516 #define         UDF_VCB_IC_DIRTY_RO                    (0x04000000)
517 #define         UDF_VCB_IC_W2K_COMPAT_VLABEL           (0x08000000)
518 #define         UDF_VCB_IC_CACHE_BAD_VDS               (0x10000000)
519 #define         UDF_VCB_IC_WAIT_CD_SPINUP              (0x20000000)
520 #define         UDF_VCB_IC_SHOW_BLANK_CD               (0x40000000)
521 #define         UDF_VCB_IC_ADAPTEC_NONALLOC_COMPAT     (0x80000000)
522 
523 // Some defines
524 #define UDFIsDvdMedia(Vcb)       (Vcb->DVD_Mode)
525 #define UDFIsWriteParamsReq(Vcb) (Vcb->WriteParamsReq && !Vcb->DVD_Mode)
526 
527 /**************************************************************************
528     we will store all of our global variables in one structure.
529     Global variables are not specific to any mounted volume BUT
530     by definition are required for successful operation of the
531     FSD implementation.
532 **************************************************************************/
533 typedef struct _UDFData {
534 
535 #ifdef _UDF_STRUCTURES_H_
536     UDFIdentifier               NodeIdentifier;
537     // the fields in this list are protected by the following resource
538     ERESOURCE                   GlobalDataResource;
539     // each driver has a driver object created for it by the NT I/O Mgr.
540     //  we are no exception to this rule.
541     PDRIVER_OBJECT              DriverObject;
542     // we will create a device object for our FSD as well ...
543     //  Although not really required, it helps if a helper application
544     //  writen by us wishes to send us control information via
545     //  IOCTL requests ...
546     PDEVICE_OBJECT              UDFDeviceObject;
547     PDEVICE_OBJECT              UDFDeviceObject_CD;
548     PDEVICE_OBJECT              UDFDeviceObject_HDD;
549     PDEVICE_OBJECT              UDFDeviceObject_TAPE;
550     PDEVICE_OBJECT              UDFDeviceObject_OTHER;
551     PDEVICE_OBJECT              UDFFilterDeviceObject;
552     // we will keep a list of all logical volumes for our UDF FSD
553     LIST_ENTRY                  VCBQueue;
554     // the NT Cache Manager, the I/O Manager and we will conspire
555     //  to bypass IRP usage using the function pointers contained
556     //  in the following structure
557     FAST_IO_DISPATCH            UDFFastIoDispatch;
558     // The NT Cache Manager uses the following call backs to ensure
559     //  correct locking hierarchy is maintained
560     CACHE_MANAGER_CALLBACKS     CacheMgrCallBacks;
561     // structures allocated from a zone need some fields here. Note
562     //  that under version 4.0, it might be better to use lookaside
563     //  lists
564     KSPIN_LOCK                  ZoneAllocationSpinLock;
565     ZONE_HEADER                 ObjectNameZoneHeader;
566     ZONE_HEADER                 CCBZoneHeader;
567     ZONE_HEADER                 FCBZoneHeader;
568     ZONE_HEADER                 IrpContextZoneHeader;
569 //    ZONE_HEADER                 FileInfoZoneHeader;
570     VOID                        *ObjectNameZone;
571     VOID                        *CCBZone;
572     VOID                        *FCBZone;
573     VOID                        *IrpContextZone;
574 //    VOID                        *FileInfoZone;
575     // currently, there is a single default zone size value used for
576     //  all zones. This should ideally be changed by you to be 1 per
577     //  type of zone (e.g. a default size for the FCB zone might be
578     //  different from the default size for the ByteLock zone).
579 
580     //  Of course, you will need to use different values (min/max)
581     //  for lookaside lists (if you decide to use them instead)
582     uint32                      DefaultZoneSizeInNumStructs;
583     // Handle returned by the MUP is stored here.
584     HANDLE                      MupHandle;
585     // IsSync Resource
586 //    ERESOURCE                   IsSyncResource;
587     // Is operation synchronous flag
588 //    BOOLEAN                     IsSync;
589 
590     // delayed close support
591     ERESOURCE                   DelayedCloseResource;
592     ULONG                       MaxDelayedCloseCount;
593     ULONG                       DelayedCloseCount;
594     ULONG                       MinDelayedCloseCount;
595     ULONG                       MaxDirDelayedCloseCount;
596     ULONG                       DirDelayedCloseCount;
597     ULONG                       MinDirDelayedCloseCount;
598     LIST_ENTRY                  DelayedCloseQueue;
599     LIST_ENTRY                  DirDelayedCloseQueue;
600     WORK_QUEUE_ITEM             CloseItem;
601     WORK_QUEUE_ITEM             LicenseKeyItem;
602     BOOLEAN                     LicenseKeyItemStarted;
603     BOOLEAN                     FspCloseActive;
604     BOOLEAN                     ReduceDelayedClose;
605     BOOLEAN                     ReduceDirDelayedClose;
606 
607     ULONG                       CPU_Count;
608     LARGE_INTEGER               UDFLargeZero;
609 
610     // mount event (for udf gui app)
611     PKEVENT                     MountEvent;
612 
613 #endif //_UDF_STRUCTURES_H_
614     //HKEY                        hUdfRootKey;
615     UNICODE_STRING              SavedRegPath;
616     UNICODE_STRING              UnicodeStrRoot;
617     UNICODE_STRING              UnicodeStrSDir;
618     UNICODE_STRING              AclName;
619 //    WCHAR                       UnicodeStrRootBuffer[2];
620 
621     ULONG                       WCacheMaxFrames;
622     ULONG                       WCacheMaxBlocks;
623     ULONG                       WCacheBlocksPerFrameSh;
624     ULONG                       WCacheFramesToKeepFree;
625 
626     // some state information is maintained in the flags field
627     uint32                      UDFFlags;
628 
629     PVOID                       AutoFormatCount;
630 
631 } UDFData, *PtrUDFData;
632 
633 // valid flag values for the global data structure
634 #define     UDF_DATA_FLAGS_RESOURCE_INITIALIZED     (0x00000001)
635 #define     UDF_DATA_FLAGS_ZONES_INITIALIZED        (0x00000002)
636 #define     UDF_DATA_FLAGS_BEING_UNLOADED           (0x00000004)
637 
638 /**/
639 
640 extern VOID UDFSetModified(
641     IN PVCB        Vcb
642     );
643 
644 extern VOID UDFPreClrModified(
645     IN PVCB        Vcb
646     );
647 
648 extern VOID UDFClrModified(
649     IN PVCB        Vcb
650     );
651 
652 
653 #define FILE_ID_CACHE_GRANULARITY 16
654 #define DLOC_LIST_GRANULARITY 16
655 
656 typedef LONGLONG               FILE_ID;
657 typedef FILE_ID                *PFILE_ID;
658 
659 #endif //__UDF_COMMON_STRUCT__H__
660