Commit Graph

2192 Commits

Author SHA1 Message Date
Tom Cherry 4a679454d7 init: cleanup exit() uses
Primarily, this fixes a bug where a forked child of property service
uses exit() instead of _exit, which has the unintended consequences of
running the global destructors of init proper, which leads to
unintended cleanup.

Secondly, this replaces the remaining calls of exit() that really
should be LOG(FATAL).

Test: boot sailfish
Change-Id: I779228e7d44a73186bc7685bb723c4b9278a0a2d
2017-09-26 16:30:03 -07:00
Mark Salyzyn bfd05b69a5 init: shutdown,thermal shut off display immediately
Remove a source of heat.

Test: manual
Change-Id: I9a7391ddb121b6748a4f49f4b5bfb77453ca1514
2017-09-26 14:06:51 -07:00
Tom Cherry 242f47d544 Merge "init: fix typo" am: 15a14d1ad9 am: 00a15fc9bf
am: 707a5ad27a

Change-Id: I3ae60ec3703ae653929d5e5bfb6f3cefd300b28a
2017-09-20 00:48:32 +00:00
Tom Cherry 00a15fc9bf Merge "init: fix typo"
am: 15a14d1ad9

Change-Id: I3805f03671f0ed09320df88b96b5cd958a9f742d
2017-09-20 00:45:07 +00:00
Tom Cherry a141907ecf init: fix typo
Test: build
Change-Id: I2f6ff60356087f9fd6c6f24e3923d70b9e93dcf8
2017-09-19 13:13:17 -07:00
Tom Cherry 8b4315330e Merge "init: use protobuf for serialization of persistent properties" am: f5dba11085 am: 61b81a0341
am: 74c45a41cc

Change-Id: I517f2cbd9c0c2bde93ccb65afe8933e8294ff1ae
2017-09-19 17:20:29 +00:00
Tom Cherry 61b81a0341 Merge "init: use protobuf for serialization of persistent properties"
am: f5dba11085

Change-Id: I6177b5b86290a50884f6212d45a09604b69cffd6
2017-09-19 17:16:59 +00:00
Tom Cherry f5dba11085 Merge "init: use protobuf for serialization of persistent properties" 2017-09-19 17:07:00 +00:00
Tom Cherry a97faba653 init: use protobuf for serialization of persistent properties
I probably should have done this from the start...  There's a shim to
convert my manually serialized format to protobuf, and since that has
not yet shipped, it'll be reverted in a short period of time.

Test: init unit tests
Test: upgrade from legacy and intermediate property formats successfully
Change-Id: Iad25f6c30d0b44d294230a53dd6876222d1c785b
2017-09-19 09:56:31 -07:00
Tom Cherry 6a842f9883 Merge "init: add exec_background command" am: 424ed42fb4 am: a6d75117e2
am: a53db4220f

Change-Id: I8e718e5647908c7dc98bf8ca7e398f73808a7d43
2017-09-18 21:42:08 +00:00
Tom Cherry a6d75117e2 Merge "init: add exec_background command"
am: 424ed42fb4

Change-Id: I9529146ea9b29b2fb2e2c92f3533efc4e3106943
2017-09-18 21:37:38 +00:00
Tom Cherry 424ed42fb4 Merge "init: add exec_background command" 2017-09-18 21:33:26 +00:00
Tom Cherry 3631c545b8 init: add exec_background command
This command functions similarly to `exec` except that it does not
cause init to halt executing commands until the process has
terminated.  It is useful for launching simple one time background
tasks.

Bug: 65736247
Test: create an exec_background service and see it function properly
Change-Id: I719c8b85479b65201770aedc0a13191303007c11
2017-09-18 12:19:47 -07:00
Tom Cherry 845a91d6b7 Merge "init: fix crash when reboot is triggered by a builtin" am: b92415cee2 am: 171587d10e
am: e50fd398ef

Change-Id: I5b8cb44b4d93049d844738468f8755dce4916e86
2017-09-15 21:21:24 +00:00
Tom Cherry 171587d10e Merge "init: fix crash when reboot is triggered by a builtin"
am: b92415cee2

Change-Id: I4137679d88e58c706f14adeeaf84b41426079de4
2017-09-15 21:14:08 +00:00
Tom Cherry b92415cee2 Merge "init: fix crash when reboot is triggered by a builtin" 2017-09-15 21:08:52 +00:00
Tom Cherry 3633a4014a init: fix crash when reboot is triggered by a builtin
Builtin commands may set the sys.powerctl property, which causes
reboot to be immediately processed.  Unfortunately, part of the reboot
processing involves clearing the action queue, so when this scenario
happens, ActionManager::ExecuteOneCommand() can abort due to its state
being unexpectedly changed.

Longer term, the real fix here is to split init and property service.
In this case, the property sets will be sent to property service and
the reboot will only be processed once property service responds back
to init that the property has been set.  Since that will not happen
within the action queue, there will be no risk of failure.

Short term, this change sets a flag in init to shutdown the device
before the next action is run, which defers the shutdown enough to fix
the crash, but continues to prevent any further commands from running.

Bug: 65374456
Test: force bullhead into the repro case and observe that it no longer
      repros

Change-Id: I89c73dad8d7912a845d694b095cab061b8dcc05e
2017-09-15 21:07:41 +00:00
Tom Cherry 27d73e9105 Merge "init: fix hiding of move constructors of Result<T>" am: db7b8f5e28 am: 6213ce0dc1
am: 9c374424ae

Change-Id: Ia0f4171d84e484084cc043e64ade4dfa28e88254
2017-09-15 20:34:24 +00:00
Tom Cherry 6213ce0dc1 Merge "init: fix hiding of move constructors of Result<T>"
am: db7b8f5e28

