Commit graph

2247 commits

Author SHA1 Message Date
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
Tom Cherry
57ef66b6fa ueventd: add test to ensure selabel_lookup() is thread safe
selabel_lookup() must be threadsafe, but had failed in the past.

Bug: 63861738
Test: this newly added test
Change-Id: I78bdb8e555433e8217ac6d4be112ba91de9f03bb
2017-08-08 13:11:44 -07:00
Tom Cherry
91066e4616 Merge "init: more unique_fd, less goto" am: 401c9cb330 am: 0908ca721a am: 613fd13dc2
am: bb0c02c06e

Change-Id: I72fe94758c651684fd9edcf7d657bd2c3096596b
2017-08-04 20:58:31 +00:00
Tom Cherry
bb0c02c06e Merge "init: more unique_fd, less goto" am: 401c9cb330 am: 0908ca721a
am: 613fd13dc2

Change-Id: I83c87dd1f06b1a4246981e2b4d9eaf9a275569eb
2017-08-04 20:38:58 +00:00
Tom Cherry
613fd13dc2 Merge "init: more unique_fd, less goto" am: 401c9cb330
am: 0908ca721a

Change-Id: Iab85433cbe327daf6854444dc235adf31acd0925
2017-08-04 20:32:56 +00:00
Tom Cherry
0908ca721a Merge "init: more unique_fd, less goto"
am: 401c9cb330

Change-Id: If621924a00686b41889d4e75ad360c3c3d3d4a85
2017-08-04 20:26:57 +00:00
Tom Cherry
7c4609cfb3 init: more unique_fd, less goto
Test: boot bullhead
Change-Id: I3c31ca045538d9c9dbbf9c8f27f63033344627fd
2017-08-04 20:12:56 +00:00
Tom Cherry
f331fa07d1 Merge "init: use unique_fd in builtins.cpp" am: c34afb1cd5 am: 76756aa1dd am: 54032d387a
am: 99a538a4bb

Change-Id: I83e3e48828adb1d2f10c1aab1021dc3f7553d5a0
2017-08-02 17:48:12 +00:00
Tom Cherry
99a538a4bb Merge "init: use unique_fd in builtins.cpp" am: c34afb1cd5 am: 76756aa1dd
am: 54032d387a

Change-Id: I20865544dd1692979c8fbd21c05272a98c00eca4
2017-08-02 17:27:03 +00:00
Tom Cherry
54032d387a Merge "init: use unique_fd in builtins.cpp" am: c34afb1cd5
am: 76756aa1dd

Change-Id: Idbb7f13966643faa2e38ac954e21d6af2daed4f5
2017-08-02 17:22:30 +00:00
Tom Cherry
76756aa1dd Merge "init: use unique_fd in builtins.cpp"
am: c34afb1cd5

Change-Id: I9f1fef77ab4d3f873180f305177e586d44a22c49
2017-08-02 17:18:33 +00:00
Tom Cherry
7037991f04 init: use unique_fd in builtins.cpp
Test: boot

Change-Id: I09295856dbd0de9436a95a2fe99ab6be156b995f
2017-08-01 14:22:44 -07:00
Tom Cherry
48b9bccf48 Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe am: 2a2a8d9ec0 am: b1c18af247 am: 3d6b46a789
am: c31c4d5c6d

Change-Id: I0c20d57379aa545ea91633e33a7583604d947a52
2017-08-01 20:35:46 +00:00
Tom Cherry
c31c4d5c6d Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe am: 2a2a8d9ec0 am: b1c18af247
am: 3d6b46a789

Change-Id: I704cb309efb106cff34c28b9c7fde3e86bb34cc0
2017-08-01 20:32:12 +00:00
Tom Cherry
3d6b46a789 Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe am: 2a2a8d9ec0
am: b1c18af247

Change-Id: I501b47b2aecaed3b4c15636f09bd337b4ea799c0
2017-08-01 20:29:10 +00:00
Tom Cherry
b1c18af247 Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe
am: 2a2a8d9ec0

Change-Id: Id39de0d3d62c1e0f3585ae7817940dbbebfa6ae3
2017-08-01 20:25:57 +00:00
Tom Cherry
2a2a8d9ec0 Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe
* changes:
  init: rename ServiceManager to ServiceList and clean it up
  init: move reaping from ServiceManager to signal_handler.cpp
  init: move exec operations out of ServiceManager
2017-08-01 20:15:02 +00:00
Tom Cherry
911b9b1d6e init: rename ServiceManager to ServiceList and clean it up
ServiceManager is essentially just a list now that the rest of its
functionality has been moved elsewhere, so the class is renamed
appropriately.

The ServiceList::Find* functions have been cleaned up into a single
smaller interface.
The ServiceList::ForEach functions have been removed in favor of
ServiceList itself being directly iterable.

Test: boot bullhead
Change-Id: Ibd57c103338f03b83d81e8b48ea0e46cd48fd8f0
2017-08-01 11:06:17 -07:00
Tom Cherry
eeee83106b init: move reaping from ServiceManager to signal_handler.cpp
signal_handler.cpp itself needs to be cleaned up, but this is a step
to clean up ServiceManager.

Test: boot bullhead
Change-Id: I81f1e8ac4d09692cfb364bc702cbd3deb61aa55a
2017-08-01 11:06:17 -07:00
Tom Cherry
3b81f2d623 init: move exec operations out of ServiceManager
These can be implemented without ServiceManager, so we remove them and
make ServiceManager slightly less of a God class.

