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