summaryrefslogtreecommitdiffstats
path: root/commands/ubi.c
diff options
context:
space:
mode:
authorMichael Grzeschik <m.grzeschik@pengutronix.de>2014-08-28 13:01:41 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-09-01 09:49:35 +0200
commit57bba7bcdadab6652406c183c32db360a8910ac3 (patch)
tree89b9526857766b8a6026b6ff8e1d55b8b135029a /commands/ubi.c
parent45615e3ec10c38298c1b9780e13a884aff49bae1 (diff)
downloadbarebox-57bba7bcdadab6652406c183c32db360a8910ac3.tar.gz
barebox-57bba7bcdadab6652406c183c32db360a8910ac3.tar.xz
ubi: add setting devnum to ubiattach
Sometimes we need to have a defined devicenumber for the ubi partitions. This patch adds the option to ubiattach. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/ubi.c')
-rw-r--r--commands/ubi.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/commands/ubi.c b/commands/ubi.c
index d593e71c2a..94da799b8c 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -65,9 +65,13 @@ static int do_ubiattach(int argc, char *argv[])
struct mtd_info_user user;
int fd, ret;
int vid_hdr_offset = 0;
+ int devnum = UBI_DEV_NUM_AUTO;
- while((opt = getopt(argc, argv, "O:")) > 0) {
+ while((opt = getopt(argc, argv, "d:O:")) > 0) {
switch(opt) {
+ case 'd':
+ devnum = simple_strtoul(optarg, NULL, 0);
+ break;
case 'O':
vid_hdr_offset = simple_strtoul(optarg, NULL, 0);
break;
@@ -91,7 +95,7 @@ static int do_ubiattach(int argc, char *argv[])
goto err;
}
- ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, vid_hdr_offset, 20);
+ ret = ubi_attach_mtd_dev(user.mtd, devnum, vid_hdr_offset, 20);
if (ret < 0)
printf("failed to attach: %s\n", strerror(-ret));
else
@@ -104,13 +108,14 @@ err:
BAREBOX_CMD_HELP_START(ubiattach)
BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-d DEVNUM", "device number")
BAREBOX_CMD_HELP_OPT ("-O OFFS", "VID header offset")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(ubiattach)
.cmd = do_ubiattach,
BAREBOX_CMD_DESC("attach mtd device to UBI")
- BAREBOX_CMD_OPTS("[-O] MTDDEV")
+ BAREBOX_CMD_OPTS("[-dO] MTDDEV")
BAREBOX_CMD_GROUP(CMD_GRP_PART)
BAREBOX_CMD_HELP(cmd_ubiattach_help)
BAREBOX_CMD_END