diff options
author | Pali Rohár <pali@kernel.org> | 2022-02-13 01:09:46 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-02-28 10:33:11 -0500 |
commit | 11f29d443622070c9423ed5fda74b9564570aac7 (patch) | |
tree | 3f69b209af8f00ed44ee648aeeebe3d8114f221e /tools/imagetool.c | |
parent | a900c7f8161b74fc66ec715e68e7244b53f04298 (diff) | |
download | u-boot-11f29d443622070c9423ed5fda74b9564570aac7.zip u-boot-11f29d443622070c9423ed5fda74b9564570aac7.tar.gz u-boot-11f29d443622070c9423ed5fda74b9564570aac7.tar.bz2 |
tools: mkimage/dumpimage: Allow to use -l with -T
Currently -l option for mkimage and dumpimage ignores option -T and always
tries to autodetect image type.
With this change it is possible to tell mkimage and dumpimage to parse
image file as specific type (and not random autodetected type). This allows
to use mkimage -l or dumpimage -l as tool for validating image.
params.type for -l option is now by default initialized to zero
(IH_TYPE_INVALID) instead of IH_TYPE_KERNEL. imagetool_get_type() for
IH_TYPE_INVALID returns NULL, which is assigned to tparams. mkimage and
dumpimage code is extended to handle tparams with NULL for -l option. And
imagetool_verify_print_header() is extended to do validation via tparams if
is not NULL.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/imagetool.c')
-rw-r--r-- | tools/imagetool.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/imagetool.c b/tools/imagetool.c index ba1f64a..5ad6d74 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -26,6 +26,12 @@ struct image_type_params *imagetool_get_type(int type) return NULL; } +static int imagetool_verify_print_header_by_type( + void *ptr, + struct stat *sbuf, + struct image_type_params *tparams, + struct image_tool_params *params); + int imagetool_verify_print_header( void *ptr, struct stat *sbuf, @@ -39,6 +45,9 @@ int imagetool_verify_print_header( struct image_type_params **start = __start_image_type; struct image_type_params **end = __stop_image_type; + if (tparams) + return imagetool_verify_print_header_by_type(ptr, sbuf, tparams, params); + for (curr = start; curr != end; curr++) { if ((*curr)->verify_header) { retval = (*curr)->verify_header((unsigned char *)ptr, @@ -65,7 +74,7 @@ int imagetool_verify_print_header( return retval; } -int imagetool_verify_print_header_by_type( +static int imagetool_verify_print_header_by_type( void *ptr, struct stat *sbuf, struct image_type_params *tparams, |