summaryrefslogtreecommitdiffstats
path: root/commands/ubi.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-09-17 07:12:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-18 09:17:13 +0200
commit2830faf5e5080aa1177cf42246db3b20825ff697 (patch)
tree0a38f0bdbac525bd28ad88eb7a71d7a274bcea85 /commands/ubi.c
parent56ee5d3aac2d73dbe1e699000cb83eea18278e68 (diff)
downloadbarebox-2830faf5e5080aa1177cf42246db3b20825ff697.tar.gz
barebox-2830faf5e5080aa1177cf42246db3b20825ff697.tar.xz
command: ubiattach: add option to pass VID offset
use the same option as linux -O as example due to a bug in already deployed kernel we must for the VID offset at 512 even it should be at 256 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/ubi.c')
-rw-r--r--commands/ubi.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/commands/ubi.c b/commands/ubi.c
index 2041df3fd5..57ae79025d 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -58,13 +58,25 @@ BAREBOX_CMD_END
static int do_ubiattach(int argc, char *argv[])
{
+ int opt;
struct mtd_info_user user;
int fd, ret;
+ int vid_hdr_offset = 0;
+
+ while((opt = getopt(argc, argv, "O:")) > 0) {
+ switch(opt) {
+ case 'O':
+ vid_hdr_offset = simple_strtoul(optarg, NULL, 0);
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
- if (argc != 2)
+ if (optind == argc)
return COMMAND_ERROR_USAGE;
- fd = open(argv[1], O_RDWR);
+ fd = open(argv[optind], O_RDWR);
if (fd < 0) {
perror("open");
return 1;
@@ -76,7 +88,7 @@ static int do_ubiattach(int argc, char *argv[])
goto err;
}
- ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0, 20);
+ ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, vid_hdr_offset, 20);
if (ret < 0)
printf("failed to attach: %s\n", strerror(-ret));
else
@@ -88,7 +100,7 @@ err:
}
static const __maybe_unused char cmd_ubiattach_help[] =
-"Usage: ubiattach <mtddev>\n"
+"Usage: ubiattach [-O vid-hdr-offset] <mtddev>\n"
"Attach <mtddev> to ubi\n";
BAREBOX_CMD_START(ubiattach)