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

Commit d52b17ff authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge "ueventd: require opt-in for modalias handling"

parents d0e5bcc1 457e28f1
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ void DeviceHandler::HandleDevice(const std::string& action, const std::string& d
    }
}

void DeviceHandler::HandleDeviceEvent(const Uevent& uevent) {
void DeviceHandler::HandleUevent(const Uevent& uevent) {
    if (uevent.action == "add" || uevent.action == "change" || uevent.action == "online") {
        FixupSysPermissions(uevent.path, uevent.subsystem);
    }
@@ -418,6 +418,10 @@ void DeviceHandler::HandleDeviceEvent(const Uevent& uevent) {
    HandleDevice(uevent.action, devpath, block, uevent.major, uevent.minor, links);
}

void DeviceHandler::ColdbootDone() {
    skip_restorecon_ = true;
}

DeviceHandler::DeviceHandler(std::vector<Permissions> dev_permissions,
                             std::vector<SysfsPermissions> sysfs_permissions,
                             std::vector<Subsystem> subsystems, std::set<std::string> boot_devices,
+5 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <selinux/label.h>

#include "uevent.h"
#include "uevent_handler.h"

namespace android {
namespace init {
@@ -105,7 +106,7 @@ class Subsystem {
    std::string dir_name_ = "/dev";
};

class DeviceHandler {
class DeviceHandler : public UeventHandler {
  public:
    friend class DeviceHandlerTester;

@@ -113,11 +114,12 @@ class DeviceHandler {
    DeviceHandler(std::vector<Permissions> dev_permissions,
                  std::vector<SysfsPermissions> sysfs_permissions, std::vector<Subsystem> subsystems,
                  std::set<std::string> boot_devices, bool skip_restorecon);
    virtual ~DeviceHandler() = default;

    void HandleDeviceEvent(const Uevent& uevent);
    void HandleUevent(const Uevent& uevent) override;
    void ColdbootDone() override;

    std::vector<std::string> GetBlockDeviceSymlinks(const Uevent& uevent) const;
    void set_skip_restorecon(bool value) { skip_restorecon_ = value; }

  private:
    bool FindPlatformDevice(std::string path, std::string* platform_device_path) const;
+6 −5
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ using android::base::WriteFully;
namespace android {
namespace init {

std::vector<std::string> firmware_directories;

static void LoadFirmware(const Uevent& uevent, const std::string& root, int fw_fd, size_t fw_size,
                         int loading_fd, int data_fd) {
    // Start transfer.
@@ -58,7 +56,10 @@ static bool IsBooting() {
    return access("/dev/.booting", F_OK) == 0;
}

static void ProcessFirmwareEvent(const Uevent& uevent) {
FirmwareHandler::FirmwareHandler(std::vector<std::string> firmware_directories)
    : firmware_directories_(std::move(firmware_directories)) {}

void FirmwareHandler::ProcessFirmwareEvent(const Uevent& uevent) {
    int booting = IsBooting();

    LOG(INFO) << "firmware: loading '" << uevent.firmware << "' for '" << uevent.path << "'";
@@ -80,7 +81,7 @@ static void ProcessFirmwareEvent(const Uevent& uevent) {
    }

try_loading_again:
    for (const auto& firmware_directory : firmware_directories) {
    for (const auto& firmware_directory : firmware_directories_) {
        std::string file = firmware_directory + uevent.firmware;
        unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC));
        struct stat sb;
@@ -104,7 +105,7 @@ try_loading_again:
    write(loading_fd, "-1", 2);
}

void HandleFirmwareEvent(const Uevent& uevent) {
void FirmwareHandler::HandleUevent(const Uevent& uevent) {
    if (uevent.subsystem != "firmware" || uevent.action != "add") return;

    // Loading the firmware in a child means we can do that in parallel...
+12 −2
Original line number Diff line number Diff line
@@ -21,13 +21,23 @@
#include <vector>

#include "uevent.h"
#include "uevent_handler.h"

namespace android {
namespace init {

extern std::vector<std::string> firmware_directories;
class FirmwareHandler : public UeventHandler {
  public:
    explicit FirmwareHandler(std::vector<std::string> firmware_directories);
    virtual ~FirmwareHandler() = default;

void HandleFirmwareEvent(const Uevent& uevent);
    void HandleUevent(const Uevent& uevent) override;

  private:
    void ProcessFirmwareEvent(const Uevent& uevent);

    std::vector<std::string> firmware_directories_;
};

}  // namespace init
}  // namespace android
+3 −3
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ bool FirstStageMount::InitRequiredDevices() {
        bool found = false;
        auto dm_callback = [this, &dm_path, &found](const Uevent& uevent) {
            if (uevent.path == dm_path) {
                device_handler_->HandleDeviceEvent(uevent);
                device_handler_->HandleUevent(uevent);
                found = true;
                return ListenerAction::kStop;
            }
@@ -273,7 +273,7 @@ ListenerAction FirstStageMount::HandleBlockDevice(const std::string& name, const
            lp_metadata_partition_ = links[0];
        }
        required_devices_partition_names_.erase(iter);
        device_handler_->HandleDeviceEvent(uevent);
        device_handler_->HandleUevent(uevent);
        if (required_devices_partition_names_.empty()) {
            return ListenerAction::kStop;
        } else {
@@ -310,7 +310,7 @@ bool FirstStageMount::InitMappedDevice(const std::string& dm_device) {
    auto verity_callback = [&device_name, &dm_device, this, &found](const Uevent& uevent) {
        if (uevent.device_name == device_name) {
            LOG(VERBOSE) << "Creating device-mapper device : " << dm_device;
            device_handler_->HandleDeviceEvent(uevent);
            device_handler_->HandleUevent(uevent);
            found = true;
            return ListenerAction::kStop;
        }
Loading