Loading fs_mgr/fs_mgr_overlayfs.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -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"; } Loading @@ -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; } Loading Loading @@ -829,11 +833,12 @@ 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); } } } } if (fs_mgr_overlayfs_mount(mount_point)) ret = true; } return ret; Loading Loading @@ -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) { Loading fs_mgr/tests/adb-remount-test.sh +28 −5 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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} </dev/null` echo "${D}" if [ X"${D}" = X"${D##* 100[%] }" ]; then if [ X"${D}" = X"${D##* 100[%] }" ] && ${no_dedupe} ; then overlayfs_needed=false elif ! ${overlayfs_supported}; then die "need overlayfs, but do not have it" Loading Loading @@ -597,6 +603,7 @@ echo "${GREEN}[ OK ]${NORMAL} /vendor content remains after reboot" >&2 echo "${GREEN}[ RUN ]${NORMAL} flash vendor, confirm its content disappears" >&2 H=`adb_sh echo '${HOSTNAME}' </dev/null 2>/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 Loading @@ -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) || Loading Loading @@ -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 && 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" Loading @@ -662,8 +676,17 @@ else adb_root || die "adb root" B="`adb_cat /vendor/hello`" && 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 Loading Loading
fs_mgr/fs_mgr_overlayfs.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -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"; } Loading @@ -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; } Loading Loading @@ -829,11 +833,12 @@ 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); } } } } if (fs_mgr_overlayfs_mount(mount_point)) ret = true; } return ret; Loading Loading @@ -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) { Loading
fs_mgr/tests/adb-remount-test.sh +28 −5 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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} </dev/null` echo "${D}" if [ X"${D}" = X"${D##* 100[%] }" ]; then if [ X"${D}" = X"${D##* 100[%] }" ] && ${no_dedupe} ; then overlayfs_needed=false elif ! ${overlayfs_supported}; then die "need overlayfs, but do not have it" Loading Loading @@ -597,6 +603,7 @@ echo "${GREEN}[ OK ]${NORMAL} /vendor content remains after reboot" >&2 echo "${GREEN}[ RUN ]${NORMAL} flash vendor, confirm its content disappears" >&2 H=`adb_sh echo '${HOSTNAME}' </dev/null 2>/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 Loading @@ -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) || Loading Loading @@ -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 && 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" Loading @@ -662,8 +676,17 @@ else adb_root || die "adb root" B="`adb_cat /vendor/hello`" && 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 Loading