* Sync up to trunk head (r65394).
[reactos.git] / drivers / filesystems / ext2 / inc / struct.h
1 /*************************************************************************
2 *
3 * File: struct.h
4 *
5 * Module: Ext2 File System Driver (Kernel mode execution only)
6 *
7 * Description:
8 * This file contains structure definitions for the sample file system
9 * driver. Note that all structures are prefixed with the letters
10 * "Ext2". The structures are all aligned using normal alignment
11 * used by the compiler (typically quad-word aligned).
12 *
13 * Author: Manoj Paul Joseph
14 *
15 *
16 *************************************************************************/
17
18 #ifndef _EXT2_STRUCTURES_H_
19 #define _EXT2_STRUCTURES_H_
20
21 /**************************************************************************
22 some useful definitions
23 **************************************************************************/
24 typedef CHAR int8;
25 typedef SHORT int16;
26 typedef LONG int32;
27
28 typedef UCHAR uint8;
29 typedef USHORT uint16;
30 typedef ULONG uint32;
31
32 typedef PVOID PBCB;
33
34 //
35 // This is a huge hack that will create a broken driver for GCC.
36 // The driver should use PSEH2.
37 //
38 #ifdef _MSC_VER
39 #define try __try
40 #define except __except
41 #define finally __finally
42 #else
43 #define try if (1)
44 #define except(x) if (0 && (x))
45 #define finally if (1)
46 #define GetExceptionInformation() 0
47 #define GetExceptionCode() 0
48 #endif
49
50 // we will use the LARGE_INTEGER structure as defined by NT
51
52 /**************************************************************************
53 some empty typedefs defined here so we can reference them easily
54 **************************************************************************/
55 struct _Ext2Identifier;
56 struct _Ext2ObjectName;
57 struct _Ext2ContextControlBlock;
58 struct _Ext2NTRequiredFCB;
59 struct _Ext2DiskDependentFCB;
60 struct _Ext2FileControlBlock;
61 struct _Ext2FileByteLocks;
62 struct _Ext2VolumeControlBlock;
63 struct _Ext2IrpContext;
64 struct _Ext2Data;
65
66 /**************************************************************************
67 each structure has a unique "node type" or signature associated with it
68 **************************************************************************/
69 #define EXT2_NODE_TYPE_OBJECT_NAME (0xfdecba01)
70 #define EXT2_NODE_TYPE_CCB (0xfdecba02)
71 #define EXT2_NODE_TYPE_FCB (0xfdecba03)
72 #define EXT2_NODE_TYPE_LOCKS (0xfdecba04)
73 #define EXT2_NODE_TYPE_VCB (0xfdecba05)
74 #define EXT2_NODE_TYPE_IRP_CONTEXT (0xfdecba06)
75 #define EXT2_NODE_TYPE_GLOBAL_DATA (0xfdecba07)
76 #define EXT2_NODE_TYPE_IO_CONTEXT (0xfdecba08)
77 #define EXT2_NODE_TYPE_SAVED_BCB (0xfdecba09)
78 #define EXT2_NODE_TYPE_FREED (0x10101010)
79 #define EXT2_NODE_TYPE_INVALID (0x10101010)
80
81 /**************************************************************************
82 every structure has a node type, and a node size associated with it.
83 The node type serves as a signature field. The size is used for
84 consistency checking ...
85 **************************************************************************/
86 typedef struct _Ext2Identifier {
87 uint32 NodeType; // a 32 bit identifier for the structure
88 uint32 NodeSize; // computed as sizeof(structure)
89 } Ext2Identifier, *PtrExt2Identifier;
90
91 /**************************************************************************
92 Structures for byte-range lock support.
93 **************************************************************************/
94 typedef struct Ext2FileLockAnchor {
95 LIST_ENTRY GrantedFileLockList;
96 LIST_ENTRY PendingFileLockList;
97 } Ext2FileLockAnchor, *PtrExt2FileLockAnchor;
98
99 typedef struct Ext2FileLockInfo {
100 Ext2Identifier NodeIdentifier;
101 uint32 FileLockFlags;
102 PVOID OwningProcess;
103 LARGE_INTEGER StartingOffset;
104 LARGE_INTEGER Length;
105 LARGE_INTEGER EndingOffset;
106 ULONG Key;
107 BOOLEAN ExclusiveLock;
108 PIRP PendingIRP;
109 LIST_ENTRY NextFileLockEntry;
110 } Ext2FileLockInfo, *PtrExt2FileLockInfo;
111
112 #define EXT2_BYTE_LOCK_NOT_FROM_ZONE (0x80000000)
113 #define EXT2_BYTE_LOCK_IS_PENDING (0x00000001)
114
115 /**************************************************************************
116 Every open on-disk object must have a name associated with it
117 This name has two components:
118 (a) the path-name (prefix) that leads to this on-disk object
119 (b) the name of the object itself
120 Note that with multiply linked objects, a single object might be
121 associated with more than one name structure.
122 This sample FSD does not correctly support multiply linked objects.
123
124 This structure must be quad-word aligned because it is zone allocated.
125 **************************************************************************/
126 typedef struct _Ext2ObjectName {
127 Ext2Identifier NodeIdentifier;
128 uint32 ObjectNameFlags;
129 // an absolute pathname of the object is stored below
130 UNICODE_STRING ObjectName;
131 } Ext2ObjectName, *PtrExt2ObjectName;
132
133 #define EXT2_OB_NAME_NOT_FROM_ZONE (0x80000000)
134
135 /**************************************************************************
136 Each file open instance is represented by a context control block.
137 For each successful create/open request; a file object and a CCB will
138 be created.
139 For open operations performed internally by the FSD, there may not
140 exist file objects; but a CCB will definitely be created.
141
142 This structure must be quad-word aligned because it is zone allocated.
143 **************************************************************************/
144 typedef struct _Ext2ContextControlBlock {
145 Ext2Identifier NodeIdentifier;
146 // ptr to the associated FCB
147 struct _Ext2FileControlBlock *PtrFCB;
148 // all CCB structures for a FCB are linked together
149 LIST_ENTRY NextCCB;
150 // each CCB is associated with a file object
151 PFILE_OBJECT PtrFileObject;
152 // flags (see below) associated with this CCB
153 uint32 CCBFlags;
154 // current byte offset is required sometimes
155 LARGE_INTEGER CurrentByteOffset;
156 // if this CCB represents a directory object open, we may
157 // need to maintain a search pattern
158
159 // PSTRING DirectorySearchPattern;
160 UNICODE_STRING DirectorySearchPattern;
161
162 // The full path name for the file...
163 UNICODE_STRING AbsolutePathName;
164
165 // Rename/Link Target file name
166 // Used only in a Rename/Link operation
167 UNICODE_STRING RenameLinkTargetFileName;
168
169 // we must maintain user specified file time values
170 uint32 UserSpecifiedTime;
171
172
173 } Ext2CCB, *PtrExt2CCB;
174
175
176 /**************************************************************************
177 the following CCBFlags values are relevant. These flag
178 values are bit fields; therefore we can test whether
179 a bit position is set (1) or not set (0).
180 **************************************************************************/
181
182 // some on-disk file/directories are opened by EXT2 itself
183 // as opposed to being opened on behalf of a user process
184 #define EXT2_CCB_OPENED_BY_EXT2 (0x00000001)
185 // the file object specified synchronous access at create/open time.
186 // this implies that EXT2 must maintain the current byte offset
187 #define EXT2_CCB_OPENED_FOR_SYNC_ACCESS (0x00000002)
188 // file object specified sequential access for this file
189 #define EXT2_CCB_OPENED_FOR_SEQ_ACCESS (0x00000004)
190 // the CCB has had an IRP_MJ_CLEANUP issued on it. we must
191 // no longer allow the file object / CCB to be used in I/O requests.
192 #define EXT2_CCB_CLEANED (0x00000008)
193 // if we were invoked via the fast i/o path to perform file i/o;
194 // we should set the CCB access/modification time at cleanup
195 #define EXT2_CCB_ACCESSED (0x00000010)
196 #define EXT2_CCB_MODIFIED (0x00000020)
197 // if an application process set the file date time, we must
198 // honor that request and *not* overwrite the values at cleanup
199 #define EXT2_CCB_ACCESS_TIME_SET (0x00000040)
200 #define EXT2_CCB_MODIFY_TIME_SET (0x00000080)
201 #define EXT2_CCB_CREATE_TIME_SET (0x00000100)
202
203 #define EXT2_CCB_NOT_FROM_ZONE (0x80000000)
204
205 // this CCB was allocated for a "volume open" operation
206 #define EXT2_CCB_VOLUME_OPEN (0x00000100)
207
208 /**************************************************************************
209 each open file/directory/volume is represented by a file control block.
210 NOTE: Currently, EXT2 does not handle multiply linked files correctly.
211 In your FSD implementation, you must be careful about handling
212 such on-disk files correctly i.e. a single (unique) FCB must
213 represent an on-disk file/directory regardless of the path used
214 to access the on-disk object.
215 With the current EXT2 implementation, an on-disk file object
216 with more than a single (hard) link will be treated incorrectly!
217
218 Each FCB can logically be divided into two:
219 (a) a structure that must have a field of type FSRTL_COMMON_FCB_HEADER
220 as the first field in the structure.
221 This portion should also contain other structures/resources required
222 by the NT Cache Manager
223 We will call this structure the "NT Required" FCB. Note that this
224 portion of the FCB must be allocated from non-paged pool.
225 (b) the remainder of the FCB is dependent upon the particular FSD
226 requirements.
227 This portion of the FCB could possibly be allocated from paged
228 memory, though in the sample FSD, it will always be allocated
229 from non-paged pool.
230
231 FCB structures are protected by the MainResource as well as the
232 PagingIoResource. Of course, if your FSD implementation requires
233 it, you can associate other syncronization structures with the
234 FCB.
235
236 This structure must be quad-word aligned because it is zone allocated.
237 **************************************************************************/
238 typedef struct _Ext2NTRequiredFCB
239 {
240 FSRTL_COMMON_FCB_HEADER CommonFCBHeader;
241 SECTION_OBJECT_POINTERS SectionObject;
242 ERESOURCE MainResource;
243 ERESOURCE PagingIoResource;
244 } Ext2NTRequiredFCB, *PtrExt2NTRequiredFCB;
245
246 typedef struct _Ext2DiskDependentFCB
247 {
248 // although the sample FSD does not maintain on-disk data structures,
249 // this structure serves as a reminder of the logical separation that
250 // your FSD can maintain between the disk dependent and the disk
251 // independent portions of the FCB.
252 uint16 DummyField; // placeholder
253 } Ext2DiskDependentFCB, *PtrExt2DiskDependentFCB;
254
255 typedef struct _Ext2FileControlBlock
256 {
257 Ext2Identifier NodeIdentifier;
258 // we will go ahead and embed the "NT Required FCB" right here.
259 // Note though that it is just as acceptable to simply allocate
260 // memory separately for the other half of the FCB and store a
261 // pointer to the "NT Required" portion here instead of embedding
262 // it ...
263 Ext2NTRequiredFCB NTRequiredFCB;
264 // the disk dependent portion of the FCB is embedded right here
265 Ext2DiskDependentFCB DiskDependentFCB;
266 // this FCB belongs to some mounted logical volume
267 struct _Ext2VolumeControlBlock *PtrVCB;
268 // to be able to access all open file(s) for a volume, we will
269 // link all FCB structures for a logical volume together
270 LIST_ENTRY NextFCB;
271
272 // to be used if this FCB is on the Closable FCB List...
273 struct _ClosableFCBs
274 {
275 LIST_ENTRY ClosableFCBList;
276 BOOLEAN OnClosableFCBList;
277 }ClosableFCBs;
278
279 // some state information for the FCB is maintained using the
280 // flags field
281 uint32 FCBFlags;
282 // all CCB's for this particular FCB are linked off the following
283 // list head.
284 LIST_ENTRY CCBListHead;
285 // NT requires that a file system maintain and honor the various
286 // SHARE_ACCESS modes ...
287 SHARE_ACCESS FCBShareAccess;
288 // to identify the lazy writer thread(s) we will grab and store
289 // the thread id here when a request to acquire resource(s)
290 // arrives ..
291 uint32 LazyWriterThreadID;
292 // whenever a file stream has a create/open operation performed,
293 // the Reference count below is incremented AND the OpenHandle count
294 // below is also incremented.
295 // When an IRP_MJ_CLEANUP is received, the OpenHandle count below
296 // is decremented.
297 // When an IRP_MJ_CLOSE is received, the Reference count below is
298 // decremented.
299 // When the Reference count goes down to zero, the FCB can be de-allocated.
300 // Note that a zero Reference count implies a zero OpenHandle count.
301 // This invariant must always hold true ... (if it is really an invariant,
302 // shoudn't the previous statement be redundant ... hmmm!!!)
303 LONG ReferenceCount;
304 LONG OpenHandleCount;
305 // for the sample fsd, there exists a 1-1 correspondence between an
306 // object name structure and a FCB
307 PtrExt2ObjectName FCBName;
308 // we will maintain some time information here to make our life easier
309 LARGE_INTEGER CreationTime;
310 LARGE_INTEGER LastAccessTime;
311 LARGE_INTEGER LastWriteTime;
312 // Byte-range file lock support (we roll our own)
313 Ext2FileLockAnchor FCBByteRangeLock;
314 // The OPLOCK support package requires the following structure
315 OPLOCK FCBOplock;
316
317 // The I-Node no of this file / folder
318 ULONG INodeNo;
319 ULONG ParentINodeNo;
320 // Pointers to blocks
321 uint32 IBlock[EXT2_N_BLOCKS];
322
323 USHORT LinkCount;
324 union _DCBFCB
325 {
326 struct
327 {
328 PFILE_OBJECT PtrDirFileObject;
329 } Dcb;
330
331 struct _FCB
332 {
333 PFILE_OBJECT PtrDirFileObject;
334 // FCB specific stuff go here...
335 } Fcb;
336
337 }DcbFcb;
338
339 } Ext2FCB, *PtrExt2FCB, Ext2DCB, *PtrExt2DCB;
340
341 /**************************************************************************
342 the following FCBFlags values are relevant. These flag
343 values are bit fields; therefore we can test whether
344 a bit position is set (1) or not set (0).
345 **************************************************************************/
346 #define EXT2_FCB_IN_INIT (0x00000001)
347 #define EXT2_FCB_IN_TEARDOWN (0x00000002)
348 #define EXT2_FCB_PAGE_FILE (0x00000004)
349 #define EXT2_FCB_DIRECTORY (0x00000008)
350 #define EXT2_FCB_ROOT_DIRECTORY (0x00000018)
351 #define EXT2_FCB_WRITE_THROUGH (0x00000020)
352 #define EXT2_FCB_MAPPED (0x00000040)
353 #define EXT2_FCB_FAST_IO_READ_IN_PROGESS (0x00000080)
354 #define EXT2_FCB_FAST_IO_WRITE_IN_PROGESS (0x00000100)
355 #define EXT2_FCB_DELETE_ON_CLOSE (0x00000200)
356 #define EXT2_FCB_MODIFIED (0x00000400)
357 #define EXT2_FCB_ACCESSED (0x00000800)
358 #define EXT2_FCB_READ_ONLY (0x00001000)
359
360 #define EXT2_INITIALIZED_MAIN_RESOURCE (0x00002000)
361 #define EXT2_INITIALIZED_PAGING_IO_RESOURCE (0x00004000)
362 #define EXT2_FCB_BLOCKS_INITIALIZED (0x00008000)
363 #define EXT2_FCB_SPECIAL_FILE (0x00010000)
364 #define EXT2_FCB_HIDDEN_FILE (0x00020000)
365 #define EXT2_FCB_NOT_FROM_ZONE (0x80000000)
366
367
368 typedef struct _GroupDescriptors
369 {
370 uint32 InodeTablesBlock; /* Inodes table block => bg_inode_table */
371 uint32 InodeBitmapBlock; /* Inodes bitmap block => bg_inode_bitmap */
372 uint32 BlockBitmapBlock; /* Blocks bitmap block => bg_block_bitmap */
373 uint32 FreeBlocksCount;
374 uint32 FreeInodesCount;
375 }Ext2GroupDescriptors, *PtrExt2GroupDescriptors;
376
377
378
379 /**************************************************************************
380 A logical volume is represented using the following structure.
381 This structure is allocated as part of the device extension
382 for a device object that this sample FSD will create, to represent
383 the mounted logical volume.
384
385 NOTE: If you were to extend this sample FSD to be a "real" FSD,
386 you would be worried about allocated clusters/sectiors,
387 bitmaps providing such information for the mounted volume,
388 dirty/modified clusters/sectiors etc.
389 This sample FSD does not maintain such information in the
390 in-memory VCB, though you may wish to consider it.
391 **************************************************************************/
392 typedef struct _Ext2VolumeControlBlock
393 {
394 Ext2Identifier NodeIdentifier;
395
396 // Required to use the Cache Manager.
397 FSRTL_COMMON_FCB_HEADER CommonVCBHeader;
398 SECTION_OBJECT_POINTERS SectionObject;
399 // a resource to protect the fields contained within the VCB
400 ERESOURCE VCBResource;
401
402 // a resource to synchronise paging io
403 ERESOURCE PagingIoResource;
404
405 // Pointer to a stream file object created for the volume information
406 // to be more easily read from secondary storage (with the support of
407 // the NT Cache Manager).
408 PFILE_OBJECT PtrStreamFileObject;
409
410 // each VCB is accessible off a global linked list
411 LIST_ENTRY NextVCB;
412
413 // each VCB points to a VPB structure created by the NT I/O Manager
414 PVPB PtrVPB;
415
416 // a set of flags that might mean something useful
417 uint32 VCBFlags;
418
419 // A count of the number of open files/directories
420 // As long as the count is != 0, the volume cannot
421 // be dismounted or locked.
422 uint32 VCBOpenCount;
423
424 // a global list of all FCB structures associated with the VCB
425 LIST_ENTRY FCBListHead;
426
427 //
428 // a list of FCBs created at the FSD's initiative...
429 // These FCBs have a reference count of 0
430 // This list should never be allowed to cross a limit...
431 //
432 struct Ext2ClosableFCB
433 {
434 LIST_ENTRY ClosableFCBListHead;
435 ULONG Count;
436 }ClosableFCBs;
437 // we will maintain a global list of IRP's that are pending
438 // because of a directory notify request.
439 LIST_ENTRY NextNotifyIRP;
440 // the above list is protected only by the mutex declared below
441 KMUTEX NotifyIRPMutex;
442 // for each mounted volume, we create a device object. Here then
443 // is a back pointer to that device object
444 PDEVICE_OBJECT VCBDeviceObject;
445 // We also retain a pointer to the physical device object on which we
446 // have mounted ourselves. The I/O Manager passes us a pointer to this
447 // device object when requesting a mount operation.
448 PDEVICE_OBJECT TargetDeviceObject;
449 // the volume structure contains a pointer to the root directory FCB
450 PtrExt2FCB PtrRootDirectoryFCB;
451 // the complete name of the user visible drive letter we serve
452 uint8 *PtrVolumePath;
453 // For volume open operations, we do not create a FCB (we use the VCB
454 // directly instead). Therefore, all CCB structures for the volume
455 // open operation are linked directly off the VCB
456 LIST_ENTRY VolumeOpenListHead;
457
458
459 // Volume information
460 ULONG BlocksCount;
461 ULONG InodesCount;
462 ULONG ReservedBlocksCount;
463 ULONG FreeBlocksCount;
464 ULONG FreeInodesCount;
465 ULONG LogBlockSize; // Block size = 1024 << LogBlockSize
466 ULONG InodeSize;
467
468 // Group Information Saved up in the VCB...
469 PtrExt2GroupDescriptors PtrGroupDescriptors;
470 ULONG NoOfGroups;
471
472 uint32 InodesPerGroup;
473 uint32 BlocksPerGroup;
474
475 } Ext2VCB, *PtrExt2VCB;
476
477 // some valid flags for the VCB
478 #define EXT2_VCB_FLAGS_VOLUME_MOUNTED (0x00000001)
479 #define EXT2_VCB_FLAGS_VOLUME_LOCKED (0x00000002)
480 #define EXT2_VCB_FLAGS_BEING_DISMOUNTED (0x00000004)
481 #define EXT2_VCB_FLAGS_SHUTDOWN (0x00000008)
482 #define EXT2_VCB_FLAGS_VOLUME_READ_ONLY (0x00000010)
483
484 #define EXT2_VCB_FLAGS_VCB_INITIALIZED (0x00000020)
485
486 typedef struct _EXT2_IO_CONTEXT
487 {
488 Ext2Identifier NodeIdentifier;
489 ULONG ReadWriteLength;
490 LONG Count;
491 PIRP PtrMasterIrp;
492 PKEVENT PtrSyncEvent;
493
494 } EXT2_IO_CONTEXT, *PEXT2_IO_CONTEXT;
495
496
497 typedef struct _Ext2SavedBCBs
498 {
499 Ext2Identifier NodeIdentifier;
500 PBCB PtrBCB;
501 LIST_ENTRY SavedBCBsListEntry;
502
503 } EXT2_SAVED_BCBS, *PEXT2_SAVED_BCBS;
504
505
506 /**************************************************************************
507 The IRP context encapsulates the current request. This structure is
508 used in the "common" dispatch routines invoked either directly in
509 the context of the original requestor, or indirectly in the context
510 of a system worker thread.
511 **************************************************************************/
512 typedef struct _Ext2IrpContext
513 {
514 Ext2Identifier NodeIdentifier;
515 uint32 IrpContextFlags;
516 // copied from the IRP
517 uint8 MajorFunction;
518 // copied from the IRP
519 uint8 MinorFunction;
520
521 // to queue this IRP for asynchronous processing
522 WORK_QUEUE_ITEM WorkQueueItem;
523 // the IRP for which this context structure was created
524 PIRP Irp;
525 // the target of the request (obtained from the IRP)
526 PDEVICE_OBJECT TargetDeviceObject;
527 // if an exception occurs, we will store the code here
528 NTSTATUS SavedExceptionCode;
529
530 // This list entry is used if asnchronous processing is required...
531 LIST_ENTRY ThreadQueueListEntry;
532
533 // This list entry is used if BCBs are to be saved and then flushed...
534 // Could have been put somewhere else...
535 LIST_ENTRY SavedBCBsListHead;
536 ULONG SavedCount;
537
538 } Ext2IrpContext, *PtrExt2IrpContext;
539
540 #define EXT2_IRP_CONTEXT_CAN_BLOCK (0x00000001)
541 #define EXT2_IRP_CONTEXT_WRITE_THROUGH (0x00000002)
542 #define EXT2_IRP_CONTEXT_EXCEPTION (0x00000004)
543 #define EXT2_IRP_CONTEXT_DEFERRED_WRITE (0x00000008)
544 #define EXT2_IRP_CONTEXT_ASYNC_PROCESSING (0x00000010)
545 #define EXT2_IRP_CONTEXT_NOT_TOP_LEVEL (0x00000020)
546
547 #define EXT2_IRP_CONTEXT_NOT_FROM_ZONE (0x80000000)
548
549 typedef struct _Ext2ThreadQueue
550 {
551 HANDLE QueueHandlerThread;
552
553 LIST_ENTRY ThreadQueueListHead; // This holds the Contexts
554 // that are to be scheduled
555 KSPIN_LOCK SpinLock; // To synchronize access to
556 // the list
557 KEVENT QueueEvent; // The Worker thread queue
558 // package waits on this event
559 } Ext2ThreadQueue;
560
561 /**************************************************************************
562 we will store all of our global variables in one structure.
563 Global variables are not specific to any mounted volume BUT
564 by definition are required for successful operation of the
565 FSD implementation.
566 **************************************************************************/
567 typedef struct _Ext2Data
568 {
569 Ext2Identifier NodeIdentifier;
570 // the fields in this list are protected by the following resource
571 ERESOURCE GlobalDataResource;
572 // each driver has a driver object created for it by the NT I/O Mgr.
573 // we are no exception to this rule.
574 PDRIVER_OBJECT Ext2DriverObject;
575 // we will create a device object for our FSD as well ...
576 // Although not really required, it helps if a helper application
577 // writen by us wishes to send us control information via
578 // IOCTL requests ...
579 PDEVICE_OBJECT Ext2DeviceObject;
580 // we will keep a list of all logical volumes for our sample FSD
581 LIST_ENTRY NextVCB;
582 // the NT Cache Manager, the I/O Manager and we will conspire
583 // to bypass IRP usage using the function pointers contained
584 // in the following structure
585 FAST_IO_DISPATCH Ext2FastIoDispatch;
586 // The NT Cache Manager uses the following call backs to ensure
587 // correct locking hierarchy is maintained
588 CACHE_MANAGER_CALLBACKS CacheMgrCallBacks;
589 // structures allocated from a zone need some fields here. Note
590 // that under version 4.0, it might be better to use lookaside
591 // lists
592 KSPIN_LOCK ZoneAllocationSpinLock;
593 ZONE_HEADER ObjectNameZoneHeader;
594 ZONE_HEADER CCBZoneHeader;
595 ZONE_HEADER FCBZoneHeader;
596 ZONE_HEADER ByteLockZoneHeader;
597 ZONE_HEADER IrpContextZoneHeader;
598 void *ObjectNameZone;
599 void *CCBZone;
600 void *FCBZone;
601 void *ByteLockZone;
602 void *IrpContextZone;
603
604 // currently, there is a single default zone size value used for
605 // all zones. This should ideally be changed by you to be 1 per
606 // type of zone (e.g. a default size for the FCB zone might be
607 // different from the default size for the ByteLock zone).
608
609 // Of course, you will need to use different values (min/max)
610 // for lookaside lists (if you decide to use them instead)
611 uint32 DefaultZoneSizeInNumStructs;
612
613 // some state information is maintained in the flags field
614 uint32 Ext2Flags;
615
616 // Handle returned by the MUP is stored here.
617 HANDLE MupHandle;
618
619 // Time difference
620 LARGE_INTEGER TimeDiff;
621
622 // The Worker Thread package uses this structure...
623 Ext2ThreadQueue ThreadQueue;
624
625 }Ext2Data, *PtrExt2Data;
626
627 // valid flag values for the global data structure
628 #define EXT2_DATA_FLAGS_RESOURCE_INITIALIZED (0x00000001)
629 #define EXT2_DATA_FLAGS_ZONES_INITIALIZED (0x00000002)
630
631 // a default size of the number of pages of non-paged pool allocated
632 // for each of the zones ...
633
634 // Note that the values are absolutely arbitrary, the only information
635 // worth using from the values themselves is that they increase for
636 // larger systems (i.e. systems with more memory)
637 #define EXT2_DEFAULT_ZONE_SIZE_SMALL_SYSTEM (0x4)
638 #define EXT2_DEFAULT_ZONE_SIZE_MEDIUM_SYSTEM (0x8)
639 #define EXT2_DEFAULT_ZONE_SIZE_LARGE_SYSTEM (0xc)
640
641 // another simplistic (brain dead ? :-) method used is to simply double
642 // the values for a "server" machine
643
644 // So, for all you guys who "modified" the registry ;-) to change the
645 // wkstation into a server, tough luck !
646 #define EXT2_NTAS_MULTIPLE (0x2)
647
648 /***************************************************************************
649 The following locking hierarchy is maintained in this sample filesystem
650 driver:
651
652 (a) the global structure resource can be acquired at any time. However,
653 it is an "end resource" i.e. once acquired, no other resource can
654 be obtained until the global structure resource is released.
655 (b) the logical volume resource must be acquired (if required) before
656 any of the other resources are acquired.
657 (c) a file control block can be acquired next (if required). If two
658 FCB structures need to be acquired, the FCB "higher" in the directory
659 tree must be acquired first.
660 For a FCB, the "main resource" must be acquired first before a
661 "paging i/o" resource is acquired.
662
663 Whenever a file is opened, the logical volume structure is referenced.
664 This ensures that the volume cannot be dismounted while any file is open.
665
666 ***************************************************************************/
667
668 typedef struct _IO_RUN
669 {
670 UINT LogicalBlock;
671 UINT StartOffset;
672 UINT EndOffset;
673 PIRP PtrAssociatedIrp;
674
675 } EXT2_IO_RUN, *PEXT2_IO_RUN;
676
677 typedef struct _SIBlocks
678 {
679 PBCB PtrBCB;
680 ULONG * PtrSIBlocks;
681 } EXT2_SIBLOCKS, *PEXT2_SIBLOCKS;
682
683 #endif // has this file been included?
684