Skip to content

Commit

Permalink
aboot/fs_boot: Scan for subpartitions on all GPT devices even if on s…
Browse files Browse the repository at this point in the history
…dcard
  • Loading branch information
TravMurav committed Mar 21, 2022
1 parent e79f7ba commit 3f885f1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions app/aboot/fs_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static const char *bootable_parts[] = {
"system",
"cache",
"userdata",
"rootfs",
};

static bool fsboot_bootable_part(char *label)
Expand Down Expand Up @@ -107,17 +108,21 @@ static int fsboot_find_and_boot(int bdev_id, void* target, size_t sz)
int i = 0, j = 0, ret = 0;
char dev_name[128];
bdev_t *dev = NULL;
bool is_gpt = false;

/* HACK: There is no hd1p0 for some reason */
if (bdev_id == 1)
i = 1;

sprintf(dev_name, "hd%d", bdev_id);
dev = bio_open(dev_name);
if (!dev) {
dprintf(CRITICAL, "fs-boot: Can't open %s\n", dev_name);
return -1;
}

/* HACK: There is no hd1p0 on GPT devices for some reason */
is_gpt = dev->is_gpt;
if (is_gpt)
i = 1;

bio_close(dev);

if (!target)
Expand All @@ -142,8 +147,12 @@ static int fsboot_find_and_boot(int bdev_id, void* target, size_t sz)
if (target && ret >= 0)
return ret;

/* Only check subpartitions on emmc */
if (ret < 0 && bdev_id == FS_BOOT_DEV_EMMC) {
/*
* Only check subpartitions on GPT partitions,
* we expect MBR to always be "flat" but GPT with full bootloader chain
* may appear on any mmc (e.g. db410c with sdcard boot mode)
*/
if (ret < 0 && is_gpt) {
j = 0;
sprintf(dev_name, "hd%dp%dp%d", bdev_id, i, j);
while (dev = bio_open(dev_name)) {
Expand Down

0 comments on commit 3f885f1

Please sign in to comment.