From 7b4a65a27d2621b58c634d02c6a068ed9562383c Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Thu, 28 Jun 2018 09:43:43 +0200 Subject: ubi-utils: ubimkvol: add support for skipping CRC check of a static volume when opening 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 Reviewed-by: Boris Brezillon Signed-off-by: Quentin Schulz Signed-off-by: David Oberhollenzer --- 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..1950061 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= 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 " [-h] [-a ] [-n ] [-N ]\n" -"\t\t\t[-s ] [-S ] [-t ] [-V] [-m]\n" +"\t\t\t[-s ] [-S ] [-t ] [-V] [-m] [-k]\n" "\t\t\t[--alignment=][--vol_id=] [--name=]\n" "\t\t\t[--size=] [--lebs=] [--type=] [--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"); -- cgit v1.2.3