aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-06-30 02:47:45 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-06-30 02:47:45 +0200
commite9b3fcc3e457642788f7011fe9f7fe9917156fa4 (patch)
tree5f350a92054f272442e5c11bd1f94d5323ca20fa
parentf798ba97171b7ecac3ecc5b8e6a0e4eb1301a391 (diff)
downloadbusybox-w32-e9b3fcc3e457642788f7011fe9f7fe9917156fa4.tar.gz
busybox-w32-e9b3fcc3e457642788f7011fe9f7fe9917156fa4.tar.bz2
busybox-w32-e9b3fcc3e457642788f7011fe9f7fe9917156fa4.zip
ubi_tools: enhance -s option to allow size multiplier to match mtd-utils
Based on patch by Paul B. Henson <henson@acm.org> function old new delta static.size_suffixes - 32 +32 ubi_tools_main 1141 1148 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/ubi_tools.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c
index 33059873a..d923f1c5a 100644
--- a/miscutils/ubi_tools.c
+++ b/miscutils/ubi_tools.c
@@ -92,6 +92,13 @@ static unsigned get_num_from_file(const char *path, unsigned max, const char *er
92int ubi_tools_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 92int ubi_tools_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
93int ubi_tools_main(int argc UNUSED_PARAM, char **argv) 93int ubi_tools_main(int argc UNUSED_PARAM, char **argv)
94{ 94{
95 static const struct suffix_mult size_suffixes[] = {
96 { "KiB", 1024 },
97 { "MiB", 1024*1024 },
98 { "GiB", 1024*1024*1024 },
99 { "", 0 }
100 };
101
95 unsigned opts; 102 unsigned opts;
96 char *ubi_ctrl; 103 char *ubi_ctrl;
97 int fd; 104 int fd;
@@ -140,7 +147,7 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv)
140#define OPTION_t (1 << 6) 147#define OPTION_t (1 << 6)
141 148
142 if (opts & OPTION_s) 149 if (opts & OPTION_s)
143 size_bytes = xatoull(size_bytes_str); 150 size_bytes = xatoull_sfx(size_bytes_str, size_suffixes);
144 argv += optind; 151 argv += optind;
145 ubi_ctrl = *argv++; 152 ubi_ctrl = *argv++;
146 153