diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index e5f6ecb62..c6856ca1a 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -59,6 +59,7 @@ TMPDIR=${TMPDIR:-/tmp} print_time=false start_time=`date +%s` ACTIVE_SLOT= +OVERLAYFS_BACKING="cache mnt/scratch" ADB_WAIT=4m FASTBOOT_WAIT=2m @@ -788,6 +789,41 @@ skip_unrelated_mounts() { grep -v "[%] /\(data_mirror\|apex\|bionic\|system\|vendor\)/[^ ][^ ]*$" } +[ "USAGE: surgically_wipe_overlayfs + +Surgically wipe any mounted overlayfs scratch files. + +Returns: true if wiped anything" ] +surgically_wipe_overlayfs() { + local wiped_anything=false + for d in ${OVERLAYFS_BACKING}; do + if adb_su test -d "/${d}/overlay" &2 + adb_su rm -rf "/${d}/overlay" /dev/null 2>/dev/null + ( echo "${df_header_line}" + echo "${overlay_mounts}" + ) >&2 + return 0 +} + ## ## MAINLINE ## @@ -975,7 +1011,6 @@ if ! wait_for_screen && ${screen_wait}; then fi # Can we test remount -R command? -OVERLAYFS_BACKING="cache mnt/scratch" overlayfs_supported=true if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \ "2" != "`get_property partition.system.verified`" ]; then @@ -986,14 +1021,7 @@ if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \ adb_wait ${ADB_WAIT} || true if inAdb; then - reboot=false - for d in ${OVERLAYFS_BACKING}; do - if adb_test -d /${d}/overlay; then - adb_su rm -rf /${d}/overlay &2 # devices that remount the physical content rather than overlayfs. # So lets do our best to surgically wipe the overlayfs state without # having to go through enable-verity transition. -reboot=false -for d in ${OVERLAYFS_BACKING}; do - if adb_test -d /${d}/overlay; then - echo "${YELLOW}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2 - adb_sh rm -rf /${d}/overlay &2 adb_reboot && adb_wait ${ADB_WAIT} || @@ -1091,14 +1110,10 @@ if ${reboot}; then adb_root || die "lost device after elevation to root after wipe `usb_status`" fi -D=`adb_sh df -k &2 && +is_overlayfs_mounted && die "overlay takeover unexpected at this phase" echo "${GREEN}[ OK ]${NORMAL} no overlay present before setup" >&2 + overlayfs_needed=true D=`adb_sh cat /proc/mounts &2 - fi - done - if ! ${has_overlayfs_setup}; then + if ! is_overlayfs_mounted; then die "no overlay being setup after disable-verity -R" fi fi @@ -1630,12 +1638,7 @@ echo "${GREEN}[ OK ]${NORMAL} remount command works from setup" >&2 # Prerequisite is an overlayfs deconstructed device but with verity disabled. # This also saves a lot of 'noise' from the command doing a mkfs on backing # storage and all the related tuning and adjustment. -for d in ${OVERLAYFS_BACKING}; do - if adb_test -d /${d}/overlay; then - adb_su rm -rf /${d}/overlay