Skip to content

Commit

Permalink
Ext4's typical GPT partition type not recognized
Browse files Browse the repository at this point in the history
Adding additional entries to the efi conversion array will help prevent
the overwriting of the GPTs of disks with in-use file systems in more
cases. Most notably, this adds partition type 8300 "Linux filesystem"
(0FC63DAF-8483-4772-8E79-3D69D8477DE4), which is often used for ext4 and
btrfs, among others.

This commit itself does nothing to address the underlying problematic
behavior that check_slice() isn't called on partitions of an
unrecognized type, even when they contain a currently mounted file
system.

The additional entries were derived from these two resources:
https://en.wikipedia.org/wiki/GUID_Partition_Table
http://sourceforge.net/p/gptfdisk/code/ci/master/tree/parttypes.cc

Signed-off-by: ilovezfs <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#4016
  • Loading branch information
ilovezfs authored and behlendorf committed Dec 4, 2015
1 parent fc80384 commit 917b8c5
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 1 deletion.
126 changes: 126 additions & 0 deletions include/sys/efi_partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,132 @@ typedef struct efi_gpe_Attrs {
#define EFI_FREEBSD_ZFS { 0x516e7cba, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
{ 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }

/* From Wikipedia */

#define EFI_BIOS_BOOT { 0x21686148, 0x6449, 0x6e6f, 0x74, 0x4e, \
{ 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } }
#define EFI_INTC_RS { 0xd3bfe2de, 0x3daf, 0x11df, 0xba, 0x40, \
{ 0xe3, 0xa5, 0x56, 0xd8, 0x95, 0x93 } }
#define EFI_SNE_BOOT { 0xf4019732, 0x066e, 0x4e12, 0x82, 0x73, \
{ 0x34, 0x6c, 0x56, 0x41, 0x49, 0x4f } }
#define EFI_LENOVO_BOOT { 0xbfbfafe7, 0xa34f, 0x448a, 0x9a, 0x5b, \
{ 0x62, 0x13, 0xeb, 0x73, 0x6c, 0x22 } }
#define EFI_MSFT_LDMM { 0x5808c8aa, 0x7e8f, 0x42e0, 0x85, 0xd2, \
{ 0xe1, 0xe9, 0x04, 0x34, 0xcf, 0xb3 } }
#define EFI_MSFT_LDMD { 0xaf9b60a0, 0x1431, 0x4f62, 0xbc, 0x68, \
{ 0x33, 0x11, 0x71, 0x4a, 0x69, 0xad } }
#define EFI_MSFT_RE { 0xde94bba4, 0x06d1, 0x4d40, 0xa1, 0x6a, \
{ 0xbf, 0xd5, 0x01, 0x79, 0xd6, 0xac } }
#define EFI_IBM_GPFS { 0x37affc90, 0xef7d, 0x4e96, 0x91, 0xc3, \
{ 0x2d, 0x7a, 0xe0, 0x55, 0xb1, 0x74 } }
#define EFI_MSFT_STORAGESPACES { 0xe75caf8f, 0xf680, 0x4cee, 0xaf, 0xa3, \
{ 0xb0, 0x01, 0xe5, 0x6e, 0xfc, 0x2d } }
#define EFI_HPQ_DATA { 0x75894c1e, 0x3aeb, 0x11d3, 0xb7, 0xc1, \
{ 0x7b, 0x03, 0xa0, 0x00, 0x00, 0x00 } }
#define EFI_HPQ_SVC { 0xe2a1e728, 0x32e3, 0x11d6, 0xa6, 0x82, \
{ 0x7b, 0x03, 0xa0, 0x00, 0x00, 0x00 } }
#define EFI_RHT_DATA { 0x0fc63daf, 0x8483, 0x4772, 0x8e, 0x79, \
{ 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4 } }
#define EFI_RHT_HOME { 0x933ac7e1, 0x2eb4, 0x4f13, 0xb8, 0x44, \
{ 0x0e, 0x14, 0xe2, 0xae, 0xf9, 0x15 } }
#define EFI_RHT_SRV { 0x3b8f8425, 0x20e0, 0x4f3b, 0x90, 0x7f, \
{ 0x1a, 0x25, 0xa7, 0x6f, 0x98, 0xe8 } }
#define EFI_RHT_DMCRYPT { 0x7ffec5c9, 0x2d00, 0x49b7, 0x89, 0x41, \
{ 0x3e, 0xa1, 0x0a, 0x55, 0x86, 0xb7 } }
#define EFI_RHT_LUKS { 0xca7d7ccb, 0x63ed, 0x4c53, 0x86, 0x1c, \
{ 0x17, 0x42, 0x53, 0x60, 0x59, 0xcc } }
#define EFI_FREEBSD_DISKLABEL { 0x516e7cb4, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
{ 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
#define EFI_AAPL_RAID { 0x52414944, 0x0000, 0x11aa, 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
#define EFI_AAPL_RAIDOFFLINE { 0x52414944, 0x5f4f, 0x11aa, 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
#define EFI_AAPL_BOOT { 0x426f6f74, 0x0000, 0x11aa, 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
#define EFI_AAPL_LABEL { 0x4c616265, 0x6c00, 0x11aa, 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
#define EFI_AAPL_TVRECOVERY { 0x5265636f, 0x7665, 0x11aa, 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
#define EFI_AAPL_CORESTORAGE { 0x53746f72, 0x6167, 0x11aa, 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
#define EFI_NETBSD_SWAP { 0x49f48d32, 0xb10e, 0x11dc, 0xb9, 0x9b, \
{ 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } }
#define EFI_NETBSD_FFS { 0x49f48d5a, 0xb10e, 0x11dc, 0xb9, 0x9b, \
{ 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } }
#define EFI_NETBSD_LFS { 0x49f48d82, 0xb10e, 0x11dc, 0xb9, 0x9b, \
{ 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } }
#define EFI_NETBSD_RAID { 0x49f48daa, 0xb10e, 0x11dc, 0xb9, 0x9b, \
{ 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } }
#define EFI_NETBSD_CAT { 0x2db519c4, 0xb10f, 0x11dc, 0xb9, 0x9b, \
{ 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } }
#define EFI_NETBSD_CRYPT { 0x2db519ec, 0xb10f, 0x11dc, 0xb9, 0x9b, \
{ 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } }
#define EFI_GOOG_KERN { 0xfe3a2a5d, 0x4f32, 0x41a7, 0xb7, 0x25, \
{ 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09 } }
#define EFI_GOOG_ROOT { 0x3cb8e202, 0x3b7e, 0x47dd, 0x8a, 0x3c, \
{ 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec } }
#define EFI_GOOG_RESV { 0x2e0a753d, 0x9e48, 0x43b0, 0x83, 0x37, \
{ 0xb1, 0x51, 0x92, 0xcb, 0x1b, 0x5e } }
#define EFI_HAIKU_BFS { 0x42465331, 0x3ba3, 0x10f1, 0x80, 0x2a, \
{ 0x48, 0x61, 0x69, 0x6b, 0x75, 0x21 } }
#define EFI_MIDNIGHTBSD_BOOT { 0x85d5e45e, 0x237c, 0x11e1, 0xb4, 0xb3, \
{ 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } }
#define EFI_MIDNIGHTBSD_DATA { 0x85d5e45a, 0x237c, 0x11e1, 0xb4, 0xb3, \
{ 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } }
#define EFI_MIDNIGHTBSD_SWAP { 0x85d5e45b, 0x237c, 0x11e1, 0xb4, 0xb3, \
{ 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } }
#define EFI_MIDNIGHTBSD_UFS { 0x0394ef8b, 0x237e, 0x11e1, 0xb4, 0xb3, \
{ 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } }
#define EFI_MIDNIGHTBSD_VINUM { 0x85d5e45c, 0x237c, 0x11e1, 0xb4, 0xb3, \
{ 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } }
#define EFI_MIDNIGHTBSD_ZFS { 0x85d5e45d, 0x237c, 0x11e1, 0xb4, 0xb3, \
{ 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } }
#define EFI_CEPH_JOURNAL { 0x45b0969e, 0x9b03, 0x4f30, 0xb4, 0xc6, \
{ 0xb4, 0xb8, 0x0c, 0xef, 0xf1, 0x06 } }
#define EFI_CEPH_DMCRYPTJOURNAL { 0x45b0969e, 0x9b03, 0x4f30, 0xb4, 0xc6, \
{ 0x5e, 0xc0, 0x0c, 0xef, 0xf1, 0x06 } }
#define EFI_CEPH_OSD { 0x4fbd7e29, 0x9d25, 0x41b8, 0xaf, 0xd0, \
{ 0x06, 0x2c, 0x0c, 0xef, 0xf0, 0x5d } }
#define EFI_CEPH_DMCRYPTOSD { 0x4fbd7e29, 0x9d25, 0x41b8, 0xaf, 0xd0, \
{ 0x5e, 0xc0, 0x0c, 0xef, 0xf0, 0x5d } }
#define EFI_CEPH_CREATE { 0x89c57f98, 0x2fe5, 0x4dc0, 0x89, 0xc1, \
{ 0xf3, 0xad, 0x0c, 0xef, 0xf2, 0xbe } }
#define EFI_CEPH_DMCRYPTCREATE { 0x89c57f98, 0x2fe5, 0x4dc0, 0x89, 0xc1, \
{ 0x5e, 0xc0, 0x0c, 0xef, 0xf2, 0xbe } }
#define EFI_OPENBSD_DISKLABEL { 0x824cc7a0, 0x36a8, 0x11e3, 0x89, 0x0a, \
{ 0x95, 0x25, 0x19, 0xad, 0x3f, 0x61 } }
#define EFI_BBRY_QNX { 0xcef5a9ad, 0x73bc, 0x4601, 0x89, 0xf3, \
{ 0xcd, 0xee, 0xee, 0xe3, 0x21, 0xa1 } }
#define EFI_BELL_PLAN9 { 0xc91818f9, 0x8025, 0x47af, 0x89, 0xd2, \
{ 0xf0, 0x30, 0xd7, 0x00, 0x0c, 0x2c } }
#define EFI_VMW_KCORE { 0x9d275380, 0x40ad, 0x11db, 0xbf, 0x97, \
{ 0x00, 0x0c, 0x29, 0x11, 0xd1, 0xb8 } }
#define EFI_VMW_VMFS { 0xaa31e02a, 0x400f, 0x11db, 0x95, 0x90, \
{ 0x00, 0x0c, 0x29, 0x11, 0xd1, 0xb8 } }
#define EFI_VMW_RESV { 0x9198effc, 0x31c0, 0x11db, 0x8f, 0x78, \
{ 0x00, 0x0c, 0x29, 0x11, 0xd1, 0xb8 } }