Change-Id: I933df61a6d5a523b7872ae0d8af091722f7c0e90
2017-09-15 20:29:05 +00:00
Tom Cherry d1c9cd0499 init: fix hiding of move constructors of Result<T>
This is needed to have Result<Result<T>> work correctly.

Test: init unit tests
Change-Id: If7d23d1ea13f3727b567d3baf0eee1d8d0e5a196
2017-09-15 20:17:38 +00:00
Tom Cherry 32be6da555 Merge "init: fix variable scope issue with ExpandArgs()" am: 1973110355 am: 698981df84
am: 7954cc1324

Change-Id: I708fa1135b8426b8741a0235e58230928609fc2a
2017-09-12 16:43:25 +00:00
Tom Cherry 698981df84 Merge "init: fix variable scope issue with ExpandArgs()"
am: 1973110355

Change-Id: I6a257ae81ee2b4a3c128f5d4f4724cf1534670c7
2017-09-12 16:37:34 +00:00
Tom Cherry 1973110355 Merge "init: fix variable scope issue with ExpandArgs()" 2017-09-12 16:31:13 +00:00
Tom Cherry 5e405cacb1 init: fix variable scope issue with ExpandArgs()
ExpandArgs() was factored out of Service::Start() to clean up init,
however this introduced a bug: the scope of expanded_args ends when
ExpandArgs() returns, yet pointers to the c strings contained within
those std::strings are returned from the function.  These pointers are
invalid and have been seen to cause failures on real devices.

This change moves the execv() into ExpandArgs() and renames it
ExpandArgsAndExecv() to keep the clean separation of Service::Start()
but fix the variable scope issue.

Bug: 65303004
Test: boot fugu
Change-Id: I612128631f5b58d040bffcbc2220593ad16cd450
2017-09-11 16:08:54 -07:00
Luis Hector Chavez 056283e86e Merge "init: Allow clean system shutdown upon SIGTERM" am: 61cb88add2 am: 721b2d6035
am: 69596c2d00

Change-Id: I4a54c3c076401ebda1623a6e1880f60fb5695c8c
2017-09-07 20:11:29 +00:00
Luis Hector Chavez 721b2d6035 Merge "init: Allow clean system shutdown upon SIGTERM"
am: 61cb88add2

Change-Id: If0a495fa067440f0b59969ac0dbc010b4687b52f
2017-09-07 20:06:58 +00:00
Treehugger Robot 61cb88add2 Merge "init: Allow clean system shutdown upon SIGTERM" 2017-09-07 19:59:29 +00:00
Luis Hector Chavez 9f97f47940 init: Allow clean system shutdown upon SIGTERM
This allows Android to cleanly shutdown when running in a PID namespace
in a way that does not rely on adbd running. This is useful to allow
Android to be running in a container and its lifetime managed by an
OCI-compliant tool.

Bug: 65415372
Test: `kill -TERM 1` as root is correctly dropped.
Test: `kill -TERM 1` from the init PID namespace causes init to cleanly shutdown.
Change-Id: Ia66ebdb436221919081bc4723337c0c7f1e53b09
2017-09-07 10:47:04 -07:00
Tom Cherry e4dcb98e49 Merge "Log pid for writes to sys.powerctl" am: 2827106d7d am: c1968fb0c9
am: 17b2996743

Change-Id: I418f732c92e8ae8effe2645e6b2703976fbcd316
2017-09-06 17:14:55 +00:00
Tom Cherry c1968fb0c9 Merge "Log pid for writes to sys.powerctl"
am: 2827106d7d

Change-Id: I2fb780c5809d4c18950c114c07a7363723aa121a
2017-09-06 17:09:08 +00:00
Tom Cherry a84e14da1e Log pid for writes to sys.powerctl
Unless a process logs that it is requesting a device to reboot, there
are no logs to show which process triggered a reboot.  This change
introduces such a log in property service such that system initiated
reboots can be clearly blamed back to a calling process.

Bug: 64214361
Test: reboot and check kernel log for reboot string
Change-Id: I18de33d2a0933d20bdb581025b78020c88c5c6eb
2017-09-05 12:47:08 -07:00
kaichieh 84fb623f64 Merge "Add odm sepolicy support to selinux.cpp" am: f899548cdb am: 1aecf73b43
am: a4d04e1f26

Change-Id: Iba1cb0c66fffe8d59bf9056bd9a6e6932518d4e4
2017-09-04 05:12:57 +00:00
kaichieh 1aecf73b43 Merge "Add odm sepolicy support to selinux.cpp"
am: f899548cdb

Change-Id: I33f7ded656fa2e61e130f158a2d8915f68524b91
2017-09-04 04:55:58 +00:00
Treehugger Robot f899548cdb Merge "Add odm sepolicy support to selinux.cpp" 2017-09-04 04:45:33 +00:00
Wei Wang d51d09bf38 Merge "init: add option to read file fully on readahead" am: d97a1710b8 am: df9ac65c75
am: cd2d1faea2

Change-Id: I0614738843369e5c7ee4e39792969d7cc9e516d8
2017-09-02 03:13:16 +00:00
Wei Wang df9ac65c75 Merge "init: add option to read file fully on readahead"
am: d97a1710b8

Change-Id: I2a49bd384b1fe621314916c1f325c03b7fa43162
2017-09-02 03:01:14 +00:00
Wei Wang 02628f3b23 init: add option to read file fully on readahead
Bug: 62413151
Test: boottime, dumpcache
Change-Id: I1a7b69f0619428e4db31c5a7639c5d895c89ecdb
2017-09-01 15:15:51 -07:00
kaichieh eef4cd7d08 Add odm sepolicy support to selinux.cpp
init: support loading odm sepolicy

Currently init merges two sepolicy cil files:
    - /system/etc/selinux/plat_sepolicy.cil
    - /vendor/etc/selinux/nonplat_sepolicy.cil

This change replaces nonplat_sepolicy.cil with the following two files:
    - /vendor/etc/selinux/declaration/nonplat_declaration.cil
    - /vendor/etc/selinux/vender_sepolicy.cil