Test: boot bullhead
Test: init unit tests
Change-Id: Ia6e546fe5292255412245256f7d230af4ece135f
2017-08-01 11:06:04 -07:00
Tom Cherry
f62a7f56fe Merge "init: fix process restarting" am: eb3fa92191 am: 25422816d4 am: b435774e01
am: 2f77438b4d

Change-Id: I212c1f8e5f08f11d071dc1e46f929aa18e9da06d
2017-08-01 17:15:00 +00:00
Tom Cherry
2f77438b4d Merge "init: fix process restarting" am: eb3fa92191 am: 25422816d4
am: b435774e01

Change-Id: Ibbf50172f4a6358363e2d1889ae631eaeca8004c
2017-08-01 17:11:08 +00:00
Tom Cherry
b435774e01 Merge "init: fix process restarting" am: eb3fa92191
am: 25422816d4

Change-Id: I4b55c13edc6a3f8076acbe878078913f35f17e26
2017-08-01 17:07:31 +00:00
Tom Cherry
25422816d4 Merge "init: fix process restarting"
am: eb3fa92191

Change-Id: Ic03cf607631c49c1d37584f7641d9300a79f5457
2017-08-01 17:04:44 +00:00
Tom Cherry
eb3fa92191 Merge "init: fix process restarting" 2017-08-01 16:53:52 +00:00
Tom Cherry
d269e3a795 init: fix process restarting
The time data types associated with restarting processes halfway moved
to std::chrono and halfway didn't.  In this intermediate state, the
times would get converted from nanoseconds to seconds then to
milliseconds.  The precision lost when converting to seconds would
cause the main loop of init to spin whenever a process was within a
second of being restarted.

This patch cleans up this logic and uses nanoseconds and milliseconds
explicitly, with a ceiling to milliseconds to prevent unneeded
spinning.

Test: boot bullhead, kill processes, see that they restart sanely.

Change-Id: I0b017ba0e50c09704b0c5cdfcde1dba461804593
2017-07-31 16:00:18 -07:00
Bo Hu
01128555ac Merge "Allow the use of a custom Android DT directory" am: 6fa0884188 am: 8b2e0e03d4 am: 8bdf7ed10e
am: 5e8de93697

Change-Id: I065dbef72e7bc4d6233c9f73786139a78e9098d8
2017-07-29 07:12:49 +00:00
Bo Hu
5e8de93697 Merge "Allow the use of a custom Android DT directory" am: 6fa0884188 am: 8b2e0e03d4
am: 8bdf7ed10e

Change-Id: I6e924fb7f52650343ba4ae591e09deee6a366905
2017-07-29 07:10:18 +00:00
Bo Hu
8bdf7ed10e Merge "Allow the use of a custom Android DT directory" am: 6fa0884188
am: 8b2e0e03d4

Change-Id: I5c5f80c6c55ff8d7bae1f52593dec3ef6efa9908
2017-07-29 07:07:48 +00:00
Bo Hu
8b2e0e03d4 Merge "Allow the use of a custom Android DT directory"
am: 6fa0884188

Change-Id: I1c37cb0c809b2ed51d61e6b1e8ea87830e48eda5
2017-07-29 07:05:18 +00:00
Bo Hu
6fa0884188 Merge "Allow the use of a custom Android DT directory" 2017-07-29 06:58:07 +00:00
Tom Cherry
56fd494914 Merge "init: remove Parser singleton and related cleanup" am: 379123f9ab am: bf4afbb288 am: 1b74d14b7e
am: a78298e8a6

Change-Id: I3aaa252ad83a982a471188d5fc2f84f258892cd6
2017-07-28 16:50:47 +00:00
Tom Cherry
a78298e8a6 Merge "init: remove Parser singleton and related cleanup" am: 379123f9ab am: bf4afbb288
am: 1b74d14b7e

Change-Id: Ifaaeae8fb3f43235846207fa02a83edbc1e427d9
2017-07-28 16:42:55 +00:00
Tom Cherry
1b74d14b7e Merge "init: remove Parser singleton and related cleanup" am: 379123f9ab
am: bf4afbb288

Change-Id: Ie2e9d6b92bbc6011796c63da990c44281046b59a
2017-07-28 16:39:57 +00:00
Tom Cherry
bf4afbb288 Merge "init: remove Parser singleton and related cleanup"
am: 379123f9ab

Change-Id: I3ef698fb1f18bcaf7dd5e1c01f1fb01bead2aa0a
2017-07-28 16:36:54 +00:00
Tom Cherry
379123f9ab Merge "init: remove Parser singleton and related cleanup" 2017-07-28 16:29:36 +00:00
Yu Ning
c01022a62e Allow the use of a custom Android DT directory
On platforms that use ACPI instead of Device Tree (DT), such as
Ranchu x86/x86_64, /proc/device-tree/firmware/android/ does not
exist. As a result, Android O is unable to mount /system, etc.
at the first stage of init:

 init: First stage mount skipped (missing/incompatible fstab in
 device tree)

Those platforms may create another directory that mimics the layout
of the standard DT directory in procfs, and store early mount
configuration there. E.g., Ranchu x86/x86_64 creates one in sysfs
using information encoded in the ACPI tables:

 https://android-review.googlesource.com/442472
 https://android-review.googlesource.com/443432
 https://android-review.googlesource.com/442393
 https://android-review.googlesource.com/442395

Therefore, instead of hardcoding the Android DT path, load it from
the kernel command line using a new Android-specific property key
("androidboot.android_dt_dir"). If no such property exists, fall
back to the standard procfs path (so no change is needed for DT-
aware platforms).

Note that init/ and fs_mgr/ each have their own copy of the Android
DT path, because they do not share any global state. A future CL
should remove the duplication by refactoring.