/* From GPT fdisk */

#define EFI_RHT_ROOTX86 { 0x44479540, 0xf297, 0x41b2, 0x9a, 0xf7, \
{ 0xd1, 0x31, 0xd5, 0xf0, 0x45, 0x8a } }
#define EFI_RHT_ROOTAMD64 { 0x4f68bce3, 0xe8cd, 0x4db1, 0x96, 0xe7, \
{ 0xfb, 0xca, 0xf9, 0x84, 0xb7, 0x09 } }
#define EFI_RHT_ROOTARM { 0x69dad710, 0x2ce4, 0x4e3c, 0xb1, 0x6c, \
{ 0x21, 0xa1, 0xd4, 0x9a, 0xbe, 0xd3 } }
#define EFI_RHT_ROOTARM64 { 0xb921b045, 0x1df0, 0x41c3, 0xaf, 0x44, \
{ 0x4c, 0x6f, 0x28, 0x0d, 0x3f, 0xae } }
#define EFI_ACRONIS_SECUREZONE { 0x0311fc50, 0x01ca, 0x4725, 0xad, 0x77, \
{ 0x9a, 0xdb, 0xb2, 0x0a, 0xce, 0x98 } }
#define EFI_ONIE_BOOT { 0x7412f7d5, 0xa156, 0x4b13, 0x81, 0xdc, \
{ 0x86, 0x71, 0x74, 0x92, 0x93, 0x25 } }
#define EFI_ONIE_CONFIG { 0xd4e6e2cd, 0x4469, 0x46f3, 0xb5, 0xcb, \
{ 0x1b, 0xff, 0x57, 0xaf, 0xc1, 0x49 } }
#define EFI_IBM_PPRPBOOT { 0x9e1a2d38, 0xc612, 0x4316, 0xaa, 0x26, \
{ 0x8b, 0x49, 0x52, 0x1e, 0x5a, 0x8b } }
#define EFI_FREEDESKTOP_BOOT { 0xbc13c2ff, 0x59e6, 0x4262, 0xa3, 0x52, \
{ 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72 } }

