From 49cd68db2dd3e6b17c67054ad87a3e7c9e303318 Mon Sep 17 00:00:00 2001 From: Luke go Date: Tue, 24 Nov 2020 17:39:02 +0900 Subject: [PATCH] ODROID-COMMON: mpt: Find boot device. - When mount the mpt, find boot device from the 'boot_device' arguments. Change-Id: I6d092783f4d081bd803933a8036c0fad2607d82d --- block/partitions/mpt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/block/partitions/mpt.c b/block/partitions/mpt.c index 5bb1139214d5..677ffb716420 100644 --- a/block/partitions/mpt.c +++ b/block/partitions/mpt.c @@ -83,11 +83,28 @@ static void applyInfo(struct parsed_partitions *state, int slot, struct ptable_t state->parts[state->next].has_info = true; } +#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON) +#define BOOT_DEVICE_LENGTH 12 + +static char boot_device[BOOT_DEVICE_LENGTH] = ""; + +static int __init get_boot_device(char *str) +{ + if (str) { + strncpy(boot_device, str, sizeof(str) - 1); + boot_device[sizeof(str)-1] = '\0'; + } + return 0; +} +__setup("boot_device=", get_boot_device); +#endif + int mpt_partition(struct parsed_partitions *state) { Sector sect; unsigned char *data; struct ptable_t *mpt; + struct gendisk *disk; data = read_part_sector(state, MPT_PARTITION_SECTOR_OFFSET, §); if (!data) @@ -100,6 +117,14 @@ int mpt_partition(struct parsed_partitions *state) return 0; } + disk = state->bdev->bd_disk; + if (strncmp(disk->disk_name, boot_device, strlen(disk->disk_name))) { + printk(KERN_CONT "current, boot - (%s, %s)\n", + disk->disk_name, boot_device); + + return 1; + } + printk(KERN_CONT "magic - %s\n", mpt->magic); printk(KERN_CONT "version - %s\n", mpt->version); printk(KERN_CONT "checksum - %x, result - %x\n", mpt->checksum, mpt_partition_checksum(mpt->partitions,