And support merging another default (but optional):
    - /odm/etc/selinux/odm_sepolicy.cil.

Bug: 64240127
Test: boot sailfish normally without odm.cil
Test: boot another device having odm.cil
Change-Id: I0b7f8c656c73ddb0fd46f2af3c625d7c81566f2f
2017-09-01 18:13:29 +08:00
Tom Cherry b5d7e00815 Merge "use a single file for storing persistent properties" am: e1f9a58c86 am: 39088d35ee
am: f8d36679bf

Change-Id: Id6b9812de8f7cc774fe7300d0b9e13a0d2b3b248
2017-08-30 19:55:39 +00:00
Tom Cherry 39088d35ee Merge "use a single file for storing persistent properties"
am: e1f9a58c86

Change-Id: Iea9d022eee79e3a4ccf9f5ebc6739d565b6e51b1
2017-08-30 19:42:08 +00:00
Tom Cherry e1f9a58c86 Merge "use a single file for storing persistent properties" 2017-08-30 19:30:18 +00:00
Tom Cherry 16fad42007 use a single file for storing persistent properties
We have seen that storing persistent properties in separate files
causes increased boot latency compared to if they were stored in a
single contiguous file.

This change creates a simple format for a contiguously stored property
file, and adds the support for arbitrary characters in the names of
persistent properties, which previously had been restricted.  It has a
mechanism for converting older devices to the new format as well.

Bug: 64392887
Test: boot bullhead with new properties
Test: boot bullhead and verify old properties are converted to the new
      property file
Test: corrupt property file and ensure that it gets recovered from memory
Test: new unit tests
Change-Id: I60d8201d655ce5c97b33faae81d5ca8dbbb21a14
2017-08-29 17:45:06 -07:00
Tom Cherry 2235fa414f Merge "init: fix signal handling and LOG(FATAL) in child processes" am: 30bf4b7500 am: 43e92299e9
am: 5727a169c1

Change-Id: I7dd7729df2b1073946b7a9a350e528a95eed72fd
2017-08-28 22:05:17 +00:00
Tom Cherry 43e92299e9 Merge "init: fix signal handling and LOG(FATAL) in child processes"
am: 30bf4b7500

Change-Id: I9147d02a9e710f9e8068a9b3b061768daf2648e9
2017-08-28 21:55:45 +00:00
Tom Cherry 30bf4b7500 Merge "init: fix signal handling and LOG(FATAL) in child processes" 2017-08-28 21:45:38 +00:00
Tom Cherry d0f3e414a0 Merge "init: support setting rlimits per service" am: 459aa1cac6 am: c39a5082dc
am: d47ccf8277

Change-Id: I29a5baea3ba8193724fc94a57cf1d770a9a46d62
2017-08-28 19:52:07 +00:00
Tom Cherry c39a5082dc Merge "init: support setting rlimits per service"
am: 459aa1cac6

Change-Id: I4ef5abc3371ce52783bfb14669bcffe33febb73e
2017-08-28 19:39:08 +00:00
Treehugger Robot 459aa1cac6 Merge "init: support setting rlimits per service" 2017-08-28 19:27:08 +00:00
Tom Cherry 487378ae14 Merge "init: log all failures of Service::Start()" am: 9bde0dc769 am: 849b481786
am: fb32e15da8

Change-Id: Ie658e3036ea452e4d93a8e947d860040fc7cce5d
2017-08-28 17:40:29 +00:00
Tom Cherry 849b481786 Merge "init: log all failures of Service::Start()"
am: 9bde0dc769

Change-Id: Ibb27338bb694482108ffc558b2823c583a9701d3
2017-08-28 17:30:28 +00:00
Tom Cherry 9bde0dc769 Merge "init: log all failures of Service::Start()" 2017-08-28 17:22:11 +00:00
Tom Cherry 7ac013de7e init: support setting rlimits per service
Add a new service option, `rlimit` that allows a given rlimit to be
set for a specific service instead of globally.

Use the same parsing, now allowing text such as 'cpu' or 'rtprio'
instead of relying on the enum value for the `setrlimit` builtin
command as well.

Bug: 63882119
Bug: 64894637

Test: boot bullhead, run a test app that attempts to set its rtprio to
      95, see that the priority set fails normally but passes when
      `rlimit rtprio 99 99` is used as its service option.
      See that this fails when `rlimit rtprio 50 50` is used as well.
Test: new unit tests

Change-Id: I4a13ca20e8529937d8b4bc11718ffaaf77523a52
2017-08-28 10:19:50 -07:00
Nick Kralevich 44836221c6 Merge "Clarify SELinux service error message" am: 54a28300b7 am: 706a898cd0
am: 787b5038f4

Change-Id: Ifcc645d820701368e65d8701fcacaf581b5c660d
2017-08-25 23:20:47 +00:00
Nick Kralevich 706a898cd0 Merge "Clarify SELinux service error message"
am: 54a28300b7

Change-Id: I638bad81212c20b1c0065eab98ab2e043b643aac
2017-08-25 23:16:47 +00:00
Tom Cherry 1ca83249a1 init: fix signal handling and LOG(FATAL) in child processes
Child processes inherit the signal handlers and the 'Aborter' for
logging from their parent process.  In the case of init, fork()'ed
processes, will attempt to reboot the system if they receive a fatal
signal or if they call LOG(FATAL).  This is not the correct behavior;
these processes should terminate due to the provided signal like other
processes on the system.

This is particularly important as there are multiple LOG(FATAL) calls
in service.cpp for failures after fork() but before execv() when a
service is started.

Note, that pthread_atfork() is not a viable solution since clone() is
used in some cases instead of fork() and atfork handlers are not
called with clone().

Test: LOG(FATAL) from a child process of init and see that it
      terminates due to a signal correctly
