update for HEAD-2003091401
[reactos.git] / drivers / fs / ntfs / ntfs.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2002 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  * COPYRIGHT:        See COPYING in the top level directory
22  * PROJECT:          ReactOS kernel
23  * FILE:             services/fs/ntfs/ntfs.c
24  * PURPOSE:          NTFS filesystem driver
25  * PROGRAMMER:       Eric Kohl
26  */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <ddk/ntddk.h>
31
32 //#define NDEBUG
33 #include <debug.h>
34
35 #include "ntfs.h"
36
37
38 /* GLOBALS *****************************************************************/
39
40 PNTFS_GLOBAL_DATA NtfsGlobalData;
41
42
43 /* FUNCTIONS ****************************************************************/
44
45 NTSTATUS STDCALL
46 DriverEntry(PDRIVER_OBJECT DriverObject,
47             PUNICODE_STRING RegistryPath)
48 /*
49  * FUNCTION: Called by the system to initalize the driver
50  * ARGUMENTS:
51  *           DriverObject = object describing this driver
52  *           RegistryPath = path to our configuration entries
53  * RETURNS: Success or failure
54  */
55 {
56   PDEVICE_OBJECT DeviceObject;
57   NTSTATUS Status;
58   UNICODE_STRING DeviceName = UNICODE_STRING_INITIALIZER(L"\\Ntfs");
59
60   DPRINT("NTFS 0.0.1\n");
61
62   Status = IoCreateDevice(DriverObject,
63                           sizeof(NTFS_GLOBAL_DATA),
64                           &DeviceName,
65                           FILE_DEVICE_DISK_FILE_SYSTEM,
66                           0,
67                           FALSE,
68                           &DeviceObject);
69   if (!NT_SUCCESS(Status))
70     {
71       return(Status);
72     }
73
74   /* Initialize global data */
75   NtfsGlobalData = DeviceObject->DeviceExtension;
76   RtlZeroMemory(NtfsGlobalData,
77                 sizeof(NTFS_GLOBAL_DATA));
78   NtfsGlobalData->DriverObject = DriverObject;
79   NtfsGlobalData->DeviceObject = DeviceObject;
80
81   /* Initialize driver data */
82   DeviceObject->Flags = DO_DIRECT_IO;
83   DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH) NtfsClose;
84   DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH) NtfsCreate;
85   DriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH) NtfsRead;
86   DriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH) NtfsWrite;
87   DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
88     (PDRIVER_DISPATCH) NtfsFileSystemControl;
89   DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
90     (PDRIVER_DISPATCH) NtfsDirectoryControl;
91   DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
92     (PDRIVER_DISPATCH) NtfsQueryInformation;
93   DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
94     (PDRIVER_DISPATCH) NtfsQueryVolumeInformation;
95   DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
96     (PDRIVER_DISPATCH) NtfsSetVolumeInformation;
97
98   DriverObject->DriverUnload = NULL;
99
100   IoRegisterFileSystem(DeviceObject);
101
102   return(STATUS_SUCCESS);
103 }
104