* [PATCH 1/1] command: ubiattach: add option to pass VID offset
@ 2013-09-17 5:12 Jean-Christophe PLAGNIOL-VILLARD
2013-09-18 6:55 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-17 5:12 UTC (permalink / raw)
To: barebox
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>
---
commands/ubi.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/commands/ubi.c b/commands/ubi.c
index 2041df3..57ae790 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)
--
1.8.4.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] command: ubiattach: add option to pass VID offset
2013-09-17 5:12 [PATCH 1/1] command: ubiattach: add option to pass VID offset Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-18 6:55 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-09-18 6:55 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Tue, Sep 17, 2013 at 07:12:08AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 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>
Applied, thanks
Sascha
> ---
> commands/ubi.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/commands/ubi.c b/commands/ubi.c
> index 2041df3..57ae790 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)
> --
> 1.8.4.rc1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-18 6:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-17 5:12 [PATCH 1/1] command: ubiattach: add option to pass VID offset Jean-Christophe PLAGNIOL-VILLARD
2013-09-18 6:55 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox