diff --git a/reactos/Makefile b/reactos/Makefile index ff89c7e4cf9..ccaae4074d2 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -46,8 +46,8 @@ DEVICE_DRIVERS = vidport vga blue ide null floppy #INPUT_DRIVERS = keyboard INPUT_DRIVERS = keyboard mouclass psaux -#FS_DRIVERS = vfat minix ext2 template -FS_DRIVERS = vfat ms np cdfs +#FS_DRIVERS = minix ext2 template +FS_DRIVERS = vfat ms np cdfs fs_rec #NET_DRIVERS = ndis tdi tcpip tditest wshtcpip afd NET_DRIVERS = ndis tdi tcpip tditest wshtcpip afd diff --git a/reactos/bootc.lst b/reactos/bootc.lst index 500af15dffa..0e9fefeedfb 100644 --- a/reactos/bootc.lst +++ b/reactos/bootc.lst @@ -4,6 +4,6 @@ system32\drivers\class2.sys system32\drivers\disk.sys system32\drivers\cdrom.sys system32\drivers\vfatfs.sys -system32\drivers\cdfs.sys +system32\drivers\fs_rec.sys system32\config\system.hiv * diff --git a/reactos/drivers/fs/cdfs/cdfs.c b/reactos/drivers/fs/cdfs/cdfs.c index bcbd262cd78..e9b12c62b8c 100644 --- a/reactos/drivers/fs/cdfs/cdfs.c +++ b/reactos/drivers/fs/cdfs/cdfs.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cdfs.c,v 1.3 2002/05/14 23:16:23 ekohl Exp $ +/* $Id: cdfs.c,v 1.4 2002/05/15 09:39:54 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -61,7 +61,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, DbgPrint("CDFS 0.0.2\n"); RtlInitUnicodeString(&DeviceName, - L"\\Device\\cdfs"); + L"\\Cdfs"); Status = IoCreateDevice(DriverObject, sizeof(CDFS_GLOBAL_DATA), &DeviceName, diff --git a/reactos/drivers/fs/cdfs/close.c b/reactos/drivers/fs/cdfs/close.c index 993513ef3f4..de6ff97c015 100644 --- a/reactos/drivers/fs/cdfs/close.c +++ b/reactos/drivers/fs/cdfs/close.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: close.c,v 1.2 2002/05/01 13:15:42 ekohl Exp $ +/* $Id: close.c,v 1.3 2002/05/15 09:39:54 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -87,12 +87,20 @@ CdfsClose(PDEVICE_OBJECT DeviceObject, DPRINT("CdfsClose() called\n"); + if (DeviceObject == CdfsGlobalData->DeviceObject) + { + DPRINT("Closing file system\n"); + Status = STATUS_SUCCESS; + goto ByeBye; + } + Stack = IoGetCurrentIrpStackLocation(Irp); FileObject = Stack->FileObject; DeviceExtension = DeviceObject->DeviceExtension; Status = CdfsCloseFile(DeviceExtension,FileObject); +ByeBye: Irp->IoStatus.Status = Status; Irp->IoStatus.Information = 0; diff --git a/reactos/drivers/fs/cdfs/create.c b/reactos/drivers/fs/cdfs/create.c index 85caacbf354..7bd9476831e 100644 --- a/reactos/drivers/fs/cdfs/create.c +++ b/reactos/drivers/fs/cdfs/create.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: create.c,v 1.3 2002/05/09 15:53:02 ekohl Exp $ +/* $Id: create.c,v 1.4 2002/05/15 09:39:54 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -218,10 +218,10 @@ CdfsCreate(PDEVICE_OBJECT DeviceObject, PDEVICE_EXTENSION DeviceExt; NTSTATUS Status; - if (DeviceObject->Size == sizeof(DEVICE_OBJECT)) + if (DeviceObject == CdfsGlobalData->DeviceObject) { /* DeviceObject represents FileSystem instead of logical volume */ - DPRINT("FsdCreate called with file system\n"); + DPRINT("Opening file system\n"); Irp->IoStatus.Information = FILE_OPENED; Status = STATUS_SUCCESS; goto ByeBye; @@ -235,7 +235,6 @@ CdfsCreate(PDEVICE_OBJECT DeviceObject, Irp); ExReleaseResourceLite(&DeviceExt->DirResource); - ByeBye: Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, diff --git a/reactos/drivers/fs/fs_rec/.cvsignore b/reactos/drivers/fs/fs_rec/.cvsignore new file mode 100644 index 00000000000..43fea5d4fbf --- /dev/null +++ b/reactos/drivers/fs/fs_rec/.cvsignore @@ -0,0 +1,6 @@ +base.tmp +junk.tmp +temp.exp +fs_rec.coff +fs_rec.sys.unstripped +*.d \ No newline at end of file diff --git a/reactos/drivers/fs/fs_rec/blockdev.c b/reactos/drivers/fs/fs_rec/blockdev.c new file mode 100644 index 00000000000..c8008bb907a --- /dev/null +++ b/reactos/drivers/fs/fs_rec/blockdev.c @@ -0,0 +1,108 @@ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: blockdev.c,v 1.1 2002/05/15 09:40:47 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/fs/fs_rec/blockdev.c + * PURPOSE: Filesystem recognizer driver + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +#include "fs_rec.h" + + +/* FUNCTIONS ****************************************************************/ + +NTSTATUS +FsRecReadSectors(IN PDEVICE_OBJECT DeviceObject, + IN ULONG DiskSector, + IN ULONG SectorCount, + IN ULONG SectorSize, + IN OUT PUCHAR Buffer) +{ + PIO_STACK_LOCATION Stack; + IO_STATUS_BLOCK IoStatus; + LARGE_INTEGER Offset; + ULONG BlockSize; + KEVENT Event; + PIRP Irp; + NTSTATUS Status; + + KeInitializeEvent(&Event, + NotificationEvent, + FALSE); + + Offset.QuadPart = (LONGLONG)DiskSector * (LONGLONG)SectorSize; + BlockSize = SectorCount * SectorSize; + + DPRINT("FsrecReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n", + DeviceObject, DiskSector, Buffer); + DPRINT("Offset %I64x BlockSize %ld\n", + Offset.QuadPart, + BlockSize); + + DPRINT("Building synchronous FSD Request...\n"); + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, + DeviceObject, + Buffer, + BlockSize, + &Offset, + &Event, + &IoStatus); + if (Irp == NULL) + { + DPRINT("IoBuildSynchronousFsdRequest failed\n"); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + DPRINT("Calling IO Driver... with irp %x\n", Irp); + Status = IoCallDriver(DeviceObject, Irp); + + DPRINT("Waiting for IO Operation for %x\n", Irp); + if (Status == STATUS_PENDING) + { + DPRINT("Operation pending\n"); + KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); + DPRINT("Getting IO Status... for %x\n", Irp); + Status = IoStatus.Status; + } + + if (!NT_SUCCESS(Status)) + { + DPRINT("FsrecReadSectors() failed (Status %x)\n", Status); + DPRINT("(DeviceObject %x, DiskSector %x, Buffer %x, Offset 0x%I64x)\n", + DeviceObject, DiskSector, Buffer, + Offset.QuadPart); + return(Status); + } + + DPRINT("Block request succeeded for %x\n", Irp); + + return(STATUS_SUCCESS); +} + +/* EOF */ diff --git a/reactos/drivers/fs/fs_rec/cdfs.c b/reactos/drivers/fs/fs_rec/cdfs.c new file mode 100644 index 00000000000..485b18a8613 --- /dev/null +++ b/reactos/drivers/fs/fs_rec/cdfs.c @@ -0,0 +1,128 @@ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: cdfs.c,v 1.1 2002/05/15 09:40:47 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/fs/fs_rec/cdfs.c + * PURPOSE: Filesystem recognizer driver + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +#include "fs_rec.h" + + +/* FUNCTIONS ****************************************************************/ + +static NTSTATUS +FsRecIsCdfsVolume(IN PDEVICE_OBJECT DeviceObject) +{ + PUCHAR Buffer; + NTSTATUS Status; + + Buffer = ExAllocatePool(NonPagedPool, + 2048); + if (Buffer == NULL) + { + return(STATUS_INSUFFICIENT_RESOURCES); + } + + Status = FsRecReadSectors(DeviceObject, + 16, /* CDFS_PVD_SECTOR */ + 1, + 2048, + Buffer); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + + Buffer[6] = 0; + DPRINT("CD-identifier: [%.5s]\n", Buffer + 1); + + Status = (Buffer[0] == 1 && + Buffer[1] == 'C' && + Buffer[2] == 'D' && + Buffer[3] == '0' && + Buffer[4] == '0' && + Buffer[5] == '1') ? STATUS_SUCCESS : STATUS_UNRECOGNIZED_VOLUME; + + ExFreePool(Buffer); + + return(Status); +} + + +NTSTATUS +FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + UNICODE_STRING RegistryPath; + NTSTATUS Status; + + Stack = IoGetCurrentIrpStackLocation(Irp); + + switch (Stack->MinorFunction) + { + case IRP_MN_MOUNT_VOLUME: + DPRINT("Cdfs: IRP_MN_MOUNT_VOLUME\n"); + + Status = FsRecIsCdfsVolume(Stack->Parameters.MountVolume.DeviceObject); + if (NT_SUCCESS(Status)) + { + DPRINT("Identified CDFS volume\n"); + Status = STATUS_FS_DRIVER_REQUIRED; + } + break; + + case IRP_MN_LOAD_FILE_SYSTEM: + DPRINT("Cdfs: IRP_MN_LOAD_FILE_SYSTEM\n"); +#if 0 + RtlInitUnicodeString(&RegistryPath, FSD_REGISTRY_PATH); +#endif + RtlInitUnicodeString(&RegistryPath, + L"\\SystemRoot\\system32\\drivers\\cdfs.sys"); + Status = ZwLoadDriver(&RegistryPath); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwLoadDriver failed (Status %x)\n", Status); + } + else + { + IoUnregisterFileSystem(DeviceObject); + } + break; + + default: + DPRINT("Cdfs: Unknown minor function %lx\n", Stack->MinorFunction); + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + return(Status); +} + +/* EOF */ diff --git a/reactos/drivers/fs/fs_rec/fat.c b/reactos/drivers/fs/fs_rec/fat.c new file mode 100644 index 00000000000..2c93ac68477 --- /dev/null +++ b/reactos/drivers/fs/fs_rec/fat.c @@ -0,0 +1,95 @@ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: fat.c,v 1.1 2002/05/15 09:40:47 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/fs/fs_rec/vfat.c + * PURPOSE: Filesystem recognizer driver + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES *****************************************************************/ + +#include + +//#define NDEBUG +#include + +#include "fs_rec.h" + + +/* FUNCTIONS ****************************************************************/ + + +NTSTATUS +FsRecVfatFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + UNICODE_STRING RegistryPath; + NTSTATUS Status; + + Stack = IoGetCurrentIrpStackLocation(Irp); + + switch (Stack->MinorFunction) + { + case IRP_MN_MOUNT_VOLUME: + DPRINT("Fat: IRP_MN_MOUNT_VOLUME\n"); + Status = STATUS_INVALID_DEVICE_REQUEST; +#if 0 + Status = FsRecIsFatVolume(Stack->Parameters.MountVolume.DeviceObject); + if (NT_SUCCESS(Status)) + { + DPRINT("Identified FAT volume\n"); + Status = STATUS_FS_DRIVER_REQUIRED; + } +#endif + break; + + case IRP_MN_LOAD_FILE_SYSTEM: + DPRINT("Fat: IRP_MN_LOAD_FILE_SYSTEM\n"); + Status = STATUS_INVALID_DEVICE_REQUEST; +#if 0 +#if 0 + RtlInitUnicodeString(&RegistryPath, FSD_REGISTRY_PATH); +#endif + RtlInitUnicodeString(&RegistryPath, + L"\\SystemRoot\\system32\\drivers\\vfatfs.sys"); + Status = ZwLoadDriver(&RegistryPath); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwLoadDriver failed (Status %x)\n", Status); + } + else + { + IoUnregisterFileSystem(DeviceObject); + } +#endif + break; + + default: + DPRINT("Fat: Unknown minor function %lx\n", Stack->MinorFunction); + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + return(Status); +} + +/* EOF */ diff --git a/reactos/drivers/fs/fs_rec/fs_rec.c b/reactos/drivers/fs/fs_rec/fs_rec.c new file mode 100644 index 00000000000..648bf68d635 --- /dev/null +++ b/reactos/drivers/fs/fs_rec/fs_rec.c @@ -0,0 +1,245 @@ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: fs_rec.c,v 1.1 2002/05/15 09:40:47 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/fs/fs_rec/fs_rec.c + * PURPOSE: Filesystem recognizer driver + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +#include "fs_rec.h" + + +/* FUNCTIONS ****************************************************************/ + +NTSTATUS STDCALL +FsRecCreate(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + NTSTATUS Status; + + + Status = STATUS_SUCCESS; + + + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, + IO_NO_INCREMENT); + + return(Status); +} + + +NTSTATUS STDCALL +FsRecClose(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, + IO_NO_INCREMENT); + + return(STATUS_SUCCESS); +} + + +NTSTATUS STDCALL +FsRecFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PDEVICE_EXTENSION DeviceExt; + NTSTATUS Status; + + DeviceExt = DeviceObject->DeviceExtension; + switch (DeviceExt->FsType) + { + case FS_TYPE_VFAT: + Status = FsRecVfatFsControl(DeviceObject, Irp); + break; + + case FS_TYPE_CDFS: + Status = FsRecCdfsFsControl(DeviceObject, Irp); + break; + + case FS_TYPE_NTFS: + Status = FsRecNtfsFsControl(DeviceObject, Irp); + break; + + default: + Status = STATUS_INVALID_DEVICE_REQUEST; + } + + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, + IO_NO_INCREMENT); + + return(Status); +} + + +VOID STDCALL +FsRecUnload(IN PDRIVER_OBJECT DriverObject) +{ + PDEVICE_OBJECT NextDevice; + PDEVICE_OBJECT ThisDevice; + + /* Delete all remaining device objects */ + NextDevice = DriverObject->DeviceObject; + while (NextDevice != NULL) + { + ThisDevice = NextDevice; + NextDevice = NextDevice->NextDevice; + IoDeleteDevice(ThisDevice); + } +} + + +static NTSTATUS +FsRecRegisterFs(PDRIVER_OBJECT DriverObject, + PWSTR FsName, + PWSTR RecognizerName, + ULONG DeviceType, + ULONG FsType) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatus; + PDEVICE_EXTENSION DeviceExt; + UNICODE_STRING DeviceName; + UNICODE_STRING FileName; + PDEVICE_OBJECT DeviceObject; + HANDLE FileHandle; + NTSTATUS Status; + + RtlInitUnicodeString(&FileName, + FsName); + + InitializeObjectAttributes(&ObjectAttributes, + &FileName, + OBJ_CASE_INSENSITIVE, + 0, + NULL); + + Status = ZwCreateFile(&FileHandle, + 0x100000, + &ObjectAttributes, + &IoStatus, + NULL, + 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, + OPEN_EXISTING, + 0, + NULL, + 0); + if (NT_SUCCESS(Status)) + { + ZwClose(FileHandle); + return(STATUS_IMAGE_ALREADY_LOADED); + } + + /* Create recognizer device object */ + RtlInitUnicodeString(&DeviceName, + RecognizerName); + + Status = IoCreateDevice(DriverObject, + sizeof(DEVICE_EXTENSION), + &DeviceName, + DeviceType, + 0, + FALSE, + &DeviceObject); + + if (NT_SUCCESS(Status)) + { + DeviceExt = DeviceObject->DeviceExtension; + DeviceExt->FsType = FsType; + IoRegisterFileSystem(DeviceObject); + DPRINT("Created recognizer device '%wZ'\n", &DeviceName); + } + + return(Status); +} + + +NTSTATUS STDCALL +DriverEntry(PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath) +{ + PCONFIGURATION_INFORMATION ConfigInfo; + ULONG DeviceCount; + NTSTATUS Status; + + DPRINT("FileSystem recognizer 0.0.1\n"); + + DeviceCount = 0; + + DriverObject->MajorFunction[IRP_MJ_CREATE] = FsRecCreate; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsRecClose; + DriverObject->MajorFunction[IRP_MJ_CLEANUP] = FsRecClose; + DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FsRecFsControl; + DriverObject->DriverUnload = FsRecUnload; + + ConfigInfo = IoGetConfigurationInformation(); + + if (ConfigInfo->CDRomCount > 0) + { + Status = FsRecRegisterFs(DriverObject, + L"\\Cdfs", + L"\\FileSystem\\CdfsRecognizer", + FILE_DEVICE_CD_ROM_FILE_SYSTEM, + FS_TYPE_CDFS); + if (NT_SUCCESS(Status)) + { + DeviceCount++; + } + } + +#if 0 + Status = FsRecRegisterFs(DriverObject, + L"\\Fat", + L"\\FileSystem\\FatRecognizer", + FILE_DEVICE_DISK_FILE_SYSTEM, + FS_TYPE_VFAT); + if (NT_SUCCESS(Status)) + { + DeviceCount++; + } +#endif + + Status = FsRecRegisterFs(DriverObject, + L"\\Ntfs", + L"\\FileSystem\\NtfsRecognizer", + FILE_DEVICE_DISK_FILE_SYSTEM, + FS_TYPE_NTFS); + if (NT_SUCCESS(Status)) + { + DeviceCount++; + } + + return((DeviceCount > 0) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL); +} + +/* EOF */ diff --git a/reactos/drivers/fs/fs_rec/fs_rec.h b/reactos/drivers/fs/fs_rec/fs_rec.h new file mode 100644 index 00000000000..e5f387981c6 --- /dev/null +++ b/reactos/drivers/fs/fs_rec/fs_rec.h @@ -0,0 +1,73 @@ +/* + This is a File System Recognizer for RomFs. + Copyright (C) 2001 Bo Brantén. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +// +// Registry path for the FSD and this driver +// + +#define FSD_REGISTRY_PATH \ + L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\RomFs" + +#define FSR_REGISTRY_PATH \ + L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\RomFsRec" + + +/* Filesystem types (add new filesystems here)*/ +#define FS_TYPE_UNUSED 0 +#define FS_TYPE_VFAT 1 +#define FS_TYPE_NTFS 2 +#define FS_TYPE_CDFS 3 + + + +typedef struct _DEVICE_EXTENSION +{ + ULONG FsType; +} DEVICE_EXTENSION, *PDEVICE_EXTENSION; + + +/* blockdev.c */ + +NTSTATUS +FsRecReadSectors(IN PDEVICE_OBJECT DeviceObject, + IN ULONG DiskSector, + IN ULONG SectorCount, + IN ULONG SectorSize, + IN OUT PUCHAR Buffer); + + +/* cdfs.c */ + +NTSTATUS +FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + + +/* ntfs.c */ + +NTSTATUS +FsRecNtfsFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + + +/* vfat.c */ + +NTSTATUS +FsRecVfatFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +/* EOF */ diff --git a/reactos/drivers/fs/fs_rec/fs_rec.rc b/reactos/drivers/fs/fs_rec/fs_rec.rc new file mode 100644 index 00000000000..946e3f937a5 --- /dev/null +++ b/reactos/drivers/fs/fs_rec/fs_rec.rc @@ -0,0 +1,39 @@ + +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD + PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", RES_STR_COMPANY_NAME + VALUE "FileDescription", "Filesystem recognizer driver\0" + VALUE "FileVersion", "0.0.1\0" + VALUE "InternalName", "fs_rec\0" + VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT + VALUE "OriginalFilename", "fs_rec.sys\0" + VALUE "ProductName", RES_STR_PRODUCT_NAME + VALUE "ProductVersion", RES_STR_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + diff --git a/reactos/drivers/fs/fs_rec/makefile b/reactos/drivers/fs/fs_rec/makefile new file mode 100644 index 00000000000..e1f0a0a11eb --- /dev/null +++ b/reactos/drivers/fs/fs_rec/makefile @@ -0,0 +1,24 @@ +# $Id: makefile,v 1.1 2002/05/15 09:40:47 ekohl Exp $ + +PATH_TO_TOP = ../../.. + +TARGET_TYPE = driver + +TARGET_NAME = fs_rec + +TARGET_OBJECTS = \ + blockdev.o \ + fs_rec.o \ + cdfs.o \ + fat.o \ + ntfs.o + +DEP_OBJECTS = $(TARGET_OBJECTS) + +TARGET_CFLAGS = -g + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +include $(TOOLS_PATH)/depend.mk diff --git a/reactos/drivers/fs/fs_rec/ntfs.c b/reactos/drivers/fs/fs_rec/ntfs.c new file mode 100644 index 00000000000..2fe143b3036 --- /dev/null +++ b/reactos/drivers/fs/fs_rec/ntfs.c @@ -0,0 +1,95 @@ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: ntfs.c,v 1.1 2002/05/15 09:40:47 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/fs/fs_rec/ntfs.c + * PURPOSE: Filesystem recognizer driver + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES *****************************************************************/ + +#include + +//#define NDEBUG +#include + +#include "fs_rec.h" + + +/* FUNCTIONS ****************************************************************/ + + +NTSTATUS +FsRecNtfsFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + UNICODE_STRING RegistryPath; + NTSTATUS Status; + + Stack = IoGetCurrentIrpStackLocation(Irp); + + switch (Stack->MinorFunction) + { + case IRP_MN_MOUNT_VOLUME: + DPRINT("NTFS: IRP_MN_MOUNT_VOLUME\n"); + Status = STATUS_INVALID_DEVICE_REQUEST; +#if 0 + Status = FsRecIsNtfsVolume(Stack->Parameters.MountVolume.DeviceObject); + if (NT_SUCCESS(Status)) + { + DPRINT("Identified NTFS volume\n"); + Status = STATUS_FS_DRIVER_REQUIRED; + } +#endif + break; + + case IRP_MN_LOAD_FILE_SYSTEM: + DPRINT("NTFS: IRP_MN_LOAD_FILE_SYSTEM\n"); + Status = STATUS_INVALID_DEVICE_REQUEST; +#if 0 +#if 0 + RtlInitUnicodeString(&RegistryPath, FSD_REGISTRY_PATH); +#endif + RtlInitUnicodeString(&RegistryPath, + L"\\SystemRoot\\system32\\drivers\\ntfs.sys"); + Status = ZwLoadDriver(&RegistryPath); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwLoadDriver failed (Status %x)\n", Status); + } + else + { + IoUnregisterFileSystem(DeviceObject); + } +#endif + break; + + default: + DPRINT("NTFS: Unknown minor function %lx\n", Stack->MinorFunction); + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + return(Status); +} + +/* EOF */ diff --git a/reactos/install.bat b/reactos/install.bat index abf46e0c8cc..ab337d19136 100644 --- a/reactos/install.bat +++ b/reactos/install.bat @@ -27,6 +27,7 @@ copy ntoskrnl\ntoskrnl.sym %ROS_INSTALL%\symbols copy hal\halx86\hal.dll %ROS_INSTALL%\system32 copy services\fs\vfat\vfatfs.sys %ROS_INSTALL%\system32\drivers copy services\fs\cdfs\cdfs.sys %ROS_INSTALL%\system32\drivers +copy services\fs\fs_rec\fs_rec.sys %ROS_INSTALL%\system32\drivers copy services\fs\ms\msfs.sys %ROS_INSTALL%\system32\drivers copy services\fs\np\npfs.sys %ROS_INSTALL%\system32\drivers copy services\bus\acpi\acpi.sys %ROS_INSTALL%\system32\drivers diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index 9ac1cc45016..e9a4d3a20ed 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: io.h,v 1.18 2002/04/10 09:58:02 ekohl Exp $ +/* $Id: io.h,v 1.19 2002/05/15 09:38:35 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -265,16 +265,11 @@ VOID IoInitVpbImplementation (VOID); NTSTATUS -IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN AllowRawMount); +IoMountVolume(IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN AllowRawMount); POBJECT IoOpenSymlink(POBJECT SymbolicLink); POBJECT IoOpenFileOnDevice(POBJECT SymbolicLink, PWCHAR Name); -PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction, - PDEVICE_OBJECT DeviceObject, - PKEVENT UserEvent, - PIO_STATUS_BLOCK IoStatusBlock, - PDEVICE_OBJECT DeviceToMount); VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost); NTSTATUS STDCALL diff --git a/reactos/ntoskrnl/io/buildirp.c b/reactos/ntoskrnl/io/buildirp.c index 6f02cafc8fa..3edfb4ada96 100644 --- a/reactos/ntoskrnl/io/buildirp.c +++ b/reactos/ntoskrnl/io/buildirp.c @@ -1,4 +1,4 @@ -/* $Id: buildirp.c,v 1.27 2002/04/10 09:57:31 ekohl Exp $ +/* $Id: buildirp.c,v 1.28 2002/05/15 09:39:02 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -69,74 +69,14 @@ NTSTATUS IoPrepareIrpBuffer(PIRP Irp, return(STATUS_SUCCESS); } -PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction, - PDEVICE_OBJECT DeviceObject, - PKEVENT UserEvent, - PIO_STATUS_BLOCK IoStatusBlock, - PDEVICE_OBJECT DeviceToMount) -/* - * FUNCTION: Allocates and sets up a filesystem control IRP - * ARGUMENTS: - * MinorFunction = Type of filesystem control - * DeviceObject = Device object to send the request to - * UserEvent = Event used to notify the caller of completion - * IoStatusBlock (OUT) = Used to return the status of the operation - * DeviceToMount = Device to mount (for the IRP_MN_MOUNT_VOLUME - * or IRP_MN_VERIFY_VOLUME request) - */ -{ - PIRP Irp; - PIO_STACK_LOCATION StackPtr; - - Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); - if (Irp==NULL) - { - return(NULL); - } - - Irp->UserIosb = IoStatusBlock; - DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); - Irp->UserEvent = UserEvent; - Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - - StackPtr = IoGetNextIrpStackLocation(Irp); - StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL; - StackPtr->MinorFunction = MinorFunction; - StackPtr->Flags = 0; - StackPtr->Control = 0; - StackPtr->DeviceObject = DeviceObject; - StackPtr->FileObject = NULL; - StackPtr->CompletionRoutine = NULL; - - switch(MinorFunction) - { - case IRP_MN_USER_FS_REQUEST: - break; - - case IRP_MN_MOUNT_VOLUME: - StackPtr->Parameters.MountVolume.Vpb = DeviceToMount->Vpb; - StackPtr->Parameters.MountVolume.DeviceObject = DeviceToMount; - break; - - case IRP_MN_VERIFY_VOLUME: - StackPtr->Parameters.VerifyVolume.Vpb = DeviceToMount->Vpb; - StackPtr->Parameters.VerifyVolume.DeviceObject = DeviceToMount; - break; - - case IRP_MN_LOAD_FILE_SYSTEM: - break; - } - return(Irp); -} -PIRP -STDCALL +PIRP STDCALL IoBuildAsynchronousFsdRequest(ULONG MajorFunction, - PDEVICE_OBJECT DeviceObject, - PVOID Buffer, - ULONG Length, - PLARGE_INTEGER StartingOffset, - PIO_STATUS_BLOCK IoStatusBlock) + PDEVICE_OBJECT DeviceObject, + PVOID Buffer, + ULONG Length, + PLARGE_INTEGER StartingOffset, + PIO_STATUS_BLOCK IoStatusBlock) /* * FUNCTION: Allocates and sets up an IRP to be sent to lower level drivers * ARGUMENTS: @@ -218,15 +158,17 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, return(Irp); } -PIRP STDCALL IoBuildDeviceIoControlRequest(ULONG IoControlCode, - PDEVICE_OBJECT DeviceObject, - PVOID InputBuffer, - ULONG InputBufferLength, - PVOID OutputBuffer, - ULONG OutputBufferLength, - BOOLEAN InternalDeviceIoControl, - PKEVENT Event, - PIO_STATUS_BLOCK IoStatusBlock) + +PIRP STDCALL +IoBuildDeviceIoControlRequest(ULONG IoControlCode, + PDEVICE_OBJECT DeviceObject, + PVOID InputBuffer, + ULONG InputBufferLength, + PVOID OutputBuffer, + ULONG OutputBufferLength, + BOOLEAN InternalDeviceIoControl, + PKEVENT Event, + PIO_STATUS_BLOCK IoStatusBlock) /* * FUNCTION: Allocates and sets up an IRP to be sent to drivers * ARGUMENTS: @@ -392,8 +334,8 @@ PIRP STDCALL IoBuildDeviceIoControlRequest(ULONG IoControlCode, return(Irp); } -PIRP -STDCALL + +PIRP STDCALL IoBuildSynchronousFsdRequest(ULONG MajorFunction, PDEVICE_OBJECT DeviceObject, PVOID Buffer, @@ -576,5 +518,4 @@ IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction, return(Irp); } - /* EOF */ diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index 0ed9fcda8ec..9616696cf83 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.56 2002/04/10 09:57:31 ekohl Exp $ +/* $Id: create.c,v 1.57 2002/05/15 09:39:02 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -130,12 +130,12 @@ IopCreateFile(PVOID ObjectBody, { if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED)) { - DPRINT("Trying to mount storage device\n"); - Status = IoTryToMountStorageDevice(DeviceObject, FALSE); + DPRINT("Mount the logical volume\n"); + Status = IoMountVolume(DeviceObject, FALSE); DPRINT("Status %x\n", Status); if (!NT_SUCCESS(Status)) { - CPRINT("Failed to mount storage device (status %x)\n", + CPRINT("Failed to mount logical volume (Status %x)\n", Status); return(Status); } diff --git a/reactos/ntoskrnl/io/fs.c b/reactos/ntoskrnl/io/fs.c index 25489696327..b3ade7fb2af 100644 --- a/reactos/ntoskrnl/io/fs.c +++ b/reactos/ntoskrnl/io/fs.c @@ -1,4 +1,4 @@ -/* $Id: fs.c,v 1.25 2002/04/27 19:22:55 hbirr Exp $ +/* $Id: fs.c,v 1.26 2002/05/15 09:39:02 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -209,53 +209,124 @@ IoShutdownRegisteredFileSystems(VOID) } -NTSTATUS -IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject, - PDEVICE_OBJECT DeviceToMount) +static NTSTATUS +IopMountFileSystem(PDEVICE_OBJECT DeviceObject, + PDEVICE_OBJECT DeviceToMount) { - PIRP Irp; - IO_STATUS_BLOCK IoStatusBlock; - NTSTATUS Status; - PKEVENT Event; // KEVENT must be allocated from non paged pool, not stack - - DPRINT("IoAskFileSystemToMountDevice(DeviceObject %x, DeviceToMount %x)\n", - DeviceObject,DeviceToMount); - - assert_irql(PASSIVE_LEVEL); - Event = ExAllocatePool( NonPagedPool, sizeof( KEVENT ) ); - if( Event == 0 ) - return STATUS_INSUFFICIENT_RESOURCES; - KeInitializeEvent(Event,NotificationEvent,FALSE); - Irp = IoBuildFilesystemControlRequest(IRP_MN_MOUNT_VOLUME, - DeviceObject, - Event, - &IoStatusBlock, - DeviceToMount); - Status = IoCallDriver(DeviceObject,Irp); - if (Status==STATUS_PENDING) - { - KeWaitForSingleObject(Event,Executive,KernelMode,FALSE,NULL); - Status = IoStatusBlock.Status; - } - ExFreePool( Event ); - return(Status); + IO_STATUS_BLOCK IoStatusBlock; + PIO_STACK_LOCATION StackPtr; + PKEVENT Event; + PIRP Irp; + NTSTATUS Status; + + DPRINT("IoAskFileSystemToMountDevice(DeviceObject %x, DeviceToMount %x)\n", + DeviceObject,DeviceToMount); + + assert_irql(PASSIVE_LEVEL); + Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT)); + if (Event == NULL) + { + return(STATUS_INSUFFICIENT_RESOURCES); + } + KeInitializeEvent(Event, NotificationEvent, FALSE); + + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); + if (Irp==NULL) + { + ExFreePool(Event); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + Irp->UserIosb = &IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); + Irp->UserEvent = Event; + Irp->Tail.Overlay.Thread = PsGetCurrentThread(); + + StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL; + StackPtr->MinorFunction = IRP_MN_MOUNT_VOLUME; + StackPtr->Flags = 0; + StackPtr->Control = 0; + StackPtr->DeviceObject = DeviceObject; + StackPtr->FileObject = NULL; + StackPtr->CompletionRoutine = NULL; + + StackPtr->Parameters.MountVolume.Vpb = DeviceToMount->Vpb; + StackPtr->Parameters.MountVolume.DeviceObject = DeviceToMount; + + Status = IoCallDriver(DeviceObject,Irp); + if (Status==STATUS_PENDING) + { + KeWaitForSingleObject(Event,Executive,KernelMode,FALSE,NULL); + Status = IoStatusBlock.Status; + } + + ExFreePool(Event); + + return(Status); +} + + +static NTSTATUS +IopLoadFileSystem(IN PDEVICE_OBJECT DeviceObject) +{ + IO_STATUS_BLOCK IoStatusBlock; + PIO_STACK_LOCATION StackPtr; + PKEVENT Event; + PIRP Irp; + NTSTATUS Status; + + DPRINT("IopLoadFileSystem(DeviceObject %x)\n", DeviceObject); + + assert_irql(PASSIVE_LEVEL); + Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT)); + if (Event == NULL) + { + return(STATUS_INSUFFICIENT_RESOURCES); + } + KeInitializeEvent(Event, NotificationEvent, FALSE); + + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); + if (Irp==NULL) + { + ExFreePool(Event); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + Irp->UserIosb = &IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); + Irp->UserEvent = Event; + Irp->Tail.Overlay.Thread = PsGetCurrentThread(); + + StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL; + StackPtr->MinorFunction = IRP_MN_LOAD_FILE_SYSTEM; + StackPtr->Flags = 0; + StackPtr->Control = 0; + StackPtr->DeviceObject = DeviceObject; + StackPtr->FileObject = NULL; + StackPtr->CompletionRoutine = NULL; + + Status = IoCallDriver(DeviceObject,Irp); + if (Status==STATUS_PENDING) + { + KeWaitForSingleObject(Event,Executive,KernelMode,FALSE,NULL); + Status = IoStatusBlock.Status; + } + + ExFreePool(Event); + + return(Status); } NTSTATUS -IoAskFileSystemToLoad(IN PDEVICE_OBJECT DeviceObject) -{ - UNIMPLEMENTED; -} - - -NTSTATUS -IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN AllowRawMount) +IoMountVolume(IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN AllowRawMount) /* - * FUNCTION: Trys to mount a storage device + * FUNCTION: Mounts a logical volume * ARGUMENTS: - * DeviceObject = Device to try and mount + * DeviceObject = Device to mount * RETURNS: Status */ { @@ -267,7 +338,8 @@ IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, assert_irql(PASSIVE_LEVEL); - DPRINT("IoTryToMountStorageDevice(DeviceObject %x)\n",DeviceObject); + DPRINT("IoMountVolume(DeviceObject %x AllowRawMount %x)\n", + DeviceObject, AllowRawMount); switch (DeviceObject->DeviceType) { @@ -305,17 +377,21 @@ IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, continue; } KeReleaseSpinLock(&FileSystemListLock,oldlvl); - Status = IoAskFileSystemToMountDevice(current->DeviceObject, - DeviceObject); + Status = IopMountFileSystem(current->DeviceObject, + DeviceObject); KeAcquireSpinLock(&FileSystemListLock,&oldlvl); switch (Status) { case STATUS_FS_DRIVER_REQUIRED: KeReleaseSpinLock(&FileSystemListLock,oldlvl); - (void)IoAskFileSystemToLoad(DeviceObject); + Status = IopLoadFileSystem(current->DeviceObject); + if (!NT_SUCCESS(Status)) + { + return(Status); + } KeAcquireSpinLock(&FileSystemListLock,&oldlvl); current_entry = FileSystemListHead.Flink; - break; + continue; case STATUS_SUCCESS: DeviceObject->Vpb->Flags = DeviceObject->Vpb->Flags | @@ -339,7 +415,7 @@ IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, * IoVerifyVolume * * DESCRIPTION - * Veriyfy the file system type and volume information or mount + * Verify the file system type and volume information or mount * a file system. * * ARGUMENTS @@ -357,13 +433,13 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount) { IO_STATUS_BLOCK IoStatusBlock; + PIO_STACK_LOCATION StackPtr; PKEVENT Event; PIRP Irp; NTSTATUS Status; - DPRINT1("IoVerifyVolume(DeviceObject %x AllowRawMount %x)\n", - DeviceObject, - AllowRawMount); + DPRINT("IoVerifyVolume(DeviceObject %x AllowRawMount %x)\n", + DeviceObject, AllowRawMount); Status = STATUS_SUCCESS; @@ -385,11 +461,29 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, NotificationEvent, FALSE); - Irp = IoBuildFilesystemControlRequest(IRP_MN_VERIFY_VOLUME, - DeviceObject, - Event, - &IoStatusBlock, - NULL); //DeviceToMount); + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); + if (Irp==NULL) + { + ExFreePool(Event); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + Irp->UserIosb = &IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); + Irp->UserEvent = Event; + Irp->Tail.Overlay.Thread = PsGetCurrentThread(); + + StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL; + StackPtr->MinorFunction = IRP_MN_VERIFY_VOLUME; + StackPtr->Flags = 0; + StackPtr->Control = 0; + StackPtr->DeviceObject = DeviceObject; + StackPtr->FileObject = NULL; + StackPtr->CompletionRoutine = NULL; + + StackPtr->Parameters.VerifyVolume.Vpb = DeviceObject->Vpb; + StackPtr->Parameters.VerifyVolume.DeviceObject = DeviceObject; Status = IoCallDriver(DeviceObject, Irp); @@ -418,8 +512,8 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, } /* Start mount sequence */ - Status = IoTryToMountStorageDevice(DeviceObject, - AllowRawMount); + Status = IoMountVolume(DeviceObject, + AllowRawMount); KeSetEvent(&DeviceObject->DeviceLock, IO_NO_INCREMENT, diff --git a/reactos/system.hiv b/reactos/system.hiv index abdd987fe7f..92bd1d4e155 100644 --- a/reactos/system.hiv +++ b/reactos/system.hiv @@ -94,6 +94,12 @@ REGEDIT4 "Start"=dword:00000001 "Type"=dword:00000001 +[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Fs_Rec] +"ImagePath"="system32\drivers\fs_rec.sys" +"Group"="Boot file system" +"Start"=dword:00000000 +"Type"=dword:00000008 + [\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ide] "ImagePath"="system32\drivers\ide.sys" "Group"="Primary Disk"