mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
1f2d67a841
Rename the Ext2 recognizer to a more generic Ext to be more future-proof with a possible upcoming ext4 support. Also, it already makes no sense to use the name ext2 as it already recognizes all the FS of the "Ext family". In addition, add the Ext Recognizer for CDs.
111 lines
3.2 KiB
C
111 lines
3.2 KiB
C
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS File System Recognizer
|
|
* FILE: drivers/filesystems/fs_rec/ext.c
|
|
* PURPOSE: EXT Recognizer
|
|
* PROGRAMMER: Eric Kohl
|
|
* Pierre Schweitzer (pierre@reactos.org)
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include "fs_rec.h"
|
|
#include "ext.h"
|
|
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
BOOLEAN
|
|
NTAPI
|
|
FsRecIsExtVolume(IN PEXT_SUPER_BLOCK SuperBlock)
|
|
{
|
|
/* Just check for magic */
|
|
return (SuperBlock->Magic == EXT_SUPER_MAGIC);
|
|
}
|
|
|
|
NTSTATUS
|
|
NTAPI
|
|
FsRecExtFsControl(IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp)
|
|
{
|
|
PIO_STACK_LOCATION Stack;
|
|
NTSTATUS Status;
|
|
PDEVICE_OBJECT MountDevice;
|
|
PEXT_SUPER_BLOCK Spb = NULL;
|
|
ULONG SectorSize;
|
|
LARGE_INTEGER Offset;
|
|
BOOLEAN DeviceError = FALSE;
|
|
PAGED_CODE();
|
|
|
|
/* Get the I/O Stack and check the function type */
|
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
switch (Stack->MinorFunction)
|
|
{
|
|
case IRP_MN_MOUNT_VOLUME:
|
|
|
|
/* Assume failure */
|
|
Status = STATUS_UNRECOGNIZED_VOLUME;
|
|
|
|
/* Get the device object and request the sector size */
|
|
MountDevice = Stack->Parameters.MountVolume.DeviceObject;
|
|
if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
|
|
{
|
|
/* Try to read the superblock */
|
|
Offset.QuadPart = EXT_SB_OFFSET;
|
|
if (FsRecReadBlock(MountDevice,
|
|
&Offset,
|
|
EXT_SB_SIZE,
|
|
SectorSize,
|
|
(PVOID)&Spb,
|
|
&DeviceError))
|
|
{
|
|
/* Check if it's an actual EXT volume */
|
|
if (FsRecIsExtVolume(Spb))
|
|
{
|
|
/* It is! */
|
|
Status = STATUS_FS_DRIVER_REQUIRED;
|
|
}
|
|
}
|
|
|
|
/* Free the boot sector if we have one */
|
|
ExFreePool(Spb);
|
|
}
|
|
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\\Ext2fs");
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Invalid request */
|
|
Status = STATUS_INVALID_DEVICE_REQUEST;
|
|
}
|
|
|
|
/* Return Status */
|
|
return Status;
|
|
}
|
|
|
|
/* EOF */
|