From ae8b8a4e00c67dc3b7373c3a41a15afb8c396fc4 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 12 Aug 2019 08:10:00 -0700 Subject: [PATCH] fs_mgr: adb-remount-test: non-verity recovery For devices that do not have verity, or start the test with verity disabled, but are using overlayfs, use a 'secret' surgical technique to revert the device back to original state. adb enable-verity will carry risk in that if the device did not arrive with verity enabled, we can not guarantee it will boot if we turn on verity. Test: atest adb-remount-sh Bug: 138649540 Change-Id: If6d55c57fb9daca9305c42a4df2c18c7f8c5eefa --- fs_mgr/tests/adb-remount-test.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 642f2c1e6..397d8e5a1 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -890,14 +890,37 @@ adb_sh ls -l /dev/block/by-name/ /dev/null | # If reboot too soon after fresh flash, could trip device update failure logic wait_for_screen # Can we test remount -R command? +OVERLAYFS_BACKING="cache mnt/scratch" overlayfs_supported=true -if [ "orange" = "`get_property ro.boot.verifiedbootstate`" -a \ - "2" = "`get_property partition.system.verified`" ]; then +if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \ + "2" != "`get_property partition.system.verified`" ]; then restore() { ${overlayfs_supported} || return 0 inFastboot && fastboot reboot && - adb_wait ${ADB_WAIT} + adb_wait ${ADB_WAIT} || + true + if inAdb; then + reboot=false + for d in ${OVERLAYFS_BACKING}; do + if adb_su ls -d /${d}/overlay /dev/null 2>/dev/null; then + adb_su rm -rf /${d}/overlay /dev/null 2>/dev/null && @@ -956,7 +979,6 @@ echo "${GREEN}[ RUN ]${NORMAL} Checking current overlayfs status" >&2 # So lets do our best to surgically wipe the overlayfs state without # having to go through enable-verity transition. reboot=false -OVERLAYFS_BACKING="cache mnt/scratch" for d in ${OVERLAYFS_BACKING}; do if adb_sh ls -d /${d}/overlay /dev/null 2>/dev/null; then echo "${ORANGE}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2 @@ -1468,7 +1490,7 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then } dd if=/dev/zero of=${img} bs=4096 count=16 2>/dev/null && fastboot_wait ${FASTBOOT_WAIT} || - die "reboot into fastboot `usb_status`" + die "reboot into fastboot to flash scratch `usb_status`" fastboot flash --force ${scratch_partition} ${img} err=${?} cleanup