From 8ac3a0e4ad335171cc67c4b8bc37e0d344ccb199 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Fri, 3 Jun 2016 20:34:09 +0100 Subject: [PATCH] Recognise GRUB2 core.img (#766989) Recognise GRUB2 core.img boot code written to a partition without a file system. Such setups are possible/likely with GPT partitioned disks as there is a specific partition type reserved for it [1][2]: 21686148-6449-6E6F-744E-656564454649 (BIOS Boot partition) [1] GUID Partition Table, Partition types https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs [2] BIOS boot partition https://en.wikipedia.org/wiki/BIOS_boot_partition Bug 766989 - zfsonline support - need file system name support for ZFS type codes --- include/Utils.h | 13 +++++++------ src/GParted_Core.cc | 32 ++++++++++++++++++++------------ src/Utils.cc | 2 ++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/include/Utils.h b/include/Utils.h index 22567881..e14a5279 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -90,14 +90,15 @@ enum FILESYSTEM // Recognised signatures but otherwise unsupported file system types FS_BITLOCKER = 25, - FS_LINUX_SWRAID = 26, - FS_LINUX_SWSUSPEND = 27, - FS_REFS = 28, - FS_ZFS = 29, + FS_GRUB2_CORE_IMG = 26, + FS_LINUX_SWRAID = 27, + FS_LINUX_SWSUSPEND = 28, + FS_REFS = 29, + FS_ZFS = 30, // Partition space usage colours - FS_USED = 30, - FS_UNUSED = 31 + FS_USED = 31, + FS_UNUSED = 32 } ; enum SIZE_UNIT diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 9768ab80..5b8c0a8c 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -1548,19 +1548,27 @@ FILESYSTEM GParted_Core::detect_filesystem_internal( PedDevice * lp_device, PedP const char * sig2; FILESYSTEM fstype; } signatures[] = { - //offset1, sig1 , offset2, sig2 , fstype - { 65536LL, "ReIsEr4" , 0LL, NULL , FS_REISER4 }, - { 512LL, "LABELONE" , 536LL, "LVM2", FS_LVM2_PV }, - { 0LL, "LUKS\xBA\xBE", 0LL, NULL , FS_LUKS }, - { 65600LL, "_BHRfS_M" , 0LL, NULL , FS_BTRFS }, - { 3LL, "-FVE-FS-" , 0LL, NULL , FS_BITLOCKER }, - { 1030LL, "\x34\x34" , 0LL, NULL , FS_NILFS2 } + //offset1, sig1 , offset2, sig2 , fstype + { 65536LL, "ReIsEr4" , 0LL, NULL , FS_REISER4 }, + { 512LL, "LABELONE" , 536LL, "LVM2", FS_LVM2_PV }, + { 0LL, "LUKS\xBA\xBE" , 0LL, NULL , FS_LUKS }, + { 65600LL, "_BHRfS_M" , 0LL, NULL , FS_BTRFS }, + { 3LL, "-FVE-FS-" , 0LL, NULL , FS_BITLOCKER }, + { 1030LL, "\x34\x34" , 0LL, NULL , FS_NILFS2 }, + { 0LL, "\x52\x56\xBE\x1B", 0LL, NULL , FS_GRUB2_CORE_IMG }, + { 0LL, "\x52\x56\xBE\x6F", 0LL, NULL , FS_GRUB2_CORE_IMG }, + { 0LL, "\x52\xE8\x28\x01", 0LL, NULL , FS_GRUB2_CORE_IMG }, + { 0LL, "\x52\xBF\xF4\x81", 0LL, NULL , FS_GRUB2_CORE_IMG } }; - // Reference: - // Detecting BitLocker - // http://blogs.msdn.com/b/si_team/archive/2006/10/26/detecting-bitlocker.aspx - // Consider validation of BIOS Parameter Block fields as unnecessary for - // simple recognition only of BitLocker. + // For simple BitLocker recognition consider validation of BIOS Parameter block + // fields unnecessary. + // * Detecting BitLocker + // http://blogs.msdn.com/b/si_team/archive/2006/10/26/detecting-bitlocker.aspx + // + // Recognise GRUB2 core.img just by any of the possible first 4 bytes of x86 CPU + // instructions it starts with. + // * bootinfoscript v0.74 line 1963 [GRUB2 core.img possible staring 4 bytes] + // https://github.com/arvidjaar/bootinfoscript/blob/b1f711e39d7aa4021f4ad3d31468a8b1e1b3fda7/bootinfoscript#L1963 for ( unsigned int i = 0 ; i < sizeof( signatures ) / sizeof( signatures[0] ) ; i ++ ) { diff --git a/src/Utils.cc b/src/Utils.cc index 165c13bb..8a8da5e9 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -115,6 +115,7 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem ) case FS_UNUSED : return "#FFFFFF" ; //white case FS_LVM2_PV : return "#B39169" ; //face skin dark case FS_BITLOCKER : return "#494066" ; //purple shadow + case FS_GRUB2_CORE_IMG : return "#666666" ; //~ dark gray case FS_LUKS : return "#625B81" ; //purple dark case FS_LINUX_SWRAID : return "#5A4733" ; // ~ dark brown case FS_LINUX_SWSUSPEND : return "#884631" ; //red dark @@ -291,6 +292,7 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem ) case FS_UNUSED : return _("unused") ; case FS_LVM2_PV : return "lvm2 pv" ; case FS_BITLOCKER : return "bitlocker" ; + case FS_GRUB2_CORE_IMG : return "grub2 core.img"; case FS_LUKS : return "luks"; case FS_LINUX_SWRAID : return "linux-raid" ; case FS_LINUX_SWSUSPEND : return "linux-suspend" ;