With this CL as well as the above ones, the said warning is gone,
but early mount fails. That is a separate bug, though, and will be
addressed by another CL.

Test: Boot patched sdk_phone_x86-userdebug system image with patched
      Goldfish 3.18 x86 kernel in patched Android Emulator, verify
      the "init: First stage mount skipped" warning no longer shows
      in dmesg.

Change-Id: Ib6df577319503ec1ca778de2b5458cc72ce07415
Signed-off-by: Yu Ning <yu.ning@intel.com>
2017-07-28 11:10:48 +08:00
Tom Cherry
67dee626e0 init: remove Parser singleton and related cleanup
* Remove the Parser singleton (Hooray!)
* Rename parser.* to tokenizer.* as this is actually a tokenizer
* Rename init_parser.* to parser.* as this is a generic parser
* Move contents of init_parser_test.cpp to service_test.cpp as this
  actually is a test of the parsing in MakeExecOneshotService() and
  nothing related to (init_)parser.cpp

Test: boot bullhead
Test: bool sailfish
Test: init unit tests
Change-Id: I4fe39e6483f58ebd3ce5ee715a45dbba0acf5d91
2017-07-27 13:23:32 -07:00
Tom Cherry
9909bdb565 Merge "init: shutdown services in the opposite order that they started" am: 8e7942cbd1 am: 9f030d89dc am: 70c71dfe58
am: ae66073276

Change-Id: I96b818458182fd3d27cb8faa5319e05fec5aaf91
2017-07-27 17:54:44 +00:00
Tom Cherry
ae66073276 Merge "init: shutdown services in the opposite order that they started" am: 8e7942cbd1 am: 9f030d89dc
am: 70c71dfe58

Change-Id: If82ec58b0c7f3dc028d61365c280ee0b0f7d3cc5
2017-07-27 17:52:21 +00:00
Tom Cherry
70c71dfe58 Merge "init: shutdown services in the opposite order that they started" am: 8e7942cbd1
am: 9f030d89dc

Change-Id: I5c83460633c56fcf740ca939b0dd931bee6854ab
2017-07-27 17:50:13 +00:00
Tom Cherry
9f030d89dc Merge "init: shutdown services in the opposite order that they started"
am: 8e7942cbd1

Change-Id: Ibd6b25f77dc3f4033902ec25323ff4e6cab024a2
2017-07-27 17:48:12 +00:00
Tom Cherry
8e7942cbd1 Merge "init: shutdown services in the opposite order that they started" 2017-07-27 17:42:46 +00:00
Ben Fennema
983a404e10 Merge "init: fix type of 2nd argument passed to prctl" am: 1b506c54c2 am: f01f4e9d4a am: ec7afe31a0
am: 2953e1af9b

Change-Id: I09b2790e3800bcad1c8639bc13e16a7c066b5477
2017-07-27 07:05:58 +00:00
Ben Fennema
2953e1af9b Merge "init: fix type of 2nd argument passed to prctl" am: 1b506c54c2 am: f01f4e9d4a
am: ec7afe31a0

Change-Id: I2b46745a6d68b4c5fb4b1a91deecb28b0388d6b9
2017-07-27 07:03:30 +00:00
Ben Fennema
ec7afe31a0 Merge "init: fix type of 2nd argument passed to prctl" am: 1b506c54c2
am: f01f4e9d4a

Change-Id: Ie84551e47139dbdbbf7a9a27a849718b43e00fa7
2017-07-27 07:00:28 +00:00
Ben Fennema
f01f4e9d4a Merge "init: fix type of 2nd argument passed to prctl"
am: 1b506c54c2

Change-Id: I5b4de3ee0e55d99e8d63f98fdcbd39de70ff0337
2017-07-27 06:57:58 +00:00
Ben Fennema
a72436067d init: fix type of 2nd argument passed to prctl
prctl(PR_SET_SECUREBITS, ...) expects an unsigned long as its 2nd argument.
Passing in a int64_t happens to work with a 64-bit kernel, but does not
work with a 32-bit kernel.

Bug: 63680332
Test: boot 32-bit kernel; verify services with capabilities can successfully
      set those capabilties
Change-Id: I60250d107a77b54b2e9fe3419b4480b921c7e2f8
Signed-off-by: Ben Fennema <fennema@google.com>
2017-07-27 03:31:18 +00:00
Tom Cherry
29c3e7eb65 Merge "init: only use signed-integer-overflow sanitizer" am: a19f481c8c am: 2eada2af9c am: 9d36683fd7
am: a12e34cc31

Change-Id: Ia95c9a4198a0e857d71e79b5595286c57a94e445
2017-07-27 02:38:35 +00:00
Tom Cherry
a12e34cc31 Merge "init: only use signed-integer-overflow sanitizer" am: a19f481c8c am: 2eada2af9c
am: 9d36683fd7

Change-Id: I31be7dc0620e55dea1e97f2f26f59dce028cb563
2017-07-27 01:26:33 +00:00
Tom Cherry
9d36683fd7 Merge "init: only use signed-integer-overflow sanitizer" am: a19f481c8c
am: 2eada2af9c

Change-Id: Ic0da94313de22222d4312cf097fd5dcd43c76344
2017-07-27 00:58:03 +00:00
Tom Cherry
2eada2af9c Merge "init: only use signed-integer-overflow sanitizer"
am: a19f481c8c

