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.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: drivers/fs/fs_rec/fs_rec.c
24 * PURPOSE: Filesystem recognizer driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
38 /* FUNCTIONS ****************************************************************/
41 FsRecCreate(IN PDEVICE_OBJECT DeviceObject,
47 Status = STATUS_SUCCESS;
50 Irp->IoStatus.Status = Status;
51 IoCompleteRequest(Irp,
59 FsRecClose(IN PDEVICE_OBJECT DeviceObject,
62 Irp->IoStatus.Status = STATUS_SUCCESS;
63 IoCompleteRequest(Irp,
66 return(STATUS_SUCCESS);
71 FsRecFsControl(IN PDEVICE_OBJECT DeviceObject,
74 PDEVICE_EXTENSION DeviceExt;
77 DeviceExt = DeviceObject->DeviceExtension;
78 switch (DeviceExt->FsType)
81 Status = FsRecVfatFsControl(DeviceObject, Irp);
85 Status = FsRecNtfsFsControl(DeviceObject, Irp);
89 Status = FsRecCdfsFsControl(DeviceObject, Irp);
93 Status = FsRecUdfsFsControl(DeviceObject, Irp);
97 Status = STATUS_INVALID_DEVICE_REQUEST;
100 Irp->IoStatus.Status = Status;
101 IoCompleteRequest(Irp,
109 FsRecUnload(IN PDRIVER_OBJECT DriverObject)
111 PDEVICE_OBJECT NextDevice;
112 PDEVICE_OBJECT ThisDevice;
114 /* Delete all remaining device objects */
115 NextDevice = DriverObject->DeviceObject;
116 while (NextDevice != NULL)
118 ThisDevice = NextDevice;
119 NextDevice = NextDevice->NextDevice;
120 IoDeleteDevice(ThisDevice);
126 FsRecRegisterFs(PDRIVER_OBJECT DriverObject,
128 PWSTR RecognizerName,
132 OBJECT_ATTRIBUTES ObjectAttributes;
133 IO_STATUS_BLOCK IoStatus;
134 PDEVICE_EXTENSION DeviceExt;
135 UNICODE_STRING DeviceName;
136 UNICODE_STRING FileName;
137 PDEVICE_OBJECT DeviceObject;
141 RtlInitUnicodeString(&FileName,
144 InitializeObjectAttributes(&ObjectAttributes,
146 OBJ_CASE_INSENSITIVE,
150 Status = ZwCreateFile(&FileHandle,
156 FILE_SHARE_READ | FILE_SHARE_WRITE,
161 if (NT_SUCCESS(Status))
164 return(STATUS_IMAGE_ALREADY_LOADED);
167 /* Create recognizer device object */
168 RtlInitUnicodeString(&DeviceName,
171 Status = IoCreateDevice(DriverObject,
172 sizeof(DEVICE_EXTENSION),
179 if (NT_SUCCESS(Status))
181 DeviceExt = DeviceObject->DeviceExtension;
182 DeviceExt->FsType = FsType;
183 IoRegisterFileSystem(DeviceObject);
184 DPRINT("Created recognizer device '%wZ'\n", &DeviceName);
192 DriverEntry(PDRIVER_OBJECT DriverObject,
193 PUNICODE_STRING RegistryPath)
195 PCONFIGURATION_INFORMATION ConfigInfo;
199 DPRINT("FileSystem recognizer 0.0.2\n");
203 DriverObject->MajorFunction[IRP_MJ_CREATE] = FsRecCreate;
204 DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsRecClose;
205 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = FsRecClose;
206 DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FsRecFsControl;
207 DriverObject->DriverUnload = FsRecUnload;
209 ConfigInfo = IoGetConfigurationInformation();
211 if (ConfigInfo->CdRomCount > 0)
213 Status = FsRecRegisterFs(DriverObject,
215 L"\\FileSystem\\CdfsRecognizer",
216 FILE_DEVICE_CD_ROM_FILE_SYSTEM,
218 if (NT_SUCCESS(Status))
223 Status = FsRecRegisterFs(DriverObject,
225 L"\\FileSystem\\UdfsRecognizer",
226 FILE_DEVICE_CD_ROM_FILE_SYSTEM,
228 if (NT_SUCCESS(Status))
234 Status = FsRecRegisterFs(DriverObject,
236 L"\\FileSystem\\FatRecognizer",
237 FILE_DEVICE_DISK_FILE_SYSTEM,
239 if (NT_SUCCESS(Status))
244 Status = FsRecRegisterFs(DriverObject,
246 L"\\FileSystem\\NtfsRecognizer",
247 FILE_DEVICE_DISK_FILE_SYSTEM,
249 if (NT_SUCCESS(Status))
254 return((DeviceCount > 0) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);