summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <klto@zhaw.ch>2009-10-26 13:46:40 +0100
committerTobias Klauser <klto@zhaw.ch>2009-10-26 13:46:40 +0100
commit3198bdc4357c2256b62ba58b6c7e6a1aa593d168 (patch)
tree1c67f6e3934cfe6f5655d5feed91bd00eb6f1ba4
parentf83fca77fa4366462bb443f2cff50af9f3e4bfb7 (diff)
Support specifying image size in hex
-rw-r--r--mkubootenv.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/mkubootenv.c b/mkubootenv.c
index 598d95a..2ccaa7b 100644
--- a/mkubootenv.c
+++ b/mkubootenv.c
@@ -236,13 +236,23 @@ int main(int argc, char **argv)
/* parse commandline options */
for (i = 1; (i + 1 < argc) && (argv[i][0] == '-'); i++) {
switch (argv[i][1]) {
- case 's':
- img_size = strtol(argv[++i], NULL, 10);
- if (img_size <= 0) {
- err("Invalid target image size: %zd. Must be greater than 0.\n", img_size);
- exit(EXIT_FAILURE);
+ case 's': {
+ char *opt = argv[++i];
+
+ if (strlen(opt) > 2 && opt[0] == '0' &&
+ (opt[1] == 'x' || opt[1] == 'X')) {
+ img_size = strtol(opt, NULL, 16);
+ } else {
+ img_size = strtol(opt, NULL, 10);
+
+ if (img_size <= 0) {
+ err("Invalid target image size: %zd. Must be greater than 0.\n", img_size);
+ exit(EXIT_FAILURE);
+ }
}
+ dbg("img_size: %d\n", img_size);
break;
+ }
case 'r':
reverse = true;
break;