From cff159a1d18982e636cb5fbc0be8987beb332cbf Mon Sep 17 00:00:00 2001 From: Bo Branten Date: Tue, 25 Jun 2024 14:07:46 +0200 Subject: [PATCH] Ext2Mgr list other common filesystems --- Ext2Mgr/enumDisk.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++ Ext2Mgr/super.h | 21 +++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/Ext2Mgr/enumDisk.cpp b/Ext2Mgr/enumDisk.cpp index 6558277..b4ad0b5 100644 --- a/Ext2Mgr/enumDisk.cpp +++ b/Ext2Mgr/enumDisk.cpp @@ -2189,6 +2189,57 @@ Ext2QueryVolumeFS( // Show swap partitions as unused. volume->FssInfo.AvailableAllocationUnits = volume->FssInfo.TotalAllocationUnits; volume->bRecognized = TRUE; + goto errorout; + } + + if (*((PULONG)&buffer[XFS_MAGIC_OFFSET]) == XFS_SB_MAGIC_LE) { + volume->FsaInfo.FileSystemNameLength = 6; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'X'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'F'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'S'; + goto errorout; + } + + // The LVM superblock is stored in one of the first 4 sectors as an option to pvcreate + if ((memcmp(&buffer[0*512], LVM_MAGIC, 8) == 0) || + (memcmp(&buffer[1*512], LVM_MAGIC, 8) == 0) || + (memcmp(&buffer[2*512], LVM_MAGIC, 8) == 0) || + (memcmp(&buffer[3*512], LVM_MAGIC, 8) == 0)) { + volume->FsaInfo.FileSystemNameLength = 6; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'L'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'V'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'M'; + goto errorout; + } + + if (*((PULONG)&buffer[512]) == BSD_DISKMAGIC) { + volume->FsaInfo.FileSystemNameLength = 6; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'B'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'S'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'D'; + goto errorout; + } + + Ext2Read(Handle, FALSE, 512, (ULONGLONG)BTRFS_SUPER_BLOCK_OFFSET, 4096, buffer); + + if (*((PULONGLONG)&buffer[BTRFS_MAGIC_OFFSET]) == BTRFS_MAGIC) { + volume->FsaInfo.FileSystemNameLength = 10; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'B'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'T'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'R'; + volume->FsaInfo.FileSystemName[3] = (WCHAR)'F'; + volume->FsaInfo.FileSystemName[4] = (WCHAR)'S'; + goto errorout; + } + + Ext2Read(Handle, FALSE, 512, (ULONGLONG)RAID_SUPER_BLOCK_OFFSET, 4096, buffer); + + if (*((PULONG)&buffer[RAID_MAGIC_OFFSET]) == RAID_MAGIC) { + volume->FsaInfo.FileSystemNameLength = 8; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'R'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'A'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'I'; + volume->FsaInfo.FileSystemName[3] = (WCHAR)'D'; } errorout: diff --git a/Ext2Mgr/super.h b/Ext2Mgr/super.h index 31be164..c1c5e1e 100644 --- a/Ext2Mgr/super.h +++ b/Ext2Mgr/super.h @@ -1,7 +1,7 @@ #ifndef SUPER_H #define SUPER_H -/* The following is a subset of ext4.h used by the application */ +/* This is a subset of ext4.h used by the application */ typedef unsigned char __u8; typedef unsigned short __u16, __le16; @@ -232,4 +232,23 @@ struct ext4_super_block { EXT4_FEATURE_INCOMPAT_FLEX_BG| \ EXT4_FEATURE_INCOMPAT_CSUM_SEED) +/* Definitions for other common filesystems so the application can list them. */ + +#define BTRFS_MAGIC 0x4D5F53665248425FULL /* '_BHRfS_M' */ +#define BTRFS_MAGIC_OFFSET 64 +#define BTRFS_SUPER_BLOCK_OFFSET 0x10000 + +#define XFS_SB_MAGIC_BE 0x58465342 /* 'XFSB' */ +#define XFS_SB_MAGIC_LE 0x42534658 /* 'BSFX' */ +#define XFS_MAGIC_OFFSET 0 +#define XFS_SUPER_BLOCK_OFFSET 0 + +#define RAID_MAGIC 0xa92b4efc +#define RAID_MAGIC_OFFSET 0 +#define RAID_SUPER_BLOCK_OFFSET 0x1000 + +#define LVM_MAGIC "LABELONE" + +#define BSD_DISKMAGIC 0x82564557 /* The disk magic number */ + #endif /* SUPER_H */