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

Commit 515a5bdd authored by David Anderson's avatar David Anderson
Browse files

ueventd: Put dm-user devices in a folder



When a device-mapper table contains a "user" entry, a corresponding
dm-user misc control device is created. The devices are put into a
separate folder by default, which currently confuses ueventd, and we
wind up with paths like:

    /dev/dm-user!blah

Special case these devices so they wind up as:

    /dev/dm-user/blah

Test: dmctl create blah user 0 100 test-device
      /dev/dm-user/test-device exists
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
Change-Id: I313db07c3400f14f3ed0ffa20fdac2ac3e34b6d3
parent fe1eba00
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);
    }