Commit graph

1531 commits

Author SHA1 Message Date
Tom Cherry
07ea1a8833 Merge "init: fix last_reboot_reason string" am: 59c74a3bd1 am: 2be5884903
am: 8705f89826

Change-Id: Idaf8218594f50b860fdd9e5d12b8e6f7a4fe0e68
2017-04-27 20:29:32 +00:00
Treehugger Robot
59c74a3bd1 Merge "init: fix last_reboot_reason string" 2017-04-27 19:39:53 +00:00
Keun-young Park
6c61e087e4 Merge "set default shutdown timeout to 6 secs" am: 47d15ed5b9 am: 0020d4c076
am: 09c780db3a

Change-Id: I38ec920f5034b2adc9ab8354144cae1fe554d753
2017-04-26 22:49:02 +00:00
Keun-young Park
47d15ed5b9 Merge "set default shutdown timeout to 6 secs" 2017-04-26 22:35:26 +00:00
Keun-young Park
b549370bf3 Merge "do not start shutdown animation from init" am: 84d43c8df7 am: 76a3b3ce5c
am: a15436569f

Change-Id: I5fea05ff1c4d5cfb2d50b9aab7805d229c43d89b
2017-04-26 21:27:01 +00:00
Keun-young Park
5b1300c154 Merge "add additional dump for timeout" am: 8cde09064e am: fadad58262
am: 606df0e2cb

Change-Id: I386ee368f2fd08575b69cc776ea2ccee55bdd225
2017-04-26 21:26:43 +00:00
Treehugger Robot
84d43c8df7 Merge "do not start shutdown animation from init" 2017-04-26 20:59:56 +00:00
Keun-young Park
7feab68238 set default shutdown timeout to 6 secs
- Test data shows that most shutdown finishes in 6 secs.
- The original 10 secs is too long wih no shutdown animation
  running in screen.

bug: 36657139
Test: check time with reboot
Change-Id: I9a805ddfde8156b066485902048d0cd01365c453
2017-04-26 13:58:31 -07:00
Keun-young Park
8cde09064e Merge "add additional dump for timeout" 2017-04-26 20:53:21 +00:00
Tom Cherry
a52ce58d2e Merge changes Ibe91fd2d,I59e2bd9e am: b0a14f8feb am: 4ba72d9b73
am: 9ef76bdc72

Change-Id: I49823a29c3f9aaee75ca1d6d2bd092ed2cddd3f4
2017-04-26 19:59:49 +00:00
Treehugger Robot
b0a14f8feb Merge changes Ibe91fd2d,I59e2bd9e
* changes:
  init: remove 'computing context for service'... message
  init: use full command for exec services' names
2017-04-26 19:46:04 +00:00
Keun-young Park
1663e97fe1 add additional dump for timeout
- add sysrq-trigger current tasks dump
- This helps detecting kernel thread stuck in a specific driver

bug: 37573746
Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 2000 -f -e 15 -w 30  -v -a

Change-Id: Icb20b5fba63d601bb937f004f5889a9bc8340b34
2017-04-26 10:16:23 -07:00
Tom Cherry
47336cebc3 init: fix last_reboot_reason string
This got moved when refactoring the reboot commands.

Bug: 37540660
Test: verify bullhead's last_reboot_reason is correct
Change-Id: I3b86496fc469ca41645df7e7ba8bb51dd25b6b38
2017-04-26 16:17:08 +00:00
Tom Cherry
6f7ef2fb34 init: remove 'computing context for service'... message
This line shows up immediately before starting a service for each
service without a 'seclabel' option, essentially becoming log spam.

We already log if we fail to compute the context as well.

Test: Boot bullhead

Change-Id: Ibe91fd2dd9f53a8ae2ca95ccea1636ecef2af224
2017-04-25 17:46:13 -07:00
Tom Cherry
86e31a8123 init: use full command for exec services' names
Before:
init: starting service 'exec 4 (/system/bin/vdc)'...
init: starting service 'exec 5 (/system/bin/tzdatacheck)'...
init: starting service 'exec 6 (/system/bin/bootstat)'...
init: starting service 'exec 7 (/system/bin/bootstat)'...

