3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/fs/vfat/iface.c
22 * PURPOSE: VFAT Filesystem
23 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
26 /* INCLUDES *****************************************************************/
33 /* GLOBALS *****************************************************************/
35 PVFAT_GLOBAL_DATA VfatGlobalData
;
37 /* FUNCTIONS ****************************************************************/
40 * FUNCTION: Called by the system to initialize the driver
42 * DriverObject = object describing this driver
43 * RegistryPath = path to our configuration entries
44 * RETURNS: Success or failure
49 IN PDRIVER_OBJECT DriverObject
,
50 IN PUNICODE_STRING RegistryPath
)
52 PDEVICE_OBJECT DeviceObject
;
53 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\Fat");
56 UNREFERENCED_PARAMETER(RegistryPath
);
58 Status
= IoCreateDevice(DriverObject
,
59 sizeof(VFAT_GLOBAL_DATA
),
61 FILE_DEVICE_DISK_FILE_SYSTEM
,
65 if (Status
== STATUS_OBJECT_NAME_EXISTS
||
66 Status
== STATUS_OBJECT_NAME_COLLISION
)
68 /* Try an other name, if 'Fat' is already in use. 'Fat' is also used by fastfat.sys on W2K */
69 RtlInitUnicodeString(&DeviceName
, L
"\\RosFat");
70 Status
= IoCreateDevice(DriverObject
,
71 sizeof(VFAT_GLOBAL_DATA
),
73 FILE_DEVICE_DISK_FILE_SYSTEM
,
79 if (!NT_SUCCESS(Status
))
84 VfatGlobalData
= DeviceObject
->DeviceExtension
;
85 RtlZeroMemory (VfatGlobalData
, sizeof(VFAT_GLOBAL_DATA
));
86 VfatGlobalData
->DriverObject
= DriverObject
;
87 VfatGlobalData
->DeviceObject
= DeviceObject
;
89 DeviceObject
->Flags
|= DO_DIRECT_IO
;
90 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = VfatBuildRequest
;
91 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = VfatBuildRequest
;
92 DriverObject
->MajorFunction
[IRP_MJ_READ
] = VfatBuildRequest
;
93 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = VfatBuildRequest
;
94 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = VfatBuildRequest
;
95 DriverObject
->MajorFunction
[IRP_MJ_QUERY_INFORMATION
] = VfatBuildRequest
;
96 DriverObject
->MajorFunction
[IRP_MJ_SET_INFORMATION
] = VfatBuildRequest
;
97 DriverObject
->MajorFunction
[IRP_MJ_DIRECTORY_CONTROL
] = VfatBuildRequest
;
98 DriverObject
->MajorFunction
[IRP_MJ_QUERY_VOLUME_INFORMATION
] = VfatBuildRequest
;
99 DriverObject
->MajorFunction
[IRP_MJ_SET_VOLUME_INFORMATION
] = VfatBuildRequest
;
100 DriverObject
->MajorFunction
[IRP_MJ_SHUTDOWN
] = VfatShutdown
;
101 DriverObject
->MajorFunction
[IRP_MJ_LOCK_CONTROL
] = VfatBuildRequest
;
102 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = VfatBuildRequest
;
103 DriverObject
->MajorFunction
[IRP_MJ_FLUSH_BUFFERS
] = VfatBuildRequest
;
104 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = VfatBuildRequest
;
106 DriverObject
->DriverUnload
= NULL
;
109 VfatGlobalData
->CacheMgrCallbacks
.AcquireForLazyWrite
= VfatAcquireForLazyWrite
;
110 VfatGlobalData
->CacheMgrCallbacks
.ReleaseFromLazyWrite
= VfatReleaseFromLazyWrite
;
111 VfatGlobalData
->CacheMgrCallbacks
.AcquireForReadAhead
= VfatAcquireForReadAhead
;
112 VfatGlobalData
->CacheMgrCallbacks
.ReleaseFromReadAhead
= VfatReleaseFromReadAhead
;
115 VfatInitFastIoRoutines(&VfatGlobalData
->FastIoDispatch
);
116 DriverObject
->FastIoDispatch
= &VfatGlobalData
->FastIoDispatch
;
119 ExInitializeNPagedLookasideList(&VfatGlobalData
->FcbLookasideList
,
120 NULL
, NULL
, 0, sizeof(VFATFCB
), TAG_FCB
, 0);
121 ExInitializeNPagedLookasideList(&VfatGlobalData
->CcbLookasideList
,
122 NULL
, NULL
, 0, sizeof(VFATCCB
), TAG_CCB
, 0);
123 ExInitializeNPagedLookasideList(&VfatGlobalData
->IrpContextLookasideList
,
124 NULL
, NULL
, 0, sizeof(VFAT_IRP_CONTEXT
), TAG_IRP
, 0);
126 ExInitializeResourceLite(&VfatGlobalData
->VolumeListLock
);
127 InitializeListHead(&VfatGlobalData
->VolumeListHead
);
128 IoRegisterFileSystem(DeviceObject
);
129 return STATUS_SUCCESS
;