diff options
author | Philippe Reynes <philippe.reynes@softathome.com> | 2022-04-22 17:46:49 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-05-06 14:39:15 -0400 |
commit | 26f404c7665265946305f2883cfad1b785d35bb2 (patch) | |
tree | e6ca1a9458487ae2d50992641212cd7d1351ad63 | |
parent | 5c783b54d605aa21c8e3e0e188ab99d58135addd (diff) | |
download | u-boot-26f404c7665265946305f2883cfad1b785d35bb2.tar.gz u-boot-26f404c7665265946305f2883cfad1b785d35bb2.tar.bz2 u-boot-26f404c7665265946305f2883cfad1b785d35bb2.zip |
cmd: gpt: add subcommand repair
Adds a sub-command repair to the command gpt
that allow to repair a corrupted gpt table. If
the both gpt table (primary and backup) are
valid, then the command does nothing.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
-rw-r--r-- | cmd/gpt.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -586,6 +586,15 @@ err: return errno; } +static int gpt_repair(struct blk_desc *blk_dev_desc) +{ + int ret = 0; + + ret = gpt_repair_headers(blk_dev_desc); + + return ret; +} + static int gpt_default(struct blk_desc *blk_dev_desc, const char *str_part) { int ret; @@ -997,7 +1006,10 @@ static int do_gpt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } - if ((strcmp(argv[1], "write") == 0) && (argc == 5)) { + if (strcmp(argv[1], "repair") == 0) { + printf("Repairing GPT: "); + ret = gpt_repair(blk_dev_desc); + } else if ((strcmp(argv[1], "write") == 0) && (argc == 5)) { printf("Writing GPT: "); ret = gpt_default(blk_dev_desc, argv[4]); } else if ((strcmp(argv[1], "verify") == 0)) { @@ -1036,6 +1048,8 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt, " Restore or verify GPT information on a device connected\n" " to interface\n" " Example usage:\n" + " gpt repair mmc 0\n" + " - repair the GPT on the device\n" " gpt write mmc 0 $partitions\n" " - write the GPT to device\n" " gpt verify mmc 0 $partitions\n" |