After:
init: starting service 'exec 4 (/system/bin/vdc --wait cryptfs mountdefaultencrypted)'...
init: starting service 'exec 5 (/system/bin/tzdatacheck /system/usr/share/zoneinfo /data/misc/zoneinfo)'...
init: starting service 'exec 6 (/system/bin/bootstat -r post_decrypt_time_elapsed)'...
init: starting service 'exec 7 (/system/bin/bootstat --record_boot_complete)'...

Test: Boot bullhead, observe above logging change
Change-Id: I59e2bd9e3d341bbed9537c972e47246d0a12769d
2017-04-25 17:35:46 -07:00
Bowgo Tsai
eac5c8859d Merge "init: fix first stage mount failure when two fstab entries have verity_loc" am: 8df35dcb1c am: 8954cd9379
am: 225177279a

Change-Id: I7bc19c9b430d23282e824797ddc3652a1efea383
2017-04-26 00:19:58 +00:00
Treehugger Robot
8df35dcb1c Merge "init: fix first stage mount failure when two fstab entries have verity_loc" 2017-04-26 00:06:47 +00:00
Tom Cherry
e8b8045f96 Merge "init: rename 'Trigger' to 'Event' and convert to std::variant" am: d9ebf06117 am: d45b6f44d5
am: f9557f175c

Change-Id: Ie900559a7b7d1b70aac2b9e52b1a06727348eae8
2017-04-25 21:59:03 +00:00
Tom Cherry
7bd11f7f1b Merge changes I1f70f2c4,I698ca962,Idbbf2682 am: 960ed3ce1b am: 4cd8d5e9f5
am: bfbe459ff1

Change-Id: I90526601990c7d4d3cbd2b8f3a35bf2c4c8a2ef8
2017-04-25 21:58:47 +00:00
Tom Cherry
d9ebf06117 Merge "init: rename 'Trigger' to 'Event' and convert to std::variant" 2017-04-25 21:44:19 +00:00
Tom Cherry
960ed3ce1b Merge changes I1f70f2c4,I698ca962,Idbbf2682
* changes:
  init: remove unused parts of parser.cpp
  ueventd: replace ueventd_parser.cpp with init_parser.cpp
  init: add Parser::AddSingleLineParser()
2017-04-25 21:44:07 +00:00
Tom Cherry
ad6741c6f8 init: remove unused parts of parser.cpp
Now that ueventd is using init's parser, we no longer need anything
other than the tokenizer from parser.cpp.

Test: Boot bullhead
Change-Id: I1f70f2c4479af576174bd74dd919d81817500216
2017-04-25 11:24:33 -07:00
Tom Cherry
fe062055cb ueventd: replace ueventd_parser.cpp with init_parser.cpp
Previously init_parser.cpp was made generic and capable of parsing any
number of differently named 'sections' or prefixed lines.  We now use
these capabilities to do the parsing for ueventd.

Bug: 36250207
Bug: 33785894

Test: boot bullhead and ensure the right /dev nodes exist
      with the right permissions set
Test: verify no boot time difference
Change-Id: I698ca962d414f8135af32f6c9cd778841b2b8b53
2017-04-25 11:24:24 -07:00
Bowgo Tsai
71881fffd6 init: fix first stage mount failure when two fstab entries have verity_loc
The previous check is incorrect because it compares the basename of
previous verity_loc with the full path of current verity_loc.

Changes it to compare the full device file path instead of just the basename
of verity_loc. This can catch the case of two different verity_loc
values with the same basename, e.g.,

  - verify=/dev/block/platform/SOC.0/by-name/metadata
  - verify=/dev/block/platform/SOC.1/by-name/metadata

Bug: 37413399
Bug: 37619597
Test: first stage mount /system and /vendor with the following fs_mgr_flags on bullhead
        - wait,verify=/dev/block/platform/soc.0/f9824900.sdhci/by-name/metadataa
Test: first stage mount /system and /vendor with different verity_loc values
      on bullhead, checks it bails out
