00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "UdfProcs.h"
00022
00023
00024
00025
00026
00027 #define BugCheckFileId (UDFS_BUG_CHECK_UDFINIT)
00028
00029
00030
00031
00032
00033 #define Dbg (UDFS_DEBUG_LEVEL_UDFINIT)
00034
00035
NTSTATUS
00036
DriverEntry(
00037 IN
PDRIVER_OBJECT DriverObject,
00038 IN PUNICODE_STRING RegistryPath
00039 );
00040
00041
VOID
00042
UdfInitializeGlobalData (
00043 IN
PDRIVER_OBJECT DriverObject,
00044 IN
PDEVICE_OBJECT *FileSystemDeviceObjects
00045 );
00046
00047
#ifdef ALLOC_PRAGMA
00048
#pragma alloc_text(INIT, DriverEntry)
00049
#pragma alloc_text(INIT, UdfInitializeGlobalData)
00050
#endif
00051
00052
00053
00054
00055
00056
00057
NTSTATUS
00058
DriverEntry(
00059 IN
PDRIVER_OBJECT DriverObject,
00060 IN PUNICODE_STRING RegistryPath
00061 )
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 {
00083
NTSTATUS Status;
00084 UNICODE_STRING UnicodeString;
00085
PDEVICE_OBJECT UdfsFileSystemDeviceObjects[
NUMBER_OF_FS_OBJECTS];
00086
PDEVICE_OBJECT UdfsDiskFileSystemDeviceObject;
00087
00088
00089
00090
00091
00092
00093
00094
00095
ASSERT( NUMBER_OF_FS_OBJECTS >= 2 );
00096 RtlZeroMemory( &UdfsFileSystemDeviceObjects,
sizeof(
PDEVICE_OBJECT) * NUMBER_OF_FS_OBJECTS );
00097
00098
RtlInitUnicodeString( &UnicodeString, L
"\\UdfsCdRom" );
00099
00100
Status =
IoCreateDevice( DriverObject,
00101 0,
00102 &UnicodeString,
00103 FILE_DEVICE_CD_ROM_FILE_SYSTEM,
00104 0,
00105 FALSE,
00106 &UdfsFileSystemDeviceObjects[0] );
00107
00108
if (!
NT_SUCCESS( Status )) {
00109
return Status;
00110 }
00111
00112
RtlInitUnicodeString( &UnicodeString, L
"\\UdfsDisk" );
00113
00114
Status =
IoCreateDevice( DriverObject,
00115 0,
00116 &UnicodeString,
00117 FILE_DEVICE_DISK_FILE_SYSTEM,
00118 0,
00119 FALSE,
00120 &UdfsFileSystemDeviceObjects[1] );
00121
00122
if (!
NT_SUCCESS( Status )) {
00123
00124
ObDereferenceObject( UdfsFileSystemDeviceObjects[0] );
00125
return Status;
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 DriverObject->MajorFunction[
IRP_MJ_CREATE] =
00143 DriverObject->MajorFunction[
IRP_MJ_CLOSE] =
00144 DriverObject->MajorFunction[
IRP_MJ_READ] =
00145 DriverObject->MajorFunction[
IRP_MJ_QUERY_INFORMATION] =
00146 DriverObject->MajorFunction[
IRP_MJ_SET_INFORMATION] =
00147 DriverObject->MajorFunction[
IRP_MJ_QUERY_VOLUME_INFORMATION]=
00148 DriverObject->MajorFunction[
IRP_MJ_DIRECTORY_CONTROL] =
00149 DriverObject->MajorFunction[
IRP_MJ_FILE_SYSTEM_CONTROL] =
00150 DriverObject->MajorFunction[
IRP_MJ_DEVICE_CONTROL] =
00151 DriverObject->MajorFunction[
IRP_MJ_LOCK_CONTROL] =
00152 DriverObject->MajorFunction[
IRP_MJ_CLEANUP] =
00153 DriverObject->MajorFunction[
IRP_MJ_PNP] = (
PDRIVER_DISPATCH)
UdfFsdDispatch;
00154
00155 DriverObject->FastIoDispatch = &
UdfFastIoDispatch;
00156
00157
00158
00159
00160
00161
UdfInitializeGlobalData( DriverObject, UdfsFileSystemDeviceObjects );
00162
00163
00164
00165
00166
00167
IoRegisterFileSystem( UdfsFileSystemDeviceObjects[0] );
00168
IoRegisterFileSystem( UdfsFileSystemDeviceObjects[1] );
00169
00170
00171
00172
00173
00174
return( STATUS_SUCCESS );
00175 }
00176
00177
00178
00179
00180
00181
00182
VOID
00183 UdfInitializeGlobalData (
00184 IN
PDRIVER_OBJECT DriverObject,
00185 IN
PDEVICE_OBJECT *UdfsFileSystemDeviceObjects
00186 )
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
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
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;
00225
UdfFastIoDispatch.
FastIoRead =
FsRtlCopyRead;
00226
00227
UdfFastIoDispatch.
FastIoQueryBasicInfo =
NULL;
00228
UdfFastIoDispatch.
FastIoQueryStandardInfo =
NULL;
00229
UdfFastIoDispatch.
FastIoLock =
NULL;
00230
UdfFastIoDispatch.
FastIoUnlockSingle =
NULL;
00231
UdfFastIoDispatch.
FastIoUnlockAll =
NULL;
00232
UdfFastIoDispatch.
FastIoUnlockAllByKey =
NULL;
00233
UdfFastIoDispatch.
FastIoQueryNetworkOpenInfo =
NULL;
00234
00235
00236
00237
00238
00239
UdfInitializeCrc16( 4129 );
00240
00241
00242
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
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
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
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
00317
00318
00319
00320 LcbMaxDepth =
00321 CcbMaxDepth =
00322 FcbDataMaxDepth =
00323 FcbNonPagedMaxDepth = (
USHORT) (
UdfData.
MaxDelayedCloseCount -
UdfData.
MinDelayedCloseCount);
00324
00325
00326
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 }