Test: LOG(FATAL) from init proper and see that it reboots to the
      bootloader

Change-Id: I875ebd7a5f6b3f5e3e2c028af3306917c4409db3
2017-08-25 15:10:48 -07:00
Nick Kralevich 1ea19eb44d Clarify SELinux service error message
1) Attempt to make the error message associated with a missing service
better.
2) Provide a link to more in-depth documentation.

Bug: 65023716
Test: code compiles.
Change-Id: Ie0f1896fb41d5afd11501f046cb51d4c8afe0a62
2017-08-25 14:01:06 -07:00
Tom Cherry 702ca9ada2 init: log all failures of Service::Start()
The move to returning Result from Service::Start() for better context
when starting process through init's builtins stops Service::Start()
failures from being logged from other contexts.  This change adds
those logs along with their context.

Test: boot bullhead, fail to start services via `setprop ctl.start`,
      see the expected error in dmesg

Change-Id: I45294f6abf00852f3d4c549a32eaf4920a51e6f0
2017-08-25 11:01:52 -07:00
Tom Cherry c6b2317d59 Merge "init: do not load persistent properties from temporary /data" am: b1d93a8136 am: b916f49bd7
am: ec9aa8ce7c

Change-Id: I893fcae4ba573b50d096d065eed2d6ec1ac47ad0
2017-08-25 16:51:21 +00:00
Tom Cherry b916f49bd7 Merge "init: do not load persistent properties from temporary /data"
am: b1d93a8136

Change-Id: I3dd6423db9bf9e799e438f2e5f50dfc77a0d78f8
2017-08-25 16:43:22 +00:00
Tom Cherry b1d93a8136 Merge "init: do not load persistent properties from temporary /data" 2017-08-25 16:37:20 +00:00
Mark Salyzyn 8b2136afe0 Merge "Switch /data/misc/reboot/last_reboot_reason to persistent property" am: 13cb599536 am: 37c6015d9d
am: a0641b5c13

Change-Id: Ia78340ffa961a3375dfa5f6b012f4f98bd7b01e3
2017-08-25 14:47:51 +00:00
Mark Salyzyn 37c6015d9d Merge "Switch /data/misc/reboot/last_reboot_reason to persistent property"
am: 13cb599536

Change-Id: Ib6c1b51668b892288db931b09b099bf5ed28fbae
2017-08-25 14:24:21 +00:00
Mark Salyzyn 73e6b49c0c Switch /data/misc/reboot/last_reboot_reason to persistent property
Switch from /data/misc/reboot/last_reboot_reason to persistent
Android property persist.sys.boot.reason for indicating why the
device is rebooted or shutdown.

persist.sys.boot.reason has a standard as outlined in b/63736262 and
the associated investigation. Made adjustments to the values so that
we did not create a problem even before we started. Compliance is
part of the tests in boot_reason_test.sh.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 64687998
Change-Id: I812c55a12faf7cb7ff92101009be058ad9958d07
2017-08-24 15:13:48 -07:00
Tom Cherry 9951b792b1 init: do not load persistent properties from temporary /data
With full disk encryption, a temporary /data partition is mounted to
start a minimum subset of the frameworks.  Later, once /data can be
decrypted it is mounted again.  load_persist_props is called both when
the temporary /data partition is mounted and again after the real
/data is mounted; this is a mistake.

This change checks to see if we're a FDE device and if so, returns the
first time load_persist_props is called.

Test: boot bullhead (FDE) with and without boot pin and check that
      persistent properties are loaded
Test: boot sailfish (FBE) and check that persistent properties are loaded
Change-Id: I6ed725072bdb27d80bfa6575d0a4876b08c6a4bc
2017-08-24 14:24:59 -07:00
Dmitry Shmidt e9b1299f74 Merge "init: Fix -DUSER_MODE_LINUX compilation" am: 9a38df3f5f am: d1821522aa
am: 14a60d2e19

Change-Id: I67de65e24f4573166aa2e48160b33b3506e28ad1
2017-08-24 01:35:14 +00:00
Dmitry Shmidt d1821522aa Merge "init: Fix -DUSER_MODE_LINUX compilation"
am: 9a38df3f5f

Change-Id: I26d86100bb8f76325b46ba2c2d066e856d910396
2017-08-24 01:23:01 +00:00
Treehugger Robot 9a38df3f5f Merge "init: Fix -DUSER_MODE_LINUX compilation" 2017-08-24 01:14:36 +00:00
Tom Cherry c3e9c2adca Merge changes I316c13e3,I4d99744d,Id9614b72,I7c98a0b7 am: a78b5b300b am: e0db940e52
am: ab6b6e2c3c

Change-Id: I8a3894121ff73bea73192f918252dd3db3bcbf53
2017-08-23 22:55:43 +00:00
Tom Cherry e0db940e52 Merge changes I316c13e3,I4d99744d,Id9614b72,I7c98a0b7
am: a78b5b300b

Change-Id: I0e4221611fb34489b2ecdd713933a2e4ba4e5055
2017-08-23 22:24:09 +00:00
Dmitry Shmidt c3bc509096 init: Fix -DUSER_MODE_LINUX compilation
Bug: 64985489
Test: Manual

Change-Id: Ib37d2b9affe500b66b9243fb24a7dee23b7730f2
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-08-23 14:57:07 -07:00
Tom Cherry 68f2a46145 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
2017-08-23 11:05:37 -07:00
Tom Cherry 76af7e6a0c init: log Service failures via Result<T>
Log Service failures via Result<T> such that their context can be
captured when interacting with services through builtin functions.

Test: boot bullhead
Change-Id: I4d99744d64008d4a06a404e3c9817182c6e177bc
2017-08-23 11:05:37 -07:00
Tom Cherry 130e3d7204 init: pass errors from one Result<T> to another better
Result<T> currently has two problems,
1) A failing Result<T> cannot be easily constructed from a Result<U>'s
error.
2) errno is lost when passing .error() through multiple Result<T>'s

