Skip to content

Commit 466d9c4

Browse files
digetxaxboe
authored andcommitted
partitions/efi: Support non-standard GPT location
Support looking up GPT at a non-standard location specified by a block device driver. Acked-by: Davidlohr Bueso <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Reviewed-by: Ulf Hansson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 0bdfbca commit 466d9c4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

block/partitions/efi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
585585
gpt_header *pgpt = NULL, *agpt = NULL;
586586
gpt_entry *pptes = NULL, *aptes = NULL;
587587
legacy_mbr *legacymbr;
588+
struct gendisk *disk = state->disk;
589+
const struct block_device_operations *fops = disk->fops;
588590
sector_t total_sectors = get_capacity(state->disk);
589591
u64 lastlba;
590592

@@ -619,6 +621,16 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
619621
if (!good_agpt && force_gpt)
620622
good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
621623

624+
if (!good_agpt && force_gpt && fops->alternative_gpt_sector) {
625+
sector_t agpt_sector;
626+
int err;
627+
628+
err = fops->alternative_gpt_sector(disk, &agpt_sector);
629+
if (!err)
630+
good_agpt = is_gpt_valid(state, agpt_sector,
631+
&agpt, &aptes);
632+
}
633+
622634
/* The obviously unsuccessful case */
623635
if (!good_pgpt && !good_agpt)
624636
goto fail;

0 commit comments

Comments
 (0)