diff options
author | Patrick Georgi <pgeorgi@chromium.org> | 2015-09-11 13:48:24 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-09-21 13:01:22 +0000 |
commit | a9992d3da5d28dc9f8423fe17497231f894fa9d9 (patch) | |
tree | e3e853d374bc98a9fb6de7a0fd1f1108a03a722c /util | |
parent | 239c74231b7758a2eea99ccb327c4f8f1482503b (diff) |
ifdfake: allow "base+size" description of regions
This is more in line with how fmd/fmap specify ranges.
Change-Id: Iecf8250e84d6eb267711ded446909b21147f1a9c
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/11623
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ifdfake/ifdfake.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/util/ifdfake/ifdfake.c b/util/ifdfake/ifdfake.c index b70b6aeedf..7b268df738 100644 --- a/util/ifdfake/ifdfake.c +++ b/util/ifdfake/ifdfake.c @@ -91,24 +91,39 @@ static void write_image(const region_t regions[], const char *const image) static int parse_region(const char *_arg, region_t *const region) { char *const start = strdup(_arg); + int size_spec = 0; + unsigned long first, second; if (!start) { fprintf(stderr, "Out of memory.\n"); exit(EXIT_FAILURE); } - char *const colon = strchr(start, ':'); + char *colon = strchr(start, ':'); if (!colon) { - free(start); - return -1; + colon = strchr(start, '+'); + if (!colon) { + free(start); + return -1; + } + size_spec = 1; } *colon = '\0'; char *const end = colon + 1; errno = 0; - region->base = strtoul(start, NULL, 0); - region->limit = strtoul(end, NULL, 0); - region->size = region->limit - region->base + 1; + first = strtoul(start, NULL, 0); + second = strtoul(end, NULL, 0); + + if (size_spec) { + region->base = first; + region->size = second; + region->limit = region->base + region->size - 1; + } else { + region->base = first; + region->limit = second; + region->size = region->limit - region->base + 1; + } free(start); if (errno) { |