This change fixes both problems having Result<T>::error() return a
ResultError class that contains the std::string error message and int
errno.

It additionally has ostream operators to continue to allow printing
the error string directly to an ostream and also to pass the errno
through to another Result<T> class via Error() creation.

Lastly, it provides a new constructor for Result<T> for ResultError,
such that a Result<T> can be constructed from Result<U>::error().

Test: boot bullhead, init unit tests
Change-Id: Id9614b727cdabd2f5498b0da0e598e9aff7d9ae0
2017-08-23 11:04:32 -07:00
Tom Cherry 6de21f1112 init: cleanup environment handling
Init keep its own copy of the environment that it uses for execve when
starting services.  This is unnecessary however as libc already has
functions that mutate the environment and the environment that init
uses is clean for starting services.  This change removes init's copy
of the environment and uses the libc functions instead.

This also makes small clean-up to the way the Service class stores
service specific environment variables.

Test: boot bullhead
Change-Id: I7c98a0b7aac9fa8f195ae33bd6a7515bb56faf78
2017-08-23 10:09:21 -07:00
Wei Wang 6c827ffb4f Merge "init: add log to time spent in waiting for file" am: 7f16cad877 am: 78f06df7b1 am: 9d4dc02f95
am: 9478eaa5a0

Change-Id: I9f20e47696503da7f13a4bcd10a0f793dd273a42
2017-08-23 00:16:22 +00:00
Wei Wang 9478eaa5a0 Merge "init: add log to time spent in waiting for file" am: 7f16cad877 am: 78f06df7b1
am: 9d4dc02f95

Change-Id: Iaca5c0efc5fcd9ba9810846f3862faf610599337
2017-08-22 23:54:45 +00:00
Wei Wang 9d4dc02f95 Merge "init: add log to time spent in waiting for file" am: 7f16cad877
am: 78f06df7b1

Change-Id: I0833d0007980d65a95fb7c96c00a0e16718b7fda
2017-08-22 23:39:47 +00:00
Wei Wang 4cea121872 init: add log to time spent in waiting for file
Bug: 64925999
Test: boot and take log
Change-Id: I7d37906708b5a4a195fb1ba1113641656d419e62
2017-08-22 14:09:11 -07:00
Andreas Huber 9c0804bbb0 Fix use-after-free of stack-allocated temporary string. am: c41b838baa am: a5efddda90
am: dbd2ac1202

Change-Id: I3afd60abcb45a9ae39388630edb274b8eca3ecc1
2017-08-21 17:46:28 +00:00
Andreas Huber dbd2ac1202 Fix use-after-free of stack-allocated temporary string. am: c41b838baa
am: a5efddda90

Change-Id: Ic0871bfae738d3b1854a7543843c0a9cc72c049d
2017-08-21 17:40:57 +00:00
Andreas Huber a5efddda90 Fix use-after-free of stack-allocated temporary string.
am: c41b838baa

Change-Id: I3eac4b22b885e7991256e5a7df8f37e6b9a10cce
2017-08-21 17:33:56 +00:00
Andreas Huber c41b838baa Fix use-after-free of stack-allocated temporary string.
Bug: 64848081
Test: built and successfully booted again
Merged-In: I93c899249bf2cc5ab8d880c0eaff471518e73121

Change-Id: I93c899249bf2cc5ab8d880c0eaff471518e73121
2017-08-21 09:44:56 -07:00
Tom Cherry 9128a0ba32 Merge "init: only set ro.boottime.<service> properties once." am: fe0607575d am: a1a6826c59 am: a82cc92437
am: bc4a6c49d9

Change-Id: Ib7ae7cb1b93708f8302c48903cc89396d533f47a
2017-08-18 20:24:10 +00:00
Tom Cherry bc4a6c49d9 Merge "init: only set ro.boottime.<service> properties once." am: fe0607575d am: a1a6826c59
am: a82cc92437

Change-Id: Id7cda0d04382c78a3978ceb79e087b37da38cd4a
2017-08-18 20:18:10 +00:00
Tom Cherry a82cc92437 Merge "init: only set ro.boottime.<service> properties once." am: fe0607575d
am: a1a6826c59

Change-Id: I7ed7631167f0d65c2a72efe26a727c18007c1c78
2017-08-18 20:12:10 +00:00
Tom Cherry ba20645490 Merge "ueventd: fix subsystem list logic issues" am: edf03e23bb am: 6698195d64 am: b843ae51a4
am: a74ad8d256

Change-Id: I707e019a2fe702c2e70d631699da813da8b0720e
2017-08-18 20:11:46 +00:00
Tom Cherry a1a6826c59 Merge "init: only set ro.boottime.<service> properties once."
am: fe0607575d

Change-Id: I1ef16e0a09803a4b3681227135ce2f1ec17b6401
2017-08-18 20:05:45 +00:00
Tom Cherry a74ad8d256 Merge "ueventd: fix subsystem list logic issues" am: edf03e23bb am: 6698195d64
am: b843ae51a4

Change-Id: I2f4002ba13d747db9ee8713b7bb59caaebd36033
2017-08-18 20:05:44 +00:00
Tom Cherry b843ae51a4 Merge "ueventd: fix subsystem list logic issues" am: edf03e23bb
am: 6698195d64

Change-Id: I4b8e3285645ee956f313e3904c16825460b350e2
2017-08-18 20:00:14 +00:00
Tom Cherry fe0607575d Merge "init: only set ro.boottime.<service> properties once." 2017-08-18 19:59:29 +00:00
Tom Cherry 6698195d64 Merge "ueventd: fix subsystem list logic issues"
am: edf03e23bb

