3 * Copyright (C) 2002 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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/filesystem/ntfs/ntfs.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMER: Eric Kohl
27 /* INCLUDES *****************************************************************/
34 /* GLOBALS *****************************************************************/
36 PNTFS_GLOBAL_DATA NtfsGlobalData
= NULL
;
39 /* FUNCTIONS ****************************************************************/
42 DriverEntry(PDRIVER_OBJECT DriverObject
,
43 PUNICODE_STRING RegistryPath
)
45 * FUNCTION: Called by the system to initialize the driver
47 * DriverObject = object describing this driver
48 * RegistryPath = path to our configuration entries
49 * RETURNS: Success or failure
53 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(DEVICE_NAME
);
55 TRACE_(NTFS
, "DriverEntry(%p, '%wZ')\n", DriverObject
, RegistryPath
);
57 /* Initialize global data */
58 NtfsGlobalData
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(NTFS_GLOBAL_DATA
), 'GRDN');
61 Status
= STATUS_INSUFFICIENT_RESOURCES
;
64 RtlZeroMemory(NtfsGlobalData
, sizeof(NTFS_GLOBAL_DATA
));
65 NtfsGlobalData
->Identifier
.Type
= NTFS_TYPE_GLOBAL_DATA
;
66 NtfsGlobalData
->Identifier
.Size
= sizeof(NTFS_GLOBAL_DATA
);
68 ExInitializeResourceLite(&NtfsGlobalData
->Resource
);
70 /* Keep trace of Driver Object */
71 NtfsGlobalData
->DriverObject
= DriverObject
;
73 /* Initialize IRP functions array */
74 NtfsInitializeFunctionPointers(DriverObject
);
76 /* Initialize CC functions array */
77 NtfsGlobalData
->CacheMgrCallbacks
.AcquireForLazyWrite
= NtfsAcqLazyWrite
;
78 NtfsGlobalData
->CacheMgrCallbacks
.ReleaseFromLazyWrite
= NtfsRelLazyWrite
;
79 NtfsGlobalData
->CacheMgrCallbacks
.AcquireForReadAhead
= NtfsAcqReadAhead
;
80 NtfsGlobalData
->CacheMgrCallbacks
.ReleaseFromReadAhead
= NtfsRelReadAhead
;
82 /* Driver can't be unloaded */
83 DriverObject
->DriverUnload
= NULL
;
85 Status
= IoCreateDevice(DriverObject
,
86 sizeof(NTFS_GLOBAL_DATA
),
88 FILE_DEVICE_DISK_FILE_SYSTEM
,
91 &NtfsGlobalData
->DeviceObject
);
92 if (!NT_SUCCESS(Status
))
94 WARN_(NTFS
, "IoCreateDevice failed with status: %lx\n", Status
);
98 NtfsGlobalData
->DeviceObject
->Flags
|= DO_DIRECT_IO
;
100 /* Register file system */
101 IoRegisterFileSystem(NtfsGlobalData
->DeviceObject
);
102 ObReferenceObject(NtfsGlobalData
->DeviceObject
);
105 if (!NT_SUCCESS(Status
))
109 ExDeleteResourceLite(&NtfsGlobalData
->Resource
);
110 ExFreePoolWithTag(NtfsGlobalData
, 'GRDN');
118 NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject
)
120 * FUNCTION: Called within the driver entry to initialize the IRP functions array
122 * DriverObject = object describing this driver
126 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = NtfsFsdCreate
;
127 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = NtfsFsdClose
;
128 DriverObject
->MajorFunction
[IRP_MJ_READ
] = NtfsFsdRead
;
129 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = NtfsFsdWrite
;
130 DriverObject
->MajorFunction
[IRP_MJ_QUERY_INFORMATION
] = NtfsFsdQueryInformation
;
131 DriverObject
->MajorFunction
[IRP_MJ_QUERY_VOLUME_INFORMATION
] = NtfsFsdDispatch
;
132 DriverObject
->MajorFunction
[IRP_MJ_SET_VOLUME_INFORMATION
] = NtfsFsdDispatch
;
133 DriverObject
->MajorFunction
[IRP_MJ_DIRECTORY_CONTROL
] = NtfsFsdDirectoryControl
;
134 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = NtfsFsdFileSystemControl
;