fs_mgr_overlayfs_mount_fstab_entry(): Rename source device name

adb-remount-test.sh would fail if a overlayfs named "overlay" is mounted
in first_stage_init via fs_mgr_overlayfs_mount_fstab_entry():

  [  FAILED  ] overlay takeover unexpected at this phase

Prepend the source device name with "overlay-", so that the overlayfs
mounted by fs_mgr_overlayfs_mount_fstab_entry() mustn't be named
"overlay".

Bug: 188862155
Test: adb-remount-test.sh
Change-Id: Ia0b3f1c92ed5650c3e584fba23758344a4733657
This commit is contained in:
Yi-Yo Chiang 2021-05-22 22:14:53 +08:00
parent 71db89b1da
commit 7b90e6936c

View file

@ -1310,13 +1310,15 @@ bool fs_mgr_overlayfs_mount_fstab_entry(const android::fs_mgr::FstabEntry& entry
options += ",override_creds=off";
}
// Use .blk_device as the mount() source for debugging purposes.
// Overlayfs is pseudo filesystem, so the source device is a symbolic value and isn't used to
// back the filesystem. /proc/mounts would show the source as the device name of the mount.
auto report = "__mount(source=" + entry.blk_device + ",target=" + entry.mount_point +
",type=overlay," + options + ")=";
auto ret = mount(entry.blk_device.c_str(), entry.mount_point.c_str(), "overlay",
MS_RDONLY | MS_NOATIME, options.c_str());
// Use "overlay-" + entry.blk_device as the mount() source, so that adb-remout-test don't
// confuse this with adb remount overlay, whose device name is "overlay".
// Overlayfs is a pseudo filesystem, so the source device is a symbolic value and isn't used to
// back the filesystem. However the device name would be shown in /proc/mounts.
auto source = "overlay-" + entry.blk_device;
auto report = "__mount(source=" + source + ",target=" + entry.mount_point + ",type=overlay," +
options + ")=";
auto ret = mount(source.c_str(), entry.mount_point.c_str(), "overlay", MS_RDONLY | MS_NOATIME,
options.c_str());
if (ret) {
PERROR << report << ret;
return false;