Change-Id: I017c8bd9f0790d45e08e57df9a2878e4f62c5f9c
2017-04-26 01:23:19 +08:00
Tom Cherry
35c5bcc89c init: add Parser::AddSingleLineParser()
Add the ability to override the current section being parsed and
instead parse a line by itself if a given line starts with a specific
prefix.

Test: Boot bullhead
Change-Id: Idbbf2682b78996b41d05f3db655c8937a8c6ccda
2017-04-25 10:19:37 -07:00
Tom Cherry
26ed9cb706 init: rename 'Trigger' to 'Event' and convert to std::variant
The term 'trigger' should be used in 'Action' to indicate what causes
the 'Action' to be executed.

The term 'event' should be used in ActionManager's queue to indicate
a state change that is checked against the 'triggers' of an 'Action' to
see if it should execute.

Convert the previous Trigger class to std::variant, as the latter is
better suited for this use.

Change-Id: I2558367c8318b536aa69fcec93793f1c12857ef5
2017-04-25 17:14:23 +00:00
Jaekyun Seok
01d4504a6c Merge "Update persist.sys.usb.config on runtime" am: 41346e553b am: ac945881b3
am: 33e7e21645

Change-Id: I1e5ad9da360bfb3cb4970e12a76522fd0a5126b8
2017-04-25 04:02:35 +00:00
Treehugger Robot
41346e553b Merge "Update persist.sys.usb.config on runtime" 2017-04-25 03:51:17 +00:00
Jaekyun Seok
0cf3a07e14 Update persist.sys.usb.config on runtime
persist.sys.usb.config values can't be combined on build-time when
property files are split into each partition.
So we need to apply the same rule of
build/make/tools/post_process_props.py on runtime.

Test: building succeeded and tested on sailfish.
Bug: 37617113
Bug: 37648659

Change-Id: I78cdffee446d3ae6a89f138faed5f3149e4b507d
2017-04-25 01:31:19 +00:00
Bowgo Tsai
6433e8dca2 Merge "init: set ro.boot.avb_version in recovery mode" am: f1bd536efd am: a1da077454
am: aacfa4f8c2

Change-Id: I6d38d066f4b23bd01e9b3aaf5143563a19d45cbd
2017-04-25 00:41:37 +00:00
Bowgo Tsai
58357f2b7e Merge "init: moving early mount logic into init_first_stage.cpp" am: bcd36a20d4 am: 2d7818a104
am: 47fe14b456

Change-Id: Ie677f3e01fe6a8f0cee96b70d29ab54d5b9cdaa8
2017-04-25 00:41:22 +00:00
Treehugger Robot
f1bd536efd Merge "init: set ro.boot.avb_version in recovery mode" 2017-04-25 00:31:41 +00:00
Treehugger Robot
bcd36a20d4 Merge "init: moving early mount logic into init_first_stage.cpp" 2017-04-25 00:31:27 +00:00
Jeff Vander Stoep
fb62e61ec0 Merge "Sepolicy load: use -N flag to skip neverallow checks" into oc-dev
am: c53ae9ed3e

Change-Id: I4d59716ee79fdc4514d84c771fa6b45693691f50
2017-04-24 22:46:32 +00:00
Jeff Vander Stoep
955e36492e Sepolicy load: use -N flag to skip neverallow checks
Fixes issue where attributes used exclusively in neverallow
rules were removed from policy.

Bug: 37357742
Test: Force on-device compile by removing precompiled policy.
      Verify no increase in compile time.

Change-Id: I0d145fd311c2ddcb226a827f2a997f10c20a8379
2017-04-24 21:12:13 +00:00
Tom Cherry
d0ea8a98cd Merge changes Ic446c026,I86568a5b am: 51b7cb006f am: 41dbec9791
am: fea35fc7e4

Change-Id: Ia5e7465015618317132c63cdfaddd8cb63c2425a
2017-04-24 19:23:38 +00:00
Bowgo Tsai
fd18a452be init: set ro.boot.avb_version in recovery mode
Previously we set ro.boot.avb_version during the first stage mount in normal mode:
  - https://android-review.googlesource.com/#/c/371774/

