From 1f2d67a841b7e427db7d98de502bba5c9575c1c5 Mon Sep 17 00:00:00 2001 From: Vincent Franchomme Date: Mon, 18 Nov 2024 21:27:16 +0100 Subject: [PATCH] [FS_REC] Rename Ext2 recognizer to Ext recognizer (#7497) 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. --- drivers/filesystems/fs_rec/CMakeLists.txt | 2 +- drivers/filesystems/fs_rec/{ext2.c => ext.c} | 24 ++++++++--------- drivers/filesystems/fs_rec/{ext2.h => ext.h} | 24 ++++++++--------- drivers/filesystems/fs_rec/fs_rec.c | 28 ++++++++++++++------ drivers/filesystems/fs_rec/fs_rec.h | 4 +-- 5 files changed, 47 insertions(+), 35 deletions(-) rename drivers/filesystems/fs_rec/{ext2.c => ext.c} (83%) rename drivers/filesystems/fs_rec/{ext2.h => ext.h} (59%) diff --git a/drivers/filesystems/fs_rec/CMakeLists.txt b/drivers/filesystems/fs_rec/CMakeLists.txt index c231d3d378d..d014a864719 100644 --- a/drivers/filesystems/fs_rec/CMakeLists.txt +++ b/drivers/filesystems/fs_rec/CMakeLists.txt @@ -2,7 +2,7 @@ list(APPEND SOURCE blockdev.c btrfs.c cdfs.c - ext2.c + ext.c fat.c fatx.c ffs.c diff --git a/drivers/filesystems/fs_rec/ext2.c b/drivers/filesystems/fs_rec/ext.c similarity index 83% rename from drivers/filesystems/fs_rec/ext2.c rename to drivers/filesystems/fs_rec/ext.c index 94464617e1b..40722e19b1d 100644 --- a/drivers/filesystems/fs_rec/ext2.c +++ b/drivers/filesystems/fs_rec/ext.c @@ -1,8 +1,8 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS File System Recognizer - * FILE: drivers/filesystems/fs_rec/ext2.c - * PURPOSE: EXT2 Recognizer + * FILE: drivers/filesystems/fs_rec/ext.c + * PURPOSE: EXT Recognizer * PROGRAMMER: Eric Kohl * Pierre Schweitzer (pierre@reactos.org) */ @@ -10,7 +10,7 @@ /* INCLUDES *****************************************************************/ #include "fs_rec.h" -#include "ext2.h" +#include "ext.h" #define NDEBUG #include @@ -19,21 +19,21 @@ BOOLEAN NTAPI -FsRecIsExt2Volume(IN PEXT2_SUPER_BLOCK SuperBlock) +FsRecIsExtVolume(IN PEXT_SUPER_BLOCK SuperBlock) { /* Just check for magic */ - return (SuperBlock->Magic == EXT2_SUPER_MAGIC); + return (SuperBlock->Magic == EXT_SUPER_MAGIC); } NTSTATUS NTAPI -FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) +FsRecExtFsControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) { PIO_STACK_LOCATION Stack; NTSTATUS Status; PDEVICE_OBJECT MountDevice; - PEXT2_SUPER_BLOCK Spb = NULL; + PEXT_SUPER_BLOCK Spb = NULL; ULONG SectorSize; LARGE_INTEGER Offset; BOOLEAN DeviceError = FALSE; @@ -53,16 +53,16 @@ FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject, if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize)) { /* Try to read the superblock */ - Offset.QuadPart = EXT2_SB_OFFSET; + Offset.QuadPart = EXT_SB_OFFSET; if (FsRecReadBlock(MountDevice, &Offset, - EXT2_SB_SIZE, + EXT_SB_SIZE, SectorSize, (PVOID)&Spb, &DeviceError)) { - /* Check if it's an actual EXT2 volume */ - if (FsRecIsExt2Volume(Spb)) + /* Check if it's an actual EXT volume */ + if (FsRecIsExtVolume(Spb)) { /* It is! */ Status = STATUS_FS_DRIVER_REQUIRED; diff --git a/drivers/filesystems/fs_rec/ext2.h b/drivers/filesystems/fs_rec/ext.h similarity index 59% rename from drivers/filesystems/fs_rec/ext2.h rename to drivers/filesystems/fs_rec/ext.h index 7ff0303fe3d..17fea26cd07 100644 --- a/drivers/filesystems/fs_rec/ext2.h +++ b/drivers/filesystems/fs_rec/ext.h @@ -1,13 +1,13 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS File System Recognizer - * FILE: drivers/filesystems/fs_rec/ext2.h - * PURPOSE: EXT2 Header File + * FILE: drivers/filesystems/fs_rec/ext.h + * PURPOSE: EXT Header File * PROGRAMMER: Pierre Schweitzer (pierre@reactos.org) */ #include -typedef struct _EXT2_SUPER_BLOCK { +typedef struct _EXT_SUPER_BLOCK { ULONG InodesCount; ULONG BlocksCount; ULONG ReservedBlocksCount; @@ -34,15 +34,15 @@ typedef struct _EXT2_SUPER_BLOCK { USHORT DefResUid; USHORT DefResGid; // Partial -} EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK; +} EXT_SUPER_BLOCK, *PEXT_SUPER_BLOCK; #include -C_ASSERT(FIELD_OFFSET(EXT2_SUPER_BLOCK, FreeInodesCount) == 0x10); -C_ASSERT(FIELD_OFFSET(EXT2_SUPER_BLOCK, BlocksPerGroup) == 0x20); -C_ASSERT(FIELD_OFFSET(EXT2_SUPER_BLOCK, WriteTime) == 0x30); -C_ASSERT(FIELD_OFFSET(EXT2_SUPER_BLOCK, LastCheck) == 0x40); -C_ASSERT(FIELD_OFFSET(EXT2_SUPER_BLOCK, DefResUid) == 0x50); +C_ASSERT(FIELD_OFFSET(EXT_SUPER_BLOCK, FreeInodesCount) == 0x10); +C_ASSERT(FIELD_OFFSET(EXT_SUPER_BLOCK, BlocksPerGroup) == 0x20); +C_ASSERT(FIELD_OFFSET(EXT_SUPER_BLOCK, WriteTime) == 0x30); +C_ASSERT(FIELD_OFFSET(EXT_SUPER_BLOCK, LastCheck) == 0x40); +C_ASSERT(FIELD_OFFSET(EXT_SUPER_BLOCK, DefResUid) == 0x50); -#define EXT2_SUPER_MAGIC 0xEF53 -#define EXT2_SB_OFFSET 0x400 -#define EXT2_SB_SIZE 0x400 +#define EXT_SUPER_MAGIC 0xEF53 +#define EXT_SB_OFFSET 0x400 +#define EXT_SB_SIZE 0x400 diff --git a/drivers/filesystems/fs_rec/fs_rec.c b/drivers/filesystems/fs_rec/fs_rec.c index 1dd5b4d2697..8274c459fa0 100644 --- a/drivers/filesystems/fs_rec/fs_rec.c +++ b/drivers/filesystems/fs_rec/fs_rec.c @@ -158,10 +158,10 @@ FsRecFsControl(IN PDEVICE_OBJECT DeviceObject, Status = FsRecUdfsFsControl(DeviceObject, Irp); break; - case FS_TYPE_EXT2: + case FS_TYPE_EXT: - /* Send EXT2 command */ - Status = FsRecExt2FsControl(DeviceObject, Irp); + /* Send EXT command */ + Status = FsRecExtFsControl(DeviceObject, Irp); break; case FS_TYPE_BTRFS: @@ -329,6 +329,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT CdfsObject; PDEVICE_OBJECT UdfsObject; PDEVICE_OBJECT FatObject; + PDEVICE_OBJECT ExtObject; PAGED_CODE(); @@ -430,17 +431,28 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, 0); if (NT_SUCCESS(Status)) DeviceCount++; - /* Register EXT2 */ + /* Register EXT */ Status = FsRecRegisterFs(DriverObject, NULL, - NULL, - L"\\Ext2fs", - L"\\FileSystem\\Ext2Recognizer", - FS_TYPE_EXT2, + &ExtObject, + L"\\Extfs", + L"\\FileSystem\\ExtRecognizer", + FS_TYPE_EXT, FILE_DEVICE_DISK_FILE_SYSTEM, 0); if (NT_SUCCESS(Status)) DeviceCount++; + /* Register EXT for CDs */ + Status = FsRecRegisterFs(DriverObject, + ExtObject, + NULL, + L"\\ExtfsCdrom", + L"\\FileSystem\\ExtCdRomRecognizer", + FS_TYPE_EXT, + FILE_DEVICE_CD_ROM_FILE_SYSTEM, + 0); + if (NT_SUCCESS(Status)) DeviceCount++; + /* Register BTRFS */ Status = FsRecRegisterFs(DriverObject, NULL, diff --git a/drivers/filesystems/fs_rec/fs_rec.h b/drivers/filesystems/fs_rec/fs_rec.h index fe56d1ac18f..db3112b06c7 100644 --- a/drivers/filesystems/fs_rec/fs_rec.h +++ b/drivers/filesystems/fs_rec/fs_rec.h @@ -173,7 +173,7 @@ typedef enum _FILE_SYSTEM_TYPE FS_TYPE_NTFS, FS_TYPE_CDFS, FS_TYPE_UDFS, - FS_TYPE_EXT2, + FS_TYPE_EXT, FS_TYPE_BTRFS, FS_TYPE_REISERFS, FS_TYPE_FFS, @@ -227,7 +227,7 @@ FsRecUdfsFsControl( NTSTATUS NTAPI -FsRecExt2FsControl( +FsRecExtFsControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp );