From d0694f5ac9871fe415235739fd62ff6effe5bf11 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Sat, 12 May 2012 14:15:36 +0800 Subject: [PATCH] Check kernel image size when building image Kernel and ramdisk image together are copied into a 16MB partition. This CL logs their size when building image. If they are larger than 14MB, warning message is emitted. If they reached 16MB, building fails. BUG=chromium-os:27739 TEST=Build success on x86 and arm. Check log and see kernel image size logged. Lower the size limit to 6MB and build x86 factory install shim and see build fail. Change-Id: I4c4895c2989b302aa0c3624127518468566d1148 Reviewed-on: https://gerrit.chromium.org/gerrit/22543 Reviewed-by: Mike Frysinger Commit-Ready: Vic Yang Tested-by: Vic Yang --- bin/cros_make_image_bootable | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/cros_make_image_bootable b/bin/cros_make_image_bootable index 33ac51399d..c538a094ad 100755 --- a/bin/cros_make_image_bootable +++ b/bin/cros_make_image_bootable @@ -228,6 +228,16 @@ make_image_bootable() { --keys_dir="${FLAGS_keys_dir}" \ ${use_dev_keys} + # Check the size of kernel image and issue warning when image size is + # near the limit. + local kernel_image_size=$(stat -c '%s' ${FLAGS_output_dir}/vmlinuz.image) + info "Kernel image size is ${kernel_image_size} bytes." + if [[ ${kernel_image_size} -gt $((16 * 1024 * 1024)) ]]; then + die "Kernel image is larger than 16 MB." + elif [[ ${kernel_image_size} -gt $((14 * 1024 * 1024)) ]]; then + warn "Kernel image is larger than 14 MB. Limit is 16 MB." + fi + local rootfs_hash_size=$(stat -c '%s' ${FLAGS_rootfs_hash}) info "Appending rootfs.hash (${rootfs_hash_size} bytes) to the root fs" if [[ ${rootfs_hash_size} -gt $((FLAGS_rootfs_hash_pad * 1024 * 1024)) ]]