From f95d1509370b7f40ef356ff69a332bd0356ab044 Mon Sep 17 00:00:00 2001 From: Samuel Cobb <68509699+sjcobb2022@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:17:06 +0100 Subject: [PATCH] drm: Follow symlinks for AQ_DRM_DEVICES (#34) --- src/backend/drm/DRM.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 93ba80c..e954e85 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include @@ -135,6 +137,22 @@ static std::vector> scanGPUs(SP backend) { backend->log(AQ_LOG_DEBUG, std::format("drm: Explicit device list {}", explicitGpus)); Hyprutils::String::CVarList explicitDevices(explicitGpus, 0, ':', true); + // Iterate over GPUs and canonicalize the paths + for (auto& d : explicitDevices) { + std::error_code ec; + + auto canonicalFilePath = std::filesystem::canonical(d, ec); + + // If there is an error, log and continue. + // TODO: Verify that the path is a valid DRM device. (https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/backend/session/session.c?ref_type=heads#L369-387) + if (ec) { + backend->log(AQ_LOG_ERROR, std::format("drm: Failed to canonicalize path {}", d)); + continue; + } + + d = canonicalFilePath.string(); + } + for (auto& d : explicitDevices) { bool found = false; for (auto& vd : devices) {