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

Commit 3d879b10 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "fs_mgr: support reading fstab based on ro.boot.hardware.platform"

parents 4ef714ea 018d7f69
Loading
Loading
Loading
Loading
+30 −11
Original line number Diff line number Diff line
@@ -700,25 +700,44 @@ struct fstab *fs_mgr_read_fstab_dt()
}

/*
 * tries to load default fstab.<hardware> file from /odm/etc, /vendor/etc
 * or /. loads the first one found and also combines fstab entries passed
 * in from device tree.
 * Identify path to fstab file. Lookup is based on pattern
 * fstab.<hardware>, fstab.<hardware.platform> in folders
   /odm/etc, vendor/etc, or /.
 */
struct fstab *fs_mgr_read_fstab_default()
static std::string get_fstab_path()
{
    for (const char* prop : {"hardware", "hardware.platform"}) {
        std::string hw;

        if (!fs_mgr_get_boot_config(prop, &hw)) continue;

        for (const char* prefix : {"/odm/etc/fstab.", "/vendor/etc/fstab.", "/fstab."}) {
            std::string fstab_path = prefix + hw;
            if (access(fstab_path.c_str(), F_OK) == 0) {
                return fstab_path;
            }
        }
    }

    return std::string();
}

/*
 * loads the fstab file and combines with fstab entries passed in from device tree.
 */
struct fstab *fs_mgr_read_fstab_default()
{
    std::string default_fstab;

    // Use different fstab paths for normal boot and recovery boot, respectively
    if (access("/sbin/recovery", F_OK) == 0) {
        default_fstab = "/etc/recovery.fstab";
    } else if (fs_mgr_get_boot_config("hardware", &hw)) {  // normal boot
        for (const char *prefix : {"/odm/etc/fstab.","/vendor/etc/fstab.", "/fstab."}) {
            default_fstab = prefix + hw;
            if (access(default_fstab.c_str(), F_OK) == 0) break;
    } else {  // normal boot
        default_fstab = get_fstab_path();
    }
    } else {
        LWARNING << __FUNCTION__ << "(): failed to find device hardware name";

    if (default_fstab.empty()) {
        LWARNING << __FUNCTION__ << "(): failed to find device default fstab";
    }

    // combines fstab entries passed in from device tree with