diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp index 390868311..2c4299a25 100644 --- a/fs_mgr/fs_mgr_overlayfs.cpp +++ b/fs_mgr/fs_mgr_overlayfs.cpp @@ -626,8 +626,8 @@ const std::string kMkExt4("/system/bin/mke2fs"); // Only a suggestion for _first_ try during mounting std::string fs_mgr_overlayfs_scratch_mount_type() { - if (!access(kMkF2fs.c_str(), X_OK)) return "f2fs"; - if (!access(kMkExt4.c_str(), X_OK)) return "ext4"; + if (!access(kMkF2fs.c_str(), X_OK) && fs_mgr_access("/sys/fs/f2fs")) return "f2fs"; + if (!access(kMkExt4.c_str(), X_OK) && fs_mgr_access("/sys/fs/ext4")) return "ext4"; return "auto"; } @@ -642,7 +642,11 @@ std::string fs_mgr_overlayfs_scratch_device() { // Create from within single super device; auto& dm = DeviceMapper::Instance(); const auto partition_name = android::base::Basename(kScratchMountPoint); - if (!dm.GetDmDevicePathByName(partition_name, &path)) return ""; + if (!dm.GetDmDevicePathByName(partition_name, &path)) { + // non-DAP A/B device? + if (fs_mgr_access(super_device)) return ""; + path = kPhysicalDevice + "system" + (slot_number ? "_a" : "_b"); + } } return scratch_device_cache = path; } @@ -829,8 +833,9 @@ bool fs_mgr_overlayfs_mount_all(Fstab* fstab) { true /* readonly */)) { auto has_overlayfs_dir = fs_mgr_access(kScratchMountPoint + kOverlayTopDir); fs_mgr_overlayfs_umount_scratch(); - if (has_overlayfs_dir) + if (has_overlayfs_dir) { fs_mgr_overlayfs_mount_scratch(scratch_device, mount_type); + } } } } @@ -882,10 +887,6 @@ bool fs_mgr_overlayfs_setup(const char* backing, const char* mount_point, bool* for (const auto& overlay_mount_point : kOverlayMountPoints) { if (backing && backing[0] && (overlay_mount_point != backing)) continue; if (overlay_mount_point == kScratchMountPoint) { - if (!fs_mgr_rw_access(fs_mgr_overlayfs_super_device(fs_mgr_overlayfs_slot_number())) || - !fs_mgr_overlayfs_has_logical(fstab)) { - continue; - } if (!fs_mgr_overlayfs_setup_scratch(fstab, change)) continue; } else { if (std::find_if(fstab.begin(), fstab.end(), [&overlay_mount_point](const auto& entry) { diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 0765f04a2..42f3f2903 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -309,7 +309,7 @@ skip_administrative_mounts() { -e "^\(overlay\|tmpfs\|none\|sysfs\|proc\|selinuxfs\|debugfs\) " \ -e "^\(bpf\|cg2_bpf\|pstore\|tracefs\|adb\|mtp\|ptp\|devpts\) " \ -e "^\(/data/media\|/dev/block/loop[0-9]*\) " \ - -e " /\(cache\|mnt/scratch\|mnt/vendor/persist\|metadata\) " + -e " /\(cache\|mnt/scratch\|mnt/vendor/persist\|persist\|metadata\) " } if [ X"-s" = X"${1}" -a -n "${2}" ]; then @@ -403,9 +403,15 @@ if echo "${D}" | grep /dev/root >/dev/null; then echo "${D}" | grep -v /dev/root` fi D=`echo "${D}" | cut -s -d' ' -f1 | sort -u` +no_dedupe=true +for d in ${D}; do + adb_sh tune2fs -l $d 2>&1 | + grep "Filesystem features:.*shared_blocks" >/dev/null && + no_dedupe=false +done D=`adb_sh df -k ${D} &2 echo "${GREEN}[ RUN ]${NORMAL} flash vendor, confirm its content disappears" >&2 H=`adb_sh echo '${HOSTNAME}' /dev/null` +is_userspace_fastboot=false if [ -z "${ANDROID_PRODUCT_OUT}" ]; then echo "${ORANGE}[ WARNING ]${NORMAL} build tree not setup, skipping" elif [ ! -s "${ANDROID_PRODUCT_OUT}/vendor.img" ]; then @@ -609,6 +616,8 @@ else fastboot flash vendor || ( fastboot reboot && false) || die "fastboot flash vendor" + fastboot_getvar is-userspace yes && + is_userspace_fastboot=true if [ -n "${scratch_paritition}" ]; then fastboot_getvar partition-type:${scratch_partition} raw || ( fastboot reboot && false) || @@ -654,7 +663,12 @@ else echo "${D}" | grep "^overlay .* /system\$" >/dev/null || die "overlay /system takeover after flash vendor" echo "${D}" | grep "^overlay .* /vendor\$" >/dev/null && - die "overlay supposed to be minus /vendor takeover after flash vendor" + if ${is_userspace_fastboot}; then + die "overlay supposed to be minus /vendor takeover after flash vendor" + else + echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing, ignoring a failure" + ( die "overlay supposed to be minus /vendor takeover after flash vendor" ) + fi fi B="`adb_cat /system/hello`" || die "re-read /system/hello after flash vendor" @@ -662,8 +676,17 @@ else adb_root || die "adb root" B="`adb_cat /vendor/hello`" && - die "re-read /vendor/hello after flash vendor" - check_eq "cat: /vendor/hello: No such file or directory" "${B}" vendor after flash vendor + if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then + die "re-read /vendor/hello after flash vendor" + else + echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing, ignoring a failure" + ( die "re-read /vendor/hello after flash vendor" ) + fi + if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then + check_eq "cat: /vendor/hello: No such file or directory" "${B}" vendor after flash vendor + else + ( check_eq "cat: /vendor/hello: No such file or directory" "${B}" vendor after flash vendor ) + fi fi echo "${GREEN}[ RUN ]${NORMAL} remove test content (cleanup)" >&2