Spoof GPT partitions of type 21686148-6449-6e6f-744e-656564454649 (a.k.a.
authorkrw <krw@openbsd.org>
Sat, 8 May 2021 16:41:24 +0000 (16:41 +0000)
committerkrw <krw@openbsd.org>
Sat, 8 May 2021 16:41:24 +0000 (16:41 +0000)
"IdontNeedEFI", a.k.a. "BIOS boot") as FS_BOOT. Often used to contain the second
stage boot loader binary on disk images.

Makes it easier to recognize/overwrite/remove the contents.

Not yet supported in fdisk(8).

Example image provided by mlarkin@

sys/kern/subr_disk.c
sys/sys/disklabel.h

index 7125e3f..40397a9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: subr_disk.c,v 1.238 2021/01/19 19:36:48 mvs Exp $     */
+/*     $OpenBSD: subr_disk.c,v 1.239 2021/05/08 16:41:24 krw Exp $     */
 /*     $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $  */
 
 /*
@@ -697,7 +697,7 @@ gpt_get_fstype(struct uuid *uuid_part)
 {
        static int init = 0;
        static struct uuid uuid_openbsd, uuid_msdos, uuid_chromefs,
-           uuid_linux, uuid_hfs, uuid_unused, uuid_efi_system;
+           uuid_linux, uuid_hfs, uuid_unused, uuid_efi_system, uuid_bios_boot;
        static const uint8_t gpt_uuid_openbsd[] = GPT_UUID_OPENBSD;
        static const uint8_t gpt_uuid_msdos[] = GPT_UUID_MSDOS;
        static const uint8_t gpt_uuid_chromerootfs[] = GPT_UUID_CHROMEROOTFS;
@@ -705,6 +705,7 @@ gpt_get_fstype(struct uuid *uuid_part)
        static const uint8_t gpt_uuid_hfs[] = GPT_UUID_APPLE_HFS;
        static const uint8_t gpt_uuid_unused[] = GPT_UUID_UNUSED;
        static const uint8_t gpt_uuid_efi_system[] = GPT_UUID_EFI_SYSTEM;
+       static const uint8_t gpt_uuid_bios_boot[] = GPT_UUID_BIOS_BOOT;
 
        if (init == 0) {
                uuid_dec_be(gpt_uuid_openbsd, &uuid_openbsd);
@@ -714,6 +715,7 @@ gpt_get_fstype(struct uuid *uuid_part)
                uuid_dec_be(gpt_uuid_hfs, &uuid_hfs);
                uuid_dec_be(gpt_uuid_unused, &uuid_unused);
                uuid_dec_be(gpt_uuid_efi_system, &uuid_efi_system);
+               uuid_dec_be(gpt_uuid_bios_boot, &uuid_bios_boot);
                init = 1;
        }
 
@@ -731,6 +733,8 @@ gpt_get_fstype(struct uuid *uuid_part)
                return FS_HFS;
        else if (!memcmp(uuid_part, &uuid_efi_system, sizeof(struct uuid)))
                return FS_MSDOS;
+       else if (!memcmp(uuid_part, &uuid_bios_boot, sizeof(struct uuid)))
+               return FS_BOOT;
        else
                return FS_OTHER;
 }
index f1034e6..db8656e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: disklabel.h,v 1.77 2020/11/14 20:53:31 guenther Exp $ */
+/*     $OpenBSD: disklabel.h,v 1.78 2021/05/08 16:41:25 krw Exp $      */
 /*     $NetBSD: disklabel.h,v 1.41 1996/05/10 23:07:37 mark Exp $      */
 
 /*
@@ -441,6 +441,9 @@ struct gpt_partition {
 #define GPT_UUID_APPLE_UFS \
     { 0x55, 0x46, 0x53, 0x00, 0x00, 0x00, 0x11, 0xaa, \
       0xaa, 0x11, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac }
+#define GPT_UUID_BIOS_BOOT \
+    { 0x21, 0x68, 0x61, 0x48, 0x64, 0x49, 0x6e, 0x6f, \
+      0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 }
 
 /* DOS partition table -- located at start of some disks. */
 #define        DOS_LABELSECTOR 1