Change-Id: I7f1e3ad1008f4d7d3588bbeca7c72bb0d9defeec
2017-07-27 00:49:55 +00:00
Tom Cherry
5938379e91 init: shutdown services in the opposite order that they started
Currently, the order that we kill to services during shutdown is the
order of services_ in ServiceManager and that is defacto the order in
which they were parsed, which is not a very useful ordering.

Related to this, we have seen a few issues during shutdown that may be
related to services with dependencies on other services, where the
dependency is killed first and the dependent service then misbehaves.

This change allows services to keep track of the order in which they
were started and shutdown then uses that information to kill running
services in the opposite order that they were started.

Bug: 64067984
Test: Boot and reboot bullhead

Change-Id: I6b4cacb03aed2a72ae98a346bce41ed5434a09c2
2017-07-26 16:48:06 -07:00
Tom Cherry
2ffd65e1d1 init: only use signed-integer-overflow sanitizer
We've blown up twice in init due to the unsigned integer overflow
sanitizer despite the overflows in question being both defined and
intentional.

Test: boot
Change-Id: I08effe3202ac1367d858982ff5478b3a088bab37
2017-07-26 14:25:25 -07:00
Lennart Wieboldt
6da3de27be Merge "Remove LOCAL_CLANG and clang: true" am: 80ec81cf4b am: f7b315c985 am: 8a8b97b271
am: e1332dd01b

Change-Id: I193d86abf96e64b29efc7266f4fa3a26b5d2b3af
2017-07-25 22:39:58 +00:00
Lennart Wieboldt
e1332dd01b Merge "Remove LOCAL_CLANG and clang: true" am: 80ec81cf4b am: f7b315c985
am: 8a8b97b271

Change-Id: I7e691abe2e2ccec5d9477c528d603c081c0a5661
2017-07-25 22:35:56 +00:00
Lennart Wieboldt
8a8b97b271 Merge "Remove LOCAL_CLANG and clang: true" am: 80ec81cf4b
am: f7b315c985

Change-Id: Id5ebeb3271a36f21bf28c186f7ec227d31bb10ac
2017-07-25 22:33:27 +00:00
Lennart Wieboldt
f7b315c985 Merge "Remove LOCAL_CLANG and clang: true"
am: 80ec81cf4b

Change-Id: Ia7f79d8e25ee9870fe44d198568d0e5dabdff811
2017-07-25 22:28:56 +00:00
Treehugger Robot
80ec81cf4b Merge "Remove LOCAL_CLANG and clang: true" 2017-07-25 22:20:23 +00:00
Wei Wang
4cca10cf7e Merge "Do not umount roofs even if it is R/W." am: 43567e39dc am: 22782a7269 am: 34e13498dc
am: 081c1921e0

Change-Id: I0e7da9de55bd7f8b39561aa0a3a9a8b434749ddb
2017-07-25 20:51:18 +00:00
Wei Wang
081c1921e0 Merge "Do not umount roofs even if it is R/W." am: 43567e39dc am: 22782a7269
am: 34e13498dc

Change-Id: I8b3c0cefd23d5e7e44da02e13cc173472834b070
2017-07-25 20:47:48 +00:00
Wei Wang
34e13498dc Merge "Do not umount roofs even if it is R/W." am: 43567e39dc
am: 22782a7269

Change-Id: I84024bff22fee8569c0f1193d6f3d8417d3cbc1b
2017-07-25 20:44:21 +00:00
Wei Wang
22782a7269 Merge "Do not umount roofs even if it is R/W."
am: 43567e39dc

Change-Id: I89bfb662469c28559eb628e48aee1ecb262ad2ee
2017-07-25 20:41:19 +00:00
Steve Muckle
c2548ea392 Merge "init: add support for global seccomp boot option" am: 9f1980e2fc am: 5a79972238 am: eb7db75c28
am: aa4bb9552f

Change-Id: I0b7c6112549b8cfba1f4069515d666534ee9e3e2
2017-07-25 20:36:49 +00:00
Treehugger Robot
43567e39dc Merge "Do not umount roofs even if it is R/W." 2017-07-25 20:35:50 +00:00
Steve Muckle
aa4bb9552f Merge "init: add support for global seccomp boot option" am: 9f1980e2fc am: 5a79972238
am: eb7db75c28

Change-Id: I5fabba13d6b269ffca8731fc83dbd590ae388239
2017-07-25 20:33:53 +00:00
Steve Muckle
eb7db75c28 Merge "init: add support for global seccomp boot option" am: 9f1980e2fc
am: 5a79972238

Change-Id: Ide7500d4ff4d9eebf2fea1d81ff77044a6d63c57
2017-07-25 20:30:30 +00:00
Steve Muckle
5a79972238 Merge "init: add support for global seccomp boot option"
am: 9f1980e2fc

Change-Id: I35532202b360ef32cdb21c048cd3d2e1139b7d67
2017-07-25 20:26:29 +00:00
Treehugger Robot
9f1980e2fc Merge "init: add support for global seccomp boot option" 2017-07-25 20:18:51 +00:00
Wei Wang
a01c27eef8 Do not umount roofs even if it is R/W.
Latest device has rootfs instead of "/system" mount point

Bug: 37737296
Test: adb remount, reboot, and check log
Change-Id: I315ecf71e85255fc55c3a80619920b456bad0956
2017-07-25 10:55:10 -07:00
Lennart Wieboldt
cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02:00
Wei Wang
2257815813 Merge "init: Fire shutdown trigger for thermal shutdown" am: 603cae8b48 am: b0a6129c43 am: fc2f0a0ce7
am: 9a63ee349d

