Merge "fs_mgr_overlayfs: Polish fs_mgr_overlayfs_mount_fstab_entry()" am: 71db89b1da
am: 349cb5d4c7
am: 51c0482fe4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1710550 Change-Id: I868f0d080569db73ba9a6490e34f4ec06198c271
This commit is contained in:
commit
a415993ea8
3 changed files with 29 additions and 15 deletions
|
@ -92,7 +92,7 @@ bool fs_mgr_overlayfs_mount_all(Fstab*) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const std::string&, const std::string&) {
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const android::fs_mgr::FstabEntry&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1299,16 +1299,30 @@ static void TryMountScratch() {
|
|||
}
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const std::string& lowers,
|
||||
const std::string& mount_point) {
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const android::fs_mgr::FstabEntry& entry) {
|
||||
if (fs_mgr_overlayfs_invalid()) return false;
|
||||
|
||||
std::string aux = "lowerdir=" + lowers + ",override_creds=off";
|
||||
auto rc = mount("overlay", mount_point.c_str(), "overlay", MS_RDONLY | MS_NOATIME, aux.c_str());
|
||||
// Create the mount point in case it doesn't exist.
|
||||
mkdir(entry.mount_point.c_str(), 0755);
|
||||
|
||||
if (rc == 0) return true;
|
||||
auto options = kLowerdirOption + entry.lowerdir;
|
||||
if (fs_mgr_overlayfs_valid() == OverlayfsValidResult::kOverrideCredsRequired) {
|
||||
options += ",override_creds=off";
|
||||
}
|
||||
|
||||
return false;
|
||||
// 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());
|
||||
if (ret) {
|
||||
PERROR << report << ret;
|
||||
return false;
|
||||
}
|
||||
LINFO << report << ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_mount_all(Fstab* fstab) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
android::fs_mgr::Fstab fs_mgr_overlayfs_candidate_list(const android::fs_mgr::Fstab& fstab);
|
||||
|
||||
bool fs_mgr_overlayfs_mount_all(android::fs_mgr::Fstab* fstab);
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry (const std::string& lowers, const std::string& mount_point);
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const android::fs_mgr::FstabEntry& entry);
|
||||
std::vector<std::string> fs_mgr_overlayfs_required_devices(android::fs_mgr::Fstab* fstab);
|
||||
bool fs_mgr_overlayfs_setup(const char* backing = nullptr, const char* mount_point = nullptr,
|
||||
bool* change = nullptr, bool force = true);
|
||||
|
|
|
@ -542,6 +542,7 @@ bool FirstStageMount::MountPartitions() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Handle overlayfs entries later.
|
||||
if (current->fs_type == "overlay") {
|
||||
++current;
|
||||
continue;
|
||||
|
@ -571,6 +572,12 @@ bool FirstStageMount::MountPartitions() {
|
|||
current = end;
|
||||
}
|
||||
|
||||
for (const auto& entry : fstab_) {
|
||||
if (entry.fs_type == "overlay") {
|
||||
fs_mgr_overlayfs_mount_fstab_entry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// If we don't see /system or / in the fstab, then we need to create an root entry for
|
||||
// overlayfs.
|
||||
if (!GetEntryForMountPoint(&fstab_, "/system") && !GetEntryForMountPoint(&fstab_, "/")) {
|
||||
|
@ -596,13 +603,6 @@ bool FirstStageMount::MountPartitions() {
|
|||
};
|
||||
MapScratchPartitionIfNeeded(&fstab_, init_devices);
|
||||
|
||||
for (auto current = fstab_.begin(); current != fstab_.end(); ) {
|
||||
if (current->fs_type == "overlay") {
|
||||
fs_mgr_overlayfs_mount_fstab_entry(current->lowerdir, current->mount_point);
|
||||
}
|
||||
++current;
|
||||
}
|
||||
|
||||
fs_mgr_overlayfs_mount_all(&fstab_);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue