fs_mgr: overlay: support non-DAP A/B devices
Loosen some tests and borrow logic from retrofit Dynamic Android
Partitions (DAP) A/B devices. In non-DAP A/B device case
/mnt/scratch is used, backed by the system other partition.
Tested on taimen with CONFIG_OVERLAY_FS added to its pre 4.6 kernel,
and BOARD_EXT4_SHARE_DUP_BLOCKS := true added to board config. Also
tested on a retrofit DAP A/B device and an untouched taimen.
Test: adb_remount_test.sh
Bug: 120448575
Change-Id: I72aaf4d68db1c3ac380aba425346ab6443cadad3
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index 89d1d82..2c4299a 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -642,7 +642,11 @@
// 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;
}
@@ -883,10 +887,6 @@
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) {