Fix ext2 recognizer compilation, but let it disabled atm

svn path=/trunk/; revision=32292
This commit is contained in:
Hervé Poussineau 2008-02-11 16:41:25 +00:00
parent 7b726051e8
commit 4797b6a8d5
5 changed files with 109 additions and 113 deletions

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS File System Recognizer
* FILE: drivers/fs/fs_rec/ext2.c (based on vfat.c) * FILE: drivers/filesystems/fs_rec/ext2.c
* PURPOSE: Filesystem recognizer driver * PURPOSE: EXT2 Recognizer
* PROGRAMMER: Eric Kohl * PROGRAMMER: Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include "fs_rec.h"
#include <rosrtl/string.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#include "fs_rec.h"
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
static NTSTATUS BOOLEAN
FsRecIsExt2Volume(IN PDEVICE_OBJECT DeviceObject) NTAPI
FsRecIsExt2Volume(IN PVOID PackedBootSector)
{ {
NTSTATUS Status; /* For now, always return failure... */
PARTITION_INFORMATION PartitionInfo; return FALSE;
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;
} }
NTSTATUS NTSTATUS
NTAPI
FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject, FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
{ {
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
UNICODE_STRING RegistryPath; NTSTATUS Status;
NTSTATUS Status; PDEVICE_OBJECT MountDevice;
PVOID Bpb = NULL;
ULONG SectorSize;
LARGE_INTEGER Offset = {{0}};
BOOLEAN DeviceError = FALSE;
PAGED_CODE();
Stack = IoGetCurrentIrpStackLocation(Irp); /* Get the I/O Stack and check the function type */
Stack = IoGetCurrentIrpStackLocation(Irp);
switch (Stack->MinorFunction) switch (Stack->MinorFunction)
{ {
case IRP_MN_MOUNT_VOLUME: 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;
case IRP_MN_LOAD_FILE_SYSTEM: /* Assume failure */
DPRINT("FAT: IRP_MN_LOAD_FILE_SYSTEM\n"); Status = STATUS_UNRECOGNIZED_VOLUME;
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;
default: /* Get the device object and request the sector size */
DPRINT("FAT: Unknown minor function %lx\n", Stack->MinorFunction); MountDevice = Stack->Parameters.MountVolume.DeviceObject;
Status = STATUS_INVALID_DEVICE_REQUEST; if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
break; {
/* 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;
}
}
/* Free the boot sector if we have one */
ExFreePool(Bpb);
}
else
{
/* We have some sort of failure in the storage stack */
DeviceError = TRUE;
}
/* 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 */ /* EOF */

View file

@ -15,7 +15,7 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
NTSTATUS BOOLEAN
NTAPI NTAPI
FsRecIsFatVolume(IN PPACKED_BOOT_SECTOR PackedBootSector) FsRecIsFatVolume(IN PPACKED_BOOT_SECTOR PackedBootSector)
{ {
@ -163,7 +163,7 @@ FsRecVfatFsControl(IN PDEVICE_OBJECT DeviceObject,
/* Load the file system */ /* Load the file system */
Status = FsRecLoadFileSystem(DeviceObject, Status = FsRecLoadFileSystem(DeviceObject,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Vfatfs"); L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\fastfat");
break; break;
default: default:

View file

@ -153,6 +153,12 @@ FsRecFsControl(IN PDEVICE_OBJECT DeviceObject,
Status = FsRecUdfsFsControl(DeviceObject, Irp); Status = FsRecUdfsFsControl(DeviceObject, Irp);
break; break;
case FS_TYPE_EXT2:
/* Send EXT2 command */
Status = FsRecExt2FsControl(DeviceObject, Irp);
break;
default: default:
/* Unrecognized FS */ /* Unrecognized FS */
@ -359,6 +365,16 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
FILE_DEVICE_DISK_FILE_SYSTEM); FILE_DEVICE_DISK_FILE_SYSTEM);
if (NT_SUCCESS(Status)) DeviceCount++; 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 appropriate Status */
return (DeviceCount > 0) ? STATUS_SUCCESS : STATUS_IMAGE_ALREADY_LOADED; return (DeviceCount > 0) ? STATUS_SUCCESS : STATUS_IMAGE_ALREADY_LOADED;
} }

View file

@ -180,7 +180,8 @@ typedef enum _FILE_SYSTEM_TYPE
FS_TYPE_VFAT, FS_TYPE_VFAT,
FS_TYPE_NTFS, FS_TYPE_NTFS,
FS_TYPE_CDFS, FS_TYPE_CDFS,
FS_TYPE_UDFS FS_TYPE_UDFS,
FS_TYPE_EXT2,
} FILE_SYSTEM_TYPE, *PFILE_SYSTEM_TYPE; } FILE_SYSTEM_TYPE, *PFILE_SYSTEM_TYPE;
// //
@ -234,6 +235,13 @@ FsRecUdfsFsControl(
IN PIRP Irp IN PIRP Irp
); );
NTSTATUS
NTAPI
FsRecExt2FsControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
BOOLEAN BOOLEAN
NTAPI NTAPI
FsRecGetDeviceSectors( FsRecGetDeviceSectors(

View file

@ -6,6 +6,7 @@
<library>hal</library> <library>hal</library>
<file>blockdev.c</file> <file>blockdev.c</file>
<file>cdfs.c</file> <file>cdfs.c</file>
<file>ext2.c</file>
<file>fat.c</file> <file>fat.c</file>
<file>fs_rec.c</file> <file>fs_rec.c</file>
<file>ntfs.c</file> <file>ntfs.c</file>