fastboot: add support for writing MBR
Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME)
to write MBR partition table.
Partitions are now searched using the generic function which finds any
partiiton by name. For MBR the partition names hda1, sda1, etc. are used.
Signed-off-by: Petr Kulhavy <brain@jikos.cz>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Steve Rae <steve.rae@raedomain.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 8226601..8e6aae5 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -297,6 +297,26 @@
return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0);
}
+int is_valid_dos_buf(void *buf)
+{
+ return test_block_type(buf) == DOS_MBR ? 0 : -1;
+}
+
+int write_mbr_partition(struct blk_desc *dev_desc, void *buf)
+{
+ if (is_valid_dos_buf(buf))
+ return -1;
+
+ /* write MBR */
+ if (blk_dwrite(dev_desc, 0, 1, buf) != 1) {
+ printf("%s: failed writing '%s' (1 blks at 0x0)\n",
+ __func__, "MBR");
+ return 1;
+ }
+
+ return 0;
+}
+
U_BOOT_PART_TYPE(dos) = {
.name = "DOS",
.part_type = PART_TYPE_DOS,