Skip to content

Commit c375891

Browse files
committed
block: mount partitions only from MPT if exists
fix Android 14 GPT eMMC partitions and Linux 5.15.137 this one is ok [ 1.625916] mmc0: new HS400 MMC card at address 0001 this one is too much [ 1.647094] mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 and adding partitions from MPT fails because they are already mounted as /dev/mmcblk0p* [ 1.657048] [mmcblk0p01] reserved offset 0x000002400000, size 0x000004000000 add fail [ 1.657056] [mmcblk0p02] cache offset 0x000006c00000, size 0x00000b500000 add fail [ 1.657062] [mmcblk0p03] env offset 0x000012900000, size 0x000000800000 add fail
1 parent 8c4ae3e commit c375891

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

block/partitions/core.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,29 @@ static bool blk_add_partition(struct gendisk *disk,
598598
return true;
599599
}
600600

601+
static int validate_mpt_partition(struct parsed_partitions *state)
602+
{
603+
sector_t sect_num;
604+
Sector sect;
605+
unsigned char *data;
606+
int ret = 0;
607+
608+
/* MPT signature is at 0x2400000 */
609+
sect_num = (0x2400000 / 512) *
610+
(queue_logical_block_size(state->disk->queue) / 512);
611+
612+
data = read_part_sector(state, sect_num, &sect);
613+
if (!data)
614+
return ret;
615+
616+
/* check for 'MPT\0' */
617+
if (!strncmp(data, "MPT", 4))
618+
ret = 1;
619+
620+
put_dev_sector(sect);
621+
return ret;
622+
}
623+
601624
static int blk_add_partitions(struct gendisk *disk)
602625
{
603626
struct parsed_partitions *state;
@@ -609,6 +632,20 @@ static int blk_add_partitions(struct gendisk *disk)
609632
state = check_partition(disk);
610633
if (!state)
611634
return 0;
635+
636+
/*
637+
* skip adding partitions for eMMC device
638+
* on Android 14 GPT partitions are added as block devices /dev/mmcblk0p*
639+
* which are mounted under /media
640+
* but we expects block devices from partition names like /dev/env and /dev/userdata
641+
* that's why we exit here and mount partitions from MPT
642+
*/
643+
if (validate_mpt_partition(state)) {
644+
pr_info("%s: skip mounting disk with MPT partition\n", disk->disk_name);
645+
ret = 0;
646+
goto out_free_state;
647+
}
648+
612649
if (IS_ERR(state)) {
613650
/*
614651
* I/O error reading the partition table. If we tried to read

0 commit comments

Comments
 (0)