Make sign_official_build.sh verify perform an additional rootfs sanity check using e2fsck.

This mirrors the change made for cros_make_image_bootable.

BUG=chromium-os:9578
TEST=manually ran verify on signed images including those with known rootfs corruptions.

Change-Id: I5dfdf1bfa975fbbbb4e010cd2adc6a3a7f08da15

Review URL: http://codereview.chromium.org/5367004
This commit is contained in:
Gaurav Shah
2010-11-24 14:49:52 -08:00
parent 44f34b5195
commit 5f500b19ba

View File

@@ -45,7 +45,7 @@ set -e
# Make sure the tools we need are available. # Make sure the tools we need are available.
for prereqs in gbb_utility vbutil_kernel cgpt dump_kernel_config verity \ for prereqs in gbb_utility vbutil_kernel cgpt dump_kernel_config verity \
load_kernel_test dumpe2fs sha1sum; load_kernel_test dumpe2fs sha1sum e2fsck;
do do
type -P "${prereqs}" &>/dev/null || \ type -P "${prereqs}" &>/dev/null || \
{ echo "${prereqs} tool not found."; exit 1; } { echo "${prereqs} tool not found."; exit 1; }
@@ -178,6 +178,20 @@ update_rootfs_hash() {
replace_image_partition ${image} 3 ${rootfs_image} replace_image_partition ${image} 3 ${rootfs_image}
} }
# Do a sanity check on the image's rootfs
# ARGS: Image
verify_image_rootfs() {
local image=$1
local rootfs_image=$(make_temp_file)
extract_image_partition ${image} 3 ${rootfs_image}
# This flips the read-only compatibility flag, so that e2fsck does not
# complain about unknown file system capabilities.
enable_rw_mount ${rootfs_image}
echo "Running e2fsck to check root file system for errors"
sudo e2fsck -fn "${rootfs_image}" ||
{ echo "Root file system has errors!" && exit 1;}
}
# Extracts the firmware update binaries from the a firmware update # Extracts the firmware update binaries from the a firmware update
# shell ball (generated by src/platform/firmware/pack_firmware.sh) # shell ball (generated by src/platform/firmware/pack_firmware.sh)
# Args: INPUT_SCRIPT OUTPUT_DIR # Args: INPUT_SCRIPT OUTPUT_DIR
@@ -306,6 +320,8 @@ EOF
echo "YES"; } || echo "NO" echo "YES"; } || echo "NO"
set -e set -e
verify_image_rootfs "${INPUT_IMAGE}"
# TODO(gauravsh): Check embedded firmware AU signatures. # TODO(gauravsh): Check embedded firmware AU signatures.
} }