Change-Id: I6e44b248c79a7472bea4557fc55bbf79733ecd14
2017-07-24 22:27:50 +00:00
Wei Wang
9a63ee349d Merge "init: Fire shutdown trigger for thermal shutdown" am: 603cae8b48 am: b0a6129c43
am: fc2f0a0ce7

Change-Id: I1611d973239dd15b01799fc21bdc812dfacc8036
2017-07-24 22:20:19 +00:00
Wei Wang
fc2f0a0ce7 Merge "init: Fire shutdown trigger for thermal shutdown" am: 603cae8b48
am: b0a6129c43

Change-Id: I3f88302f280809e9df98dc55dd2ca6ebd269e7bb
2017-07-24 22:17:50 +00:00
Wei Wang
b0a6129c43 Merge "init: Fire shutdown trigger for thermal shutdown"
am: 603cae8b48

Change-Id: I0bbd26f22887afcf7b2145b78239c9f8e2c45047
2017-07-24 22:15:20 +00:00
Steve Muckle
af1a9bfb8f init: add support for global seccomp boot option
Setting androidboot.seccomp=global on the kernel command line shall
enable seccomp for all processes rather than just in zygote. Doing
this has a performance impact, for now it shall just be used to audit
syscall usage during testing.

Bug: 37960259
Change-Id: I6b9fc95e9bec5e2bcfe6ef0b4343a5b422e30152
2017-07-24 13:33:54 -07:00
Wei Wang
1be2212319 init: Fire shutdown trigger for thermal shutdown
Recent change in init has bring normal shutdown sequence in
thermal-shutdown condition. This CL will make sure init fire shutdown
trigger where holds custom shutdown actions for vendor SoC/platform.

Bug: 63686426
Test: adb shell setprop sys.powerctl thermal-shutdown
Change-Id: Ieb8579fdf9c30c1a81d60466a7375c9784f3ca98
2017-07-24 13:12:22 -07:00
Tom Cherry
e4e6f3a6e6 Merge "init: use delegating constructor for Service" am: ce3b2de809 am: 9549d6889a am: d78477cf59
am: 78f18a3e37

Change-Id: I14f4510b05990778946c26048640048bbd333fcf
2017-07-24 16:43:18 +00:00
Tom Cherry
78f18a3e37 Merge "init: use delegating constructor for Service" am: ce3b2de809 am: 9549d6889a
am: d78477cf59

Change-Id: I9f43b6f3a35ff831efb4c7feb7f6cc27866bce31
2017-07-24 16:38:51 +00:00
Tom Cherry
d78477cf59 Merge "init: use delegating constructor for Service" am: ce3b2de809
am: 9549d6889a

Change-Id: I5b2c03c405b8261a2613905d8597c58b73ca4bb9
2017-07-24 16:33:03 +00:00
Tom Cherry
9549d6889a Merge "init: use delegating constructor for Service"
am: ce3b2de809

Change-Id: Ic9bd63b44f57b505b1cd379948786349e92c0c45
2017-07-24 16:27:35 +00:00
Tom Cherry
5d17d044c7 init: use delegating constructor for Service
Test: init unit tests
Change-Id: Ida0be6195a3675bfca3d979db03855b45417b11e
2017-07-21 12:42:07 -07:00
Jin Qian
998de96766 Merge changes from topic 'mke2fs_2' am: 176827e166
am: 3f531ac5cf

Change-Id: Ic83be85a8955df27adf84e9ab9a2c5e40c0166e5
2017-07-21 19:10:35 +00:00
Jin Qian
3f531ac5cf Merge changes from topic 'mke2fs_2'
am: 176827e166

Change-Id: I933e0d96d9c81c5800e4cf406582277b140f3e2b
2017-07-21 19:06:03 +00:00
Treehugger Robot
176827e166 Merge changes from topic 'mke2fs_2'
* changes:
  fastboot: add mke2fs and e2fsdroid to build package
  fastboot: call mke2fs tools to generate ext4 image
  fs_mgr: call format_f2fs correctly with -f
  init: require e2fsdroid and mke2fs when building init
  init: rename mke2fs tools with _static suffix
2017-07-21 19:00:46 +00:00
Jin Qian
00456978a2 init: require e2fsdroid and mke2fs when building init
init calls fs_mgr to format ext4 partitions. This requires
e2fsdroid and mke2fs in /system/bin/

Bug: 35219933
Change-Id: Ia32fe438cd9b9332f8e18e0cbe7f61bd050adcb1
(cherry picked from commit 041f849548)
2017-07-20 11:54:02 -07:00
Jin Qian
278b15c84c init: rename mke2fs tools with _static suffix
We build a static version for recovery mode. Give them
different names to avoid conflicts with regular version
in /system/bin/

Bug: 35219933
Change-Id: I738655ad9b9ad71c63ae604d9a4d659b0b671121
(cherry picked from commit a2421041bf)
2017-07-20 11:53:44 -07:00
Keun-young Park
cfa0a9524b Merge "init: Do full shutdown even for thermal shutdown" am: d5b36f38ef am: a064892e1a am: 614ccd7a02
am: 44dce1fed7

Change-Id: I1a01555d98864bd13695524e0cb5adff9b49b754
2017-07-20 03:36:25 +00:00
Keun-young Park
44dce1fed7 Merge "init: Do full shutdown even for thermal shutdown" am: d5b36f38ef am: a064892e1a
am: 614ccd7a02

Change-Id: Id714910ec5bdf4b94bfeee238484f4d47a9bdf01
2017-07-20 03:33:42 +00:00
Keun-young Park
614ccd7a02 Merge "init: Do full shutdown even for thermal shutdown" am: d5b36f38ef
am: a064892e1a

