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

Commit 5b271797 authored by Tom Cherry's avatar Tom Cherry
Browse files

ueventd: add the import option from the init parser

Vendors have an interest in importing ueventd files based on certain
property values.  Instead of baking this logic in the ueventd binary,
add the import option from the init parser to the ueventd parser, to
allow vendors to expand as needed.

Test: imported files are parsed
Change-Id: I674987fd48f3218e4703528c6d905b1afb5fb366
parent 77692aee
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,16 @@ For example
    uevent_socket_rcvbuf_size 16M
Sets the uevent socket rcvbuf_size to 16 megabytes.

## Importing configuration files
--------------------------------
Ueventd reads /system/etc/ueventd.rc, all other files are imported via the `import` command, which
takes the format of

    import <path>
This command parses an ueventd config file, extending the current configuration.  If _path_ is a
directory, each file in the directory is parsed as a config file. It is not recursive, nested
directories will not be parsed.  Imported files are parsed after the current file has been parsed.

## /dev
----
Ueventd listens to the kernel uevent sockets and creates/deletes nodes in `/dev` based on the
+1 −6
Original line number Diff line number Diff line
@@ -283,12 +283,7 @@ int ueventd_main(int argc, char** argv) {

    std::vector<std::unique_ptr<UeventHandler>> uevent_handlers;

    // Keep the current product name base configuration so we remain backwards compatible and
    // allow it to override everything.
    auto hardware = android::base::GetProperty("ro.hardware", "");

    auto ueventd_configuration = ParseConfig({"/system/etc/ueventd.rc", "/vendor/ueventd.rc",
                                              "/odm/ueventd.rc", "/ueventd." + hardware + ".rc"});
    auto ueventd_configuration = ParseConfig("/system/etc/ueventd.rc");

    uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
            std::move(ueventd_configuration.dev_permissions),
+4 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

#include <android-base/parseint.h>

#include "import_parser.h"
#include "keyword_map.h"
#include "parser.h"

@@ -220,10 +221,11 @@ Result<void> SubsystemParser::EndSection() {
    return {};
}

UeventdConfiguration ParseConfig(const std::vector<std::string>& configs) {
UeventdConfiguration ParseConfig(const std::string& config) {
    Parser parser;
    UeventdConfiguration ueventd_configuration;

    parser.AddSectionParser("import", std::make_unique<ImportParser>(&parser));
    parser.AddSectionParser("subsystem",
                            std::make_unique<SubsystemParser>(&ueventd_configuration.subsystems));

@@ -249,9 +251,7 @@ UeventdConfiguration ParseConfig(const std::vector<std::string>& configs) {
                               std::bind(ParseEnabledDisabledLine, _1,
                                         &ueventd_configuration.enable_parallel_restorecon));

    for (const auto& config : configs) {
    parser.ParseConfig(config);
    }

    return ueventd_configuration;
}
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ struct UeventdConfiguration {
    bool enable_parallel_restorecon = false;
};

UeventdConfiguration ParseConfig(const std::vector<std::string>& configs);
UeventdConfiguration ParseConfig(const std::string& config);

}  // namespace init
}  // namespace android
+4 −0
Original line number Diff line number Diff line
import /vendor/ueventd.rc
import /odm/ueventd.rc
import /ueventd.{ro.hardware}.rc

firmware_directories /etc/firmware/ /odm/firmware/ /vendor/firmware/ /firmware/image/
uevent_socket_rcvbuf_size 16M