summaryrefslogtreecommitdiff
path: root/ubi-utils/new-utils/src
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-02-20 18:00:42 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-02-20 19:21:31 +0200
commit56868f374f5ba88e766690236a41af36a1e51949 (patch)
tree666d134a8e43effbb5cf7418cd6f14d502efacc4 /ubi-utils/new-utils/src
parent6ef3fc52bcffd73520da5ecc3cb94d5cc16bdfc0 (diff)
ubi-tools: sanify old and new tools a bit
This commit adds compatible options to new ubimkvol, ubirmvol, and ubiupdatevol and deletes corresponding old utilities. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/new-utils/src')
-rw-r--r--ubi-utils/new-utils/src/common.c18
-rw-r--r--ubi-utils/new-utils/src/ubiattach.c (renamed from ubi-utils/new-utils/src/ubi-attach.c)2
-rw-r--r--ubi-utils/new-utils/src/ubicrc32.c (renamed from ubi-utils/new-utils/src/ubi-crc32.c)2
-rw-r--r--ubi-utils/new-utils/src/ubidetach.c (renamed from ubi-utils/new-utils/src/ubi-detach.c)2
-rw-r--r--ubi-utils/new-utils/src/ubimkvol.c (renamed from ubi-utils/new-utils/src/ubi-mkvol.c)50
-rw-r--r--ubi-utils/new-utils/src/ubinfo.c (renamed from ubi-utils/new-utils/src/ubi-info.c)2
-rw-r--r--ubi-utils/new-utils/src/ubinize.c (renamed from ubi-utils/new-utils/src/ubi-nize.c)2
-rw-r--r--ubi-utils/new-utils/src/ubirmvol.c (renamed from ubi-utils/new-utils/src/ubi-rmvol.c)51
-rw-r--r--ubi-utils/new-utils/src/ubiupdatevol.c (renamed from ubi-utils/new-utils/src/ubi-update.c)65
9 files changed, 149 insertions, 45 deletions
diff --git a/ubi-utils/new-utils/src/common.c b/ubi-utils/new-utils/src/common.c
index fec640d..50859dc 100644
--- a/ubi-utils/new-utils/src/common.c
+++ b/ubi-utils/new-utils/src/common.c
@@ -52,6 +52,24 @@ static int get_multiplier(const char *str)
if (!strcmp(str, "GiB"))
return 1024 * 1024 * 1024;
+ /* Handle deprecated stuff */
+ if (!strcmp(str, "KB") || !strcmp(str, "Kib") || !strcmp(str, "kib") ||
+ !strcmp(str, "kiB")) {
+ fprintf(stderr, "Warning: use \"KiB\" instead of \"%s\" to "
+ "specify Kilobytes - support will be removed\n", str);
+ return 1024;
+ }
+ if (!strcmp(str, "MB") || !strcmp(str, "Mib") || !strcmp(str, "mb")) {
+ fprintf(stderr, "Warning: use \"MiB\" instead of \"%s\", "
+ "this support will be removed\n", str);
+ return 1024*1024;
+ }
+ if (!strcmp(str, "GB") || !strcmp(str, "Gib") || !strcmp(str, "gb")) {
+ fprintf(stderr, "Warning: use \"GiB\" instead of \"%s\", "
+ "this support will be removed\n", str);
+ return 1024*1024*1024;
+ }
+
return -1;
}
diff --git a/ubi-utils/new-utils/src/ubi-attach.c b/ubi-utils/new-utils/src/ubiattach.c
index 7b231a6..b3d768a 100644
--- a/ubi-utils/new-utils/src/ubi-attach.c
+++ b/ubi-utils/new-utils/src/ubiattach.c
@@ -31,7 +31,7 @@
#include "common.h"
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-attach"
+#define PROGRAM_NAME "ubiattach"
/* The variables below are set by command line arguments */
struct args {
diff --git a/ubi-utils/new-utils/src/ubi-crc32.c b/ubi-utils/new-utils/src/ubicrc32.c
index d3d3136..100b3cd 100644
--- a/ubi-utils/new-utils/src/ubi-crc32.c
+++ b/ubi-utils/new-utils/src/ubicrc32.c
@@ -36,7 +36,7 @@
#define BUFSIZE 4096
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-crc32"
+#define PROGRAM_NAME "ubicrc32"
static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
" - a tool to calculate CRC32 with UBI start value (0xFFFFFFFF)";
diff --git a/ubi-utils/new-utils/src/ubi-detach.c b/ubi-utils/new-utils/src/ubidetach.c
index 0ee7954..cd48368 100644
--- a/ubi-utils/new-utils/src/ubi-detach.c
+++ b/ubi-utils/new-utils/src/ubidetach.c
@@ -31,7 +31,7 @@
#include "common.h"
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-detach"
+#define PROGRAM_NAME "ubidetach"
/* The variables below are set by command line arguments */
struct args {
diff --git a/ubi-utils/new-utils/src/ubi-mkvol.c b/ubi-utils/new-utils/src/ubimkvol.c
index 49d1905..7da788b 100644
--- a/ubi-utils/new-utils/src/ubi-mkvol.c
+++ b/ubi-utils/new-utils/src/ubimkvol.c
@@ -33,7 +33,7 @@
#include "common.h"
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-mkvol"
+#define PROGRAM_NAME "ubimkvol"
/* The variables below are set by command line arguments */
struct args {
@@ -46,6 +46,9 @@ struct args {
int nlen;
const char *node;
int maxavs;
+ /* For deprecated -d option handling */
+ int devn;
+ char dev_name[256];
};
static struct args args = {
@@ -54,10 +57,7 @@ static struct args args = {
.lebs = -1,
.alignment = 1,
.vol_id = UBI_VOL_NUM_AUTO,
- .name = NULL,
- .nlen = 0,
- .node = NULL,
- .maxavs = 0,
+ .devn = -1,
};
static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
@@ -74,8 +74,13 @@ 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"
-"-h, --help print help message\n"
-"-V, --version print program version";
+"-h, -?, --help print help message\n"
+"-V, --version print program version\n\n"
+"The following is a compatibility option which is deprecated, do not use it\n"
+"-d, --devn=<devn> UBI device number - may be used instead of the UBI\n"
+" device node name in which case the utility assumes\n"
+" that the device node is \"/dev/ubi<devn>\"";
+
static const char *usage =
"Usage: " PROGRAM_NAME " <UBI device node file name> [-h] [-a <alignment>] [-n <volume ID>] [-N <name>]\n"
@@ -96,6 +101,8 @@ 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' },
+ /* Deprecated -d option */
+ { .name = "devn", .has_arg = 1, .flag = NULL, .val = 'd' },
{ NULL, 0, NULL, 0},
};
@@ -127,7 +134,7 @@ static int parse_opt(int argc, char * const argv[])
int key;
char *endp;
- key = getopt_long(argc, argv, "a:n:N:s:S:t:hVm", long_options, NULL);
+ key = getopt_long(argc, argv, "a:n:N:s:S:t:h?Vmd:", long_options, NULL);
if (key == -1)
break;
@@ -165,12 +172,21 @@ static int parse_opt(int argc, char * const argv[])
return errmsg("bad volume ID: " "\"%s\"", optarg);
break;
+ case 'd':
+ /* Handle deprecated -d option */
+ warnmsg("-d is depricated and will be removed, do not use it");
+ args.devn = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.devn < 0)
+ return errmsg("bad UBI device number: " "\"%s\"", optarg);
+ break;
+
case 'N':
args.name = optarg;
args.nlen = strlen(args.name);
break;
case 'h':
+ case '?':
fprintf(stderr, "%s\n\n", doc);
fprintf(stderr, "%s\n\n", usage);
fprintf(stderr, "%s\n", optionsstr);
@@ -193,12 +209,18 @@ static int parse_opt(int argc, char * const argv[])
}
}
- if (optind == argc)
- return errmsg("UBI device name was not specified (use -h for help)");
- else if (optind != argc - 1)
- return errmsg("more then one UBI device specified (use -h for help)");
-
- args.node = argv[optind];
+ /* Handle deprecated -d option */
+ if (args.devn != -1) {
+ sprintf(args.dev_name, "/dev/ubi%d", args.devn);
+ args.node = args.dev_name;
+ } else {
+ if (optind == argc)
+ return errmsg("UBI device name was not specified (use -h for help)");
+ else if (optind != argc - 1)
+ return errmsg("more then one UBI device specified (use -h for help)");
+
+ args.node = argv[optind];
+ }
if (param_sanity_check())
return -1;
diff --git a/ubi-utils/new-utils/src/ubi-info.c b/ubi-utils/new-utils/src/ubinfo.c
index d469a1a..185caae 100644
--- a/ubi-utils/new-utils/src/ubi-info.c
+++ b/ubi-utils/new-utils/src/ubinfo.c
@@ -31,7 +31,7 @@
#include "common.h"
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-nfo"
+#define PROGRAM_NAME "ubinfo"
/* The variables below are set by command line arguments */
struct args {
diff --git a/ubi-utils/new-utils/src/ubi-nize.c b/ubi-utils/new-utils/src/ubinize.c
index 532b193..a78199e 100644
--- a/ubi-utils/new-utils/src/ubi-nize.c
+++ b/ubi-utils/new-utils/src/ubinize.c
@@ -37,7 +37,7 @@
#include "common.h"
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-nize"
+#define PROGRAM_NAME "ubinize"
static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
" - a tool to generate UBI images. An UBI image may contain one or more UBI "
diff --git a/ubi-utils/new-utils/src/ubi-rmvol.c b/ubi-utils/new-utils/src/ubirmvol.c
index 72bf069..5822aa0 100644
--- a/ubi-utils/new-utils/src/ubi-rmvol.c
+++ b/ubi-utils/new-utils/src/ubirmvol.c
@@ -33,26 +33,33 @@
#include "common.h"
#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-rmvol"
+#define PROGRAM_NAME "ubirmvol"
/* The variables below are set by command line arguments */
struct args {
int vol_id;
const char *node;
+ /* For deprecated -d option handling */
+ int devn;
+ char dev_name[256];
};
static struct args args = {
.vol_id = -1,
- .node = NULL,
+ .devn = -1,
};
static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
" - a tool to remove UBI volumes.";
static const char *optionsstr =
-" -n, --vol_id=<volume id> volume ID to remove\n"
-" -h, --help print help message\n"
-" -V, --version print program version";
+"-n, --vol_id=<volume id> volume ID to remove\n"
+"-h, -?, --help print help message\n"
+"-V, --version print program version\n\n"
+"The following is a compatibility option which is deprecated, do not use it\n"
+"-d, --devn=<devn> UBI device number - may be used instead of the UBI\n"
+" device node name in which case the utility assumes\n"
+" that the device node is \"/dev/ubi<devn>\"";
static const char *usage =
"Usage: " PROGRAM_NAME " <UBI device node file name> [-n <volume id>] [--vol_id=<volume id>] [-h] [--help]\n\n"
@@ -63,6 +70,8 @@ static const struct option long_options[] = {
{ .name = "vol_id", .has_arg = 1, .flag = NULL, .val = 'n' },
{ .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' },
{ .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
+ /* Deprecated -d option */
+ { .name = "devn", .has_arg = 1, .flag = NULL, .val = 'd' },
{ NULL, 0, NULL, 0},
};
@@ -82,7 +91,7 @@ static int parse_opt(int argc, char * const argv[])
int key;
char *endp;
- key = getopt_long(argc, argv, "n:hV", long_options, NULL);
+ key = getopt_long(argc, argv, "n:h?Vd:", long_options, NULL);
if (key == -1)
break;
@@ -97,11 +106,20 @@ static int parse_opt(int argc, char * const argv[])
break;
case 'h':
+ case '?':
fprintf(stderr, "%s\n\n", doc);
fprintf(stderr, "%s\n\n", usage);
fprintf(stderr, "%s\n", optionsstr);
exit(EXIT_SUCCESS);
+ case 'd':
+ /* Handle deprecated -d option */
+ warnmsg("-d is depricated and will be removed, do not use it");
+ args.devn = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.devn < 0)
+ return errmsg("bad UBI device number: " "\"%s\"", optarg);
+ break;
+
case 'V':
fprintf(stderr, "%s\n", PROGRAM_VERSION);
exit(EXIT_SUCCESS);
@@ -116,15 +134,22 @@ static int parse_opt(int argc, char * const argv[])
}
}
- if (optind == argc) {
- errmsg("UBI device name was not specified (use -h for help)");
- return -1;
- } else if (optind != argc - 1) {
- errmsg("more then one UBI device specified (use -h for help)");
- return -1;
+ /* Handle deprecated -d option */
+ if (args.devn != -1) {
+ sprintf(args.dev_name, "/dev/ubi%d", args.devn);
+ args.node = args.dev_name;
+ } else {
+ if (optind == argc) {
+ errmsg("UBI device name was not specified (use -h for help)");
+ return -1;
+ } else if (optind != argc - 1) {
+ errmsg("more then one UBI device specified (use -h for help)");
+ return -1;
+ }
+
+ args.node = argv[optind];
}
- args.node = argv[optind];
if (param_sanity_check())
return -1;
diff --git a/ubi-utils/new-utils/src/ubi-update.c b/ubi-utils/new-utils/src/ubiupdatevol.c
index bf548a9..76d9f4e 100644
--- a/ubi-utils/new-utils/src/ubi-update.c
+++ b/ubi-utils/new-utils/src/ubiupdatevol.c
@@ -37,19 +37,21 @@
#include <libubi.h>
#include "common.h"
-#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME "ubi-update"
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME "ubiupdatevol"
struct args {
int truncate;
const char *node;
const char *img;
+ /* For deprecated -d and -B options handling */
+ int devn;
+ char dev_name[256];
+ int broken_update;
};
static struct args args = {
- .truncate = 0,
- .node = NULL,
- .img = NULL,
+ .devn = -1,
};
static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
@@ -59,11 +61,16 @@ static const char *optionsstr =
"-n, --vol_id=<volume id> ID of UBI volume to update\n"
"-t, --truncate truncate volume (wipe it out)\n"
"-h, --help print help message\n"
-"-V, --version print program version";
+"-V, --version print program version\n\n"
+"The following are compatibility options which are deprecated, do not use them\n"
+"-d, --devn=<devn> UBI device number - may be used instead of the UBI\n"
+" device node name in which case the utility assumes\n"
+" that the device node is \"/dev/ubi<devn>\"\n"
+"-B, --broken-update broken update, this is for testing";
static const char *usage =
"Usage: " PROGRAM_NAME " <UBI volume node file name> [-t] [-h] [-V] [--truncate] [--help]\n"
-"\t\t[--version] <image file>\n\n"
+"\t\t\t[--version] <image file>\n\n"
"Example 1: " PROGRAM_NAME " /dev/ubi0_1 fs.img - write file \"fs.img\" to UBI volume /dev/ubi0_1\n"
"Example 2: " PROGRAM_NAME " /dev/ubi0_1 -t - wipe out UBI volume /dev/ubi0_1";
@@ -71,6 +78,9 @@ struct option long_options[] = {
{ .name = "truncate", .has_arg = 0, .flag = NULL, .val = 't' },
{ .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' },
{ .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
+ /* Deprecated -d and -B options */
+ { .name = "devn", .has_arg = 1, .flag = NULL, .val = 'd' },
+ { .name = "broken-update", .has_arg = 1, .flag = NULL, .val = 'B' },
{ NULL, 0, NULL, 0}
};
@@ -79,7 +89,7 @@ static int parse_opt(int argc, char * const argv[])
while (1) {
int key;
- key = getopt_long(argc, argv, "n:thV", long_options, NULL);
+ key = getopt_long(argc, argv, "n:th?Vd:", long_options, NULL);
if (key == -1)
break;
@@ -89,11 +99,30 @@ static int parse_opt(int argc, char * const argv[])
break;
case 'h':
+ case '?':
fprintf(stderr, "%s\n\n", doc);
fprintf(stderr, "%s\n\n", usage);
fprintf(stderr, "%s\n", optionsstr);
exit(EXIT_SUCCESS);
+ case 'd':
+ {
+ char *endp;
+
+ /* Handle deprecated -d option */
+ warnmsg("-d is depricated and will be removed, do not use it");
+ args.devn = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.devn < 0)
+ return errmsg("bad UBI device number: " "\"%s\"", optarg);
+ break;
+ }
+
+ case 'B':
+ /* Handle deprecated -B option */
+ warnmsg("-B is depricated and will be removed, do not use it");
+ args.broken_update = 1;
+ break;
+
case 'V':
fprintf(stderr, "%s\n", PROGRAM_VERSION);
exit(EXIT_SUCCESS);
@@ -107,11 +136,17 @@ static int parse_opt(int argc, char * const argv[])
}
}
- if (optind == argc)
- return errmsg("UBI device name was not specified (use -h for help)");
- else if (optind != argc - 2)
- return errmsg("specify UBI device name and image file name as first 2 "
- "parameters (use -h for help)");
+ /* Handle deprecated -d option */
+ if (args.devn != -1) {
+ sprintf(args.dev_name, "/dev/ubi%d", args.devn);
+ args.node = args.dev_name;
+ } else {
+ if (optind == argc)
+ return errmsg("UBI device name was not specified (use -h for help)");
+ else if (optind != argc - 2)
+ return errmsg("specify UBI device name and image file name as first 2 "
+ "parameters (use -h for help)");
+ }
args.node = argv[optind];
args.img = argv[optind + 1];
@@ -187,6 +222,10 @@ static int update_volume(libubi_t libubi, struct ubi_vol_info *vol_info)
goto out_free;
}
+ /* A hack to handle deprecated -B option */
+ if (args.broken_update)
+ bytes = 1;
+
fd = open(args.node, O_RDWR);
if (fd == -1) {
sys_errmsg("cannot open UBI volume \"%s\"", args.node);