diff options
| author | Tom Cherry <tomcherry@google.com> | 2017-04-24 16:59:05 -0700 |
|---|---|---|
| committer | Tom Cherry <tomcherry@google.com> | 2017-04-25 11:24:24 -0700 |
| commit | fe062055cb11fcb1a6178b046173fc0361ad5b96 (patch) | |
| tree | ea784f3dd62a9a30b51a84878c636e57cb1ee18c /init/devices.h | |
| parent | 35c5bcc89ce713aca02852dc10247a648187ea28 (diff) | |
| download | system_core-fe062055cb11fcb1a6178b046173fc0361ad5b96.tar.gz system_core-fe062055cb11fcb1a6178b046173fc0361ad5b96.tar.bz2 system_core-fe062055cb11fcb1a6178b046173fc0361ad5b96.zip | |
ueventd: replace ueventd_parser.cpp with init_parser.cpp
Previously init_parser.cpp was made generic and capable of parsing any
number of differently named 'sections' or prefixed lines. We now use
these capabilities to do the parsing for ueventd.
Bug: 36250207
Bug: 33785894
Test: boot bullhead and ensure the right /dev nodes exist
with the right permissions set
Test: verify no boot time difference
Change-Id: I698ca962d414f8135af32f6c9cd778841b2b8b53
Diffstat (limited to 'init/devices.h')
| -rw-r--r-- | init/devices.h | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/init/devices.h b/init/devices.h index 2cbae66a6..647b4c4bc 100644 --- a/init/devices.h +++ b/init/devices.h @@ -24,6 +24,8 @@ #include <string> #include <vector> +#include "init_parser.h" + enum coldboot_action_t { // coldboot continues without creating the device for the uevent COLDBOOT_CONTINUE = 0, @@ -83,9 +85,45 @@ class SysfsPermissions : public Permissions { const std::string attribute_; }; -extern std::vector<Permissions> dev_permissions; -extern std::vector<SysfsPermissions> sysfs_permissions; +class Subsystem { + public: + friend class SubsystemParser; + + Subsystem() {} + + // Returns the full path for a uevent of a device that is a member of this subsystem, + // according to the rules parsed from ueventd.rc + std::string ParseDevPath(uevent* uevent) const; + + bool operator==(const std::string& string_name) { return name_ == string_name; } + + private: + enum class DevnameSource { + DEVNAME_UEVENT_DEVNAME, + DEVNAME_UEVENT_DEVPATH, + }; + + std::string name_; + std::string dir_name_ = "/dev"; + DevnameSource devname_source_; +}; + +class SubsystemParser : public SectionParser { + public: + SubsystemParser() {} + bool ParseSection(std::vector<std::string>&& args, const std::string& filename, int line, + std::string* err) override; + bool ParseLineSection(std::vector<std::string>&& args, int line, std::string* err) override; + void EndSection() override; + + private: + bool ParseDevName(std::vector<std::string>&& args, std::string* err); + bool ParseDirName(std::vector<std::string>&& args, std::string* err); + + Subsystem subsystem_; +}; +bool ParsePermissionsLine(std::vector<std::string>&& args, std::string* err, bool is_sysfs); typedef std::function<coldboot_action_t(struct uevent* uevent)> coldboot_callback; extern coldboot_action_t handle_device_fd(coldboot_callback fn = nullptr); extern void device_init(const char* path = nullptr, coldboot_callback fn = nullptr); |
