Skip to content

Commit 0608e36

Browse files
Tom CherryGerrit Code Review
Tom Cherry
authored and
Gerrit Code Review
committed
Merge "ueventd: add the import option from the init parser"
2 parents bca7bfc + 5b27179 commit 0608e36

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

init/README.ueventd.md

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ For example
1313
uevent_socket_rcvbuf_size 16M
1414
Sets the uevent socket rcvbuf_size to 16 megabytes.
1515

16+
## Importing configuration files
17+
--------------------------------
18+
Ueventd reads /system/etc/ueventd.rc, all other files are imported via the `import` command, which
19+
takes the format of
20+
21+
import <path>
22+
This command parses an ueventd config file, extending the current configuration. If _path_ is a
23+
directory, each file in the directory is parsed as a config file. It is not recursive, nested
24+
directories will not be parsed. Imported files are parsed after the current file has been parsed.
25+
1626
## /dev
1727
----
1828
Ueventd listens to the kernel uevent sockets and creates/deletes nodes in `/dev` based on the

init/ueventd.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,7 @@ int ueventd_main(int argc, char** argv) {
283283

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

286-
// Keep the current product name base configuration so we remain backwards compatible and
287-
// allow it to override everything.
288-
auto hardware = android::base::GetProperty("ro.hardware", "");
289-
290-
auto ueventd_configuration = ParseConfig({"/system/etc/ueventd.rc", "/vendor/ueventd.rc",
291-
"/odm/ueventd.rc", "/ueventd." + hardware + ".rc"});
286+
auto ueventd_configuration = ParseConfig("/system/etc/ueventd.rc");
292287

293288
uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
294289
std::move(ueventd_configuration.dev_permissions),

init/ueventd_parser.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <android-base/parseint.h>
2323

24+
#include "import_parser.h"
2425
#include "keyword_map.h"
2526
#include "parser.h"
2627

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

223-
UeventdConfiguration ParseConfig(const std::vector<std::string>& configs) {
224+
UeventdConfiguration ParseConfig(const std::string& config) {
224225
Parser parser;
225226
UeventdConfiguration ueventd_configuration;
226227

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

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

252-
for (const auto& config : configs) {
253-
parser.ParseConfig(config);
254-
}
254+
parser.ParseConfig(config);
255255

256256
return ueventd_configuration;
257257
}

init/ueventd_parser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct UeventdConfiguration {
3636
bool enable_parallel_restorecon = false;
3737
};
3838

39-
UeventdConfiguration ParseConfig(const std::vector<std::string>& configs);
39+
UeventdConfiguration ParseConfig(const std::string& config);
4040

4141
} // namespace init
4242
} // namespace android

rootdir/ueventd.rc

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import /vendor/ueventd.rc
2+
import /odm/ueventd.rc
3+
import /ueventd.{ro.hardware}.rc
4+
15
firmware_directories /etc/firmware/ /odm/firmware/ /vendor/firmware/ /firmware/image/
26
uevent_socket_rcvbuf_size 16M
37

0 commit comments

Comments
 (0)