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 *****************************************************************/
31 /* GLOBALS *****************************************************************/
33 PVFAT_GLOBAL_DATA VfatGlobalData
;
35 /* FUNCTIONS ****************************************************************/
38 DriverEntry(PDRIVER_OBJECT DriverObject
,
39 PUNICODE_STRING RegistryPath
)
41 * FUNCTION: Called by the system to initialize the driver
43 * DriverObject = object describing this driver
44 * RegistryPath = path to our configuration entries
45 * RETURNS: Success or failure
48 PDEVICE_OBJECT DeviceObject
;
49 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\Fat");
52 Status
= IoCreateDevice(DriverObject
,
53 sizeof(VFAT_GLOBAL_DATA
),
55 FILE_DEVICE_DISK_FILE_SYSTEM
,
60 if (Status
== STATUS_OBJECT_NAME_EXISTS
||
61 Status
== STATUS_OBJECT_NAME_COLLISION
)
63 /* Try an other name, if 'Fat' is already in use. 'Fat' is also used by fastfat.sys on W2K */
64 RtlInitUnicodeString(&DeviceName
, L
"\\RosFat");
65 Status
= IoCreateDevice(DriverObject
,
66 sizeof(VFAT_GLOBAL_DATA
),
68 FILE_DEVICE_DISK_FILE_SYSTEM
,
76 if (!NT_SUCCESS(Status
))
81 VfatGlobalData
= DeviceObject
->DeviceExtension
;
82 RtlZeroMemory (VfatGlobalData
, sizeof(VFAT_GLOBAL_DATA
));
83 VfatGlobalData
->DriverObject
= DriverObject
;
84 VfatGlobalData
->DeviceObject
= DeviceObject
;
86 DeviceObject
->Flags
|= DO_DIRECT_IO
;
87 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = VfatBuildRequest
;
88 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = VfatBuildRequest
;
89 DriverObject
->MajorFunction
[IRP_MJ_READ
] = VfatBuildRequest
;
90 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = VfatBuildRequest
;
91 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = VfatBuildRequest
;
92 DriverObject
->MajorFunction
[IRP_MJ_QUERY_INFORMATION
] = VfatBuildRequest
;
93 DriverObject
->MajorFunction
[IRP_MJ_SET_INFORMATION
] = VfatBuildRequest
;
94 DriverObject
->MajorFunction
[IRP_MJ_DIRECTORY_CONTROL
] = VfatBuildRequest
;
95 DriverObject
->MajorFunction
[IRP_MJ_QUERY_VOLUME_INFORMATION
] =
97 DriverObject
->MajorFunction
[IRP_MJ_SET_VOLUME_INFORMATION
] =
99 DriverObject
->MajorFunction
[IRP_MJ_SHUTDOWN
] = VfatShutdown
;
100 DriverObject
->MajorFunction
[IRP_MJ_LOCK_CONTROL
] = VfatBuildRequest
;
101 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = VfatBuildRequest
;
102 DriverObject
->MajorFunction
[IRP_MJ_FLUSH_BUFFERS
] = VfatBuildRequest
;
103 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = VfatBuildRequest
;
105 DriverObject
->DriverUnload
= NULL
;
108 VfatGlobalData
->CacheMgrCallbacks
.AcquireForLazyWrite
= VfatAcquireForLazyWrite
;
109 VfatGlobalData
->CacheMgrCallbacks
.ReleaseFromLazyWrite
= VfatReleaseFromLazyWrite
;
110 VfatGlobalData
->CacheMgrCallbacks
.AcquireForReadAhead
= VfatAcquireForReadAhead
;
111 VfatGlobalData
->CacheMgrCallbacks
.ReleaseFromReadAhead
= VfatReleaseFromReadAhead
;
114 VfatInitFastIoRoutines(&VfatGlobalData
->FastIoDispatch
);
115 DriverObject
->FastIoDispatch
= &VfatGlobalData
->FastIoDispatch
;
118 ExInitializeNPagedLookasideList(&VfatGlobalData
->FcbLookasideList
,
119 NULL
, NULL
, 0, sizeof(VFATFCB
), TAG_FCB
, 0);
120 ExInitializeNPagedLookasideList(&VfatGlobalData
->CcbLookasideList
,
121 NULL
, NULL
, 0, sizeof(VFATCCB
), TAG_CCB
, 0);
122 ExInitializeNPagedLookasideList(&VfatGlobalData
->IrpContextLookasideList
,
123 NULL
, NULL
, 0, sizeof(VFAT_IRP_CONTEXT
), TAG_IRP
, 0);
125 ExInitializeResourceLite(&VfatGlobalData
->VolumeListLock
);
126 InitializeListHead(&VfatGlobalData
->VolumeListHead
);
127 IoRegisterFileSystem(DeviceObject
);
128 return(STATUS_SUCCESS
);