Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenstruct.h
Go to the documentation of this file.
00001 /************************************************************************* 00002 * 00003 * File: struct.h 00004 * 00005 * Module: Ext2 File System Driver (Kernel mode execution only) 00006 * 00007 * Description: 00008 * This file contains structure definitions for the sample file system 00009 * driver. Note that all structures are prefixed with the letters 00010 * "Ext2". The structures are all aligned using normal alignment 00011 * used by the compiler (typically quad-word aligned). 00012 * 00013 * Author: Manoj Paul Joseph 00014 * 00015 * 00016 *************************************************************************/ 00017 00018 #ifndef _EXT2_STRUCTURES_H_ 00019 #define _EXT2_STRUCTURES_H_ 00020 00021 /************************************************************************** 00022 some useful definitions 00023 **************************************************************************/ 00024 typedef CHAR int8; 00025 typedef SHORT int16; 00026 typedef LONG int32; 00027 00028 typedef UCHAR uint8; 00029 typedef USHORT uint16; 00030 typedef ULONG uint32; 00031 00032 typedef PVOID PBCB; 00033 00034 // 00035 // This is a huge hack that will create a broken driver for GCC. 00036 // The driver should use PSEH2. 00037 // 00038 #ifdef _MSC_VER 00039 #define try __try 00040 #define except __except 00041 #define finally __finally 00042 #else 00043 #define try if (1) 00044 #define except(x) if (0 && (x)) 00045 #define finally if (1) 00046 #define GetExceptionInformation() 0 00047 #define GetExceptionCode() 0 00048 #endif 00049 00050 // we will use the LARGE_INTEGER structure as defined by NT 00051 00052 /************************************************************************** 00053 some empty typedefs defined here so we can reference them easily 00054 **************************************************************************/ 00055 struct _Ext2Identifier; 00056 struct _Ext2ObjectName; 00057 struct _Ext2ContextControlBlock; 00058 struct _Ext2NTRequiredFCB; 00059 struct _Ext2DiskDependentFCB; 00060 struct _Ext2FileControlBlock; 00061 struct _Ext2FileByteLocks; 00062 struct _Ext2VolumeControlBlock; 00063 struct _Ext2IrpContext; 00064 struct _Ext2Data; 00065 00066 /************************************************************************** 00067 each structure has a unique "node type" or signature associated with it 00068 **************************************************************************/ 00069 #define EXT2_NODE_TYPE_OBJECT_NAME (0xfdecba01) 00070 #define EXT2_NODE_TYPE_CCB (0xfdecba02) 00071 #define EXT2_NODE_TYPE_FCB (0xfdecba03) 00072 #define EXT2_NODE_TYPE_LOCKS (0xfdecba04) 00073 #define EXT2_NODE_TYPE_VCB (0xfdecba05) 00074 #define EXT2_NODE_TYPE_IRP_CONTEXT (0xfdecba06) 00075 #define EXT2_NODE_TYPE_GLOBAL_DATA (0xfdecba07) 00076 #define EXT2_NODE_TYPE_IO_CONTEXT (0xfdecba08) 00077 #define EXT2_NODE_TYPE_SAVED_BCB (0xfdecba09) 00078 #define EXT2_NODE_TYPE_FREED (0x10101010) 00079 #define EXT2_NODE_TYPE_INVALID (0x10101010) 00080 00081 /************************************************************************** 00082 every structure has a node type, and a node size associated with it. 00083 The node type serves as a signature field. The size is used for 00084 consistency checking ... 00085 **************************************************************************/ 00086 typedef struct _Ext2Identifier { 00087 uint32 NodeType; // a 32 bit identifier for the structure 00088 uint32 NodeSize; // computed as sizeof(structure) 00089 } Ext2Identifier, *PtrExt2Identifier; 00090 00091 /************************************************************************** 00092 Structures for byte-range lock support. 00093 **************************************************************************/ 00094 typedef struct Ext2FileLockAnchor { 00095 LIST_ENTRY GrantedFileLockList; 00096 LIST_ENTRY PendingFileLockList; 00097 } Ext2FileLockAnchor, *PtrExt2FileLockAnchor; 00098 00099 typedef struct Ext2FileLockInfo { 00100 Ext2Identifier NodeIdentifier; 00101 uint32 FileLockFlags; 00102 PVOID OwningProcess; 00103 LARGE_INTEGER StartingOffset; 00104 LARGE_INTEGER Length; 00105 LARGE_INTEGER EndingOffset; 00106 ULONG Key; 00107 BOOLEAN ExclusiveLock; 00108 PIRP PendingIRP; 00109 LIST_ENTRY NextFileLockEntry; 00110 } Ext2FileLockInfo, *PtrExt2FileLockInfo; 00111 00112 #define EXT2_BYTE_LOCK_NOT_FROM_ZONE (0x80000000) 00113 #define EXT2_BYTE_LOCK_IS_PENDING (0x00000001) 00114 00115 /************************************************************************** 00116 Every open on-disk object must have a name associated with it 00117 This name has two components: 00118 (a) the path-name (prefix) that leads to this on-disk object 00119 (b) the name of the object itself 00120 Note that with multiply linked objects, a single object might be 00121 associated with more than one name structure. 00122 This sample FSD does not correctly support multiply linked objects. 00123 00124 This structure must be quad-word aligned because it is zone allocated. 00125 **************************************************************************/ 00126 typedef struct _Ext2ObjectName { 00127 Ext2Identifier NodeIdentifier; 00128 uint32 ObjectNameFlags; 00129 // an absolute pathname of the object is stored below 00130 UNICODE_STRING ObjectName; 00131 } Ext2ObjectName, *PtrExt2ObjectName; 00132 00133 #define EXT2_OB_NAME_NOT_FROM_ZONE (0x80000000) 00134 00135 /************************************************************************** 00136 Each file open instance is represented by a context control block. 00137 For each successful create/open request; a file object and a CCB will 00138 be created. 00139 For open operations performed internally by the FSD, there may not 00140 exist file objects; but a CCB will definitely be created. 00141 00142 This structure must be quad-word aligned because it is zone allocated. 00143 **************************************************************************/ 00144 typedef struct _Ext2ContextControlBlock { 00145 Ext2Identifier NodeIdentifier; 00146 // ptr to the associated FCB 00147 struct _Ext2FileControlBlock *PtrFCB; 00148 // all CCB structures for a FCB are linked together 00149 LIST_ENTRY NextCCB; 00150 // each CCB is associated with a file object 00151 PFILE_OBJECT PtrFileObject; 00152 // flags (see below) associated with this CCB 00153 uint32 CCBFlags; 00154 // current byte offset is required sometimes 00155 LARGE_INTEGER CurrentByteOffset; 00156 // if this CCB represents a directory object open, we may 00157 // need to maintain a search pattern 00158 00159 // PSTRING DirectorySearchPattern; 00160 UNICODE_STRING DirectorySearchPattern; 00161 00162 // The full path name for the file... 00163 UNICODE_STRING AbsolutePathName; 00164 00165 // Rename/Link Target file name 00166 // Used only in a Rename/Link operation 00167 UNICODE_STRING RenameLinkTargetFileName; 00168 00169 // we must maintain user specified file time values 00170 uint32 UserSpecifiedTime; 00171 00172 00173 } Ext2CCB, *PtrExt2CCB; 00174 00175 00176 /************************************************************************** 00177 the following CCBFlags values are relevant. These flag 00178 values are bit fields; therefore we can test whether 00179 a bit position is set (1) or not set (0). 00180 **************************************************************************/ 00181 00182 // some on-disk file/directories are opened by EXT2 itself 00183 // as opposed to being opened on behalf of a user process 00184 #define EXT2_CCB_OPENED_BY_EXT2 (0x00000001) 00185 // the file object specified synchronous access at create/open time. 00186 // this implies that EXT2 must maintain the current byte offset 00187 #define EXT2_CCB_OPENED_FOR_SYNC_ACCESS (0x00000002) 00188 // file object specified sequential access for this file 00189 #define EXT2_CCB_OPENED_FOR_SEQ_ACCESS (0x00000004) 00190 // the CCB has had an IRP_MJ_CLEANUP issued on it. we must 00191 // no longer allow the file object / CCB to be used in I/O requests. 00192 #define EXT2_CCB_CLEANED (0x00000008) 00193 // if we were invoked via the fast i/o path to perform file i/o; 00194 // we should set the CCB access/modification time at cleanup 00195 #define EXT2_CCB_ACCESSED (0x00000010) 00196 #define EXT2_CCB_MODIFIED (0x00000020) 00197 // if an application process set the file date time, we must 00198 // honor that request and *not* overwrite the values at cleanup 00199 #define EXT2_CCB_ACCESS_TIME_SET (0x00000040) 00200 #define EXT2_CCB_MODIFY_TIME_SET (0x00000080) 00201 #define EXT2_CCB_CREATE_TIME_SET (0x00000100) 00202 00203 #define EXT2_CCB_NOT_FROM_ZONE (0x80000000) 00204 00205 // this CCB was allocated for a "volume open" operation 00206 #define EXT2_CCB_VOLUME_OPEN (0x00000100) 00207 00208 /************************************************************************** 00209 each open file/directory/volume is represented by a file control block. 00210 NOTE: Currently, EXT2 does not handle multiply linked files correctly. 00211 In your FSD implementation, you must be careful about handling 00212 such on-disk files correctly i.e. a single (unique) FCB must 00213 represent an on-disk file/directory regardless of the path used 00214 to access the on-disk object. 00215 With the current EXT2 implementation, an on-disk file object 00216 with more than a single (hard) link will be treated incorrectly! 00217 00218 Each FCB can logically be divided into two: 00219 (a) a structure that must have a field of type FSRTL_COMMON_FCB_HEADER 00220 as the first field in the structure. 00221 This portion should also contain other structures/resources required 00222 by the NT Cache Manager 00223 We will call this structure the "NT Required" FCB. Note that this 00224 portion of the FCB must be allocated from non-paged pool. 00225 (b) the remainder of the FCB is dependent upon the particular FSD 00226 requirements. 00227 This portion of the FCB could possibly be allocated from paged 00228 memory, though in the sample FSD, it will always be allocated 00229 from non-paged pool. 00230 00231 FCB structures are protected by the MainResource as well as the 00232 PagingIoResource. Of course, if your FSD implementation requires 00233 it, you can associate other syncronization structures with the 00234 FCB. 00235 00236 This structure must be quad-word aligned because it is zone allocated. 00237 **************************************************************************/ 00238 typedef struct _Ext2NTRequiredFCB 00239 { 00240 FSRTL_COMMON_FCB_HEADER CommonFCBHeader; 00241 SECTION_OBJECT_POINTERS SectionObject; 00242 ERESOURCE MainResource; 00243 ERESOURCE PagingIoResource; 00244 } Ext2NTRequiredFCB, *PtrExt2NTRequiredFCB; 00245 00246 typedef struct _Ext2DiskDependentFCB 00247 { 00248 // although the sample FSD does not maintain on-disk data structures, 00249 // this structure serves as a reminder of the logical separation that 00250 // your FSD can maintain between the disk dependent and the disk 00251 // independent portions of the FCB. 00252 uint16 DummyField; // placeholder 00253 } Ext2DiskDependentFCB, *PtrExt2DiskDependentFCB; 00254 00255 typedef struct _Ext2FileControlBlock 00256 { 00257 Ext2Identifier NodeIdentifier; 00258 // we will go ahead and embed the "NT Required FCB" right here. 00259 // Note though that it is just as acceptable to simply allocate 00260 // memory separately for the other half of the FCB and store a 00261 // pointer to the "NT Required" portion here instead of embedding 00262 // it ... 00263 Ext2NTRequiredFCB NTRequiredFCB; 00264 // the disk dependent portion of the FCB is embedded right here 00265 Ext2DiskDependentFCB DiskDependentFCB; 00266 // this FCB belongs to some mounted logical volume 00267 struct _Ext2VolumeControlBlock *PtrVCB; 00268 // to be able to access all open file(s) for a volume, we will 00269 // link all FCB structures for a logical volume together 00270 LIST_ENTRY NextFCB; 00271 00272 // to be used if this FCB is on the Closable FCB List... 00273 struct _ClosableFCBs 00274 { 00275 LIST_ENTRY ClosableFCBList; 00276 BOOLEAN OnClosableFCBList; 00277 }ClosableFCBs; 00278 00279 // some state information for the FCB is maintained using the 00280 // flags field 00281 uint32 FCBFlags; 00282 // all CCB's for this particular FCB are linked off the following 00283 // list head. 00284 LIST_ENTRY CCBListHead; 00285 // NT requires that a file system maintain and honor the various 00286 // SHARE_ACCESS modes ... 00287 SHARE_ACCESS FCBShareAccess; 00288 // to identify the lazy writer thread(s) we will grab and store 00289 // the thread id here when a request to acquire resource(s) 00290 // arrives .. 00291 uint32 LazyWriterThreadID; 00292 // whenever a file stream has a create/open operation performed, 00293 // the Reference count below is incremented AND the OpenHandle count 00294 // below is also incremented. 00295 // When an IRP_MJ_CLEANUP is received, the OpenHandle count below 00296 // is decremented. 00297 // When an IRP_MJ_CLOSE is received, the Reference count below is 00298 // decremented. 00299 // When the Reference count goes down to zero, the FCB can be de-allocated. 00300 // Note that a zero Reference count implies a zero OpenHandle count. 00301 // This invariant must always hold true ... (if it is really an invariant, 00302 // shoudn't the previous statement be redundant ... hmmm!!!) 00303 LONG ReferenceCount; 00304 LONG OpenHandleCount; 00305 // for the sample fsd, there exists a 1-1 correspondence between an 00306 // object name structure and a FCB 00307 PtrExt2ObjectName FCBName; 00308 // we will maintain some time information here to make our life easier 00309 LARGE_INTEGER CreationTime; 00310 LARGE_INTEGER LastAccessTime; 00311 LARGE_INTEGER LastWriteTime; 00312 // Byte-range file lock support (we roll our own) 00313 Ext2FileLockAnchor FCBByteRangeLock; 00314 // The OPLOCK support package requires the following structure 00315 OPLOCK FCBOplock; 00316 00317 // The I-Node no of this file / folder 00318 ULONG INodeNo; 00319 ULONG ParentINodeNo; 00320 // Pointers to blocks 00321 uint32 IBlock[EXT2_N_BLOCKS]; 00322 00323 USHORT LinkCount; 00324 union _DCBFCB 00325 { 00326 struct 00327 { 00328 PFILE_OBJECT PtrDirFileObject; 00329 } Dcb; 00330 00331 struct _FCB 00332 { 00333 PFILE_OBJECT PtrDirFileObject; 00334 // FCB specific stuff go here... 00335 } Fcb; 00336 00337 }DcbFcb; 00338 00339 } Ext2FCB, *PtrExt2FCB, Ext2DCB, *PtrExt2DCB; 00340 00341 /************************************************************************** 00342 the following FCBFlags values are relevant. These flag 00343 values are bit fields; therefore we can test whether 00344 a bit position is set (1) or not set (0). 00345 **************************************************************************/ 00346 #define EXT2_FCB_IN_INIT (0x00000001) 00347 #define EXT2_FCB_IN_TEARDOWN (0x00000002) 00348 #define EXT2_FCB_PAGE_FILE (0x00000004) 00349 #define EXT2_FCB_DIRECTORY (0x00000008) 00350 #define EXT2_FCB_ROOT_DIRECTORY (0x00000018) 00351 #define EXT2_FCB_WRITE_THROUGH (0x00000020) 00352 #define EXT2_FCB_MAPPED (0x00000040) 00353 #define EXT2_FCB_FAST_IO_READ_IN_PROGESS (0x00000080) 00354 #define EXT2_FCB_FAST_IO_WRITE_IN_PROGESS (0x00000100) 00355 #define EXT2_FCB_DELETE_ON_CLOSE (0x00000200) 00356 #define EXT2_FCB_MODIFIED (0x00000400) 00357 #define EXT2_FCB_ACCESSED (0x00000800) 00358 #define EXT2_FCB_READ_ONLY (0x00001000) 00359 00360 #define EXT2_INITIALIZED_MAIN_RESOURCE (0x00002000) 00361 #define EXT2_INITIALIZED_PAGING_IO_RESOURCE (0x00004000) 00362 #define EXT2_FCB_BLOCKS_INITIALIZED (0x00008000) 00363 #define EXT2_FCB_SPECIAL_FILE (0x00010000) 00364 #define EXT2_FCB_HIDDEN_FILE (0x00020000) 00365 #define EXT2_FCB_NOT_FROM_ZONE (0x80000000) 00366 00367 00368 typedef struct _GroupDescriptors 00369 { 00370 uint32 InodeTablesBlock; /* Inodes table block => bg_inode_table */ 00371 uint32 InodeBitmapBlock; /* Inodes bitmap block => bg_inode_bitmap */ 00372 uint32 BlockBitmapBlock; /* Blocks bitmap block => bg_block_bitmap */ 00373 uint32 FreeBlocksCount; 00374 uint32 FreeInodesCount; 00375 }Ext2GroupDescriptors, *PtrExt2GroupDescriptors; 00376 00377 00378 00379 /************************************************************************** 00380 A logical volume is represented using the following structure. 00381 This structure is allocated as part of the device extension 00382 for a device object that this sample FSD will create, to represent 00383 the mounted logical volume. 00384 00385 NOTE: If you were to extend this sample FSD to be a "real" FSD, 00386 you would be worried about allocated clusters/sectiors, 00387 bitmaps providing such information for the mounted volume, 00388 dirty/modified clusters/sectiors etc. 00389 This sample FSD does not maintain such information in the 00390 in-memory VCB, though you may wish to consider it. 00391 **************************************************************************/ 00392 typedef struct _Ext2VolumeControlBlock 00393 { 00394 Ext2Identifier NodeIdentifier; 00395 00396 // Required to use the Cache Manager. 00397 FSRTL_COMMON_FCB_HEADER CommonVCBHeader; 00398 SECTION_OBJECT_POINTERS SectionObject; 00399 // a resource to protect the fields contained within the VCB 00400 ERESOURCE VCBResource; 00401 00402 // a resource to synchronise paging io 00403 ERESOURCE PagingIoResource; 00404 00405 // Pointer to a stream file object created for the volume information 00406 // to be more easily read from secondary storage (with the support of 00407 // the NT Cache Manager). 00408 PFILE_OBJECT PtrStreamFileObject; 00409 00410 // each VCB is accessible off a global linked list 00411 LIST_ENTRY NextVCB; 00412 00413 // each VCB points to a VPB structure created by the NT I/O Manager 00414 PVPB PtrVPB; 00415 00416 // a set of flags that might mean something useful 00417 uint32 VCBFlags; 00418 00419 // A count of the number of open files/directories 00420 // As long as the count is != 0, the volume cannot 00421 // be dismounted or locked. 00422 uint32 VCBOpenCount; 00423 00424 // a global list of all FCB structures associated with the VCB 00425 LIST_ENTRY FCBListHead; 00426 00427 // 00428 // a list of FCBs created at the FSD's initiative... 00429 // These FCBs have a reference count of 0 00430 // This list should never be allowed to cross a limit... 00431 // 00432 struct Ext2ClosableFCB 00433 { 00434 LIST_ENTRY ClosableFCBListHead; 00435 ULONG Count; 00436 }ClosableFCBs; 00437 // we will maintain a global list of IRP's that are pending 00438 // because of a directory notify request. 00439 LIST_ENTRY NextNotifyIRP; 00440 // the above list is protected only by the mutex declared below 00441 KMUTEX NotifyIRPMutex; 00442 // for each mounted volume, we create a device object. Here then 00443 // is a back pointer to that device object 00444 PDEVICE_OBJECT VCBDeviceObject; 00445 // We also retain a pointer to the physical device object on which we 00446 // have mounted ourselves. The I/O Manager passes us a pointer to this 00447 // device object when requesting a mount operation. 00448 PDEVICE_OBJECT TargetDeviceObject; 00449 // the volume structure contains a pointer to the root directory FCB 00450 PtrExt2FCB PtrRootDirectoryFCB; 00451 // the complete name of the user visible drive letter we serve 00452 uint8 *PtrVolumePath; 00453 // For volume open operations, we do not create a FCB (we use the VCB 00454 // directly instead). Therefore, all CCB structures for the volume 00455 // open operation are linked directly off the VCB 00456 LIST_ENTRY VolumeOpenListHead; 00457 00458 00459 // Volume information 00460 ULONG BlocksCount; 00461 ULONG InodesCount; 00462 ULONG ReservedBlocksCount; 00463 ULONG FreeBlocksCount; 00464 ULONG FreeInodesCount; 00465 ULONG LogBlockSize; // Block size = 1024 << LogBlockSize 00466 ULONG InodeSize; 00467 00468 // Group Information Saved up in the VCB... 00469 PtrExt2GroupDescriptors PtrGroupDescriptors; 00470 ULONG NoOfGroups; 00471 00472 uint32 InodesPerGroup; 00473 uint32 BlocksPerGroup; 00474 00475 } Ext2VCB, *PtrExt2VCB; 00476 00477 // some valid flags for the VCB 00478 #define EXT2_VCB_FLAGS_VOLUME_MOUNTED (0x00000001) 00479 #define EXT2_VCB_FLAGS_VOLUME_LOCKED (0x00000002) 00480 #define EXT2_VCB_FLAGS_BEING_DISMOUNTED (0x00000004) 00481 #define EXT2_VCB_FLAGS_SHUTDOWN (0x00000008) 00482 #define EXT2_VCB_FLAGS_VOLUME_READ_ONLY (0x00000010) 00483 00484 #define EXT2_VCB_FLAGS_VCB_INITIALIZED (0x00000020) 00485 00486 typedef struct _EXT2_IO_CONTEXT 00487 { 00488 Ext2Identifier NodeIdentifier; 00489 ULONG ReadWriteLength; 00490 LONG Count; 00491 PIRP PtrMasterIrp; 00492 PKEVENT PtrSyncEvent; 00493 00494 } EXT2_IO_CONTEXT, *PEXT2_IO_CONTEXT; 00495 00496 00497 typedef struct _Ext2SavedBCBs 00498 { 00499 Ext2Identifier NodeIdentifier; 00500 PBCB PtrBCB; 00501 LIST_ENTRY SavedBCBsListEntry; 00502 00503 } EXT2_SAVED_BCBS, *PEXT2_SAVED_BCBS; 00504 00505 00506 /************************************************************************** 00507 The IRP context encapsulates the current request. This structure is 00508 used in the "common" dispatch routines invoked either directly in 00509 the context of the original requestor, or indirectly in the context 00510 of a system worker thread. 00511 **************************************************************************/ 00512 typedef struct _Ext2IrpContext 00513 { 00514 Ext2Identifier NodeIdentifier; 00515 uint32 IrpContextFlags; 00516 // copied from the IRP 00517 uint8 MajorFunction; 00518 // copied from the IRP 00519 uint8 MinorFunction; 00520 00521 // to queue this IRP for asynchronous processing 00522 WORK_QUEUE_ITEM WorkQueueItem; 00523 // the IRP for which this context structure was created 00524 PIRP Irp; 00525 // the target of the request (obtained from the IRP) 00526 PDEVICE_OBJECT TargetDeviceObject; 00527 // if an exception occurs, we will store the code here 00528 NTSTATUS SavedExceptionCode; 00529 00530 // This list entry is used if asnchronous processing is required... 00531 LIST_ENTRY ThreadQueueListEntry; 00532 00533 // This list entry is used if BCBs are to be saved and then flushed... 00534 // Could have been put somewhere else... 00535 LIST_ENTRY SavedBCBsListHead; 00536 ULONG SavedCount; 00537 00538 } Ext2IrpContext, *PtrExt2IrpContext; 00539 00540 #define EXT2_IRP_CONTEXT_CAN_BLOCK (0x00000001) 00541 #define EXT2_IRP_CONTEXT_WRITE_THROUGH (0x00000002) 00542 #define EXT2_IRP_CONTEXT_EXCEPTION (0x00000004) 00543 #define EXT2_IRP_CONTEXT_DEFERRED_WRITE (0x00000008) 00544 #define EXT2_IRP_CONTEXT_ASYNC_PROCESSING (0x00000010) 00545 #define EXT2_IRP_CONTEXT_NOT_TOP_LEVEL (0x00000020) 00546 00547 #define EXT2_IRP_CONTEXT_NOT_FROM_ZONE (0x80000000) 00548 00549 typedef struct _Ext2ThreadQueue 00550 { 00551 HANDLE QueueHandlerThread; 00552 00553 LIST_ENTRY ThreadQueueListHead; // This holds the Contexts 00554 // that are to be scheduled 00555 KSPIN_LOCK SpinLock; // To synchronize access to 00556 // the list 00557 KEVENT QueueEvent; // The Worker thread queue 00558 // package waits on this event 00559 } Ext2ThreadQueue; 00560 00561 /************************************************************************** 00562 we will store all of our global variables in one structure. 00563 Global variables are not specific to any mounted volume BUT 00564 by definition are required for successful operation of the 00565 FSD implementation. 00566 **************************************************************************/ 00567 typedef struct _Ext2Data 00568 { 00569 Ext2Identifier NodeIdentifier; 00570 // the fields in this list are protected by the following resource 00571 ERESOURCE GlobalDataResource; 00572 // each driver has a driver object created for it by the NT I/O Mgr. 00573 // we are no exception to this rule. 00574 PDRIVER_OBJECT Ext2DriverObject; 00575 // we will create a device object for our FSD as well ... 00576 // Although not really required, it helps if a helper application 00577 // writen by us wishes to send us control information via 00578 // IOCTL requests ... 00579 PDEVICE_OBJECT Ext2DeviceObject; 00580 // we will keep a list of all logical volumes for our sample FSD 00581 LIST_ENTRY NextVCB; 00582 // the NT Cache Manager, the I/O Manager and we will conspire 00583 // to bypass IRP usage using the function pointers contained 00584 // in the following structure 00585 FAST_IO_DISPATCH Ext2FastIoDispatch; 00586 // The NT Cache Manager uses the following call backs to ensure 00587 // correct locking hierarchy is maintained 00588 CACHE_MANAGER_CALLBACKS CacheMgrCallBacks; 00589 // structures allocated from a zone need some fields here. Note 00590 // that under version 4.0, it might be better to use lookaside 00591 // lists 00592 KSPIN_LOCK ZoneAllocationSpinLock; 00593 ZONE_HEADER ObjectNameZoneHeader; 00594 ZONE_HEADER CCBZoneHeader; 00595 ZONE_HEADER FCBZoneHeader; 00596 ZONE_HEADER ByteLockZoneHeader; 00597 ZONE_HEADER IrpContextZoneHeader; 00598 void *ObjectNameZone; 00599 void *CCBZone; 00600 void *FCBZone; 00601 void *ByteLockZone; 00602 void *IrpContextZone; 00603 00604 // currently, there is a single default zone size value used for 00605 // all zones. This should ideally be changed by you to be 1 per 00606 // type of zone (e.g. a default size for the FCB zone might be 00607 // different from the default size for the ByteLock zone). 00608 00609 // Of course, you will need to use different values (min/max) 00610 // for lookaside lists (if you decide to use them instead) 00611 uint32 DefaultZoneSizeInNumStructs; 00612 00613 // some state information is maintained in the flags field 00614 uint32 Ext2Flags; 00615 00616 // Handle returned by the MUP is stored here. 00617 HANDLE MupHandle; 00618 00619 // Time difference 00620 LARGE_INTEGER TimeDiff; 00621 00622 // The Worker Thread package uses this structure... 00623 Ext2ThreadQueue ThreadQueue; 00624 00625 }Ext2Data, *PtrExt2Data; 00626 00627 // valid flag values for the global data structure 00628 #define EXT2_DATA_FLAGS_RESOURCE_INITIALIZED (0x00000001) 00629 #define EXT2_DATA_FLAGS_ZONES_INITIALIZED (0x00000002) 00630 00631 // a default size of the number of pages of non-paged pool allocated 00632 // for each of the zones ... 00633 00634 // Note that the values are absolutely arbitrary, the only information 00635 // worth using from the values themselves is that they increase for 00636 // larger systems (i.e. systems with more memory) 00637 #define EXT2_DEFAULT_ZONE_SIZE_SMALL_SYSTEM (0x4) 00638 #define EXT2_DEFAULT_ZONE_SIZE_MEDIUM_SYSTEM (0x8) 00639 #define EXT2_DEFAULT_ZONE_SIZE_LARGE_SYSTEM (0xc) 00640 00641 // another simplistic (brain dead ? :-) method used is to simply double 00642 // the values for a "server" machine 00643 00644 // So, for all you guys who "modified" the registry ;-) to change the 00645 // wkstation into a server, tough luck ! 00646 #define EXT2_NTAS_MULTIPLE (0x2) 00647 00648 /*************************************************************************** 00649 The following locking hierarchy is maintained in this sample filesystem 00650 driver: 00651 00652 (a) the global structure resource can be acquired at any time. However, 00653 it is an "end resource" i.e. once acquired, no other resource can 00654 be obtained until the global structure resource is released. 00655 (b) the logical volume resource must be acquired (if required) before 00656 any of the other resources are acquired. 00657 (c) a file control block can be acquired next (if required). If two 00658 FCB structures need to be acquired, the FCB "higher" in the directory 00659 tree must be acquired first. 00660 For a FCB, the "main resource" must be acquired first before a 00661 "paging i/o" resource is acquired. 00662 00663 Whenever a file is opened, the logical volume structure is referenced. 00664 This ensures that the volume cannot be dismounted while any file is open. 00665 00666 ***************************************************************************/ 00667 00668 typedef struct _IO_RUN 00669 { 00670 UINT LogicalBlock; 00671 UINT StartOffset; 00672 UINT EndOffset; 00673 PIRP PtrAssociatedIrp; 00674 00675 } EXT2_IO_RUN, *PEXT2_IO_RUN; 00676 00677 typedef struct _SIBlocks 00678 { 00679 PBCB PtrBCB; 00680 ULONG * PtrSIBlocks; 00681 } EXT2_SIBLOCKS, *PEXT2_SIBLOCKS; 00682 00683 #endif // has this file been included? 00684 Generated on Mon May 28 2012 04:27:23 for ReactOS by
1.7.6.1
|