Add bcachefs detection (!123)

Uses blkid from util-linux >= 2.39 [1] for detection of bcachefs file
systems.

Use util-linux's FS images when testing GParted detection.
    # wget https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/plain/tests/ts/blkid/images-fs/bcachefs.img.xz
    # zxcat bcachefs.img.xz > /dev/sdb1
    # wget https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/plain/tests/ts/blkid/images-fs/bcachefs-2.img.xz
    # zxcat bcachefs-2.img.xz > /dev/sdb2
    # blkid /dev/sdb1 /dev/sdb2
    /dev/sdb1: UUID="46bd306f-80ad-4cd0-af4f-147e7d85f393" LABEL="Label" BLOCK_SIZE="4096" UUID_SUB="72a60ede-4cb6-4374-aa70-cb38a50af5ef" TYPE="bcachefs" PARTUUID="bd47302a-b33b-47a5-83a1-ba89f52f2a45"
    /dev/sdb2: UUID="4fa11b1e-75e6-4210-9167-34e1769c0fe1" LABEL="Label" BLOCK_SIZE="512" UUID_SUB="525fa857-174a-4d3f-be33-6fe60441de7c" LABEL_SUB="Device Label" TYPE="bcachefs" PARTUUID="6a46a084-5d3b-408a-bba7-351daaea1c66"

[1] Util-linux 2.39 Release Notes
    https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.39/v2.39-ReleaseNotes
    "blkid(8) and libblkid:

       * supports bcachefs
    "

Closes !123 - Add support for bcachefs, single device file systems only
This commit is contained in:
Mike Fleetwood 2024-02-26 21:47:15 +00:00
parent fe84c574d5
commit c9b991cc95
3 changed files with 40 additions and 35 deletions

View File

@ -71,45 +71,46 @@ enum FSType
FS_EXTENDED = 6, FS_EXTENDED = 6,
// Fully supported file system types // Fully supported file system types
FS_BTRFS = 7, FS_BCACHEFS = 7,
FS_EXFAT = 8, /* Also known as fat64 */ FS_BTRFS = 8,
FS_EXT2 = 9, FS_EXFAT = 9, /* Also known as fat64 */
FS_EXT3 = 10, FS_EXT2 = 10,
FS_EXT4 = 11, FS_EXT3 = 11,
FS_F2FS = 12, FS_EXT4 = 12,
FS_FAT16 = 13, FS_F2FS = 13,
FS_FAT32 = 14, FS_FAT16 = 14,
FS_HFS = 15, FS_FAT32 = 15,
FS_HFSPLUS = 16, FS_HFS = 16,
FS_JFS = 17, FS_HFSPLUS = 17,
FS_LINUX_SWAP = 18, FS_JFS = 18,
FS_LUKS = 19, FS_LINUX_SWAP = 19,
FS_LVM2_PV = 20, FS_LUKS = 20,
FS_MINIX = 21, FS_LVM2_PV = 21,
FS_NILFS2 = 22, FS_MINIX = 22,
FS_NTFS = 23, FS_NILFS2 = 23,
FS_REISER4 = 24, FS_NTFS = 24,
FS_REISERFS = 25, FS_REISER4 = 25,
FS_UDF = 26, FS_REISERFS = 26,
FS_XFS = 27, FS_UDF = 27,
FS_XFS = 28,
// Other recognised file system types // Other recognised file system types
FS_APFS = 28, FS_APFS = 29,
FS_ATARAID = 29, FS_ATARAID = 30,
FS_BCACHE = 30, FS_BCACHE = 31,
FS_BITLOCKER = 31, FS_BITLOCKER = 32,
FS_GRUB2_CORE_IMG = 32, FS_GRUB2_CORE_IMG = 33,
FS_ISO9660 = 33, FS_ISO9660 = 34,
FS_JBD = 34, FS_JBD = 35,
FS_LINUX_SWRAID = 35, FS_LINUX_SWRAID = 36,
FS_LINUX_SWSUSPEND = 36, FS_LINUX_SWSUSPEND = 37,
FS_REFS = 37, FS_REFS = 38,
FS_UFS = 38, FS_UFS = 39,
FS_ZFS = 39, FS_ZFS = 40,
// Partition space usage colours // Partition space usage colours
FS_USED = 40, FS_USED = 41,
FS_UNUSED = 41 FS_UNUSED = 42
} ; } ;
enum SIZE_UNIT enum SIZE_UNIT

View File

@ -1246,6 +1246,8 @@ FSType GParted_Core::detect_filesystem(const PedDevice *lp_device, const PedPart
{ {
if ( fsname == "extended" ) if ( fsname == "extended" )
return FS_EXTENDED; return FS_EXTENDED;
else if (fsname == "bcachefs")
return FS_BCACHEFS;
else if ( fsname == "btrfs" ) else if ( fsname == "btrfs" )
return FS_BTRFS; return FS_BTRFS;
else if ( fsname == "exfat" ) else if ( fsname == "exfat" )

View File

@ -153,6 +153,7 @@ Glib::ustring Utils::get_color(FSType fstype)
case FS_CLEARED: return "#000000"; // Black case FS_CLEARED: return "#000000"; // Black
case FS_OTHER: return "#000000"; // Black (never displayed) case FS_OTHER: return "#000000"; // Black (never displayed)
case FS_EXTENDED: return "#95E3E5"; // Cyan Hilight [*] case FS_EXTENDED: return "#95E3E5"; // Cyan Hilight [*]
case FS_BCACHEFS: return "#C26825"; // Orange Dark [*]
case FS_BTRFS: return "#E58749"; // Orange Medium [*] case FS_BTRFS: return "#E58749"; // Orange Medium [*]
case FS_EXFAT: return "#267726"; // Accent Green Dark case FS_EXFAT: return "#267726"; // Accent Green Dark
case FS_EXT2: return "#7590AE"; // Blue Medium case FS_EXT2: return "#7590AE"; // Blue Medium
@ -347,6 +348,7 @@ const Glib::ustring Utils::get_filesystem_string(FSType fstype)
*/ */
return _("cleared"); return _("cleared");
case FS_EXTENDED: return "extended"; case FS_EXTENDED: return "extended";
case FS_BCACHEFS: return "bcachefs";
case FS_BTRFS: return "btrfs"; case FS_BTRFS: return "btrfs";
case FS_EXFAT: return "exfat"; case FS_EXFAT: return "exfat";
case FS_EXT2: return "ext2"; case FS_EXT2: return "ext2";