aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorDmitry Osipenko2021-08-20 03:45:34 +0300
committerJens Axboe2021-08-24 10:09:06 -0600
commit466d9c4904deb25e2e8dcd29d3a998f4e3fa7c17 (patch)
tree5037a2454bcee99d0562783046850dc53c5340a8 /block
parent0bdfbca8a623e262e0f343b143151000a300cbaf (diff)
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 <dbueso@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20210820004536.15791-3-digetx@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/partitions/efi.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index aaa3dc487cb5..7ca5c4c374d4 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -585,6 +585,8 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
gpt_header *pgpt = NULL, *agpt = NULL;
gpt_entry *pptes = NULL, *aptes = NULL;
legacy_mbr *legacymbr;
+ struct gendisk *disk = state->disk;
+ const struct block_device_operations *fops = disk->fops;
sector_t total_sectors = get_capacity(state->disk);
u64 lastlba;
@@ -619,6 +621,16 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
if (!good_agpt && force_gpt)
good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
+ if (!good_agpt && force_gpt && fops->alternative_gpt_sector) {
+ sector_t agpt_sector;
+ int err;
+
+ err = fops->alternative_gpt_sector(disk, &agpt_sector);
+ if (!err)
+ good_agpt = is_gpt_valid(state, agpt_sector,
+ &agpt, &aptes);
+ }
+
/* The obviously unsuccessful case */
if (!good_pgpt && !good_agpt)
goto fail;