ReactOS 0.4.15-dev-7834-g00c4b3d
ntfs.c
Go to the documentation of this file.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
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
24 * Pierre Schweitzer
25 */
26
27/* INCLUDES *****************************************************************/
28
29#include "ntfs.h"
30
31#define NDEBUG
32#include <debug.h>
33
34/* GLOBALS *****************************************************************/
35
37
38/* FUNCTIONS ****************************************************************/
39
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 */
47CODE_SEG("INIT")
52{
57 HANDLE DriverKey = NULL;
58
59 TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject, RegistryPath);
60
62 sizeof(NTFS_GLOBAL_DATA),
65 0,
66 FALSE,
68 if (!NT_SUCCESS(Status))
69 {
70 WARN_(NTFS, "IoCreateDevice failed with status: %lx\n", Status);
71 return Status;
72 }
73
74 /* Initialize global data */
75 NtfsGlobalData = DeviceObject->DeviceExtension;
77
81
83
85
86 // Read registry to determine if write support should be enabled
90 NULL,
91 NULL);
92
93 Status = ZwOpenKey(&DriverKey, KEY_READ, &Attributes);
94 if (NT_SUCCESS(Status))
95 {
99 ULONG ValueLength = sizeof(Buffer);
101
102 RtlInitUnicodeString(&ValueName, L"MyDataDoesNotMatterSoEnableExperimentalWriteSupportForEveryNTFSVolume");
103
104 Status = ZwQueryValueKey(DriverKey,
105 &ValueName,
107 Value,
109 &ResultLength);
110
111 if (NT_SUCCESS(Status) && Value->Data[0] == TRUE)
112 {
113 DPRINT1("\tEnabling write support on ALL NTFS volumes!\n");
115 }
116
117 ZwClose(DriverKey);
118 }
119
120 /* Keep trace of Driver Object */
122
123 /* Initialize IRP functions array */
125
126 /* Initialize CC functions array */
131
136 DriverObject->FastIoDispatch = &NtfsGlobalData->FastIoDispatch;
137
138 /* Initialize lookaside list for IRP contexts */
140 NULL, NULL, 0, sizeof(NTFS_IRP_CONTEXT), TAG_IRP_CTXT, 0);
141 /* Initialize lookaside list for FCBs */
143 NULL, NULL, 0, sizeof(NTFS_FCB), TAG_FCB, 0);
144 /* Initialize lookaside list for attributes contexts */
146 NULL, NULL, 0, sizeof(NTFS_ATTR_CONTEXT), TAG_ATT_CTXT, 0);
147
148 /* Driver can't be unloaded */
149 DriverObject->DriverUnload = NULL;
150
152
153 /* Register file system */
156
157 return STATUS_SUCCESS;
158}
159
160
161/*
162 * FUNCTION: Called within the driver entry to initialize the IRP functions array
163 * ARGUMENTS:
164 * DriverObject = object describing this driver
165 * RETURNS: Nothing
166 */
167CODE_SEG("INIT")
168VOID
169NTAPI
171{
173 DriverObject->MajorFunction[IRP_MJ_CLOSE] = NtfsFsdDispatch;
175 DriverObject->MajorFunction[IRP_MJ_READ] = NtfsFsdDispatch;
176 DriverObject->MajorFunction[IRP_MJ_WRITE] = NtfsFsdDispatch;
184
185 return;
186}
187
188/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define TRACE_(x)
Definition: compat.h:76
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define TAG_FCB
Definition: nodetype.h:152
BOOLEAN NTAPI NtfsAcqReadAhead(PVOID Context, BOOLEAN Wait)
Definition: fastio.c:60
BOOLEAN NTAPI NtfsAcqLazyWrite(PVOID Context, BOOLEAN Wait)
Definition: fastio.c:39
VOID NTAPI NtfsRelLazyWrite(PVOID Context)
Definition: fastio.c:51
VOID NTAPI NtfsRelReadAhead(PVOID Context)
Definition: fastio.c:72
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:36
VOID NTAPI NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject)
Definition: ntfs.c:170
FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible
Definition: ntfs.h:914
#define TAG_IRP_CTXT
Definition: ntfs.h:15
DRIVER_DISPATCH NtfsFsdDispatch
Definition: ntfs.h:892
FAST_IO_READ NtfsFastIoRead
Definition: ntfs.h:915
#define NTFS_TYPE_GLOBAL_DATA
Definition: ntfs.h:91
#define TAG_ATT_CTXT
Definition: ntfs.h:16
FAST_IO_WRITE NtfsFastIoWrite
Definition: ntfs.h:916
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define DEVICE_NAME
Definition: ext2fs.h:137
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:218
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:987
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:114
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define WARN_(ch,...)
Definition: debug.h:157
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG Type
Definition: ntfs.h:95
ULONG Size
Definition: ntfs.h:96
NPAGED_LOOKASIDE_LIST FcbLookasideList
Definition: ntfs.h:153
FAST_IO_DISPATCH FastIoDispatch
Definition: ntfs.h:151
BOOLEAN EnableWriteSupport
Definition: ntfs.h:155
NPAGED_LOOKASIDE_LIST AttrCtxtLookasideList
Definition: ntfs.h:154
ERESOURCE Resource
Definition: ntfs.h:146
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:148
NPAGED_LOOKASIDE_LIST IrpContextLookasideList
Definition: ntfs.h:152
NTFSIDENTIFIER Identifier
Definition: ntfs.h:145
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
Definition: ntfs.h:149
PDRIVER_OBJECT DriverObject
Definition: ntfs.h:147
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
Definition: cctypes.h:39
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
Definition: cctypes.h:40
PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead
Definition: cctypes.h:41
PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead
Definition: cctypes.h:42
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1736
ULONG SizeOfFastIoDispatch
Definition: iotypes.h:1733
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1735
PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible
Definition: iotypes.h:1734
Definition: cdstruc.h:902
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SET_VOLUME_INFORMATION
struct _FAST_IO_DISPATCH FAST_IO_DISPATCH
#define IRP_MJ_CLEANUP
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned char UCHAR
Definition: xmlstorage.h:181