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

Commit 4e936b4b authored by David Anderson's avatar David Anderson
Browse files

libsnapshot: Quell error spam during factory data resets.

QuerySnapshotStatus assumes IsSnapshotDevice() would return true.

Additionally, recovery does not have access to /dev/loop-control, which
cannot be used by libfiemap anyway. Access it on-demand instead of
preemptively.

Bug: N/A
Test: manual test
Change-Id: I0f746870d7a8ec6d666f0bdd2fef3464b214928b
parent e3cdd294
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include <libfiemap/image_manager.h>

#include <optional>

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
@@ -574,7 +576,7 @@ bool ImageManager::UnmapImageDevice(const std::string& name, bool force) {
        return false;
    }
    auto& dm = DeviceMapper::Instance();
    LoopControl loop;
    std::optional<LoopControl> loop;

    std::string status;
    auto status_file = GetStatusFilePath(name);
@@ -598,9 +600,14 @@ bool ImageManager::UnmapImageDevice(const std::string& name, bool force) {
                return false;
            }
        } else if (pieces[0] == "loop") {
            // Lazily connect to loop-control to avoid spurious errors in recovery.
            if (!loop.has_value()) {
                loop.emplace();
            }

            // Failure to remove a loop device is not fatal, since we can still
            // remove the backing file if we want.
            loop.Detach(pieces[1]);
            loop->Detach(pieces[1]);
        } else {
            LOG(ERROR) << "Unknown status: " << pieces[0];
        }
+1 −0
Original line number Diff line number Diff line
@@ -1692,6 +1692,7 @@ UpdateState SnapshotManager::GetUpdateState(double* progress) {
    for (const auto& snapshot : snapshots) {
        DmTargetSnapshot::Status current_status;

        if (!IsSnapshotDevice(snapshot)) continue;
        if (!QuerySnapshotStatus(snapshot, nullptr, &current_status)) continue;

        fake_snapshots_status.sectors_allocated += current_status.sectors_allocated;