diff options
author | John Crispin <blogic@openwrt.org> | 2015-07-24 09:11:24 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2015-07-24 09:11:24 +0000 |
commit | bd702b9d5276406d42d3a3eebc2ab5b912319db7 (patch) | |
tree | be53a2cb06bd3c9c9c3d9ce7b2bb6c1728ed978b /tools/firmware-utils/src/mktplinkfw.c | |
parent | b3db182b994763125d60be332ba474e26f97343d (diff) | |
download | master-187ad058-bd702b9d5276406d42d3a3eebc2ab5b912319db7.tar.gz master-187ad058-bd702b9d5276406d42d3a3eebc2ab5b912319db7.tar.bz2 master-187ad058-bd702b9d5276406d42d3a3eebc2ab5b912319db7.zip |
firmware-utils mktplinkfw: print amount of exceeding bytes
This is very useful for trimming images towards 4 MiB flash size.
Signed-off-by: Stephan Maka <stephan@spaceboyz.net>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@46469 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'tools/firmware-utils/src/mktplinkfw.c')
-rw-r--r-- | tools/firmware-utils/src/mktplinkfw.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c index 99338d4d67..12420ad995 100644 --- a/tools/firmware-utils/src/mktplinkfw.c +++ b/tools/firmware-utils/src/mktplinkfw.c @@ -591,6 +591,7 @@ static int read_to_buf(struct file_info *fdata, char *buf) static int check_options(void) { int ret; + int exceed_bytes; if (inspect_info.file_name) { ret = get_file_stat(&inspect_info); @@ -664,10 +665,10 @@ static int check_options(void) kernel_len = kernel_info.file_size; if (combined) { - if (kernel_info.file_size > - fw_max_len - sizeof(struct fw_header)) { + exceed_bytes = kernel_info.file_size - (fw_max_len - sizeof(struct fw_header)); + if (exceed_bytes > 0) { if (!ignore_size) { - ERR("kernel image is too big"); + ERR("kernel image is too big by %i bytes", exceed_bytes); return -1; } layout->fw_max_len = sizeof(struct fw_header) + @@ -691,20 +692,20 @@ static int check_options(void) DBG("kernel length aligned to %u", kernel_len); - if (kernel_len + rootfs_info.file_size > - fw_max_len - sizeof(struct fw_header)) { - ERR("images are too big"); + exceed_bytes = kernel_len + rootfs_info.file_size - (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)) { + exceed_bytes = kernel_info.file_size - (rootfs_ofs - sizeof(struct fw_header)); + if (exceed_bytes > 0) { ERR("kernel image is too big"); return -1; } - if (rootfs_info.file_size > - (fw_max_len - rootfs_ofs)) { + exceed_bytes = rootfs_info.file_size - (fw_max_len - rootfs_ofs); + if (exceed_bytes > 0) { ERR("rootfs image is too big"); return -1; } |