3 * Copyright (C) 2002,2003 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/fs/fs_rec/fs_rec.c
23 * PURPOSE: Filesystem recognizer driver
24 * PROGRAMMER: Eric Kohl
27 /* INCLUDES *****************************************************************/
35 /* FUNCTIONS ****************************************************************/
37 static NTSTATUS STDCALL
38 FsRecCreate(IN PDEVICE_OBJECT DeviceObject
,
44 Status
= STATUS_SUCCESS
;
47 Irp
->IoStatus
.Status
= Status
;
48 IoCompleteRequest(Irp
,
55 static NTSTATUS STDCALL
56 FsRecClose(IN PDEVICE_OBJECT DeviceObject
,
59 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
60 IoCompleteRequest(Irp
,
63 return(STATUS_SUCCESS
);
67 static NTSTATUS STDCALL
68 FsRecFsControl(IN PDEVICE_OBJECT DeviceObject
,
71 PDEVICE_EXTENSION DeviceExt
;
74 DeviceExt
= DeviceObject
->DeviceExtension
;
75 switch (DeviceExt
->FsType
)
78 Status
= FsRecVfatFsControl(DeviceObject
, Irp
);
82 Status
= FsRecNtfsFsControl(DeviceObject
, Irp
);
86 Status
= FsRecCdfsFsControl(DeviceObject
, Irp
);
90 Status
= FsRecUdfsFsControl(DeviceObject
, Irp
);
94 Status
= STATUS_INVALID_DEVICE_REQUEST
;
97 Irp
->IoStatus
.Status
= Status
;
98 IoCompleteRequest(Irp
,
106 FsRecUnload(IN PDRIVER_OBJECT DriverObject
)
108 PDEVICE_OBJECT NextDevice
;
109 PDEVICE_OBJECT ThisDevice
;
111 /* Delete all remaining device objects */
112 NextDevice
= DriverObject
->DeviceObject
;
113 while (NextDevice
!= NULL
)
115 ThisDevice
= NextDevice
;
116 NextDevice
= NextDevice
->NextDevice
;
117 IoDeleteDevice(ThisDevice
);
123 FsRecRegisterFs(PDRIVER_OBJECT DriverObject
,
125 PWSTR RecognizerName
,
129 OBJECT_ATTRIBUTES ObjectAttributes
;
130 IO_STATUS_BLOCK IoStatus
;
131 PDEVICE_EXTENSION DeviceExt
;
132 UNICODE_STRING DeviceName
;
133 UNICODE_STRING FileName
;
134 PDEVICE_OBJECT DeviceObject
;
138 RtlInitUnicodeString(&FileName
,
141 InitializeObjectAttributes(&ObjectAttributes
,
143 OBJ_CASE_INSENSITIVE
,
147 Status
= ZwCreateFile(&FileHandle
,
153 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
158 if (NT_SUCCESS(Status
))
161 return(STATUS_IMAGE_ALREADY_LOADED
);
164 /* Create recognizer device object */
165 RtlInitUnicodeString(&DeviceName
,
168 Status
= IoCreateDevice(DriverObject
,
169 sizeof(DEVICE_EXTENSION
),
176 if (NT_SUCCESS(Status
))
178 DeviceExt
= DeviceObject
->DeviceExtension
;
179 DeviceExt
->FsType
= FsType
;
180 IoRegisterFileSystem(DeviceObject
);
181 DPRINT("Created recognizer device '%wZ'\n", &DeviceName
);
189 DriverEntry(PDRIVER_OBJECT DriverObject
,
190 PUNICODE_STRING RegistryPath
)
192 PCONFIGURATION_INFORMATION ConfigInfo
;
196 DPRINT("FileSystem recognizer 0.0.2\n");
200 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = FsRecCreate
;
201 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = FsRecClose
;
202 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = FsRecClose
;
203 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = FsRecFsControl
;
204 DriverObject
->DriverUnload
= FsRecUnload
;
206 ConfigInfo
= IoGetConfigurationInformation();
208 if (ConfigInfo
->CdRomCount
> 0)
210 Status
= FsRecRegisterFs(DriverObject
,
212 L
"\\FileSystem\\CdfsRecognizer",
213 FILE_DEVICE_CD_ROM_FILE_SYSTEM
,
215 if (NT_SUCCESS(Status
))
220 Status
= FsRecRegisterFs(DriverObject
,
222 L
"\\FileSystem\\UdfsRecognizer",
223 FILE_DEVICE_CD_ROM_FILE_SYSTEM
,
225 if (NT_SUCCESS(Status
))
231 Status
= FsRecRegisterFs(DriverObject
,
233 L
"\\FileSystem\\FatRecognizer",
234 FILE_DEVICE_DISK_FILE_SYSTEM
,
236 if (NT_SUCCESS(Status
))
241 Status
= FsRecRegisterFs(DriverObject
,
243 L
"\\FileSystem\\NtfsRecognizer",
244 FILE_DEVICE_DISK_FILE_SYSTEM
,
246 if (NT_SUCCESS(Status
))
251 return((DeviceCount
> 0) ? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);