diff mbox series

disk: part_dos: update partition table entries after write

Message ID 20210127201944.9098-1-gary.bisson@boundarydevices.com
State Superseded
Delegated to: Tom Rini
Headers show
Series disk: part_dos: update partition table entries after write | expand

Commit Message

Gary Bisson Jan. 27, 2021, 8:19 p.m. UTC
Fixes issues when switching from GPT to MBR partition tables.

Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
---
Hi,

Sending this patch as a follow-up to the other one [1] doing the same
thing for GPT write.

Let me know if you have any questions.

Regards,
Gary

[1] https://lists.denx.de/pipermail/u-boot/2021-January/438764.html
---
 disk/part_dos.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Heinrich Schuchardt Jan. 27, 2021, 8:56 p.m. UTC | #1
On 1/27/21 9:19 PM, Gary Bisson wrote:
> Fixes issues when switching from GPT to MBR partition tables.

This does not catch all cases of changing the MBR. See function
write_mbr_partitions() with writes both the MBR and EBRs (if applicable).

Android devices typically have more than 4 partitions. Why does fastboot
not update the extended boot records?

Best regards

Heinrich

>
> Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
> ---
> Hi,
>
> Sending this patch as a follow-up to the other one [1] doing the same
> thing for GPT write.
>
> Let me know if you have any questions.
>
> Regards,
> Gary
>
> [1] https://lists.denx.de/pipermail/u-boot/2021-January/438764.html
> ---
>   disk/part_dos.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index f431925745..470886f4bb 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -499,6 +499,9 @@ int write_mbr_sector(struct blk_desc *dev_desc, void *buf)
>   		return 1;
>   	}
>
> +	/* Update the partition table entries*/
> +	part_init(dev_desc);
> +
>   	return 0;
>   }
>
>
Gary Bisson Jan. 28, 2021, 8:01 a.m. UTC | #2
Hi Heinrich,

On Wed, Jan 27, 2021 at 09:56:13PM +0100, Heinrich Schuchardt wrote:
> On 1/27/21 9:19 PM, Gary Bisson wrote:
> > Fixes issues when switching from GPT to MBR partition tables.
> 
> This does not catch all cases of changing the MBR. See function
> write_mbr_partitions() with writes both the MBR and EBRs (if applicable).

Good catch! That's correct, I missed it for 2 reasons:
1- I focused on the fastboot code which indeed only calls
write_mbr_sector()
2- I did that work on 2020.10 U-Boot which didn't include
write_mbr_partitions().

> Android devices typically have more than 4 partitions. Why does fastboot
> not update the extended boot records?

Fastboot is not only used for Android, we generally use it to flash our
Linux images as well. I guess the code just hasn't been updated to
handle EBR although I'd say that most people use GPT, especially Android
users.

Anyway, I'll submit a v2 that take care of write_mbr_partitions().

Regards,
Gary
diff mbox series

Patch

diff --git a/disk/part_dos.c b/disk/part_dos.c
index f431925745..470886f4bb 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -499,6 +499,9 @@  int write_mbr_sector(struct blk_desc *dev_desc, void *buf)
 		return 1;
 	}
 
+	/* Update the partition table entries*/
+	part_init(dev_desc);
+
 	return 0;
 }