diff options
-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"); |