Author: hpoussin Date: Mon Feb 11 19:41:25 2008 New Revision: 32292
URL: http://svn.reactos.org/svn/reactos?rev=32292&view=rev Log: Fix ext2 recognizer compilation, but let it disabled atm
Modified: trunk/reactos/drivers/filesystems/fs_rec/ext2.c trunk/reactos/drivers/filesystems/fs_rec/fat.c trunk/reactos/drivers/filesystems/fs_rec/fs_rec.c trunk/reactos/drivers/filesystems/fs_rec/fs_rec.h trunk/reactos/drivers/filesystems/fs_rec/fs_rec.rbuild
Modified: trunk/reactos/drivers/filesystems/fs_rec/ext2.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fs_rec/... ============================================================================== --- trunk/reactos/drivers/filesystems/fs_rec/ext2.c (original) +++ trunk/reactos/drivers/filesystems/fs_rec/ext2.c Mon Feb 11 19:41:25 2008 @@ -1,136 +1,107 @@ /* - * ReactOS kernel - * Copyright (C) 2002,2003 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 9284 2004-05-02 20:12:38Z hbirr $ - * * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: drivers/fs/fs_rec/ext2.c (based on vfat.c) - * PURPOSE: Filesystem recognizer driver + * PROJECT: ReactOS File System Recognizer + * FILE: drivers/filesystems/fs_rec/ext2.c + * PURPOSE: EXT2 Recognizer * PROGRAMMER: Eric Kohl */
/* INCLUDES *****************************************************************/
-#include <ddk/ntddk.h> -#include <rosrtl/string.h> - +#include "fs_rec.h" #define NDEBUG #include <debug.h>
-#include "fs_rec.h" - - /* FUNCTIONS ****************************************************************/
-static NTSTATUS -FsRecIsExt2Volume(IN PDEVICE_OBJECT DeviceObject) +BOOLEAN +NTAPI +FsRecIsExt2Volume(IN PVOID PackedBootSector) { - NTSTATUS Status; - PARTITION_INFORMATION PartitionInfo; - DISK_GEOMETRY DiskGeometry; - ULONG Size; - BOOL RecognizedFS = FALSE; - Size = sizeof(DISK_GEOMETRY); - - Status = FsRecDeviceIoControl(DeviceObject, - IOCTL_DISK_GET_DRIVE_GEOMETRY, - NULL, - 0, - &DiskGeometry, - &Size); - if (!NT_SUCCESS(Status)) - { - DPRINT("FsRecDeviceIoControl faild (%x)\n", Status); - return Status; - } - if (DiskGeometry.MediaType == FixedMedia || DiskGeometry.MediaType == RemovableMedia) - { - // We have found a hard disk - Size = sizeof(PARTITION_INFORMATION); - Status = FsRecDeviceIoControl(DeviceObject, - IOCTL_DISK_GET_PARTITION_INFO, - NULL, - 0, - &PartitionInfo, - &Size); - if (!NT_SUCCESS(Status)) - { - DPRINT("FsRecDeviceIoControl faild (%x)\n", Status); - return Status; - } - - if (PartitionInfo.PartitionType) - { - if (PartitionInfo.PartitionType == PARTITION_EXT2) - { - RecognizedFS = TRUE; - } - } - } - - return RecognizedFS ? STATUS_SUCCESS : STATUS_UNRECOGNIZED_VOLUME; + /* For now, always return failure... */ + return FALSE; }
+NTSTATUS +NTAPI +FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + NTSTATUS Status; + PDEVICE_OBJECT MountDevice; + PVOID Bpb = NULL; + ULONG SectorSize; + LARGE_INTEGER Offset = {{0}}; + BOOLEAN DeviceError = FALSE; + PAGED_CODE();
-NTSTATUS -FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PIO_STACK_LOCATION Stack; - UNICODE_STRING RegistryPath; - NTSTATUS Status; + /* Get the I/O Stack and check the function type */ + Stack = IoGetCurrentIrpStackLocation(Irp); + switch (Stack->MinorFunction) + { + case IRP_MN_MOUNT_VOLUME:
- Stack = IoGetCurrentIrpStackLocation(Irp); + /* Assume failure */ + Status = STATUS_UNRECOGNIZED_VOLUME;
- switch (Stack->MinorFunction) - { - case IRP_MN_MOUNT_VOLUME: - DPRINT("FAT: IRP_MN_MOUNT_VOLUME\n"); - Status = FsRecIsExt2Volume(Stack->Parameters.MountVolume.DeviceObject); - if (NT_SUCCESS(Status)) - { - DPRINT("Identified FAT volume\n"); - Status = STATUS_FS_DRIVER_REQUIRED; - } - break; + /* Get the device object and request the sector size */ + MountDevice = Stack->Parameters.MountVolume.DeviceObject; + if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize)) + { + /* Try to read the BPB */ + if (FsRecReadBlock(MountDevice, + &Offset, + 512, + SectorSize, + (PVOID)&Bpb, + &DeviceError)) + { + /* Check if it's an actual EXT2 volume */ + if (FsRecIsExt2Volume(Bpb)) + { + /* It is! */ + Status = STATUS_FS_DRIVER_REQUIRED; + } + }
- case IRP_MN_LOAD_FILE_SYSTEM: - DPRINT("FAT: IRP_MN_LOAD_FILE_SYSTEM\n"); - RtlRosInitUnicodeStringFromLiteral(&RegistryPath, - L"\Registry\Machine\System\CurrentControlSet\Services\Ext2"); - Status = ZwLoadDriver(&RegistryPath); - if (!NT_SUCCESS(Status)) - { - DPRINT("ZwLoadDriver failed (Status %x)\n", Status); - } - else - { - IoUnregisterFileSystem(DeviceObject); - } - break; + /* Free the boot sector if we have one */ + ExFreePool(Bpb); + } + else + { + /* We have some sort of failure in the storage stack */ + DeviceError = TRUE; + }
- default: - DPRINT("FAT: Unknown minor function %lx\n", Stack->MinorFunction); - Status = STATUS_INVALID_DEVICE_REQUEST; - break; + /* Check if we have an error on the stack */ + if (DeviceError) + { + /* Was this because of a floppy? */ + if (MountDevice->Characteristics & FILE_FLOPPY_DISKETTE) + { + /* Let the FS try anyway */ + Status = STATUS_FS_DRIVER_REQUIRED; + } + } + + break; + + case IRP_MN_LOAD_FILE_SYSTEM: + + /* Load the file system */ + Status = FsRecLoadFileSystem(DeviceObject, + L"\Registry\Machine\System\CurrentControlSet\Services\Ext2"); + break; + + default: + + /* Invalid request */ + Status = STATUS_INVALID_DEVICE_REQUEST; } - return(Status); + + /* Return Status */ + return Status; }
/* EOF */
Modified: trunk/reactos/drivers/filesystems/fs_rec/fat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fs_rec/... ============================================================================== --- trunk/reactos/drivers/filesystems/fs_rec/fat.c (original) +++ trunk/reactos/drivers/filesystems/fs_rec/fat.c Mon Feb 11 19:41:25 2008 @@ -15,7 +15,7 @@
/* FUNCTIONS ****************************************************************/
-NTSTATUS +BOOLEAN NTAPI FsRecIsFatVolume(IN PPACKED_BOOT_SECTOR PackedBootSector) { @@ -163,7 +163,7 @@
/* Load the file system */ Status = FsRecLoadFileSystem(DeviceObject, - L"\Registry\Machine\System\CurrentControlSet\Services\Vfatfs"); + L"\Registry\Machine\System\CurrentControlSet\Services\fastfat"); break;
default:
Modified: trunk/reactos/drivers/filesystems/fs_rec/fs_rec.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fs_rec/... ============================================================================== --- trunk/reactos/drivers/filesystems/fs_rec/fs_rec.c (original) +++ trunk/reactos/drivers/filesystems/fs_rec/fs_rec.c Mon Feb 11 19:41:25 2008 @@ -151,6 +151,12 @@
/* Send UDFS command */ Status = FsRecUdfsFsControl(DeviceObject, Irp); + break; + + case FS_TYPE_EXT2: + + /* Send EXT2 command */ + Status = FsRecExt2FsControl(DeviceObject, Irp); break;
default: @@ -359,6 +365,16 @@ FILE_DEVICE_DISK_FILE_SYSTEM); if (NT_SUCCESS(Status)) DeviceCount++;
+ /* Register EXT2 */ + /*Status = FsRecRegisterFs(DriverObject, + NULL, + NULL, + L"\Ext2", + L"\FileSystem\Ext2Recognizer", + FS_TYPE_EXT2, + FILE_DEVICE_DISK_FILE_SYSTEM); + if (NT_SUCCESS(Status)) DeviceCount++;*/ + /* Return appropriate Status */ return (DeviceCount > 0) ? STATUS_SUCCESS : STATUS_IMAGE_ALREADY_LOADED; }
Modified: trunk/reactos/drivers/filesystems/fs_rec/fs_rec.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fs_rec/... ============================================================================== --- trunk/reactos/drivers/filesystems/fs_rec/fs_rec.h (original) +++ trunk/reactos/drivers/filesystems/fs_rec/fs_rec.h Mon Feb 11 19:41:25 2008 @@ -180,7 +180,8 @@ FS_TYPE_VFAT, FS_TYPE_NTFS, FS_TYPE_CDFS, - FS_TYPE_UDFS + FS_TYPE_UDFS, + FS_TYPE_EXT2, } FILE_SYSTEM_TYPE, *PFILE_SYSTEM_TYPE;
// @@ -230,6 +231,13 @@ NTSTATUS NTAPI FsRecUdfsFsControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp +); + +NTSTATUS +NTAPI +FsRecExt2FsControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp );
Modified: trunk/reactos/drivers/filesystems/fs_rec/fs_rec.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fs_rec/... ============================================================================== --- trunk/reactos/drivers/filesystems/fs_rec/fs_rec.rbuild (original) +++ trunk/reactos/drivers/filesystems/fs_rec/fs_rec.rbuild Mon Feb 11 19:41:25 2008 @@ -6,6 +6,7 @@ <library>hal</library> <file>blockdev.c</file> <file>cdfs.c</file> + <file>ext2.c</file> <file>fat.c</file> <file>fs_rec.c</file> <file>ntfs.c</file>