From: Teresa Remmet <t.remmet@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] commands: ubimkvol: Add option for static volumes
Date: Wed, 22 Jun 2016 11:02:38 +0200 [thread overview]
Message-ID: <1466586161-14532-1-git-send-email-t.remmet@phytec.de> (raw)
Creating static volumes in barebox already works,
only the option was missing.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
commands/ubi.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/commands/ubi.c b/commands/ubi.c
index 844d75d..f4ff5e7 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -13,24 +13,41 @@
static int do_ubimkvol(int argc, char *argv[])
{
+ int opt;
struct ubi_mkvol_req req;
int fd, ret;
uint64_t size;
- if (argc != 4)
+ req.vol_type = UBI_DYNAMIC_VOLUME;
+
+ while ((opt = getopt(argc, argv, "t:")) > 0) {
+ switch (opt) {
+ case 't':
+ if (!strcmp(optarg, "dynamic"))
+ req.vol_type = UBI_DYNAMIC_VOLUME;
+ else if (!strcmp(optarg, "static"))
+ req.vol_type = UBI_STATIC_VOLUME;
+ else
+ return COMMAND_ERROR_USAGE;
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
+
+ if (argc - optind < 3)
return COMMAND_ERROR_USAGE;
- size = strtoull_suffix(argv[3], NULL, 0);
- req.name_len = min_t(int, strlen(argv[2]), UBI_VOL_NAME_MAX);
- strncpy(req.name, argv[2], req.name_len);
+ size = strtoull_suffix(argv[optind+2], NULL, 0);
+ req.name_len = min_t(int, strlen(argv[optind+1]), UBI_VOL_NAME_MAX);
+ strncpy(req.name, argv[optind+1], req.name_len);
req.name[req.name_len] = 0;
- req.vol_type = UBI_DYNAMIC_VOLUME;
req.bytes = size;
req.vol_id = UBI_VOL_NUM_AUTO;
req.alignment = 1;
- fd = open(argv[1], O_WRONLY);
+ fd = open(argv[optind], O_WRONLY);
if (fd < 0) {
perror("open");
return 1;
@@ -48,12 +65,13 @@ static int do_ubimkvol(int argc, char *argv[])
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_END
BAREBOX_CMD_START(ubimkvol)
.cmd = do_ubimkvol,
BAREBOX_CMD_DESC("create an UBI volume")
- BAREBOX_CMD_OPTS("UBIDEV NAME SIZE")
+ BAREBOX_CMD_OPTS("[-t] UBIDEV NAME SIZE")
BAREBOX_CMD_GROUP(CMD_GRP_PART)
BAREBOX_CMD_HELP(cmd_ubimkvol_help)
BAREBOX_CMD_END
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2016-06-22 9:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-22 9:02 Teresa Remmet [this message]
2016-06-22 9:02 ` [PATCH 2/4] mtd: UBI: Add support for updating " Teresa Remmet
2016-06-23 6:36 ` Sascha Hauer
2016-06-23 12:11 ` Teresa Remmet
2016-06-22 9:02 ` [PATCH 3/4] commands: ubi: Add ubiupdatevol command Teresa Remmet
2016-06-23 6:43 ` Sascha Hauer
2016-06-23 14:00 ` Teresa Remmet
2016-06-22 9:02 ` [PATCH 4/4] ARM: am335x_defconfig: Enable ubi fastmap and ubifs Teresa Remmet
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=1466586161-14532-1-git-send-email-t.remmet@phytec.de \
--to=t.remmet@phytec.de \
--cc=barebox@lists.infradead.org \
/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