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

Commit b2a64ccf authored by cloud.you's avatar cloud.you
Browse files

Fixed failure of clearing loopback device

Loopback device is already cleared when resetting ZRAM_BACK_DEV,
ZRAM_BACK_DEV is changed to "none" from "/dev/block/loopXX".
So it needs to read ZRAM_BACK_DEV again before checking it.

Bug: 388158025
Test:
- Boot up device with zram writeback enabled
- adb root
- adb reboot userspace

Change-Id: Ib7b648f6a50eb3ef4d3b0268ed9e11d8c6e0a181
parent 8ebd76c9
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -486,8 +486,7 @@ static Result<void> KillZramBackingDevice() {
        return ErrnoError() << "Failed to read " << ZRAM_BACK_DEV;
    }

    // cut the last "\n"
    backing_dev.erase(backing_dev.length() - 1);
    android::base::Trim(backing_dev);

    if (android::base::StartsWith(backing_dev, "none")) {
        LOG(INFO) << "No zram backing device configured";
@@ -508,6 +507,12 @@ static Result<void> KillZramBackingDevice() {
                       << " failed";
    }

    if (!android::base::ReadFileToString(ZRAM_BACK_DEV, &backing_dev)) {
        return ErrnoError() << "Failed to read " << ZRAM_BACK_DEV;
    }

    android::base::Trim(backing_dev);

    if (!android::base::StartsWith(backing_dev, "/dev/block/loop")) {
        LOG(INFO) << backing_dev << " is not a loop device. Exiting early";
        return {};