Change-Id: I4ce43385af2376bc7246f25057dd3d7d76ec5dc8
2017-08-18 19:53:48 +00:00
Tom Cherry edf03e23bb Merge "ueventd: fix subsystem list logic issues" 2017-08-18 19:47:28 +00:00
Tom Cherry fed3373b5b init: only set ro.boottime.<service> properties once.
Currently, init attempts to set ro.boottime.<service> properties
whenever a service starts, however since these properties are ro. this
means that an error is printed whenever a service is restarted.

Since these properties are intended for reporting boottime, these
subsequent writes during restarts are erroneous and therefore this
change stops attempting to write them, thus silencing the error.

Test: boot bullhead, restart processes, observe no error print
Change-Id: I372f8d5c26590fc0661b92f632410e23e6418841
2017-08-18 10:47:46 -07:00
Tom Cherry 9c8d6dd7de ueventd: fix subsystem list logic issues
1) Check subsystems list before doing usb subsystem logic.  This allows
   developers to handle usb* subsystems in ueventd.rc files.
2) Fix a bug where each subsystem_ instance is not reinitialized, but
   rather only the name_ member was set.

Test: boot bullhead
Test: check that multiple uevent_devname subsystems work when
      specified in ueventd.rc
Change-Id: Ifcac04763afcaf72a3b14ef5f3a6cb89981b51a1
2017-08-18 10:39:48 -07:00
Tom Cherry 0be5ecf56a Merge "init: replace panic() with LOG(FATAL)" am: 57a89f3ba0 am: ce2325895f am: 0ae159a920
am: 18966c55e9

Change-Id: I460028050b79b9e759996485124561e33c8cc3fa
2017-08-18 16:15:58 +00:00
Tom Cherry 18966c55e9 Merge "init: replace panic() with LOG(FATAL)" am: 57a89f3ba0 am: ce2325895f
am: 0ae159a920

Change-Id: Id6f265cd11c133269afc4b4d87370ad14a2fb7a8
2017-08-18 16:09:57 +00:00
Tom Cherry 0ae159a920 Merge "init: replace panic() with LOG(FATAL)" am: 57a89f3ba0
am: ce2325895f

Change-Id: Ia46b3e10ce0280e60c8c8dc289d3c2f01ac472e2
2017-08-18 16:03:57 +00:00
Tom Cherry ce2325895f Merge "init: replace panic() with LOG(FATAL)"
am: 57a89f3ba0

Change-Id: Ib00187f9296ea8afd2bd323a87e290e7424a864e
2017-08-18 15:58:26 +00:00
Tom Cherry 57a89f3ba0 Merge "init: replace panic() with LOG(FATAL)" 2017-08-18 15:49:46 +00:00
Tom Cherry 2e9773a30a Merge "init: fix copy/paste mistake" am: f85404521e am: ad42b33eaa am: c3398d9e87
am: 3cbfff1615

Change-Id: I736005a89352b5e313960355d4bd28bdbeb18476
2017-08-18 02:36:28 +00:00
Tom Cherry 3cbfff1615 Merge "init: fix copy/paste mistake" am: f85404521e am: ad42b33eaa
am: c3398d9e87

Change-Id: Ibafc7fc324cebeeea04f365ee949a2fa9989b37e
2017-08-18 02:20:22 +00:00
Tom Cherry c3398d9e87 Merge "init: fix copy/paste mistake" am: f85404521e
am: ad42b33eaa

Change-Id: I341f0cefac7433737f1c226a39cd3dc818baeed9
2017-08-18 02:07:25 +00:00
Tom Cherry ad42b33eaa Merge "init: fix copy/paste mistake"
am: f85404521e

Change-Id: Id7382a959f5a22e4f4897ad593ea7202aae95c19
2017-08-18 01:55:43 +00:00
Treehugger Robot f85404521e Merge "init: fix copy/paste mistake" 2017-08-18 01:49:40 +00:00
Tom Cherry d8db7ab80d init: replace panic() with LOG(FATAL)
Test: boot bullhead
Test: Introduce LOG(FATAL) at various points of init and ensure that
      it reboots to the bootloader successfully
Test: Introduce LOG(FATAL) during DoReboot() and ensure that it reboots
      instead of recursing infinitely
Test: Ensure that fatal signals reboot to bootloader

Change-Id: I409005b6fab379df2d635e3e33d2df48a1a97df3
2017-08-17 18:16:51 -07:00
Tom Cherry 94f3bcdbc1 init: fix copy/paste mistake
Test: boot bullhead
Change-Id: I0fedb48a9684e21a27a1d260b84cb49a1038ce3f
2017-08-17 16:52:10 -07:00
Wei Wang 9f37a996ce Merge "Skip unnecessary sleep during shutdown" am: e3e4ec7c97 am: 57f94aa4bc am: 0660919ccf
am: 7bba2bf2d9

Change-Id: I3b26971430325fc9b14d9de72366ee269770b5cc
2017-08-17 02:08:34 +00:00
Wei Wang 7bba2bf2d9 Merge "Skip unnecessary sleep during shutdown" am: e3e4ec7c97 am: 57f94aa4bc
am: 0660919ccf

Change-Id: I95f30c8f6f4b24daae103156dbd9996f68e38c33
2017-08-17 02:03:05 +00:00
Wei Wang 0660919ccf Merge "Skip unnecessary sleep during shutdown" am: e3e4ec7c97
am: 57f94aa4bc

Change-Id: I6eed1052bcf74bf46511ad879fdb1348e507f0f6
2017-08-17 01:56:17 +00:00
Wei Wang 57f94aa4bc Merge "Skip unnecessary sleep during shutdown"
am: e3e4ec7c97

Change-Id: Iaa8af758ebcb2c7a300dde32902d14a11b6c53d6
2017-08-17 01:54:18 +00:00
Wei Wang 8c00e42f20 Skip unnecessary sleep during shutdown
Skip sleep if timeout is zero
Skip sleep if first pass umount succeed

