From 3198bdc4357c2256b62ba58b6c7e6a1aa593d168 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 26 Oct 2009 13:46:40 +0100 Subject: Support specifying image size in hex --- mkubootenv.c | 20 +++++++++++++++----- 1 file 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; -- cgit v1.2.3-54-g00ecf