diff options
author | Tom Cherry <tomcherry@google.com> | 2017-08-22 16:15:26 -0700 |
---|---|---|
committer | Tom Cherry <tomcherry@google.com> | 2017-08-23 11:05:37 -0700 |
commit | 68f2a4614518468f1320ad3e62a6db554e509fb1 (patch) | |
tree | 379a26958c3c70d672bae20d0a099c9a82ed98a3 /init | |
parent | 76af7e6a0c4ce7759e6cc5994b5496ddb09035ee (diff) | |
download | core-68f2a4614518468f1320ad3e62a6db554e509fb1.tar.gz core-68f2a4614518468f1320ad3e62a6db554e509fb1.tar.bz2 core-68f2a4614518468f1320ad3e62a6db554e509fb1.zip |
init: enable error reporting of builtin functions
Enable error reporting when builtin functions fail. These errors are
now reported with full context including the source file and line
number, e.g.
init: Command 'write /sys/module/subsystem_restart/parameters/enable_debug ${persist.sys.ssr.enable_debug}' action=early-boot (/init.bullhead.rc:84) took 0ms and failed: cannot expand '${persist.sys.ssr.enable_debug}'
There are two small caveats:
1) There are nearly 200 reports of builtins failure due to "No such
file or directory". Many of these are due to legacy paths included
in rootdir/init.rc. Until they are cleaned up, reporting of these
failures is disabled.
2) Similarly, symlink is often used to create backwards compatible
symlinks. By their very nature, these calls are expected to fail
on newer systems that do already use the new path. Due to this,
failures of symlink due to EEXIST are not reported.
Bug: 38038887
Test: boot bullhead, only see true errors reported from builtins.
Change-Id: I316c13e3adc992cacc6d79ffee987adc8738fca0
Diffstat (limited to 'init')
-rw-r--r-- | init/action.cpp | 13 | ||||
-rw-r--r-- | init/builtins.cpp | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/init/action.cpp b/init/action.cpp index a7aa7567a..60204a8d8 100644 --- a/init/action.cpp +++ b/init/action.cpp @@ -91,8 +91,19 @@ void Action::ExecuteCommand(const Command& command) const { auto result = command.InvokeFunc(); auto duration = t.duration(); + // There are many legacy paths in rootdir/init.rc that will virtually never exist on a new + // device, such as '/sys/class/leds/jogball-backlight/brightness'. As of this writing, there + // are 198 such failures on bullhead. Instead of spamming the log reporting them, we do not + // report such failures unless we're running at the DEBUG log level. + bool report_failure = !result.has_value(); + if (report_failure && android::base::GetMinimumLogSeverity() > android::base::DEBUG && + result.error_errno() == ENOENT) { + report_failure = false; + } + // Any action longer than 50ms will be warned to user as slow operation - if (duration > 50ms || android::base::GetMinimumLogSeverity() <= android::base::DEBUG) { + if (report_failure || duration > 50ms || + android::base::GetMinimumLogSeverity() <= android::base::DEBUG) { std::string trigger_name = BuildTriggersString(); std::string cmd_str = command.BuildCommandString(); diff --git a/init/builtins.cpp b/init/builtins.cpp index 3d0ba5547..54ccf091e 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -612,6 +612,11 @@ static Result<Success> do_trigger(const std::vector<std::string>& args) { static Result<Success> do_symlink(const std::vector<std::string>& args) { if (symlink(args[1].c_str(), args[2].c_str()) < 0) { + // The symlink builtin is often used to create symlinks for older devices to be backwards + // compatible with new paths, therefore we skip reporting this error. + if (errno == EEXIST && android::base::GetMinimumLogSeverity() > android::base::DEBUG) { + return Success(); + } return ErrnoError() << "symlink() failed"; } return Success(); |