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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: fs_rec.c,v 1.1 2002/05/15 09:40:47 ekohl Exp $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/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
= FsRecCdfsFsControl(DeviceObject
, Irp
);
89 Status
= FsRecNtfsFsControl(DeviceObject
, Irp
);
93 Status
= STATUS_INVALID_DEVICE_REQUEST
;
96 Irp
->IoStatus
.Status
= Status
;
97 IoCompleteRequest(Irp
,
105 FsRecUnload(IN PDRIVER_OBJECT DriverObject
)
107 PDEVICE_OBJECT NextDevice
;
108 PDEVICE_OBJECT ThisDevice
;
110 /* Delete all remaining device objects */
111 NextDevice
= DriverObject
->DeviceObject
;
112 while (NextDevice
!= NULL
)
114 ThisDevice
= NextDevice
;
115 NextDevice
= NextDevice
->NextDevice
;
116 IoDeleteDevice(ThisDevice
);
122 FsRecRegisterFs(PDRIVER_OBJECT DriverObject
,
124 PWSTR RecognizerName
,
128 OBJECT_ATTRIBUTES ObjectAttributes
;
129 IO_STATUS_BLOCK IoStatus
;
130 PDEVICE_EXTENSION DeviceExt
;
131 UNICODE_STRING DeviceName
;
132 UNICODE_STRING FileName
;
133 PDEVICE_OBJECT DeviceObject
;
137 RtlInitUnicodeString(&FileName
,
140 InitializeObjectAttributes(&ObjectAttributes
,
142 OBJ_CASE_INSENSITIVE
,
146 Status
= ZwCreateFile(&FileHandle
,
152 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
157 if (NT_SUCCESS(Status
))
160 return(STATUS_IMAGE_ALREADY_LOADED
);
163 /* Create recognizer device object */
164 RtlInitUnicodeString(&DeviceName
,
167 Status
= IoCreateDevice(DriverObject
,
168 sizeof(DEVICE_EXTENSION
),
175 if (NT_SUCCESS(Status
))
177 DeviceExt
= DeviceObject
->DeviceExtension
;
178 DeviceExt
->FsType
= FsType
;
179 IoRegisterFileSystem(DeviceObject
);
180 DPRINT("Created recognizer device '%wZ'\n", &DeviceName
);
188 DriverEntry(PDRIVER_OBJECT DriverObject
,
189 PUNICODE_STRING RegistryPath
)
191 PCONFIGURATION_INFORMATION ConfigInfo
;
195 DPRINT("FileSystem recognizer 0.0.1\n");
199 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = FsRecCreate
;
200 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = FsRecClose
;
201 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = FsRecClose
;
202 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = FsRecFsControl
;
203 DriverObject
->DriverUnload
= FsRecUnload
;
205 ConfigInfo
= IoGetConfigurationInformation();
207 if (ConfigInfo
->CDRomCount
> 0)
209 Status
= FsRecRegisterFs(DriverObject
,
211 L
"\\FileSystem\\CdfsRecognizer",
212 FILE_DEVICE_CD_ROM_FILE_SYSTEM
,
214 if (NT_SUCCESS(Status
))
221 Status
= FsRecRegisterFs(DriverObject
,
223 L
"\\FileSystem\\FatRecognizer",
224 FILE_DEVICE_DISK_FILE_SYSTEM
,
226 if (NT_SUCCESS(Status
))
232 Status
= FsRecRegisterFs(DriverObject
,
234 L
"\\FileSystem\\NtfsRecognizer",
235 FILE_DEVICE_DISK_FILE_SYSTEM
,
237 if (NT_SUCCESS(Status
))
242 return((DeviceCount
> 0) ? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);