Change-Id: Ia6ddd5a680caa8283cf9d2a75c1eb49e1c79e413
2017-07-20 03:30:39 +00:00
Keun-young Park
a064892e1a Merge "init: Do full shutdown even for thermal shutdown"
am: d5b36f38ef

Change-Id: If0bcd287d2656279a1d364761b0145ca4464299b
2017-07-20 03:27:38 +00:00
Treehugger Robot
d5b36f38ef Merge "init: Do full shutdown even for thermal shutdown" 2017-07-20 03:21:41 +00:00
Tom Cherry
1bd7187f32 Merge "ueventd: fixup ueventd_test.cpp" am: 9aaf66b61f am: 34d4d57b87 am: 5d256bc555
am: 5b1202976e

Change-Id: Icf00ff2e4f9a949900ab6b71bba89c3815c4b5d2
2017-07-20 01:26:25 +00:00
Tom Cherry
5b1202976e Merge "ueventd: fixup ueventd_test.cpp" am: 9aaf66b61f am: 34d4d57b87
am: 5d256bc555

Change-Id: I430e26f820653edfe35ededffa853dcf5e1324ad
2017-07-20 01:20:30 +00:00
Tom Cherry
5d256bc555 Merge "ueventd: fixup ueventd_test.cpp" am: 9aaf66b61f
am: 34d4d57b87

Change-Id: I7468e871785ea74e6cd5b070bd6f18153f6304a7
2017-07-20 01:17:31 +00:00
Tom Cherry
34d4d57b87 Merge "ueventd: fixup ueventd_test.cpp"
am: 9aaf66b61f

Change-Id: I7792c9ec68b6011e0186af2d40ca07d0801a4c2f
2017-07-20 01:15:00 +00:00
Tom Cherry
9aaf66b61f Merge "ueventd: fixup ueventd_test.cpp" 2017-07-20 01:05:28 +00:00
Keun-young Park
30173874fc init: Do full shutdown even for thermal shutdown
- Skipping SIGTERM / SIGKILL / umount brings race between block
  device driver and fs layer. Do umount before shutting down.
- Reduce timeout to 1 sec for thermal shutdown and skip other time
  taking part like fsck.
- Refactor waiting part to check time in ms so that 1 sec can
  have enough resolution.

bug: 63686426
Test: adb shell setprop sys.powerctl thermal-shutdown, adb shell setprop sys.powerctl reboot and check dmesg
Change-Id: I048bac767b328c8d656a97fe65dde5f2b5bf4ae5
2017-07-19 17:27:05 -07:00
Keun-young Park
d4f4a3fcf9 Merge "dump stack before kill all" am: c13a2da2f4 am: 4e24aa2bc3 am: 2b33d96db1
am: f0a13c35f2

Change-Id: Id42c59a6488a9405c8f3301585d2b8cb18192197
2017-07-19 22:32:50 +00:00
Keun-young Park
f0a13c35f2 Merge "dump stack before kill all" am: c13a2da2f4 am: 4e24aa2bc3
am: 2b33d96db1

Change-Id: Ic9c86ce7ddf8591a9fb2d3b1cdf72057c21d4111
2017-07-19 22:29:51 +00:00
Tom Cherry
2ef572be30 ueventd: fixup ueventd_test.cpp
Use ASSERT_EQ() instead of EXPECT_EQ() to prevent segfaults after
failed API calls.

Do not run setfscreatecon_IsPerThread unless we're in permissive mode
as it will not pass otherwise.

Test: init unit tests
Change-Id: I70525d438e89f1ec036255890169a50b5007b4c4
2017-07-19 15:29:20 -07:00
Keun-young Park
2b33d96db1 Merge "dump stack before kill all" am: c13a2da2f4
am: 4e24aa2bc3

Change-Id: If924fe081a81c2061ed06e741fc5e6984e24b1f9
2017-07-19 22:26:22 +00:00
Keun-young Park
4e24aa2bc3 Merge "dump stack before kill all"
am: c13a2da2f4

Change-Id: Ie09fd8a7e95686c41d2a7af9e9e291f89c673036
2017-07-19 22:23:48 +00:00
Keun-young Park
c13a2da2f4 Merge "dump stack before kill all" 2017-07-19 22:17:06 +00:00
Keun-young Park
c59b822d1f dump stack before kill all
- If problematic process is from user, kill all kills
  it and dump does not show problematic process.

bug: 37737296
Test: reboot and check log
Change-Id: Iaa4f7d12f5a40fa7528c6672567c36e30b140372
2017-07-18 18:52:25 -07:00
Robert Benea
9865760d3d Merge "Add memcg related configs to init." am: b84666cbc0 am: 7564622f88 am: 5cf308bcde
am: eab1c14aba

Change-Id: I357cef77e7e48fdda55d55dbaeac531e0974a434
2017-07-19 01:22:40 +00:00
Robert Benea
eab1c14aba Merge "Add memcg related configs to init." am: b84666cbc0 am: 7564622f88
am: 5cf308bcde

Change-Id: Ic86a3200b5080438ad6cb33f9bc3f6ff2ecca22b
2017-07-19 01:12:40 +00:00
Robert Benea
5cf308bcde Merge "Add memcg related configs to init." am: b84666cbc0
am: 7564622f88

Change-Id: Ia9f5b5d524eb437598e9d453ca05e35d52445cc1
2017-07-19 01:03:32 +00:00
Robert Benea
7564622f88 Merge "Add memcg related configs to init."
am: b84666cbc0

