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
* 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)
IN PIRP Irp)
{
PIO_STACK_LOCATION Stack;
UNICODE_STRING RegistryPath;
NTSTATUS Status;
PIO_STACK_LOCATION Stack;
NTSTATUS Status;
PDEVICE_OBJECT MountDevice;
PVOID Bpb = NULL;
ULONG SectorSize;
LARGE_INTEGER Offset = {{0}};
BOOLEAN DeviceError = FALSE;
PAGED_CODE();
Stack = IoGetCurrentIrpStackLocation(Irp);
switch (Stack->MinorFunction)
/* Get the I/O Stack and check the function type */
Stack = IoGetCurrentIrpStackLocation(Irp);
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;
case IRP_MN_MOUNT_VOLUME:
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;
/* Assume failure */
Status = STATUS_UNRECOGNIZED_VOLUME;
default:
DPRINT("FAT: Unknown minor function %lx\n", Stack->MinorFunction);
Status = STATUS_INVALID_DEVICE_REQUEST;
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;
}
}
/* 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 */

View file

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

View file

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

View file

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

View file

@ -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>