Commit Graph

2191 Commits

Author SHA1 Message Date
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
Tom Cherry 0f4fb5497a Merge "ueventd: don't double fork firmware handlers" 2017-07-06 02:02:33 +00:00
Keun-young Park f5b616dabf Merge "add "shutdown critical" to service" am: b3915d113d am: a4ad5d0328 am: 19ec8e7bcf
am: bedc5faea7

Change-Id: I62cd1bc82531b88f5d8c8ac2dd637d5ec9d52572
2017-07-06 01:38:15 +00:00
Keun-young Park bedc5faea7 Merge "add "shutdown critical" to service" am: b3915d113d am: a4ad5d0328
am: 19ec8e7bcf

Change-Id: Ide84d7f87a9884068ebc1cc9680c997507727af3
2017-07-06 01:13:19 +00:00
Keun-young Park 19ec8e7bcf Merge "add "shutdown critical" to service" am: b3915d113d
am: a4ad5d0328

Change-Id: I6467657616371e84468975e56ac086855a298efb
2017-07-06 00:56:18 +00:00
Keun-young Park d266d37e4c add "shutdown critical" to service
- "shutdown critical" prevents killing the service during
  shutdown. And the service will be started if not running.
- Without it, services will be killed by SIGTERM / SIGKILL during shutdown.
- Even services with "shutdown critical" will be killed if shutdown
  times out.
- Removes ueventd and vold from hard coded list. Each service's rc will
  be updated to add "shutdown critical". watchdogd is still kept in the list.

bug: 37626581
Test: reboot and check last kmsg

(cherry picked from commit cccb34fce8)

Change-Id: I3c6aeb7151e64beca4b435f843ae64455217262d
2017-07-06 00:54:02 +00:00
Keun-young Park a4ad5d0328 Merge "add "shutdown critical" to service"
am: b3915d113d

Change-Id: I25b6f42478efda7077e00141042a427245393d28
2017-07-06 00:46:31 +00:00
Treehugger Robot b3915d113d Merge "add "shutdown critical" to service" 2017-07-06 00:40:55 +00:00
Wei Wang a89b61ad99 Merge "init: Support custom shutdown actions" am: c1bc4241f8 am: 5b89535442 am: b39890048c
am: 2a38e6d119