As the first stage mount is not performed in recovery mode, we need to set the
property separately in recovery mode.

Bug: 37414003

Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead in normal mode
Test: first stage mount /system with without verity on bullhead in normal mode
Test: checks ro.boot.avb_version is 1.0 on bullhead in recovery mode

Test: first mount /vendor with with vboot 1.0 on sailfish in normal mode
Test: checks ro.boot.avb_version doesn't exist on sailfish in recovery mode

Change-Id: I262e75b8b557c4de7609b4049ccb01793644245e
2017-04-24 23:10:59 +08:00
Bowgo Tsai
d262017fef init: moving early mount logic into init_first_stage.cpp
Also renames "early mount" to "first stage mount" to prevent confusion
with "mount_all --early", which is run in the init second stage.

Also creates a base class: FirstStageMount and two derived classes:
FirstStageMountVBootV1 and FirstStageMountVBootV2 to replace/refactor
existing functions:

   - early_mount() -> DoFirstStageMount() and FirstStageMount::DoFirstStageMount()

   - vboot_1_0_early_partitions -> FirstStageMountVBootV1::GetRequiredDevices()
   - vboot_2_0_early_partitions -> FirstStageMountVBootV2::GetRequiredDevices()

   - vboot_1_0_mount_partitions ->
       FirstStageMount::MountPartitions() and
       FirstStageMountVBootV1::SetUpDmVerity()

   - vboot_2_0_mount_partitions ->
       FirstStageMount::MountPartitions() and
       FirstStageMountVBootV2::SetUpDmVerity()

Bug: 37413399
Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead
Test: first stage mount /system with without verity on bullhead
Test: first stage mount /vendor with with vboot 1.0 on sailfish
Change-Id: I6584bdf7d832c9fbc8740f97c9b8b94e68a90783
2017-04-24 23:10:10 +08:00
Tom Cherry
ad54d094cd init: create init_tests.cpp
Start a init_tests.cpp file for end-to-end tests that parse small init script
segments and verify that they act as expected.

The first tests ensure that the execution order of event triggers
happens appropriately.

Test: Boot bullhead, run unit tests

Change-Id: Ic446c02605ab796fd41e0596ce1fd381aee80ce0
2017-04-21 18:27:42 -07:00
Tom Cherry
30a6f276fd init: clean up the SectionParser interface and Parser class
Remove the dependency on Action and Service from what should be a
generic Parser class.

Make ActionParser, ImportParser, and ServiceParser take a pointer to
their associated classes instead of accessing them through a
singleton.

Misc fixes to SectionParser Interface:
1) Make SectionParser::ParseLineSection() non-const as it always should
have been.
2) Use Rvalue references where appropriate
3) Remove extra std::string& filename in SectionParser::EndFile()
4) Only have SectionParser::ParseSection() as pure virtual

Document SectionParser.

Make ImportParser report the filename and line number of failed imports.

Make ServiceParser report the filename and line number of duplicated services.

Test: Boot bullhead

Change-Id: I86568a5b375fb4f27f4cb235ed1e37635f01d630
2017-04-21 18:26:40 -07:00
Tom Cherry
01d9b0e11c Merge "init: fix errno handling on KillProcessGroup" am: f890ca9a1f am: db9f2cb46d
am: c7e559ca40

Change-Id: I297778909c6b134178928462cb995f3e65d44b9a
2017-04-20 21:00:43 +00:00
William Roberts
e6ec2661b7 init: fix errno handling on KillProcessGroup
KillProcessGroup can return -1 without errno set, which produces error
messages like this:

init: Sending signal 15 to service 'vold' (pid 1806) process group...
init: failed to kill 2 processes for processgroup 1806
init: killProcessGroup(0, 1806, 15) failed: Success

Test: boot and reboot hikey.

Change-Id: I51f242da234daee84795a3fbdffe9ad1f4567140
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2017-04-19 17:21:44 -07:00
Keun-young Park
e2b04b71ae do not start shutdown animation from init
- init will only keep animation related services as shutdown critical.
- external component like system server can start shutdown animation.

