Loading init/README.ueventd.md +3 −2 Original line number Diff line number Diff line Loading @@ -59,9 +59,10 @@ device in. The section takes the below format of `subsystem_name` is used to match uevent `SUBSYSTEM` value `devname` takes one of two options `devname` takes one of three options 1. `uevent_devname` specifies that the name of the node will be the uevent `DEVNAME` 2. `uevent_devpath` specified that the name of the node will be basename uevent `DEVPATH` 2. `uevent_devpath` specifies that the name of the node will be basename uevent `DEVPATH` 3. `sys_name` specifies that the name of the node will be the contents of `/sys/DEVPATH/name` `dirname` is an optional parameter that specifies a directory within `/dev` where the node will be created. Loading init/devices.h +13 −4 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ class Subsystem { enum DevnameSource { DEVNAME_UEVENT_DEVNAME, DEVNAME_UEVENT_DEVPATH, DEVNAME_SYS_NAME, }; Subsystem() {} Loading @@ -92,10 +93,18 @@ class 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(const Uevent& uevent) const { std::string devname = devname_source_ == DEVNAME_UEVENT_DEVNAME ? uevent.device_name : android::base::Basename(uevent.path); std::string devname; if (devname_source_ == DEVNAME_UEVENT_DEVNAME) { devname = uevent.device_name; } else if (devname_source_ == DEVNAME_UEVENT_DEVPATH) { devname = android::base::Basename(uevent.path); } else if (devname_source_ == DEVNAME_SYS_NAME) { if (android::base::ReadFileToString("/sys/" + uevent.path + "/name", &devname)) { devname.pop_back(); // Remove terminating newline } else { devname = uevent.device_name; } } return dir_name_ + "/" + devname; } Loading init/ueventd_parser.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,10 @@ Result<void> SubsystemParser::ParseDevName(std::vector<std::string>&& args) { subsystem_.devname_source_ = Subsystem::DEVNAME_UEVENT_DEVPATH; return {}; } if (args[1] == "sys_name") { subsystem_.devname_source_ = Subsystem::DEVNAME_SYS_NAME; return {}; } return Error() << "invalid devname '" << args[1] << "'"; } Loading Loading
init/README.ueventd.md +3 −2 Original line number Diff line number Diff line Loading @@ -59,9 +59,10 @@ device in. The section takes the below format of `subsystem_name` is used to match uevent `SUBSYSTEM` value `devname` takes one of two options `devname` takes one of three options 1. `uevent_devname` specifies that the name of the node will be the uevent `DEVNAME` 2. `uevent_devpath` specified that the name of the node will be basename uevent `DEVPATH` 2. `uevent_devpath` specifies that the name of the node will be basename uevent `DEVPATH` 3. `sys_name` specifies that the name of the node will be the contents of `/sys/DEVPATH/name` `dirname` is an optional parameter that specifies a directory within `/dev` where the node will be created. Loading
init/devices.h +13 −4 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ class Subsystem { enum DevnameSource { DEVNAME_UEVENT_DEVNAME, DEVNAME_UEVENT_DEVPATH, DEVNAME_SYS_NAME, }; Subsystem() {} Loading @@ -92,10 +93,18 @@ class 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(const Uevent& uevent) const { std::string devname = devname_source_ == DEVNAME_UEVENT_DEVNAME ? uevent.device_name : android::base::Basename(uevent.path); std::string devname; if (devname_source_ == DEVNAME_UEVENT_DEVNAME) { devname = uevent.device_name; } else if (devname_source_ == DEVNAME_UEVENT_DEVPATH) { devname = android::base::Basename(uevent.path); } else if (devname_source_ == DEVNAME_SYS_NAME) { if (android::base::ReadFileToString("/sys/" + uevent.path + "/name", &devname)) { devname.pop_back(); // Remove terminating newline } else { devname = uevent.device_name; } } return dir_name_ + "/" + devname; } Loading
init/ueventd_parser.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,10 @@ Result<void> SubsystemParser::ParseDevName(std::vector<std::string>&& args) { subsystem_.devname_source_ = Subsystem::DEVNAME_UEVENT_DEVPATH; return {}; } if (args[1] == "sys_name") { subsystem_.devname_source_ = Subsystem::DEVNAME_SYS_NAME; return {}; } return Error() << "invalid devname '" << args[1] << "'"; } Loading