Change-Id: I6776039ebf9f87b41193cc24a9786dc80db99e43
2017-07-06 00:22:45 +00:00
Tom Cherry 38728d6ca8 Merge "Merge "ueventd: remove character device symlinks (/dev/usb/*)" am: f3ae82f57f am: 6e0b51825b am: bef2bbdf62" into oc-dr1-dev-plus-aosp
am: 93e81d4775

Change-Id: Ie1cdea248765cf8a3ab96deb59d27016a181b1f6
2017-07-06 00:21:01 +00:00
Tom Cherry 2afdb6d526 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35 am: 0924b32c1f am: 419a9ef8f1
am: fc479afbb6

Change-Id: Id45511f512fce014de32cc4d642df4cdcf5634c3
2017-07-06 00:20:08 +00:00
Wei Wang 2a38e6d119 Merge "init: Support custom shutdown actions" am: c1bc4241f8 am: 5b89535442
am: b39890048c

Change-Id: I57a0422f47094cc061163510138e9562648fdd98
2017-07-05 23:58:51 +00:00
Wei Wang b39890048c Merge "init: Support custom shutdown actions" am: c1bc4241f8
am: 5b89535442

Change-Id: I57b87dac016b4d7d6f982ee0057823eb1119bab7
2017-07-05 23:56:50 +00:00
Wei Wang 5b89535442 Merge "init: Support custom shutdown actions"
am: c1bc4241f8

Change-Id: I6bb1789dbc5edbb10f2f4d712e9ca83e6302fdf4
2017-07-05 23:54:56 +00:00
Treehugger Robot c1bc4241f8 Merge "init: Support custom shutdown actions" 2017-07-05 23:49:41 +00:00
Tom Cherry 0f296e06d6 ueventd: don't double fork firmware handlers
ueventd may be asked to handle firmware during the time critical
coldboot process.  If we double fork to avoid needing to reap the
firmware handler, then we may add significant delay to this process,
as the first child may not get scheduled quickly enough for waitpid()
to complete without delay.

Bug: 63081260
Test: boot bullhead and sailfish, check that firmwares are loaded,
      no zombie ueventd processes remain, and no new errors are shown
Change-Id: I2bac3b1fbc3a58557a00326e491c104656db27ae
2017-07-05 16:41:11 -07:00
Tom Cherry 07999f8677 Merge "ueventd: remove character device symlinks (/dev/usb/*)" am: f3ae82f57f am: 6e0b51825b
am: bef2bbdf62

Change-Id: Ice5ec0702cbdae53d7a78bceb7a24e923a488319
2017-07-05 23:37:46 +00:00
Tom Cherry fc479afbb6 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35 am: 0924b32c1f
am: 419a9ef8f1

Change-Id: I0f2e6b2b2dfed4dab480acf2562df78da8d2f65e
2017-07-05 23:37:21 +00:00
Tom Cherry bef2bbdf62 Merge "ueventd: remove character device symlinks (/dev/usb/*)" am: f3ae82f57f
am: 6e0b51825b

Change-Id: Ic31e720cd9014de76f0fd999af44ce3c3ffcd482
2017-07-05 23:01:53 +00:00
Tom Cherry 419a9ef8f1 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35
am: 0924b32c1f

Change-Id: I18a3c9a9a96a2488c7714113175f3e8115bd697f
2017-07-05 23:01:35 +00:00
Tom Cherry 6e0b51825b Merge "ueventd: remove character device symlinks (/dev/usb/*)"
am: f3ae82f57f

Change-Id: Ib601af84ed3b186705caaed05706d6b1f3c5746c
2017-07-05 22:50:35 +00:00
Tom Cherry 0924b32c1f Merge "init: reap zombies only after kill(-pid, ...)"
am: a51c40ce35

Change-Id: I4f1b7a05cdff1fe7851b528d0bdeda354011b599
2017-07-05 22:50:17 +00:00
Tom Cherry f3ae82f57f Merge "ueventd: remove character device symlinks (/dev/usb/*)" 2017-07-05 22:41:55 +00:00
Jin Qian 3ca00a3c98 Merge "init: rename mke2fs tools with _static suffix" into oc-dr1-dev
am: 5c5c544e80

Change-Id: Ifee5b6516fe3aee03df845a46421753295cbc740
2017-07-05 22:40:42 +00:00
Tom Cherry a51c40ce35 Merge "init: reap zombies only after kill(-pid, ...)" 2017-07-05 22:39:51 +00:00
TreeHugger Robot 5c5c544e80 Merge "init: rename mke2fs tools with _static suffix" into oc-dr1-dev 2017-07-05 22:33:35 +00:00
Keun-young Park cccb34fce8 add "shutdown critical" to service
- "shutdown critical" prevents killing the service during
  shutdown. And the service will be started if not running.
- Without it, services will be killed by SIGTERM / SIGKILL during shutdown.
- Even services with "shutdown critical" will be killed if shutdown
  times out.
- Removes ueventd and vold from hard coded list. Each service's rc will
  be updated to add "shutdown critical". watchdogd is still kept in the list.

bug: 37626581
Test: reboot and check last kmsg

Change-Id: Ie8cc699d1efbc59b9a2561bdd40fec64aed5a4bb
2017-07-05 14:55:22 -07:00
Wei Wang eeab491efd init: Support custom shutdown actions
We have been seeing panics and errors during shutdown sequence in
some vendor's platform, and it is required to disable error handling
during shutdown.

This CL separates the shutdown request to execute another "shutdown"
trigger at the beginning of shutdown stage. And vendor can use this
trigger to add custom commands needed for shutting down gracefully.

Bug: 38203024
Bug: 62084631
Test: device reboot/shutdown
Change-Id: I3fac4ed59f06667d86e477ee55ed391cf113717f
2017-07-05 14:49:57 -07:00
Tom Cherry 322e176f6a 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

Change-Id: I97c2e5aefd218bbdd87717ff3c375381f725de08
2017-07-05 14:05:03 -07:00
Nick Kralevich 1d4647b4ce Merge "Remove unnecessary SELinux dependencies" am: 22de50d351 am: e9b9b10c58 am: 0056e6bccc
am: 4192d74a83

Change-Id: I6d1cfcbfa98881fb24a516646f030d451fa357ee
2017-07-01 16:54:36 +00:00
Nick Kralevich 4192d74a83 Merge "Remove unnecessary SELinux dependencies" am: 22de50d351 am: e9b9b10c58
am: 0056e6bccc

Change-Id: Id160e23a6bd53238ad279bb5b28e7ca8a08c0805
2017-07-01 16:49:35 +00:00
Nick Kralevich 0056e6bccc Merge "Remove unnecessary SELinux dependencies" am: 22de50d351
am: e9b9b10c58

Change-Id: Ifead418ceb9fe806d76102d9068a32539a8b99d0
2017-07-01 16:44:36 +00:00
Nick Kralevich e9b9b10c58 Merge "Remove unnecessary SELinux dependencies"
am: 22de50d351

Change-Id: Icbd6b0df4378980eb2a7878bab1896f6ecefb6a8
2017-07-01 16:39:37 +00:00
Nick Kralevich 33391dad15 Remove unnecessary SELinux dependencies
These are unused.

Test: code compiles.
Change-Id: Idd707dfcc8f6daac3a489c791ecc364841cf31f9
2017-07-01 07:41:48 -07:00
Luis Hector Chavez 9ba4038c79 Merge "init: Read previous state of securebits before modifying" am: c10e14110a am: 19f32317b3 am: 9dabbbaa6a
am: dd79958ecb

Change-Id: Ic053669c2e3c576a27b1ee4748c635c338068105
2017-07-01 00:45:12 +00:00
Luis Hector Chavez dd79958ecb Merge "init: Read previous state of securebits before modifying" am: c10e14110a am: 19f32317b3
am: 9dabbbaa6a

Change-Id: Id5cdc260c7f6800e493c0f3b4e0da08ddca34b63
2017-07-01 00:39:42 +00:00
Luis Hector Chavez 9dabbbaa6a Merge "init: Read previous state of securebits before modifying" am: c10e14110a
am: 19f32317b3

Change-Id: I87084032373a71b507ed0604c7ff38ec076fc74a
2017-07-01 00:35:11 +00:00
Luis Hector Chavez 19f32317b3 Merge "init: Read previous state of securebits before modifying"
am: c10e14110a

Change-Id: I0a9b2dc97ebbc449288de2ce3e2745a1f60a4372
2017-07-01 00:30:42 +00:00
Luis Hector Chavez f5965519d1 init: Read previous state of securebits before modifying
When Android is running in a container, some of the securebits might be
locked, which makes prctl(PR_SET_SECUREBITS) fail.

This change gets the previous state of the process' securebits and adds
the desired bits.

Bug: 62388055
Test: aosp_bullhead-eng boots
Test: If init has non-zero securebits, it can also boot
Change-Id: Ie03bf2538f9dca40955bc58314d269246f5731bd
2017-06-30 14:42:46 -07:00
Tom Cherry 8d13d808a5 init: reap zombies only after kill(-pid, ...)
When init gets SIGCHLD, it uses waitpid() to get the pid of an exited
process.  It then calls kill(-pid, ...) to ensure that all processes
in the process group started by that process are killed as well.

There is a bug here however as waitpid() reaps the pid when it
returns, meaning that the call to kill(-pid, ...) may fail with ESRCH
as there are no remaining references to that pid.  Or worse, if the
pid is reused, the wrong processes may get the signal.

This fixes the bug by using waitid() with WNOWAIT to get the pid of an
exited process, which does not reap the pid.  It then uses waitpid()
with the returned pid to do the reap only after the above kill(-pid,
...) and other operations have completed.

Bug: 38164998
Test: kill surfaceflinger and see that processes exit and are reaped
      appropriately
Test: `adb reboot` and observe that the extraneous kill() failed
      messages do not appear

Change-Id: Ic0213e1c97e0141e6c13129dc2abbfed86de138b
2017-06-30 13:52:48 -07:00
Luis Hector Chavez ea8ac69141 Merge changes I0a95f87a,I36b22986 am: a703202093 am: 835d259e7a am: 40e88b22f2
am: 1b42dbf22c

Change-Id: Icf60412199db65e686c2f3b38087d0fc66cad7f6
2017-06-30 04:38:03 +00:00
Luis Hector Chavez 1b42dbf22c Merge changes I0a95f87a,I36b22986 am: a703202093 am: 835d259e7a
am: 40e88b22f2

Change-Id: I04e3d91d34d2c50d15ab2357db175b1f69796af1
2017-06-30 04:33:30 +00:00
Luis Hector Chavez 40e88b22f2 Merge changes I0a95f87a,I36b22986 am: a703202093
am: 835d259e7a

Change-Id: I329bddc9b470da86d07bde3ce3ab8a69c37a38e2
2017-06-30 04:29:28 +00:00
Luis Hector Chavez 835d259e7a Merge changes I0a95f87a,I36b22986
am: a703202093

Change-Id: Id0ab2a68ade41db6c1327d9b96489bf0f9a223cb
2017-06-30 04:24:32 +00:00
Luis Hector Chavez 7bb360230d init: Use ScopedCaps for cap_init()
This change homogenizes the use of std::unique_ptr for storing
capabilities in system/core/.

Bug: None
Test: m
Change-Id: I0a95f87a27b0261e9d321841d5140fc000473293
2017-06-29 14:41:23 -07:00
Luis Hector Chavez 519e5f0592 init: Reland "Terminate gracefully when CAP_SYS_BOOT is absent"
This change makes it possible for Android running in a container to
terminate cleanly instead of calling abort() when requested to shut
down.

Bug: 62388055
Test: `adb reboot` on bullhead causes no kernel panics
Test: `adb reboot` on a system without CAP_SYS_BOOT makes init terminate
       nicely

Change-Id: I36b2298610f5b4a2bf8b05103d04804883df2c88
2017-06-29 14:41:23 -07:00
Hung-ying Tyan 0c6a19657d Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev am: d334d69b70
am: 42388236a4

Change-Id: Ie8d1f695eac185e1be21073ecd3e40c0e8212d13
2017-06-28 06:34:43 +00:00
Hung-ying Tyan 42388236a4 Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev
am: d334d69b70

Change-Id: I358c9b60bf20d7852d81006bb37a9efab0dd19ad
2017-06-28 06:31:08 +00:00
TreeHugger Robot d334d69b70 Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev 2017-06-28 06:28:09 +00:00
Guang Zhu 806f2ed9be Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"" am: b5b4136ac4 am: aa447d7aa5 am: 3734cd3442
am: 387f28c18a

Change-Id: Id00c27b2d10743e0a19a6bfb8da85aa2e2c3f622
2017-06-28 02:33:21 +00:00
Guang Zhu 387f28c18a Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"" am: b5b4136ac4 am: aa447d7aa5
am: 3734cd3442

Change-Id: I5dc1e8c2ad06b162e3971aa2385dc7c00d5a37d0
2017-06-28 02:29:19 +00:00
Guang Zhu aa447d7aa5 Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent""
am: b5b4136ac4

Change-Id: Icd0a76aeb770cec04c029d30114bb3cf645a850c
2017-06-28 02:22:49 +00:00
Guang Zhu c22f93856f Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"
Bug: 63080844

This reverts commit 683ebc8059.

Change-Id: I6074ff09300fd30bfc66881ded1c4f868a845a91
2017-06-28 02:10:33 +00:00
Luis Hector Chavez 0333dedbc0 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent" am: fbb482f499 am: ec8a5f2aa6 am: 6d815a554d
am: e955adacb7

Change-Id: Ieb254ee9aaf629935fc9207ea14b086f7a8edbe5
2017-06-27 23:12:40 +00:00
Luis Hector Chavez e955adacb7 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent" am: fbb482f499 am: ec8a5f2aa6
am: 6d815a554d

Change-Id: I1ca1bb153b3e3725f695107d56cc36a54a0379f1
2017-06-27 23:07:18 +00:00
Luis Hector Chavez ec8a5f2aa6 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent"
am: fbb482f499

Change-Id: I7cff66250e7f5d0b9d55feb2ddb6d74608aa4dd9
2017-06-27 23:01:19 +00:00
Luis Hector Chavez 683ebc8059 init: Terminate gracefully when CAP_SYS_BOOT is absent
This change makes it possible for Android running in a container to
terminate cleanly instead of calling abort() when requested to shut
down.

Bug: 62388055
Test: setprop sys.powerctl reboot makes init terminate nicely

Change-Id: I31c7b475d89d7cbd665e135d9b8951dfd4bca80d
2017-06-27 13:51:46 -07:00