Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7cdbd8e6 authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge "OverlayFS support for fstab"

parents a06eac49 d926aded
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
        }
+16 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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;
+18 −0
Original line number Diff line number Diff line
@@ -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;