- Merge the remaining portion of the wlan-bringup branch
[reactos.git] / reactos / drivers / filesystems / fastfat / iface.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
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.
9 *
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.
14 *
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.
18 */
19 /*
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/fs/vfat/iface.c
22 * PURPOSE: VFAT Filesystem
23 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
24 */
25
26 /* INCLUDES *****************************************************************/
27
28 #define NDEBUG
29 #include "vfat.h"
30
31 /* GLOBALS *****************************************************************/
32
33 PVFAT_GLOBAL_DATA VfatGlobalData;
34
35 /* FUNCTIONS ****************************************************************/
36
37 NTSTATUS NTAPI
38 DriverEntry(PDRIVER_OBJECT DriverObject,
39 PUNICODE_STRING RegistryPath)
40 /*
41 * FUNCTION: Called by the system to initialize the driver
42 * ARGUMENTS:
43 * DriverObject = object describing this driver
44 * RegistryPath = path to our configuration entries
45 * RETURNS: Success or failure
46 */
47 {
48 PDEVICE_OBJECT DeviceObject;
49 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Fat");
50 NTSTATUS Status;
51
52 Status = IoCreateDevice(DriverObject,
53 sizeof(VFAT_GLOBAL_DATA),
54 &DeviceName,
55 FILE_DEVICE_DISK_FILE_SYSTEM,
56 0,
57 FALSE,
58 &DeviceObject);
59
60 if (Status == STATUS_OBJECT_NAME_EXISTS ||
61 Status == STATUS_OBJECT_NAME_COLLISION)
62 {
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),
67 &DeviceName,
68 FILE_DEVICE_DISK_FILE_SYSTEM,
69 0,
70 FALSE,
71 &DeviceObject);
72 }
73
74
75
76 if (!NT_SUCCESS(Status))
77 {
78 return (Status);
79 }
80
81 VfatGlobalData = DeviceObject->DeviceExtension;
82 RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
83 VfatGlobalData->DriverObject = DriverObject;
84 VfatGlobalData->DeviceObject = DeviceObject;
85
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] =
96 VfatBuildRequest;
97 DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
98 VfatBuildRequest;
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;
104
105 DriverObject->DriverUnload = NULL;
106
107 /* Cache manager */
108 VfatGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = VfatAcquireForLazyWrite;
109 VfatGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = VfatReleaseFromLazyWrite;
110 VfatGlobalData->CacheMgrCallbacks.AcquireForReadAhead = VfatAcquireForReadAhead;
111 VfatGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = VfatReleaseFromReadAhead;
112
113 /* Fast I/O */
114 VfatInitFastIoRoutines(&VfatGlobalData->FastIoDispatch);
115 DriverObject->FastIoDispatch = &VfatGlobalData->FastIoDispatch;
116
117 /* Private lists */
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);
124
125 ExInitializeResourceLite(&VfatGlobalData->VolumeListLock);
126 InitializeListHead(&VfatGlobalData->VolumeListHead);
127 IoRegisterFileSystem(DeviceObject);
128 return(STATUS_SUCCESS);
129 }
130
131 /* EOF */
132