Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

udfinit.c File Reference

#include "UdfProcs.h"

Go to the source code of this file.

Defines

#define BugCheckFileId   (UDFS_BUG_CHECK_UDFINIT)
#define Dbg   (UDFS_DEBUG_LEVEL_UDFINIT)
#define NPagedInit(L, S, T, D)   { ExInitializeNPagedLookasideList( (L), NULL, NULL, POOL_RAISE_IF_ALLOCATION_FAILURE, S, T, D); }
#define PagedInit(L, S, T, D)   { ExInitializePagedLookasideList( (L), NULL, NULL, POOL_RAISE_IF_ALLOCATION_FAILURE, S, T, D); }

Functions

NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
VOID UdfInitializeGlobalData (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT *FileSystemDeviceObjects)


Define Documentation

#define BugCheckFileId   (UDFS_BUG_CHECK_UDFINIT)
 

Definition at line 27 of file udfinit.c.

#define Dbg   (UDFS_DEBUG_LEVEL_UDFINIT)
 

Definition at line 33 of file udfinit.c.

#define NPagedInit L,
S,
T,
 )     { ExInitializeNPagedLookasideList( (L), NULL, NULL, POOL_RAISE_IF_ALLOCATION_FAILURE, S, T, D); }
 

Referenced by UdfInitializeGlobalData().

#define PagedInit L,
S,
T,
 )     { ExInitializePagedLookasideList( (L), NULL, NULL, POOL_RAISE_IF_ALLOCATION_FAILURE, S, T, D); }
 

Referenced by UdfInitializeGlobalData().


Function Documentation

NTSTATUS DriverEntry IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath
 

Definition at line 67 of file fs_rec.c.

