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

Commit fec3d19a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7263361 from db4c5ca0 to sc-v2-release

Change-Id: I74c1791bfed76d01099b41f54ade4ade4feead88
parents b0cda289 db4c5ca0
Loading
Loading
Loading
Loading
+37 −29
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ void EnableMandatoryFlags(Fstab* fstab) {
    }
}

bool ReadFstabFromFile(const std::string& path, Fstab* fstab) {
bool ReadFstabFromFile(const std::string& path, Fstab* fstab_out) {
    auto fstab_file = std::unique_ptr<FILE, decltype(&fclose)>{fopen(path.c_str(), "re"), fclose};
    if (!fstab_file) {
        PERROR << __FUNCTION__ << "(): cannot open file: '" << path << "'";
@@ -689,31 +689,43 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab) {

    bool is_proc_mounts = path == "/proc/mounts";

    if (!ReadFstabFile(fstab_file.get(), is_proc_mounts, fstab)) {
    Fstab fstab;
    if (!ReadFstabFile(fstab_file.get(), is_proc_mounts, &fstab)) {
        LERROR << __FUNCTION__ << "(): failed to load fstab from : '" << path << "'";
        return false;
    }
    if (!is_proc_mounts && !access(android::gsi::kGsiBootedIndicatorFile, F_OK)) {
    if (!is_proc_mounts) {
        if (!access(android::gsi::kGsiBootedIndicatorFile, F_OK)) {
            // This is expected to fail if host is android Q, since Q doesn't
            // support DSU slotting. The DSU "active" indicator file would be
            // non-existent or empty if DSU is enabled within the guest system.
            // In that case, just use the default slot name "dsu".
            std::string dsu_slot;
        if (!android::gsi::GetActiveDsu(&dsu_slot)) {
            PWARNING << __FUNCTION__ << "(): failed to get active dsu slot";
            if (!android::gsi::GetActiveDsu(&dsu_slot) && errno != ENOENT) {
                PERROR << __FUNCTION__ << "(): failed to get active DSU slot";
                return false;
            }
            if (dsu_slot.empty()) {
                dsu_slot = "dsu";
                LWARNING << __FUNCTION__ << "(): assuming default DSU slot: " << dsu_slot;
            }

            // This file is non-existent on Q vendor.
            std::string lp_names;
        ReadFileToString(gsi::kGsiLpNamesFile, &lp_names);
        TransformFstabForDsu(fstab, dsu_slot, Split(lp_names, ","));
            if (!ReadFileToString(gsi::kGsiLpNamesFile, &lp_names) && errno != ENOENT) {
                PERROR << __FUNCTION__ << "(): failed to read DSU LP names";
                return false;
            }
            TransformFstabForDsu(&fstab, dsu_slot, Split(lp_names, ","));
        } else if (errno != ENOENT) {
            PERROR << __FUNCTION__ << "(): failed to access() DSU booted indicator";
            return false;
        }
    }

    SkipMountingPartitions(fstab, false /* verbose */);
    EnableMandatoryFlags(fstab);
    SkipMountingPartitions(&fstab, false /* verbose */);
    EnableMandatoryFlags(&fstab);

    *fstab_out = std::move(fstab);
    return true;
}

@@ -788,10 +800,8 @@ bool SkipMountingPartitions(Fstab* fstab, bool verbose) {

// Loads the fstab file and combines with fstab entries passed in from device tree.
bool ReadDefaultFstab(Fstab* fstab) {
    Fstab dt_fstab;
    ReadFstabFromDt(&dt_fstab, false /* verbose */);

    *fstab = std::move(dt_fstab);
    fstab->clear();
    ReadFstabFromDt(fstab, false /* verbose */);

    std::string default_fstab_path;
    // Use different fstab paths for normal boot and recovery boot, respectively
@@ -802,15 +812,13 @@ bool ReadDefaultFstab(Fstab* fstab) {
    }

    Fstab default_fstab;
    if (!default_fstab_path.empty()) {
        ReadFstabFromFile(default_fstab_path, &default_fstab);
    } else {
        LINFO << __FUNCTION__ << "(): failed to find device default fstab";
    }

    if (!default_fstab_path.empty() && ReadFstabFromFile(default_fstab_path, &default_fstab)) {
        for (auto&& entry : default_fstab) {
            fstab->emplace_back(std::move(entry));
        }
    } else {
        LINFO << __FUNCTION__ << "(): failed to find device default fstab";
    }

    return !fstab->empty();
}
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ class SnapuserdClient {
    // must ONLY be called if the control device has already been deleted.
    bool WaitForDeviceDelete(const std::string& control_device);

    void CloseConnection() { sockfd_ = {}; }

    // Detach snapuserd. This shuts down the listener socket, and will cause
    // snapuserd to gracefully exit once all handler threads have terminated.
    // This should only be used on first-stage instances of snapuserd.
+11 −0
Original line number Diff line number Diff line
@@ -2297,6 +2297,17 @@ bool SnapshotManager::UnmapAllSnapshots(LockedFile* lock) {
            return false;
        }
    }

    // Terminate the daemon and release the snapuserd_client_ object.
    // If we need to re-connect with the daemon, EnsureSnapuserdConnected()
    // will re-create the object and establish the socket connection.
    if (snapuserd_client_) {
        LOG(INFO) << "Shutdown snapuserd daemon";
        snapuserd_client_->DetachSnapuserd();
        snapuserd_client_->CloseConnection();
        snapuserd_client_ = nullptr;
    }

    return true;
}

+2 −0
Original line number Diff line number Diff line
@@ -2019,6 +2019,8 @@ TEST_F(SnapshotUpdateTest, MapAllSnapshots) {

    // Read bytes back and verify they match the cache.
    ASSERT_TRUE(IsPartitionUnchanged("sys_b"));

    ASSERT_TRUE(sm->UnmapAllSnapshots());
}

TEST_F(SnapshotUpdateTest, CancelOnTargetSlot) {
+2 −1
Original line number Diff line number Diff line
@@ -363,8 +363,9 @@ rust_bindgen {
    local_include_dirs: ["include"],
    bindgen_flags: [
        "--whitelist-function", "multiuser_get_app_id",
        "--whitelist-function", "multiuser_get_user_id",
        "--whitelist-function", "multiuser_get_uid",
        "--whitelist-function", "multiuser_get_user_id",
        "--whitelist-var", "AID_KEYSTORE",
        "--whitelist-var", "AID_USER_OFFSET",
    ],
}
Loading