diff options
author | Quentin Schulz <quentin.schulz@bootlin.com> | 2018-06-28 09:43:43 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2018-06-28 10:23:03 +0200 |
commit | 7b4a65a27d2621b58c634d02c6a068ed9562383c (patch) | |
tree | 224320f60330094c9b639473a15f1ac2795d5794 /ubi-utils | |
parent | 5e9bc0daa41d84ce5de81c4a1665d65f51893c10 (diff) |
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 <boris.brezillon@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubi-utils')
-rw-r--r-- | ubi-utils/ubimkvol.c | 19 |
1 files 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=<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"); |