mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Leif Middelschulte <leif.middelschulte@klsmartin.com>,
	Leif Middelschulte <leif.middelschulte@gmail.com>
Subject: [PATCH] ubimkvol: add support for `volume_id` parameter
Date: Mon, 26 Nov 2018 11:06:29 +0100	[thread overview]
Message-ID: <20181126100629.10856-1-s.hauer@pengutronix.de> (raw)

From: Leif Middelschulte <leif.middelschulte@klsmartin.com>

The volume id can be used to refer to a specific volume.
This adds support to choose a corresponding argument when creating
a UBI volume.

Signed-off-by: Leif Middelschulte <leif.middelschulte@gmail.com>
---
 commands/ubi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/commands/ubi.c b/commands/ubi.c
index de5633c458..f37684102d 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -108,8 +108,9 @@ static int do_ubimkvol(int argc, char *argv[])
 	uint32_t ubinum;
 
 	req.vol_type = UBI_DYNAMIC_VOLUME;
+	req.vol_id = UBI_VOL_NUM_AUTO;
 
-	while ((opt = getopt(argc, argv, "t:")) > 0) {
+	while ((opt = getopt(argc, argv, "t:n:")) > 0) {
 		switch (opt) {
 		case 't':
 			if (!strcmp(optarg, "dynamic"))
@@ -119,6 +120,9 @@ static int do_ubimkvol(int argc, char *argv[])
 			else
 				return COMMAND_ERROR_USAGE;
 			break;
+		case 'n':
+			req.vol_id = simple_strtoul(optarg, NULL, 0);
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
@@ -133,7 +137,6 @@ static int do_ubimkvol(int argc, char *argv[])
 	req.name[req.name_len] = 0;
 
 	req.bytes = size;
-	req.vol_id = UBI_VOL_NUM_AUTO;
 	req.alignment = 1;
 
 	fd = open(argv[optind], O_WRONLY);
@@ -160,12 +163,13 @@ BAREBOX_CMD_HELP_START(ubimkvol)
 BAREBOX_CMD_HELP_TEXT("Create an UBI volume on UBIDEV with NAME and SIZE.")
 BAREBOX_CMD_HELP_TEXT("If SIZE is 0 all available space is used for the volume.")
 BAREBOX_CMD_HELP_OPT("-t <static|dynamic>",  "volume type, default is dynamic")
+BAREBOX_CMD_HELP_OPT("-n <vol_id>",  "volume ID, default is dynamically assigned")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(ubimkvol)
 	.cmd		= do_ubimkvol,
 	BAREBOX_CMD_DESC("create an UBI volume")
-	BAREBOX_CMD_OPTS("[-t] UBIDEV NAME SIZE")
+	BAREBOX_CMD_OPTS("[-tn] UBIDEV NAME SIZE")
 	BAREBOX_CMD_GROUP(CMD_GRP_PART)
 	BAREBOX_CMD_HELP(cmd_ubimkvol_help)
 BAREBOX_CMD_END
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2018-11-26 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 10:06 Sascha Hauer [this message]
2018-11-26 11:40 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181126100629.10856-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=leif.middelschulte@gmail.com \
    --cc=leif.middelschulte@klsmartin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox