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

Commit 3de05fcf authored by Douglas Anderson's avatar Douglas Anderson
Browse files

init: Move the stripping of "/devices" and "/devices/platform/" to a helper

A future change will want the same stripping when looking for USB boot
devices. Move the stripping down to the helper.

This change is intended to be a no-op and just a reorganization.

Bug: 316324155
Test: See boot devices still found
Change-Id: I025d9d68fedf652055454cbd93e15f480b6056dd
parent 6519e6d6
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -193,14 +193,6 @@ BlockDeviceInfo DeviceHandler::GetBlockDeviceInfo(const std::string& uevent_path
    BlockDeviceInfo info;

    if (FindPlatformDevice(uevent_path, &info.str)) {
        // Skip /devices/platform or /devices/ if present
        static constexpr std::string_view devices_platform_prefix = "/devices/platform/";
        static constexpr std::string_view devices_prefix = "/devices/";
        std::string_view str = info.str;

        if (ConsumePrefix(&str, devices_platform_prefix) || ConsumePrefix(&str, devices_prefix)) {
            info.str = str;
        }
        info.type = "platform";
    } else if (FindPciDevicePrefix(uevent_path, &info.str)) {
        info.type = "pci";
@@ -265,7 +257,17 @@ bool DeviceHandler::FindSubsystemDevice(std::string path, std::string* device_pa
            subsystem_paths.find(subsystem_link_path) != subsystem_paths.end()) {
            // We need to remove the mount point that we added above before returning.
            directory.erase(0, sysfs_mount_point_.size());
            *device_path = directory;

            // Skip /devices/platform or /devices/ if present
            static constexpr std::string_view devices_platform_prefix = "/devices/platform/";
            static constexpr std::string_view devices_prefix = "/devices/";
            std::string_view sv = directory;

            if (!ConsumePrefix(&sv, devices_platform_prefix)) {
                ConsumePrefix(&sv, devices_prefix);
            }
            *device_path = sv;

            return true;
        }