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

Commit d7f203b4 authored by Akilesh Kailash's avatar Akilesh Kailash Committed by Android (Google) Code Review
Browse files

Merge "snapshotctl: umount scratch after update" into main

parents d4500c4b 9033c834
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ using namespace android::storage_literals;
namespace android {
namespace snapshot {

static bool UmountScratch() {
bool UmountScratch(const bool cleanup_ota_dir) {
    Fstab fstab;
    if (!ReadFstabFromProcMounts(&fstab)) {
        LOG(ERROR) << "Cannot read /proc/mounts";
@@ -72,11 +72,13 @@ static bool UmountScratch() {

    auto ota_dir = std::string(kOtaMetadataMount) + "/" + "ota";

    if (cleanup_ota_dir) {
        std::error_code ec;
        if (std::filesystem::remove_all(ota_dir, ec) == static_cast<std::uintmax_t>(-1)) {
            LOG(ERROR) << "Failed to remove OTA directory: " << ec.message();
            return false;
        }
    }

    if (umount(kOtaMetadataMount) != 0) {
        PLOG(ERROR) << "UmountScratch failed";
@@ -88,7 +90,7 @@ static bool UmountScratch() {
}

bool CleanupScratchOtaMetadataIfPresent(const ISnapshotManager::IDeviceInfo* info) {
    if (!UmountScratch()) {
    if (!UmountScratch(true)) {
        return false;
    }

+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ std::string GetScratchOtaMetadataPartition();
std::string MapScratchOtaMetadataPartition(const std::string& device);
bool CreateScratchOtaMetadataOnSuper(const ISnapshotManager::IDeviceInfo* info = nullptr);
bool CleanupScratchOtaMetadataIfPresent(const ISnapshotManager::IDeviceInfo* info = nullptr);
bool UmountScratch(const bool cleanup_ota_dir);

}  // namespace snapshot
}  // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -281,6 +281,8 @@ bool MapSnapshots::GetCowDevicePath(std::string partition_name, std::string* cow
}

bool MapSnapshots::ApplyUpdate() {
    auto scope_guard = android::base::make_scope_guard([]() { UmountScratch(false); });

    if (!PrepareUpdate()) {
        LOG(ERROR) << "PrepareUpdate failed";
        return false;