linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Schulz <quentin.schulz@bootlin.com>
To: dedekind1@gmail.com, richard@nod.at, dwmw2@infradead.org,
	computersforpeace@gmail.com, boris.brezillon@bootlin.com,
	marek.vasut@gmail.com
Cc: linux-mtd@lists.infradead.org, thomas.petazzoni@bootlin.com,
	david.oberhollenzer@sigma-star.at,
	Quentin Schulz <quentin.schulz@bootlin.com>
Subject: [PATCH v2 3/4] ubi-utils: ubimkvol: add support for skipping CRC check of a static volume when opening
Date: Thu, 28 Jun 2018 09:43:43 +0200	[thread overview]
Message-ID: <20180628074344.10249-4-quentin.schulz@bootlin.com> (raw)
In-Reply-To: <20180628074344.10249-1-quentin.schulz@bootlin.com>

Let's let the user create static UBI volume with CRC checking at opening
disabled if desired.

Introduce the `--skipcheck` or `-k` option for such feature.

Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
---
 ubi-utils/ubimkvol.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/ubi-utils/ubimkvol.c b/ubi-utils/ubimkvol.c
index b81fc99..6c641e5 100644
--- a/ubi-utils/ubimkvol.c
+++ b/ubi-utils/ubimkvol.c
@@ -44,6 +44,7 @@ struct args {
 	const char *name;
 	const char *node;
 	int maxavs;
+	int skipcheck;
 };
 
 static struct args args = {
@@ -68,16 +69,17 @@ static const char optionsstr[] =
 "                              eraseblocks\n"
 "-m, --maxavsize               set volume size to maximum available size\n"
 "-t, --type=<static|dynamic>   volume type (dynamic, static), default is dynamic\n"
+"-k, --skipcheck               skip the CRC check done at volume open time\n"
 "-h, -?, --help                print help message\n"
 "-V, --version                 print program version";
 
 
 static const char usage[] =
 "Usage: " PROGRAM_NAME " <UBI device node file name> [-h] [-a <alignment>] [-n <volume ID>] [-N <name>]\n"
-"\t\t\t[-s <bytes>] [-S <LEBs>] [-t <static|dynamic>] [-V] [-m]\n"
+"\t\t\t[-s <bytes>] [-S <LEBs>] [-t <static|dynamic>] [-V] [-m] [-k]\n"
 "\t\t\t[--alignment=<alignment>][--vol_id=<volume ID>] [--name=<name>]\n"
 "\t\t\t[--size=<bytes>] [--lebs=<LEBs>] [--type=<static|dynamic>] [--help]\n"
-"\t\t\t[--version] [--maxavsize]\n\n"
+"\t\t\t[--version] [--maxavsize] --[skipcheck]\n\n"
 "Example: " PROGRAM_NAME " /dev/ubi0 -s 20MiB -N config_data - create a 20 Megabytes volume\n"
 "         named \"config_data\" on UBI device /dev/ubi0.";
 
@@ -91,6 +93,7 @@ static const struct option long_options[] = {
 	{ .name = "help",      .has_arg = 0, .flag = NULL, .val = 'h' },
 	{ .name = "version",   .has_arg = 0, .flag = NULL, .val = 'V' },
 	{ .name = "maxavsize", .has_arg = 0, .flag = NULL, .val = 'm' },
+	{ .name = "skipcheck", .has_arg = 0, .flag = NULL, .val = 'k' },
 	{ NULL, 0, NULL, 0},
 };
 
@@ -113,6 +116,9 @@ static int param_sanity_check(void)
 	if (len > UBI_MAX_VOLUME_NAME)
 		return errmsg("too long name (%d symbols), max is %d", len, UBI_MAX_VOLUME_NAME);
 
+	if (args.skipcheck && args.vol_type != UBI_STATIC_VOLUME)
+		return errmsg("skipcheck is only valid for static volumes");
+
 	return 0;
 }
 
@@ -121,7 +127,7 @@ static int parse_opt(int argc, char * const argv[])
 	while (1) {
 		int key, error = 0;
 
-		key = getopt_long(argc, argv, "a:n:N:s:S:t:h?Vm", long_options, NULL);
+		key = getopt_long(argc, argv, "a:n:N:s:S:t:h?Vmk", long_options, NULL);
 		if (key == -1)
 			break;
 
@@ -183,6 +189,10 @@ static int parse_opt(int argc, char * const argv[])
 			args.maxavs = 1;
 			break;
 
+		case 'k':
+			args.skipcheck = 1;
+			break;
+
 		case ':':
 			return errmsg("parameter is missing");
 
@@ -266,6 +276,9 @@ int main(int argc, char * const argv[])
 	req.vol_type = args.vol_type;
 	req.name = args.name;
 
+	if (args.skipcheck)
+		req.flags |= UBI_VOL_SKIP_CRC_CHECK_FLG;
+
 	err = ubi_mkvol(libubi, args.node, &req);
 	if (err < 0) {
 		sys_errmsg("cannot UBI create volume");
-- 
2.14.1

  parent reply	other threads:[~2018-06-28  7:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28  7:43 [PATCH v2 0/4] ubi-utils: add possibility to flag a static volume to skip CRC check when opening Quentin Schulz
2018-06-28  7:43 ` [PATCH v2 1/4] UBI: update ubi-user.h and ubi-media.h Quentin Schulz
2018-06-28  7:50   ` Boris Brezillon
2018-06-28  7:43 ` [PATCH v2 2/4] libubi: add volume flags to ubi_mkvol_request Quentin Schulz
2018-06-28  7:50   ` Boris Brezillon
2018-06-28  7:43 ` Quentin Schulz [this message]
2018-06-28  7:50   ` [PATCH v2 3/4] ubi-utils: ubimkvol: add support for skipping CRC check of a static volume when opening Boris Brezillon
2018-06-28  7:43 ` [PATCH v2 4/4] ubi-utils: ubinize: " Quentin Schulz
2018-06-28  7:50   ` Boris Brezillon
2018-06-28 11:48 ` [PATCH v2 0/4] ubi-utils: add possibility to flag a static volume to skip CRC check " David Oberhollenzer

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=20180628074344.10249-4-quentin.schulz@bootlin.com \
    --to=quentin.schulz@bootlin.com \
    --cc=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=david.oberhollenzer@sigma-star.at \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).