Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe52f394 authored by Yi-Yo Chiang's avatar Yi-Yo Chiang
Browse files

adb-remount-test: Only test mounts that are remounted by us

Right now we assume all RW mounts (minus /data & special FS) are
remounted by us and we apply the remount/overlayfs related checks
on them unconditionally. This would generate false positives when
a partition was RW but not remounted by us.
The test should instead check mounts that were remounted by us
(transitioned from RO to RW after adb-remount), and ignore
partitions that were already RW before running adb-remount.

Bug: 313609600
Test: adb-remount-test
Change-Id: I94e8a35775271f557790a458781657eb3b24a6f5
parent 711a5e24
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -1233,6 +1233,12 @@ adb_sh grep -qE " (/system|/) [^ ]* rw," /proc/mounts </dev/null &&
adb_sh grep -q " /vendor [^ ]* rw," /proc/mounts </dev/null &&
  die "/vendor is not RO"

data_device=$(adb_sh awk '$2 == "/data" { print $1; exit }' /proc/mounts)
RO=$(adb_sh grep " ro," /proc/mounts </dev/null |
    grep -v "^${data_device}" |
    skip_administrative_mounts |
    awk '{ print $1 }')

T=$(adb_date)
adb remount >&2 ||
  die -t "${T}" "adb remount"
@@ -1241,6 +1247,12 @@ adb_sh grep -qE " (/system|/) [^ ]* rw," /proc/mounts </dev/null ||
adb_sh grep -q " /vendor [^ ]* rw," /proc/mounts </dev/null ||
  die -t "${T}" "/vendor is not RW"

# Only find mounts that are remounted RO -> RW
RW=$(adb_sh grep " rw," /proc/mounts </dev/null |
    grep -v "^${data_device}" |
    skip_administrative_mounts |
    grep -E "^($(join_with '|' ${RO})) ")

scratch_on_super=false
if ${overlayfs_needed}; then
  is_overlayfs_mounted /system ||
@@ -1287,21 +1299,13 @@ if ${overlayfs_needed}; then
    fi
  done

  data_device=$(adb_sh awk '$2 == "/data" { print $1; exit }' /proc/mounts)
  # KISS (we do not support sub-mounts for system partitions currently)
  adb_sh grep "^overlay " /proc/mounts </dev/null |
    grep -vE "^overlay.* /(apex|system|vendor)/[^ ]" |
    grep " overlay ro," &&
    die "expected overlay to be RW after remount"
  adb_sh grep -v noatime /proc/mounts </dev/null |
    grep -v "^${data_device}" |
    skip_administrative_mounts |
    grep -v ' ro,' &&
    die "mounts are not noatime"

  D=$(adb_sh grep " rw," /proc/mounts </dev/null |
      grep -v "^${data_device}" |
      skip_administrative_mounts |
  D=$(echo "${RW}" |
      awk '{ print $1 }' |
      sed 's|/dev/root|/|' |
      sort -u)
@@ -1319,6 +1323,10 @@ else
  is_overlayfs_mounted && die -t "${T}" "unexpected overlay takeover"
fi

echo -n "${RW}" |
  grep -v noatime &&
  die "mounts (rw) are not noatime"

LOG OK "adb remount RW"

################################################################################