adb-remount-test: Discover fstab pathname more intelligently

Pick exactly one fstab file whose pathname suffix matches one of the
fstab suffix properties.
This helps on CF who ships redundant copies of fstab.

Bug: 243116800
Test: adb-remount-test
Change-Id: I4d38859014161e14dba1f7e19dbce44a2621d0f1
This commit is contained in:
Yi-Yo Chiang 2022-08-27 14:02:07 +08:00
parent 32277d0967
commit 9a636d2a85

View file

@ -950,14 +950,23 @@ ACTIVE_SLOT=`get_active_slot`
LOG INFO "active slot is ${ACTIVE_SLOT}"
# Acquire list of system partitions
FSTAB_SUFFIXES=(
"$(get_property ro.boot.fstab_suffix)"
"$(get_property ro.boot.hardware)"
"$(get_property ro.boot.hardware.platform)"
)
FSTAB_PATTERN='\.('"$(join_with "|" "${FSTAB_SUFFIXES[@]}")"')$'
FSTAB_FILE=$(adb_su ls -1 '/vendor/etc/fstab*' </dev/null |
grep -E "${FSTAB_PATTERN}" |
head -1)
# KISS (assume system partition mount point is "/<partition name>")
PARTITIONS=`adb_su cat /vendor/etc/fstab* </dev/null |
grep -v "^[#${SPACE}${TAB}]" |
skip_administrative_mounts |
awk '$1 ~ /^[^\/]+$/ && "/"$1 == $2 && $4 ~ /(^|,)ro(,|$)/ { print $1 }' |
sort -u |
tr '\n' ' '`
[ -n "${FSTAB_FILE}" ] &&
PARTITIONS=$(adb_su grep -v "^[#${SPACE}${TAB}]" "${FSTAB_FILE}" |
skip_administrative_mounts |
awk '$1 ~ /^[^\/]+$/ && "/"$1 == $2 && $4 ~ /(^|,)ro(,|$)/ { print $1 }' |
sort -u |
tr '\n' ' ')
PARTITIONS="${PARTITIONS:-system vendor}"
# KISS (we do not support sub-mounts for system partitions currently)
MOUNTS="`for i in ${PARTITIONS}; do