Change-Id: I437c5d05582c6a3cce632f92835ee91f419a7190
2017-07-19 01:01:27 +00:00
Robert Benea
b84666cbc0 Merge "Add memcg related configs to init." 2017-07-19 00:54:41 +00:00
Quang Luong
559674dbe3 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" am: a022ea424d am: c1e78e1331 am: be2a262b47
am: 6bcf4fb8b5

Change-Id: I1b6656bc4ec0dbebccb4fe92c6f73f9be6965353
2017-07-18 23:24:51 +00:00
Robert Benea
d485226951 Add memcg related configs to init.
Allow configuring memory.swappiness, memory.soft_limit_in_bytes
and memory.limit_in_bytes by init; by doing so there is better
control of memory consumption per native app.

Test: tested on gobo branch.
bug: 63765067
Change-Id: I8906f3ff5ef77f75a0f4cdfbf9d424a579ed52bb
2017-07-18 15:58:40 -07:00
Quang Luong
6bcf4fb8b5 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" am: a022ea424d am: c1e78e1331
am: be2a262b47

Change-Id: I223ebf56a8bbefb38735ebbcfe45c7d2a78cd50c
2017-07-18 22:39:00 +00:00
Quang Luong
be2a262b47 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" am: a022ea424d
am: c1e78e1331

Change-Id: I81d4f619f38a6f511562d98fe7a0dd64c7290f81
2017-07-18 21:26:19 +00:00
Quang Luong
c1e78e1331 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp"
am: a022ea424d

Change-Id: Ie4b2131525373fef14dfa2c7a7ec1e23a50dc56a
2017-07-18 21:20:26 +00:00
Treehugger Robot
a022ea424d Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" 2017-07-18 21:16:30 +00:00
Quang Luong
dd6a85ccd5 uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp
Modified Android.mk to define cflag "USER_MODE_LINUX" if
TARGET_USER_MODE_LINUX := true in BoardCofig.mk.
Modified set_mmap_rnd_bits_action to return 0 if "USER_MODE_LINUX" is
defined. This is needed since uml does not support the mmap_rnd_bits
sysctl, and init would otherwise crash without this check.

Test: manual

Bug: 32523022
Change-Id: I409ef64a1fa253bfb3f9fb59d0267be159819bb8
Signed-off-by: Quang Luong <qal@google.com>
2017-07-18 18:18:31 +00:00
Keun-young Park
29017c10c8 Merge "Do not umount /vendor, /system, and /oem even if they are R/W." am: 11649e8925 am: c9f601a178 am: 10b74ed2a6
am: ab54410f0d

Change-Id: Ic0d033d955e2612157dc63922ee85d4722bc9fa6
2017-07-18 03:21:07 +00:00
Keun-young Park
ab54410f0d Merge "Do not umount /vendor, /system, and /oem even if they are R/W." am: 11649e8925 am: c9f601a178
am: 10b74ed2a6

Change-Id: Ie0339f41eb166e156ab61133e6a2c19e4bbd28a2
2017-07-18 03:18:07 +00:00
Keun-young Park
10b74ed2a6 Merge "Do not umount /vendor, /system, and /oem even if they are R/W." am: 11649e8925
am: c9f601a178

Change-Id: Ia5f3096e339ed8d088482c5c11ed5e5b906e9205
2017-07-18 03:15:36 +00:00
Keun-young Park
c9f601a178 Merge "Do not umount /vendor, /system, and /oem even if they are R/W."
am: 11649e8925

Change-Id: I1b4db022ca316648dfccfa12c3f8e886e6b15b08
2017-07-18 03:12:37 +00:00
Keun-young Park
6e12b3887e Do not umount /vendor, /system, and /oem even if they are R/W.
- /vendor, /system, /oem can be remounted to R/W for development
  purpose.

- In such case, umounting these partitions can lead into some processes
  not running properly during shutdown or blocking umount of fs.

- So skip them. As it is dev feature, it is up to each developer to
  understand the risk. But for normal adb sync - reboot should be ok
  as shutdown involves sync operations.

bug: 37737296
Test: adb remount,reboot, and check last kmsg
Change-Id: Iab6a6374bc558375d359b3b49b14db93d363b1ad
2017-07-17 17:32:26 -07:00
Tom Cherry
bbd8b8b534 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads" am: 0ba56096d5 am: 730a5ddf27 am: 92b34b76b5
am: 643307dbd0

Change-Id: Ibd08ed409511c9f32b41981a7a653459dd50f72c
2017-07-17 20:04:37 +00:00
Tom Cherry
643307dbd0 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads" am: 0ba56096d5 am: 730a5ddf27
am: 92b34b76b5

Change-Id: I07b8b06af95c0c0bf8889dce0f256bb901264bcc
2017-07-17 20:01:06 +00:00
Tom Cherry
92b34b76b5 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads" am: 0ba56096d5
am: 730a5ddf27

Change-Id: I8da0974f3a8a42e2bdfb4f97af9ddc44b7483beb
2017-07-17 19:58:37 +00:00
Tom Cherry
730a5ddf27 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads"
am: 0ba56096d5

Change-Id: Ib1619e4c52402710de09e971a1e96fd7caf0f75a
2017-07-17 19:56:06 +00:00
Tom Cherry
c2e181cf1d ueventd: add tests for setegid()/setfscreatecon() and threads
setegid() and setfscreatecon() on Android both operate on a per-thread
basis, not a per-process basis.

Ueventd may take advantage of this in the future, so this CL
introduces tests that ensure that this functionality remains
consistent.