Bug: 64768138
Test: reboot
Change-Id: I5ef731611320ade51974b414f7e47520ce36b287
2017-08-16 15:41:12 -07:00
Tom Cherry db640d87cd Merge changes I7f00c5f0,Idc18f331,I1e7d3a88
am: 334929b525

Change-Id: If6526adf256c1e5958d5aa6135d9e7efd11cf1cf
2017-08-14 22:52:34 +00:00
Tom Cherry 89bcc85edf init: use Result<T> for the parsing functions
Test: boot bullhead
Merged-In: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 14:07:49 -07:00
Tom Cherry 557946e57c init: use Result<T> for builtin functions
We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context.  This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead
Merged-In: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
2017-08-14 14:07:39 -07:00
Tom Cherry 11a3aeeae3 init: introduce Result<T> for return values and error handling
init tries to propagate error information up to build context before
logging errors.  This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &output, &calculate_result_err)) {
    *err = "CalculateResult " + input + " failed: " +
      calculate_result_err;
      return false;
  }
  UseResult(output);
  return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string.  If the functional only returns success or a failure with
an error message, Result<Success> may be used.  The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T.  This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure.  ErrnoError()
additionally appends ": " + strerror(errno) to the end of  the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() << "CalculateResult " << input << " failed: "
                   << output.error();
  }
  UseResult(*output);
  return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Merged-In: I1e7d3a8820a79362245041251057fbeed2f7979b
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
2017-08-14 14:07:30 -07:00
Tom Cherry 009c13083a Merge changes I7f00c5f0,Idc18f331,I1e7d3a88 into oc-dr1-dev-plus-aosp
am: 08adddec07

Change-Id: I582ced4450761fe8540e5f11ead33c561717b1de
2017-08-14 20:31:41 +00:00
Tom Cherry c317009410 init: split security functions out of init.cpp
This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp.  It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop.  The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users.  The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
(cherry picked from commit 9afb86b25d8675927cb37c86119a7ecf19f74819)
2017-08-14 11:07:27 -07:00
Tom Cherry b592dd8aff init: use Result<T> for the parsing functions
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 10:27:33 -07:00
Tom Cherry 7fa62c58d6 init: use Result<T> for builtin functions
We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context.  This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead

Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
2017-08-14 10:27:23 -07:00
Tom Cherry 62ca663475 init: introduce Result<T> for return values and error handling
init tries to propagate error information up to build context before
logging errors.  This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &output, &calculate_result_err)) {
    *err = "CalculateResult " + input + " failed: " +
      calculate_result_err;
      return false;
  }
  UseResult(output);
  return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string.  If the functional only returns success or a failure with
an error message, Result<Success> may be used.  The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T.  This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure.  ErrnoError()
additionally appends ": " + strerror(errno) to the end of  the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() << "CalculateResult " << input << " failed: "
                   << output.error();
  }
  UseResult(*output);
  return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
2017-08-14 10:26:57 -07:00
Tom Cherry 2958df83a7 init: use Result<T> for the parsing functions
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 10:25:35 -07:00
Tom Cherry 568947d7d1 init: use Result<T> for builtin functions
We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context.  This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead

Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
2017-08-14 10:25:26 -07:00
Tom Cherry de09d52328 init: introduce Result<T> for return values and error handling
init tries to propagate error information up to build context before
logging errors.  This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &output, &calculate_result_err)) {
    *err = "CalculateResult " + input + " failed: " +
      calculate_result_err;
      return false;
  }
  UseResult(output);
  return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string.  If the functional only returns success or a failure with
an error message, Result<Success> may be used.  The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T.  This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure.  ErrnoError()
additionally appends ": " + strerror(errno) to the end of  the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() << "CalculateResult " << input << " failed: "
                   << output.error();
  }
  UseResult(*output);
  return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
2017-08-14 10:25:14 -07:00
Tom Cherry b6b9629f02 Merge "init: split security functions out of init.cpp" into oc-dev-plus-aosp
am: 08228116a8

Change-Id: I3fc6288cf03cd1e262852ceb3fc9dbcedb32c7c3
2017-08-14 16:50:01 +00:00
Tom Cherry 08228116a8 Merge "init: split security functions out of init.cpp" into oc-dev-plus-aosp 2017-08-14 16:45:19 +00:00
Tom Cherry 0c8d6d2730 init: split security functions out of init.cpp
This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp.  It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop.  The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users.  The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
2017-08-14 09:40:01 -07:00
Tom Cherry 658064ae37 Merge "init: split security functions out of init.cpp" into oc-mr1-dev-plus-aosp 2017-08-14 16:16:44 +00:00
Tom Cherry 2c486f593c Merge "init: fix format issue" am: f95338f634
am: a1051005a9

Change-Id: Ied41953b37104906e2a9551c3f5c2c34dc8168a1
2017-08-12 00:17:52 +00:00
Tom Cherry a1051005a9 Merge "init: fix format issue"
am: f95338f634

Change-Id: I771056e5543e8d1028a61fd9190e90a29b9bcfec
2017-08-12 00:15:53 +00:00
Treehugger Robot f95338f634 Merge "init: fix format issue" 2017-08-12 00:07:58 +00:00
Wei Wang 5bc171866c Merge "init: Add readahead built-in command" am: 12bd22badf am: 826bc7b507 am: 67eac4fa36
am: d8467415b0

Change-Id: I2337d70461f148424db12a710c578a12d3aa63ab
2017-08-11 22:36:17 +00:00
Wei Wang d8467415b0 Merge "init: Add readahead built-in command" am: 12bd22badf am: 826bc7b507
am: 67eac4fa36

Change-Id: I852ee7278ec94e3b483a8ef61fe34477f73517fb
2017-08-11 22:28:54 +00:00
Wei Wang 67eac4fa36 Merge "init: Add readahead built-in command" am: 12bd22badf
am: 826bc7b507