/* minimum # of bytes for partition table entires, per EFI spec */
#define EFI_MIN_ARRAY_SIZE (16 * 1024)

Expand Down
62 changes: 61 additions & 1 deletion lib/libefi/rdwr_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,67 @@ static struct uuid_to_ptag {
{ EFI_FREEBSD_SWAP },
{ EFI_FREEBSD_UFS },
{ EFI_FREEBSD_VINUM },
{ EFI_FREEBSD_ZFS }
{ EFI_FREEBSD_ZFS },
{ EFI_BIOS_BOOT },
{ EFI_INTC_RS },
{ EFI_SNE_BOOT },
{ EFI_LENOVO_BOOT },
{ EFI_MSFT_LDMM },
{ EFI_MSFT_LDMD },
{ EFI_MSFT_RE },
{ EFI_IBM_GPFS },
{ EFI_MSFT_STORAGESPACES },
{ EFI_HPQ_DATA },
{ EFI_HPQ_SVC },
{ EFI_RHT_DATA },
{ EFI_RHT_HOME },
{ EFI_RHT_SRV },
{ EFI_RHT_DMCRYPT },
{ EFI_RHT_LUKS },
{ EFI_FREEBSD_DISKLABEL },
{ EFI_AAPL_RAID },
{ EFI_AAPL_RAIDOFFLINE },
{ EFI_AAPL_BOOT },
{ EFI_AAPL_LABEL },
{ EFI_AAPL_TVRECOVERY },
{ EFI_AAPL_CORESTORAGE },
{ EFI_NETBSD_SWAP },
{ EFI_NETBSD_FFS },
{ EFI_NETBSD_LFS },
{ EFI_NETBSD_RAID },
{ EFI_NETBSD_CAT },
{ EFI_NETBSD_CRYPT },
{ EFI_GOOG_KERN },
{ EFI_GOOG_ROOT },
{ EFI_GOOG_RESV },
{ EFI_HAIKU_BFS },
{ EFI_MIDNIGHTBSD_BOOT },
{ EFI_MIDNIGHTBSD_DATA },
{ EFI_MIDNIGHTBSD_SWAP },
{ EFI_MIDNIGHTBSD_UFS },
{ EFI_MIDNIGHTBSD_VINUM },
{ EFI_MIDNIGHTBSD_ZFS },
{ EFI_CEPH_JOURNAL },
{ EFI_CEPH_DMCRYPTJOURNAL },
{ EFI_CEPH_OSD },
{ EFI_CEPH_DMCRYPTOSD },
{ EFI_CEPH_CREATE },
{ EFI_CEPH_DMCRYPTCREATE },
{ EFI_OPENBSD_DISKLABEL },
{ EFI_BBRY_QNX },
{ EFI_BELL_PLAN9 },
{ EFI_VMW_KCORE },
{ EFI_VMW_VMFS },
{ EFI_VMW_RESV },
{ EFI_RHT_ROOTX86 },
{ EFI_RHT_ROOTAMD64 },
{ EFI_RHT_ROOTARM },
{ EFI_RHT_ROOTARM64 },
{ EFI_ACRONIS_SECUREZONE },
{ EFI_ONIE_BOOT },
{ EFI_ONIE_CONFIG },
{ EFI_IBM_PPRPBOOT },
{ EFI_FREEDESKTOP_BOOT }
};

/*
Expand Down

0 comments on commit 917b8c5

Please sign in to comment.