00074 : 00075 00076 This routine is invoked once when the driver is loaded to allow the driver 00077 to initialize itself. The initialization for the driver consists of simply 00078 creating a device object for each type of file system recognized by this 00079 driver, and then registering each as active file systems. 00080 00081 Arguments: 00082 00083 DriverObject - Pointer to the driver object for this driver. 00084 00085 RegistryPath - Pointer to the registry service node for this driver. 00086 00087 Return Value: 00088 00089 The function value is the final status of the initialization for the driver. 00090 00091 --*/ 00092 00093 { 00094 PDEVICE_OBJECT UdfsMainRecognizerDeviceObject; 00095 NTSTATUS status; 00096 ULONG count = 0; 00097 00098 PAGED_CODE(); 00099 00100 // 00101 // Mark the entire driver as pagable. 00102 // 00103 00104 MmPageEntireDriver ((PVOID)DriverEntry); 00105 00106 // 00107 // Begin by initializing the driver object so that it the driver is 00108 // prepared to provide services. 00109 // 00110 00111 DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FsRecFsControl; 00112 DriverObject->MajorFunction[IRP_MJ_CREATE] = FsRecCreate; 00113 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = FsRecCleanupClose; 00114 DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsRecCleanupClose; 00115 DriverObject->DriverUnload = FsRecUnload; 00116 00117 FsRecLoadSync = ExAllocatePoolWithTag( NonPagedPool, sizeof(KEVENT), FSREC_POOL_TAG ); 00118 00119 if (FsRecLoadSync == NULL) { 00120 00121 return STATUS_INSUFFICIENT_RESOURCES; 00122 } 00123 00124 KeInitializeEvent( FsRecLoadSync, SynchronizationEvent, TRUE ); 00125 00126 // 00127 // Create and initialize each of the file system driver type device 00128 // objects. 00129 // 00130 00131 status = FsRecCreateAndRegisterDO( DriverObject, 00132 NULL, 00133 NULL, 00134 L"\\Cdfs", 00135 L"\\FileSystem\\CdfsRecognizer", 00136 CdfsFileSystem, 00137 FILE_DEVICE_CD_ROM_FILE_SYSTEM ); 00138 if (NT_SUCCESS( status )) { 00139 count++; 00140 } 00141 00142 status = FsRecCreateAndRegisterDO( DriverObject, 00143 NULL, 00144 &UdfsMainRecognizerDeviceObject, 00145 L"\\UdfsCdRom", 00146 L"\\FileSystem\\UdfsCdRomRecognizer", 00147 UdfsFileSystem, 00148 FILE_DEVICE_CD_ROM_FILE_SYSTEM ); 00149 if (NT_SUCCESS( status )) { 00150 count++; 00151 } 00152 00153 status = FsRecCreateAndRegisterDO( DriverObject, 00154 UdfsMainRecognizerDeviceObject, 00155 NULL, 00156 L"\\UdfsDisk", 00157 L"\\FileSystem\\UdfsDiskRecognizer", 00158 UdfsFileSystem, 00159 FILE_DEVICE_DISK_FILE_SYSTEM ); 00160 if (NT_SUCCESS( status )) { 00161 count++; 00162 } 00163 00164 status = FsRecCreateAndRegisterDO( DriverObject, 00165 NULL, 00166 NULL, 00167 L"\\Fat", 00168 L"\\FileSystem\\FatRecognizer", 00169 FatFileSystem, 00170 FILE_DEVICE_DISK_FILE_SYSTEM ); 00171 if (NT_SUCCESS( status )) { 00172 count++; 00173 } 00174 00175 status = FsRecCreateAndRegisterDO( DriverObject, 00176 NULL, 00177 NULL, 00178 L"\\Ntfs", 00179 L"\\FileSystem\\NtfsRecognizer", 00180 NtfsFileSystem, 00181 FILE_DEVICE_DISK_FILE_SYSTEM ); 00182 if (NT_SUCCESS( status )) { 00183 count++; 00184 } 00185 00186 if (count) { 00187 return STATUS_SUCCESS; 00188 } else { 00189 return STATUS_IMAGE_ALREADY_LOADED; 00190 } 00191 }

VOID UdfInitializeGlobalData IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT FileSystemDeviceObjects
 

Definition at line 183 of file udfinit.c.

References _FAST_IO_DISPATCH::AcquireFileForNtCreateSection, _CACHE_MANAGER_CALLBACKS::AcquireForLazyWrite, _CACHE_MANAGER_CALLBACKS::AcquireForReadAhead, _UDF_DATA::AsyncCloseQueue, _UDF_DATA::CacheManagerCallbacks, _UDF_DATA::CacheManagerVolumeCallbacks, _UDF_DATA::CloseItem, _UDF_DATA::DataResource, _UDF_DATA::DelayedCloseQueue, _UDF_DATA::DriverObject, ExInitializeFastMutex, ExInitializeResource, ExInitializeWorkItem, FAST_IO_DISPATCH, _FAST_IO_DISPATCH::FastIoCheckIfPossible, _FAST_IO_DISPATCH::FastIoLock, _FAST_IO_DISPATCH::FastIoQueryBasicInfo, _FAST_IO_DISPATCH::FastIoQueryNetworkOpenInfo, _FAST_IO_DISPATCH::FastIoQueryStandardInfo, _FAST_IO_DISPATCH::FastIoRead, _FAST_IO_DISPATCH::FastIoUnlockAll, _FAST_IO_DISPATCH::FastIoUnlockAllByKey, _FAST_IO_DISPATCH::FastIoUnlockSingle, _UDF_DATA::FileSystemDeviceObjects, FsRtlCopyRead(), _UDF_DATA::MaxDelayedCloseCount, _UDF_DATA::MinDelayedCloseCount, MmLargeSystem, MmMediumSystem, MmQuerySystemSize(), MmSmallSystem, _UDF_DATA::NodeByteSize, _UDF_DATA::NodeTypeCode, NPagedInit, NULL, NUMBER_OF_FS_OBJECTS, PagedInit, PWORKER_THREAD_ROUTINE, _FAST_IO_DISPATCH::ReleaseFileForNtCreateSection, _CACHE_MANAGER_CALLBACKS::ReleaseFromLazyWrite, _CACHE_MANAGER_CALLBACKS::ReleaseFromReadAhead, SIZEOF_FCB_DATA, SIZEOF_FCB_INDEX, SIZEOF_LOOKASIDE_LCB, _FAST_IO_DISPATCH::SizeOfFastIoDispatch, TAG_CCB, TAG_FCB_DATA, TAG_FCB_INDEX, TAG_FCB_NONPAGED, TAG_IRP_CONTEXT, TAG_LCB, UDF_DATA, UdfAcquireForCache(), UdfAcquireForCreateSection(), UdfCcbLookasideList, UdfData, _UDF_DATA::UdfDataMutex, UdfFastIoCheckIfPossible(), UdfFastIoDispatch, UdfFcbDataLookasideList, UdfFcbIndexLookasideList, UdfFcbNonPagedLookasideList, UdfFspClose(), UdfInitializeCrc16(), UdfIrpContextLookasideList, UdfLcbLookasideList, UdfNoopAcquire(), UdfNoopRelease(), UdfReleaseForCreateSection(), UdfReleaseFromCache(), UDFS_NTC_DATA_HEADER, USHORT, and _UDF_DATA::VcbQueue.

00190 : 00191 00192 This routine initializes the global Udfs data structures. 00193 00194 Arguments: 00195 00196 DriverObject - Supplies the driver object for UDFS. 00197 00198 FileSystemDeviceObjects - Supplies a vector of device objects for UDFS. 00199 00200 Return Value: 00201 00202 None. 00203 00204 --*/ 00205 00206 { 00207 USHORT CcbMaxDepth; 00208 USHORT FcbDataMaxDepth; 00209 USHORT FcbIndexMaxDepth; 00210 USHORT FcbNonPagedMaxDepth; 00211 USHORT IrpContextMaxDepth; 00212 USHORT LcbMaxDepth; 00213 00214 // 00215 // Start by initializing the FastIoDispatch Table. 00216 // 00217 00218 RtlZeroMemory( &UdfFastIoDispatch, sizeof( FAST_IO_DISPATCH )); 00219 00220 UdfFastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH); 00221 00222 UdfFastIoDispatch.AcquireFileForNtCreateSection = UdfAcquireForCreateSection; 00223 UdfFastIoDispatch.ReleaseFileForNtCreateSection = UdfReleaseForCreateSection; 00224 UdfFastIoDispatch.FastIoCheckIfPossible = UdfFastIoCheckIfPossible; // CheckForFastIo 00225 UdfFastIoDispatch.FastIoRead = FsRtlCopyRead; // Read 00226 00227 UdfFastIoDispatch.FastIoQueryBasicInfo = NULL; // QueryBasicInfo 00228 UdfFastIoDispatch.FastIoQueryStandardInfo = NULL; // QueryStandardInfo 00229 UdfFastIoDispatch.FastIoLock = NULL; // Lock 00230 UdfFastIoDispatch.FastIoUnlockSingle = NULL; // UnlockSingle 00231 UdfFastIoDispatch.FastIoUnlockAll = NULL; // UnlockAll 00232 UdfFastIoDispatch.FastIoUnlockAllByKey = NULL; // UnlockAllByKey 00233 UdfFastIoDispatch.FastIoQueryNetworkOpenInfo = NULL; // QueryNetworkInfo 00234 00235 // 00236 // Initialize the CRC table. Per UDF 1.01, we use the seed 10041 octal (4129 dec). 00237 // 00238 00239 UdfInitializeCrc16( 4129 ); 00240 00241 // 00242 // Initialize the UdfData structure. 00243 // 00244 00245 RtlZeroMemory( &UdfData, sizeof( UDF_DATA )); 00246 00247 UdfData.NodeTypeCode = UDFS_NTC_DATA_HEADER; 00248 UdfData.NodeByteSize = sizeof( UDF_DATA ); 00249 00250 UdfData.DriverObject = DriverObject; 00251 RtlCopyMemory( &UdfData.FileSystemDeviceObjects, 00252 UdfsFileSystemDeviceObjects, 00253 sizeof(PDEVICE_OBJECT) * NUMBER_OF_FS_OBJECTS ); 00254 00255 InitializeListHead( &UdfData.VcbQueue ); 00256 00257 ExInitializeResource( &UdfData.DataResource ); 00258 00259 // 00260 // Initialize the cache manager callback routines 00261 // 00262 00263 UdfData.CacheManagerCallbacks.AcquireForLazyWrite = &UdfAcquireForCache; 00264 UdfData.CacheManagerCallbacks.ReleaseFromLazyWrite = &UdfReleaseFromCache; 00265 UdfData.CacheManagerCallbacks.AcquireForReadAhead = &UdfAcquireForCache; 00266 UdfData.CacheManagerCallbacks.ReleaseFromReadAhead = &UdfReleaseFromCache; 00267 00268 UdfData.CacheManagerVolumeCallbacks.AcquireForLazyWrite = &UdfNoopAcquire; 00269 UdfData.CacheManagerVolumeCallbacks.ReleaseFromLazyWrite = &UdfNoopRelease; 00270 UdfData.CacheManagerVolumeCallbacks.AcquireForReadAhead = &UdfNoopAcquire; 00271 UdfData.CacheManagerVolumeCallbacks.ReleaseFromReadAhead = &UdfNoopRelease; 00272 00273 // 00274 // Initialize the lock mutex and the async and delay close queues. 00275 // 00276 00277 ExInitializeFastMutex( &UdfData.UdfDataMutex ); 00278 InitializeListHead( &UdfData.AsyncCloseQueue ); 00279 InitializeListHead( &UdfData.DelayedCloseQueue ); 00280 00281 ExInitializeWorkItem( &UdfData.CloseItem, 00282 (PWORKER_THREAD_ROUTINE) UdfFspClose, 00283 NULL ); 00284 00285 // 00286 // Do the initialization based on the system size. 00287 // 00288 00289 switch (MmQuerySystemSize()) { 00290 00291 case MmSmallSystem: 00292 00293 IrpContextMaxDepth = 4; 00294 UdfData.MaxDelayedCloseCount = 10; 00295 UdfData.MinDelayedCloseCount = 2; 00296 break; 00297 00298 case MmLargeSystem: 00299 00300 IrpContextMaxDepth = 24; 00301 UdfData.MaxDelayedCloseCount = 72; 00302 UdfData.MinDelayedCloseCount = 18; 00303 break; 00304 00305 default: 00306 case MmMediumSystem: 00307 00308 IrpContextMaxDepth = 8; 00309 UdfData.MaxDelayedCloseCount = 32; 00310 UdfData.MinDelayedCloseCount = 8; 00311 break; 00312 00313 } 00314 00315 // 00316 // Size lookasides to match what will commonly be dumped into them when we 00317 // run down the delayed close queues. 00318 // 00319 00320 LcbMaxDepth = 00321 CcbMaxDepth = 00322 FcbDataMaxDepth = 00323 FcbNonPagedMaxDepth = (USHORT) (UdfData.MaxDelayedCloseCount - UdfData.MinDelayedCloseCount); 00324 00325 // 00326 // We should tend to have fewer indices than files. 00327 // 00328 00329 FcbIndexMaxDepth = FcbNonPagedMaxDepth / 2; 00330 00331 #define NPagedInit(L,S,T,D) { ExInitializeNPagedLookasideList( (L), NULL, NULL, POOL_RAISE_IF_ALLOCATION_FAILURE, S, T, D); } 00332 #define PagedInit(L,S,T,D) { ExInitializePagedLookasideList( (L), NULL, NULL, POOL_RAISE_IF_ALLOCATION_FAILURE, S, T, D); } 00333 00334 NPagedInit( &UdfIrpContextLookasideList, sizeof( IRP_CONTEXT ), TAG_IRP_CONTEXT, IrpContextMaxDepth ); 00335 NPagedInit( &UdfFcbNonPagedLookasideList, sizeof( FCB_NONPAGED ), TAG_FCB_NONPAGED, FcbNonPagedMaxDepth ); 00336 00337 PagedInit( &UdfCcbLookasideList, sizeof( CCB ), TAG_CCB, CcbMaxDepth ); 00338 PagedInit( &UdfFcbIndexLookasideList, SIZEOF_FCB_INDEX, TAG_FCB_INDEX, FcbIndexMaxDepth ); 00339 PagedInit( &UdfFcbDataLookasideList, SIZEOF_FCB_DATA, TAG_FCB_DATA, FcbDataMaxDepth ); 00340 PagedInit( &UdfLcbLookasideList, SIZEOF_LOOKASIDE_LCB, TAG_LCB, LcbMaxDepth ); 00341 } }


Generated on Sat May 15 19:45:50 2004 for test by doxygen 1.3.7