OverlayFS support for fstab
Add overlayfs (lowerdir) mount entry support to fstab. overlay <final dir> overlay lowerdir=/1:/2 E.g. overlay /vendor overlay lowerdir=/odm/vnd_ovl1/1:/odm/vnd_ovl2 Test: Ensure mounting with fstab overlayfs entry Change-Id: Ib025e203f8ac1836ab62dfa96fb14e8e108f82fb
This commit is contained in:
parent
7b5e682da1
commit
d926aded73
|
@ -298,6 +298,8 @@ void ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
|
|||
if (!ParseByteCount(arg, &entry->zram_backingdev_size)) {
|
||||
LWARNING << "Warning: zram_backingdev_size= flag malformed: " << arg;
|
||||
}
|
||||
} else if (StartsWith(flag, "lowerdir=")) {
|
||||
entry->lowerdir = arg;
|
||||
} else {
|
||||
LWARNING << "Warning: unknown flag: " << flag;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,10 @@ bool fs_mgr_overlayfs_mount_all(Fstab*) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const std::string&, const std::string&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> fs_mgr_overlayfs_required_devices(Fstab*) {
|
||||
return {};
|
||||
}
|
||||
|
@ -1295,6 +1299,18 @@ static void TryMountScratch() {
|
|||
}
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_mount_fstab_entry(const std::string& lowers,
|
||||
const std::string& mount_point) {
|
||||
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());
|
||||
|
||||
if (rc == 0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_mount_all(Fstab* fstab) {
|
||||
auto ret = false;
|
||||
if (fs_mgr_overlayfs_invalid()) return ret;
|
||||
|
|
|
@ -27,6 +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);
|
||||
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);
|
||||
|
|
|
@ -55,6 +55,7 @@ struct FstabEntry {
|
|||
std::string vbmeta_partition;
|
||||
uint64_t zram_backingdev_size = 0;
|
||||
std::string avb_keys;
|
||||
std::string lowerdir;
|
||||
|
||||
struct FsMgrFlags {
|
||||
bool wait : 1;
|
||||
|
|
|
@ -331,6 +331,12 @@ bool FirstStageMount::InitRequiredDevices(std::set<std::string> devices) {
|
|||
if (devices.empty()) {
|
||||
return true;
|
||||
}
|
||||
// excluding overlays
|
||||
for (auto iter = devices.begin(); iter != devices.end(); ) {
|
||||
if (*iter=="overlay") iter = devices.erase(iter);
|
||||
else iter++;
|
||||
}
|
||||
|
||||
return block_dev_init_.InitDevices(std::move(devices));
|
||||
}
|
||||
|
||||
|
@ -542,6 +548,11 @@ bool FirstStageMount::MountPartitions() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (current->fs_type == "overlay") {
|
||||
++current;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip raw partition entries such as boot, dtbo, etc.
|
||||
// Having emmc fstab entries allows us to probe current->vbmeta_partition
|
||||
// in InitDevices() when they are AVB chained partitions.
|
||||
|
@ -591,6 +602,13 @@ 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 New Issue