diff options
| author | Alexander Couzens | 2019-04-09 17:03:34 +0000 |
|---|---|---|
| committer | Alexander Couzens | 2023-09-19 18:01:18 +0000 |
| commit | 3dc133915f876c478d01dbc29a5b70e5da075352 (patch) | |
| tree | eb34e9fb4c4ef9e26be2952f8c25c94048ba2728 | |
| parent | c18f662f3c740718c3259ce08dc6f5a059ffa7a2 (diff) | |
| download | firmware-utils-3dc133915f876c478d01dbc29a5b70e5da075352.tar.gz | |
mktplinkfw2: show exact exceed bytes when the image is to big
When an image is too big it's useful to show how many bytes the image
is to big.
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
| -rw-r--r-- | src/mktplinkfw2.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mktplinkfw2.c b/src/mktplinkfw2.c index e5981ef..e00e13c 100644 --- a/src/mktplinkfw2.c +++ b/src/mktplinkfw2.c @@ -218,6 +218,7 @@ static void usage(int status) static int check_options(void) { int ret; + int exceed_bytes; if (inspect_info.file_name) { ret = get_file_stat(&inspect_info); @@ -311,21 +312,24 @@ static int check_options(void) DBG("rootfs offset aligned to 0x%u", rootfs_ofs); - if (kernel_len + rootfs_info.file_size > - layout->fw_max_len - sizeof(struct fw_header)) { - ERR("images are too big"); + exceed_bytes = (kernel_len + rootfs_info.file_size) - + (layout->fw_max_len - sizeof(struct fw_header)); + if (exceed_bytes > 0) { + ERR("images are too big by %i bytes", exceed_bytes); return -1; } } else { - if (kernel_info.file_size > - rootfs_ofs - sizeof(struct fw_header)) { - ERR("kernel image is too big"); + exceed_bytes = kernel_info.file_size - + (rootfs_ofs - sizeof(struct fw_header)); + if (exceed_bytes > 0) { + ERR("images are too big by %i bytes", exceed_bytes); return -1; } - if (rootfs_info.file_size > - (layout->fw_max_len - rootfs_ofs)) { - ERR("rootfs image is too big"); + exceed_bytes = rootfs_info.file_size - + (layout->fw_max_len - rootfs_ofs); + if (exceed_bytes > 0) { + ERR("images are too big by %i bytes", exceed_bytes); return -1; } } |