summaryrefslogtreecommitdiffstats
path: root/common/cmd_ubi.c
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2014-01-25 07:27:11 +0100
committerTom Rini <trini@ti.com>2014-02-21 11:33:19 -0500
commitf9f4d809a0897317a0235661e934b69040e93e14 (patch)
tree7d671f3f74a5210f8db70cdedfa5dc4db8fb30fd /common/cmd_ubi.c
parent2dd285f571c5880314903a0a19b8b7da0175661c (diff)
downloadtalos-obmc-uboot-f9f4d809a0897317a0235661e934b69040e93e14.tar.gz
talos-obmc-uboot-f9f4d809a0897317a0235661e934b69040e93e14.zip
common, ubi: add ubi check volumename command
check with this ubi command, if a UBI volume with "volumename" exists in current ubi device. Signed-off-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'common/cmd_ubi.c')
-rw-r--r--common/cmd_ubi.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 122ba7e171..7c4d950e96 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -123,6 +123,27 @@ static int ubi_info(int layout)
return 0;
}
+static int ubi_check_volumename(const struct ubi_volume *vol, char *name)
+{
+ return strcmp(vol->name, name);
+}
+
+static int ubi_check(char *name)
+{
+ int i;
+
+ for (i = 0; i < (ubi->vtbl_slots + 1); i++) {
+ if (!ubi->volumes[i])
+ continue; /* Empty record */
+
+ if (!ubi_check_volumename(ubi->volumes[i], name))
+ return 0;
+ }
+
+ return -EEXIST;
+}
+
+
static int verify_mkvol_req(const struct ubi_device *ubi,
const struct ubi_mkvol_req *req)
{
@@ -558,6 +579,14 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return ubi_info(layout);
}
+ if (strcmp(argv[1], "check") == 0) {
+ if (argc > 2)
+ return ubi_check(argv[2]);
+
+ printf("Error, no volume name passed\n");
+ return 1;
+ }
+
if (strncmp(argv[1], "create", 6) == 0) {
int dynamic = 1; /* default: dynamic volume */
@@ -663,6 +692,8 @@ U_BOOT_CMD(
" header offset)\n"
"ubi info [l[ayout]]"
" - Display volume and ubi layout information\n"
+ "ubi check volumename"
+ " - check if volumename exists\n"
"ubi create[vol] volume [size] [type]"
" - create volume name with size\n"
"ubi write[vol] address volume size"
OpenPOWER on IntegriCloud