aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorDavidlohr Bueso <davidlohr@hp.com>2013-09-11 17:24:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:15 -0400
commitc2ebdc2439f50c049fd362bb225aaf78fe8e4cb8 (patch)
tree84e531378486eacbce73be8426c657b73457908f /block
parent6f79d33228fa7cf900826738a39f287cae96cd91 (diff)
partitions/efi: use lba-aware partition records
The kernel's GPT implementation currently uses the generic 'struct partition' type for dealing with legacy MBR partition records. While this is is useful for disklabels that we designed for CHS addressing, such as msdos, it doesn't adapt well to newer standards that use LBA instead, such as GUID partition tables. Furthermore, these generic partition structures do not have all the required fields to properly follow the UEFI specs. While a CHS address can be translated to LBA, it's much simpler and cleaner to just replace the partition type. This patch adds a new 'gpt_record' type that is fully compliant with EFI and will allow, in the next patches, to add more checks to properly verify a protective MBR, which is paramount to probing a device that makes use of GPT. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Davidlohr Bueso <davidlohr@hp.com> Reviewed-by: Karel Zak <kzak@redhat.com> Acked-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'block')
-rw-r--r--block/partitions/efi.c9
-rw-r--r--block/partitions/efi.h16
2 files changed, 19 insertions, 6 deletions
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index c85fc895ecdb..bd8fb22b2109 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -149,12 +149,11 @@ static u64 last_lba(struct block_device *bdev)
149 bdev_logical_block_size(bdev)) - 1ULL; 149 bdev_logical_block_size(bdev)) - 1ULL;
150} 150}
151 151
152static inline int 152static inline int pmbr_part_valid(gpt_mbr_record *part)
153pmbr_part_valid(struct partition *part)
154{ 153{
155 if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT && 154 if (part->os_type == EFI_PMBR_OSTYPE_EFI_GPT &&
156 le32_to_cpu(part->start_sect) == 1UL) 155 le32_to_cpu(part->start_sector) == 1UL)
157 return 1; 156 return 1;
158 return 0; 157 return 0;
159} 158}
160 159
diff --git a/block/partitions/efi.h b/block/partitions/efi.h
index b69ab729558f..e645ecb35bf3 100644
--- a/block/partitions/efi.h
+++ b/block/partitions/efi.h
@@ -101,11 +101,25 @@ typedef struct _gpt_entry {
101 efi_char16_t partition_name[72 / sizeof (efi_char16_t)]; 101 efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
102} __attribute__ ((packed)) gpt_entry; 102} __attribute__ ((packed)) gpt_entry;
103 103
104typedef struct _gpt_mbr_record {
105 u8 boot_indicator; /* unused by EFI, set to 0x80 for bootable */
106 u8 start_head; /* unused by EFI, pt start in CHS */
107 u8 start_sector; /* unused by EFI, pt start in CHS */
108 u8 start_track;
109 u8 os_type; /* EFI and legacy non-EFI OS types */
110 u8 end_head; /* unused by EFI, pt end in CHS */
111 u8 end_sector; /* unused by EFI, pt end in CHS */
112 u8 end_track; /* unused by EFI, pt end in CHS */
113 __le32 starting_lba; /* used by EFI - start addr of the on disk pt */
114 __le32 size_in_lba; /* used by EFI - size of pt in LBA */
115} __packed gpt_mbr_record;
116
117
104typedef struct _legacy_mbr { 118typedef struct _legacy_mbr {
105 u8 boot_code[440]; 119 u8 boot_code[440];
106 __le32 unique_mbr_signature; 120 __le32 unique_mbr_signature;
107 __le16 unknown; 121 __le16 unknown;
108 struct partition partition_record[4]; 122 gpt_mbr_record partition_record[4];
109 __le16 signature; 123 __le16 signature;
110} __attribute__ ((packed)) legacy_mbr; 124} __attribute__ ((packed)) legacy_mbr;
111 125