Loading fs_mgr/tests/adb-remount-test.sh +42 −39 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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" </dev/null; then echo "${BLUE}[ INFO ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2 adb_su rm -rf "/${d}/overlay" </dev/null wiped_anything=true fi done ${wiped_anything} } [ "USAGE: is_overlayfs_mounted Returns: true if overlayfs is mounted" ] is_overlayfs_mounted() { local df_output=$(adb_su df -k </dev/null) local df_header_line=$(echo "${df_output}" | head -1) local overlay_mounts=$(echo "${df_output}" | tail +2 | skip_unrelated_mounts | awk '$1 == "overlay" || $6 == "/mnt/scratch"') if ! echo "${overlay_mounts}" | grep -q '^overlay '; then return 1 fi >/dev/null 2>/dev/null ( echo "${df_header_line}" echo "${overlay_mounts}" ) >&2 return 0 } ## ## MAINLINE ## Loading Loading @@ -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 Loading @@ -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 </dev/null reboot=true fi done if ${reboot}; then if surgically_wipe_overlayfs; then adb_reboot && adb_wait ${ADB_WAIT} fi Loading Loading @@ -1074,16 +1102,7 @@ echo "${GREEN}[ RUN ]${NORMAL} Checking current overlayfs status" >&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 </dev/null || die "/${d}/overlay wipe" reboot=true fi done if ${reboot}; then if surgically_wipe_overlayfs; then echo "${YELLOW}[ WARNING ]${NORMAL} rebooting before test" >&2 adb_reboot && adb_wait ${ADB_WAIT} || Loading @@ -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 </dev/null` && H=`echo "${D}" | head -1` && D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` && ( echo "${H}" && echo "${D}" ) >&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 </dev/null | skip_administrative_mounts data` Loading Loading @@ -1153,14 +1168,7 @@ adb_wait "${ADB_WAIT}" && die "lost device after adb shell su root disable-verity -R $(usb_status)" if ${overlayfs_needed}; then has_overlayfs_setup=false for d in ${OVERLAYFS_BACKING}; do if adb_test -d "/${d}/overlay"; then has_overlayfs_setup=true echo "${GREEN}[ OK ]${NORMAL} /${d}/overlay is setup" >&2 fi done if ! ${has_overlayfs_setup}; then if ! is_overlayfs_mounted; then die "no overlay being setup after disable-verity -R" fi fi Loading Loading @@ -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 </dev/null || die "/${d}/overlay wipe" fi done surgically_wipe_overlayfs || true adb_reboot && adb_wait ${ADB_WAIT} || fixup_from_fastboot || Loading Loading
fs_mgr/tests/adb-remount-test.sh +42 −39 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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" </dev/null; then echo "${BLUE}[ INFO ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2 adb_su rm -rf "/${d}/overlay" </dev/null wiped_anything=true fi done ${wiped_anything} } [ "USAGE: is_overlayfs_mounted Returns: true if overlayfs is mounted" ] is_overlayfs_mounted() { local df_output=$(adb_su df -k </dev/null) local df_header_line=$(echo "${df_output}" | head -1) local overlay_mounts=$(echo "${df_output}" | tail +2 | skip_unrelated_mounts | awk '$1 == "overlay" || $6 == "/mnt/scratch"') if ! echo "${overlay_mounts}" | grep -q '^overlay '; then return 1 fi >/dev/null 2>/dev/null ( echo "${df_header_line}" echo "${overlay_mounts}" ) >&2 return 0 } ## ## MAINLINE ## Loading Loading @@ -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 Loading @@ -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 </dev/null reboot=true fi done if ${reboot}; then if surgically_wipe_overlayfs; then adb_reboot && adb_wait ${ADB_WAIT} fi Loading Loading @@ -1074,16 +1102,7 @@ echo "${GREEN}[ RUN ]${NORMAL} Checking current overlayfs status" >&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 </dev/null || die "/${d}/overlay wipe" reboot=true fi done if ${reboot}; then if surgically_wipe_overlayfs; then echo "${YELLOW}[ WARNING ]${NORMAL} rebooting before test" >&2 adb_reboot && adb_wait ${ADB_WAIT} || Loading @@ -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 </dev/null` && H=`echo "${D}" | head -1` && D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` && ( echo "${H}" && echo "${D}" ) >&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 </dev/null | skip_administrative_mounts data` Loading Loading @@ -1153,14 +1168,7 @@ adb_wait "${ADB_WAIT}" && die "lost device after adb shell su root disable-verity -R $(usb_status)" if ${overlayfs_needed}; then has_overlayfs_setup=false for d in ${OVERLAYFS_BACKING}; do if adb_test -d "/${d}/overlay"; then has_overlayfs_setup=true echo "${GREEN}[ OK ]${NORMAL} /${d}/overlay is setup" >&2 fi done if ! ${has_overlayfs_setup}; then if ! is_overlayfs_mounted; then die "no overlay being setup after disable-verity -R" fi fi Loading Loading @@ -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 </dev/null || die "/${d}/overlay wipe" fi done surgically_wipe_overlayfs || true adb_reboot && adb_wait ${ADB_WAIT} || fixup_from_fastboot || Loading