Bug: 63441941
Test: newly added unit tests
Change-Id: I8b1c62cc322b6fe44b748550a4cea8658d9efd88
2017-07-17 11:08:41 -07:00
Tom Cherry
d7ca913892 Merge "Move Timer from init to libbase" am: 896297b2ef am: 7ff0b008f7 am: 4e5c4f18d8
am: c0a9cf648b

Change-Id: Idb80a901f4c0080b932b6da247150ed4ffdb6b8e
2017-07-10 18:40:54 +00:00
Tom Cherry
c0a9cf648b Merge "Move Timer from init to libbase" am: 896297b2ef am: 7ff0b008f7
am: 4e5c4f18d8

Change-Id: Iffad0dcde94fce7dac627ebf0530420f9cfd38d1
2017-07-10 18:36:54 +00:00
Tom Cherry
4e5c4f18d8 Merge "Move Timer from init to libbase" am: 896297b2ef
am: 7ff0b008f7

Change-Id: I3d1dd6eabbf17d701eefbf7363bfe6107d4de8a4
2017-07-10 18:32:54 +00:00
Tom Cherry
7ff0b008f7 Merge "Move Timer from init to libbase"
am: 896297b2ef

Change-Id: I1990fa013fa1fe69a61711faf032db45216f6f47
2017-07-10 18:28:25 +00:00
Tom Cherry
ede0d53850 Move Timer from init to libbase
Test: boot bullhead
Test: new libbase unit tests

Change-Id: Ic398a1daa1fe92c10ea7bc1e6ac3f781cee9a5b5
2017-07-10 09:28:24 -07:00
Jin Qian
e6dfd45f00 init: require e2fsdroid and mke2fs when building init am: 041f849548
am: f361c2560c

Change-Id: Ic85298e7340a6e61aeab5cfeadaf4cb7a24ade1f
2017-07-06 21:13:13 +00:00
Jin Qian
f361c2560c init: require e2fsdroid and mke2fs when building init
am: 041f849548

Change-Id: Icf49587d20a210cdcf130aacc25ecbcbfd31f06c
2017-07-06 20:55:36 +00:00
Jin Qian
041f849548 init: require e2fsdroid and mke2fs when building init
init calls fs_mgr to format ext4 partitions. This requires
e2fsdroid and mke2fs in /system/bin/

Bug: 35219933
Change-Id: Ia32fe438cd9b9332f8e18e0cbe7f61bd050adcb1
2017-07-06 11:45:06 -07:00
Keun-young Park
3b15f44041 Merge "add "shutdown critical" to service" into oc-dr1-dev 2017-07-06 17:14:23 +00:00
Tom Cherry
c680bfeaf2 init: add info logs in first stage mount if we have to poll
It's not a error case if we do not find a device that we're attempting
to regenerate uevents for during first stage mount, but it is likely
to increase boot time, so we log a message to attribute this delay.

Bug: 63327193
Test: Boot bullhead, sailfish

Merged-In: I97c2e5aefd218bbdd87717ff3c375381f725de08
Change-Id: I97c2e5aefd218bbdd87717ff3c375381f725de08
(cherry picked from commit 322e176f6a)
2017-07-06 13:04:23 +08:00
Tom Cherry
e0d1699487 Merge "init: add info logs in first stage mount if we have to poll" am: 6a9d56775f am: 11d5611ba5 am: 7b600f8012
am: 71ed340d1e

Change-Id: I722d6d71a9505d2b579a4bb9484221b73d71d50b
2017-07-06 04:55:40 +00:00
Tom Cherry
71ed340d1e Merge "init: add info logs in first stage mount if we have to poll" am: 6a9d56775f am: 11d5611ba5
am: 7b600f8012

Change-Id: I4abc2b23c0b86059d44965b0139256f7617f48dd
2017-07-06 04:53:38 +00:00
Tom Cherry
7b600f8012 Merge "init: add info logs in first stage mount if we have to poll" am: 6a9d56775f
am: 11d5611ba5

Change-Id: Ib08ea62f6fb13cfaed6bc894bcbc548ccd8c3d55
2017-07-06 04:51:08 +00:00
Tom Cherry
11d5611ba5 Merge "init: add info logs in first stage mount if we have to poll"
am: 6a9d56775f

Change-Id: I7948db4cf1d6af6f4e6d0ddb2a2788f62317126f
2017-07-06 04:48:38 +00:00
Treehugger Robot
6a9d56775f Merge "init: add info logs in first stage mount if we have to poll" 2017-07-06 04:46:05 +00:00
Tom Cherry
1b5db82fd9 Merge "ueventd: don't double fork firmware handlers" am: 0f4fb5497a am: e944b7e0a4 am: 1eee2122ca
am: 7c4b63be8c

Change-Id: I39c17229dd4043da3ed5824b7a13b2d2e8cede4a
2017-07-06 02:53:11 +00:00
Tom Cherry
7c4b63be8c Merge "ueventd: don't double fork firmware handlers" am: 0f4fb5497a am: e944b7e0a4
am: 1eee2122ca

Change-Id: I726a412b0b01c4f829847b8ebdef97be4df5abef
2017-07-06 02:33:52 +00:00
Tom Cherry
1eee2122ca Merge "ueventd: don't double fork firmware handlers" am: 0f4fb5497a
am: e944b7e0a4

Change-Id: Ifc8c586aa3b06ecb42bf20284c461b4b7c159bc7
2017-07-06 02:21:26 +00:00
Tom Cherry
e944b7e0a4 Merge "ueventd: don't double fork firmware handlers"
am: 0f4fb5497a

Change-Id: I2a40b76e937853fd2f1eed61cc0fe4f6fa465ba2
2017-07-06 02:10:57 +00:00