From ff73cef8a6b6edff98faf202b242879e8561d1ac Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 7 Oct 2012 12:14:28 -0400 Subject: [PATCH] build_image: fall back to ro-mount automatically A rootfs built with verification cannot be mounted rw, so have the mount script try to mount things ro if the rw mount failed. BUG=None TEST=`./build_image && ./mount.sh` work Change-Id: I291ece366e03e218b3cd9ff8f30bd9a6e9cf879d Reviewed-on: https://gerrit.chromium.org/gerrit/35065 Tested-by: Mike Frysinger Reviewed-by: Liam McLoughlin Commit-Ready: Mike Frysinger --- build_library/disk_layout_util.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build_library/disk_layout_util.sh b/build_library/disk_layout_util.sh index a686d862df..aa8e08198d 100644 --- a/build_library/disk_layout_util.sh +++ b/build_library/disk_layout_util.sh @@ -158,8 +158,12 @@ EOF if [[ ${size} -gt 1 ]]; then cat <<-EOF >>"${mount}" mkdir -p ${dir} -sudo mount -o loop,offset=${start_b},sizelimit=${size_b} ${target} ${dir} || \ - rmdir ${dir} +m=( sudo mount -o loop,offset=${start_b},sizelimit=${size_b} ${target} ${dir} ) +if ! "\${m[@]}"; then + if ! "\${m[@]}" -o ro; then + rmdir ${dir} + fi +fi EOF cat <<-EOF >>"${umount}" if [[ -d ${dir} ]]; then