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

Commit 9765facb authored by David Anderson's avatar David Anderson Committed by Automerger Merge Worker
Browse files

Merge "ueventd: Put dm-user devices in a folder" am: e3a715a9

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1461564

Change-Id: I4964be83a0fcca4309c487057d16eb6a6d8ab3b6
parents f75f3830 e3a715a9
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <unistd.h>

#include <chrono>
#include <filesystem>
#include <memory>
#include <string>
#include <thread>
@@ -439,6 +440,13 @@ void DeviceHandler::HandleDevice(const std::string& action, const std::string& d
            }
        }
        unlink(devpath.c_str());

        if (android::base::StartsWith(devpath, "/dev/dm-user/")) {
            std::error_code ec;
            if (std::filesystem::is_empty("/dev/dm-user/", ec)) {
                rmdir("/dev/dm-user");
            }
        }
    }
}

@@ -496,6 +504,8 @@ void DeviceHandler::HandleUevent(const Uevent& uevent) {
    } else if (StartsWith(uevent.subsystem, "usb")) {
        // ignore other USB events
        return;
    } else if (uevent.subsystem == "misc" && StartsWith(uevent.device_name, "dm-user/")) {
        devpath = "/dev/dm-user/" + uevent.device_name.substr(8);
    } else {
        devpath = "/dev/" + Basename(uevent.path);
    }