a1aefd653f20bda237c37eeac8cff36a90010fce
[reactos.git] / reactos / drivers / fs / vfat / 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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: iface.c,v 1.72 2003/10/11 17:51:56 hbirr Exp $
20 *
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/fs/vfat/iface.c
23 * PURPOSE: VFAT Filesystem
24 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
25 * Hartmut Birr
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <ddk/ntddk.h>
31
32 #define NDEBUG
33 #include <debug.h>
34
35 #include "vfat.h"
36
37 /* GLOBALS *****************************************************************/
38
39 PVFAT_GLOBAL_DATA VfatGlobalData;
40
41 /* FUNCTIONS ****************************************************************/
42
43 NTSTATUS STDCALL
44 DriverEntry(PDRIVER_OBJECT DriverObject,
45 PUNICODE_STRING RegistryPath)
46 /*
47 * FUNCTION: Called by the system to initalize the driver
48 * ARGUMENTS:
49 * DriverObject = object describing this driver
50 * RegistryPath = path to our configuration entries
51 * RETURNS: Success or failure
52 */
53 {
54 PDEVICE_OBJECT DeviceObject;
55 UNICODE_STRING DeviceName = UNICODE_STRING_INITIALIZER(L"\\Fat");
56 NTSTATUS Status;
57
58 Status = IoCreateDevice(DriverObject,
59 sizeof(VFAT_GLOBAL_DATA),
60 &DeviceName,
61 FILE_DEVICE_DISK_FILE_SYSTEM,
62 0,
63 FALSE,
64 &DeviceObject);
65 if (!NT_SUCCESS(Status))
66 {
67 return (Status);
68 }
69 VfatGlobalData = DeviceObject->DeviceExtension;
70 RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
71 VfatGlobalData->DriverObject = DriverObject;
72 VfatGlobalData->DeviceObject = DeviceObject;
73
74 DeviceObject->Flags = DO_DIRECT_IO;
75 DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH)VfatBuildRequest;
76 DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)VfatBuildRequest;
77 DriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH)VfatBuildRequest;
78 DriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH)VfatBuildRequest;
79 DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = (PDRIVER_DISPATCH)VfatBuildRequest;
80 DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = (PDRIVER_DISPATCH)VfatBuildRequest;
81 DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = (PDRIVER_DISPATCH)VfatBuildRequest;
82 DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = (PDRIVER_DISPATCH)VfatBuildRequest;
83 DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
84 (PDRIVER_DISPATCH)VfatBuildRequest;
85 DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
86 (PDRIVER_DISPATCH)VfatBuildRequest;
87 DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = (PDRIVER_DISPATCH)VfatShutdown;
88 DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = (PDRIVER_DISPATCH)VfatBuildRequest;
89 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = (PDRIVER_DISPATCH)VfatBuildRequest;
90 DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = (PDRIVER_DISPATCH)VfatBuildRequest;
91
92 DriverObject->DriverUnload = NULL;
93
94 ExInitializeNPagedLookasideList(&VfatGlobalData->FcbLookasideList,
95 NULL, NULL, 0, sizeof(VFATFCB), TAG_FCB, 0);
96 ExInitializeNPagedLookasideList(&VfatGlobalData->CcbLookasideList,
97 NULL, NULL, 0, sizeof(VFATCCB), TAG_CCB, 0);
98 ExInitializeNPagedLookasideList(&VfatGlobalData->IrpContextLookasideList,
99 NULL, NULL, 0, sizeof(VFAT_IRP_CONTEXT), TAG_IRP, 0);
100
101 ExInitializeResourceLite(&VfatGlobalData->VolumeListLock);
102 InitializeListHead(&VfatGlobalData->VolumeListHead);
103 IoRegisterFileSystem(DeviceObject);
104 return(STATUS_SUCCESS);
105 }
106
107 /* EOF */
108