bug: 37500823
Test: reboot
Change-Id: Ief328306eba7e3b15402ae27e6236767095f508c
2017-04-19 14:30:25 -07:00
Tom Cherry
d949df5f57 Merge "init: Stop combining actions" am: 8d644d2c96 am: a0b0c8a18e
am: 779e922866

Change-Id: I83cb780715d5949a47155b98be8714604ddacb72
2017-04-19 20:10:00 +00:00
Tom Cherry
012c573e26 init: Stop combining actions
In the past, I had thought it didn't make sense to have multiple
Action classes with identical triggers within ActionManager::actions_,
and opted to instead combine these into a single action.  In theory,
it should reduce memory overhead as only one copy of the triggers
needs to be stored.

In practice, this ends up not being a good idea.

Most importantly, given a file with the below three sections in this
same order:

on boot
  setprop a b

on boot && property:true=true
  setprop c d

on boot
  setprop e f

Assuming that property 'true' == 'true', when the `boot` event
happens, the order of the setprop commands will actually be:

setprop a b
setprop e f
setprop c d

instead of the more intuitive order of:

setprop a b
setprop c d
setprop e f

This is a mistake and this CL fixes it.  It also documents this order.

Secondly, with a given 'Action' now spanning multiple files, in order
to keep track of which file a command is run from, the 'Command'
itself needs to store this.  Ironically to the original intention,
this increases total ram usage.  This change now only stores the file
name in each 'Action' instead of each 'Command'.  All in all this is a
negligible trade off of ram usage.

Thirdly, this requires a bunch of extra code and assumptions that
don't help anything else.  In particular it forces to keep property triggers
sorted for easy comparison, which I'm using an std::map for currently,
but that is not the best data structure to contain them.

Lastly, I added the filename and line number to the 'processing
action' LOG(INFO) message.

Test: Boot bullhead, observe above changes
Test: Boot sailfish, observe no change in boot time
Change-Id: I3fbcac4ee677351314e33012c758145be82346e9
2017-04-19 11:26:29 -07:00
Tom Cherry
0a03f5cb59 Merge "init: add warning that start is not synchronous" am: 06039e58d8 am: 2b78f9c0a9
am: 0a4ff0fb31

Change-Id: I32cd3f13e4f7b63da66332ff616fefa23cb5cab8
2017-04-19 18:21:51 +00:00
Wei Wang
0af7ee4a1f Merge changes from topic 'cpuset_setall' into oc-dev
* changes:
  init: use read_file and write_file to implement do_copy builtin
  init: Use std::string for write_file()
2017-04-19 16:49:59 +00:00
Yongqin Liu
67f6a530ba init: use read_file and write_file to implement do_copy builtin
this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Bug: 36726045
Bug: 36576280
Test: manual with hikey
Test: boot and init tests on bullhead
Test: cast with fugu, per b/36726045
Merged-In: If3c30a2fff58cfece2fcd27e69c30382146e6808

Change-Id: If3c30a2fff58cfece2fcd27e69c30382146e6808
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
(cherry picked from commit dbe88e7953)
2017-04-19 16:49:39 +00:00
Tom Cherry
ef52ae14ab init: Use std::string for write_file()
The content parameter of write_file() previously took a char* that was
then converted to a std::string in WriteStringToFd().  One unfortunate
effect of this, is that it is impossible to write data that contains
'\0' within it, as the new string will only contain characters up
until the '\0'.

This changes write_file() to take an std::string, such that
std::string::size() is used to determine the length of the string,
allowing it to contain null characters.

Also change the path parameter of read_file() and write_file() for
consistency.

Lastly, add a test for handling strings with '\0' in them.

Bug: 36726045
Bug: 36576280
Test: Boot bullhead, run unit tests
Change-Id: Idad60e4228ee2de741ab3ab6a4917065b5e63cd8
(cherry picked from commit 53089aa25c)
2017-04-19 16:39:08 +00:00
Bowgo Tsai
a190551d2e Merge "Set libavb version into system property for Treble OTA" into oc-dev 2017-04-19 06:13:56 +00:00