Change-Id: I3cdb1022bf863c5ffd58be0d7af5f6712c818365
2017-08-11 22:15:29 +00:00
Tom Cherry c3692b3ea9 init: split security functions out of init.cpp
This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp.  It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop.  The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users.  The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
(cherry picked from commit 9afb86b25d8675927cb37c86119a7ecf19f74819)
2017-08-11 15:01:15 -07:00
Tom Cherry 16380365c4 init: split security functions out of init.cpp
This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp.  It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop.  The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users.  The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
(cherry picked from commit 9afb86b25d8675927cb37c86119a7ecf19f74819)
2017-08-11 15:00:00 -07:00
Wei Wang 826bc7b507 Merge "init: Add readahead built-in command"
am: 12bd22badf

Change-Id: I4cd4ea9a013a1bcbe065e7dbce18f61a897393d9
2017-08-11 21:51:36 +00:00
Josh Gao 0b3c800bb3 crash_dump: during early boot, output to kmsg on userdebug.
am: 3e76ecaf80

Change-Id: I72baab899157ebc2e0379e0bd2a46d61c6f5ed8f
2017-08-11 21:23:10 +00:00
Josh Gao 3e76ecaf80 crash_dump: during early boot, output to kmsg on userdebug.
Crashes that happen before tombstoned is running are extremely hard to
diagnose, because tombstones aren't written to disk, and the window of
opportunity to get logs via `adb logcat` is small (potentially
nonexistent).

Solve this by adding a world-writable /dev/kmsg_debug on userdebug
builds, and writing to it in addition to logcat when tombstoned hasn't
started yet.

Bug: http://b/36574794
Test: stop tombstoned; crasher; dmesg
Change-Id: I46ba2dd67c188be74bd931f8a5536b6342d537f2
2017-08-11 13:29:38 -07:00
Tom Cherry 1f87cd1bd0 init: fix format issue
Trying to limit merge conflicts later...

Test: build
Change-Id: I802f2cf86b8432f65ad4dcd45bfd543ee5091775
2017-08-11 13:22:37 -07:00
Wei Wang 542aae443f init: Add readahead built-in command
Inspired by ag/2659809/, this CL add readahead built-in command in init
to let files be prefetched into pagecache for faster reading.
Readahead happens in background but due to filesystem limitation it
might take small amount of time in it reading the filesystem metadata
needed to locate the requested blocks. So the command is executed in a
forked process to not block init execution.

Bug: 62413151
Test: boottime, dumpcache
Change-Id: I56c86e2ebc20efda4aa509e6efb736bd1d92baa5
2017-08-11 11:24:08 -07:00
Tom Cherry aa7467072c Merge changes If1cffa85,I9011a959 am: 30bd51c61f am: fb9deac35c am: cd9b0c16bc
am: 3e5fd2e9df

Change-Id: I56773bd3104560ee61585135afafdaf79a8df5d4
2017-08-10 04:46:40 +00:00
Tom Cherry 3e5fd2e9df Merge changes If1cffa85,I9011a959 am: 30bd51c61f am: fb9deac35c
am: cd9b0c16bc

Change-Id: I330fc192cd46173408e1ed416f281c1648d4d977
2017-08-10 04:43:09 +00:00
Tom Cherry cd9b0c16bc Merge changes If1cffa85,I9011a959 am: 30bd51c61f
am: fb9deac35c

Change-Id: I6957a7320f43fd377267259feb42ea932cbf9ada
2017-08-10 04:39:38 +00:00
Tom Cherry fb9deac35c Merge changes If1cffa85,I9011a959
am: 30bd51c61f

Change-Id: Ib59f5e16d656185bba05ad5dcec1425f2ce72b1b
2017-08-10 04:36:11 +00:00
Tom Cherry 2a978d32d2 init: move property_service.cpp to libinit
service.cpp, which is part of libinit, references symbols in
property_service.cpp, which causes the linker to complain when linking
libinit.a in some situations.

Therefore, we move property_service.cpp to libinit.

Separately, this will make it easier to write tests for
property_service.cpp, which we will want to do in the future.

Test: build, init unit tests
Change-Id: If1cffa8510b97e9436efed3c8ea0724272383eba
2017-08-09 17:13:21 -07:00
Tom Cherry 45a9d67cec init: statically link libselinux to init_tests
The shared libselinux library does not export all of the symbols that
we use in init and the linker is now complaining about this, so let's
use the static libselinux library in init_tests to match init itself.

Test: build, init unit tests
Change-Id: I9011a959a7c49446b3529740e606140a4ee8c32d
2017-08-09 17:09:04 -07:00
Tom Cherry 85c208dd27 Merge "ueventd: add test to ensure selabel_lookup() is thread safe" am: 2c3a2a8c5c am: 3df3ec34e4 am: 7fd1bc8fc3
am: 5cd97dcd2f

Change-Id: I805db0bb7726da28204bffc734c75910c5cf9929
2017-08-08 23:33:56 +00:00
Tom Cherry 5cd97dcd2f Merge "ueventd: add test to ensure selabel_lookup() is thread safe" am: 2c3a2a8c5c am: 3df3ec34e4
am: 7fd1bc8fc3

Change-Id: Id053ade023074737b2096bb5061f2ad7798e40d6
2017-08-08 23:27:17 +00:00
Tom Cherry 7fd1bc8fc3 Merge "ueventd: add test to ensure selabel_lookup() is thread safe" am: 2c3a2a8c5c
am: 3df3ec34e4

Change-Id: I3c260731c56e903f53c20a0c52920f3ecfe3fe00
2017-08-08 23:04:04 +00:00
Tom Cherry 3df3ec34e4 Merge "ueventd: add test to ensure selabel_lookup() is thread safe"
am: 2c3a2a8c5c

Change-Id: I57b1fb1906671950a4374f515438349f368f7cad
2017-08-08 22:48:04 +00:00