Commit graph

2617 commits

Author SHA1 Message Date
Tom Cherry
132615b803 Merge "Move watchdogd out of init" 2018-08-03 19:28:14 +00:00
Hridya Valsaraju
71fb82a271 Add sideload, fastboot as reboot targets in init
Rebooting to these targets requires writing bootloader
messages and thus root. Moving them into init means that
adb, reboot don't need root to use these targets.

Test: try rebooting to these targets
Bug: 78793464
Change-Id: Ia002d1e3b1cb0c0616f60435fb9af4dce162cf84
2018-08-03 10:03:41 -07:00
Tom Cherry
106e66e475 Merge "ueventd: require opt-in for modalias handling"
am: d52b17ff0a

Change-Id: Id827bf76f889ebd996954448648365d20350ca01
2018-08-02 12:32:55 -07:00
Tom Cherry
40acb379cd Move watchdogd out of init
We're moving past a world where static executables are needed,
including watchdogd, so treat this like any other executable and place
it in /system/bin.

Bug: 73660730
Test: watchdogd still runs
Change-Id: I1f7508fd55dce6e9ee72a6ab7a085011a76c0053
2018-08-02 12:25:58 -07:00
Tom Cherry
d52b17ff0a Merge "ueventd: require opt-in for modalias handling" 2018-08-02 19:22:13 +00:00
Tom Cherry
780d80b5a6 Merge "init: run fsck for early mount partitions"
am: 6e05552e35

Change-Id: I6b44584616557ef3c58039eff6ce7eaf3c2d7623
2018-08-01 14:11:19 -07:00
Tom Cherry
6e05552e35 Merge "init: run fsck for early mount partitions" 2018-08-01 21:02:35 +00:00
Tom Cherry
457e28f129 ueventd: require opt-in for modalias handling
Some devices have modules.alias and modules.dep for modprobe and other
purposes but do not want to opt into ueventd auto loading their
modules.  Therefore we add a flag that can be added to ueventd
configuration files to opt into this behavior.

Bug: 111916071
Bug: 112048758
Test: check that modules are loaded with this opt-in
Test: check that modules are not loaded without this opt-in
Change-Id: Ifb281b273059b4671eea1ca5bc726c9e79f3adfb
2018-08-01 13:29:05 -07:00
Tom Cherry
81ae07509d init: run fsck for early mount partitions
Bug: 111883560
Test: fsck runs successfully during early mount
Change-Id: I19bcd2610f87f5331f94c228fcbec8f9379fc5e8
2018-07-31 13:58:17 -07:00
David Anderson
4444219482 Merge "liblp: Allow building liblp as a shared library."
am: 2756339c77

Change-Id: I20ea48eff3843461cdc00c470643088d350195f6
2018-07-28 15:57:51 -07:00
Treehugger Robot
2756339c77 Merge "liblp: Allow building liblp as a shared library." 2018-07-28 22:52:23 +00:00
Luis Hector Chavez
01448be93e Merge "init: Cleanly shut down subcontext processes"
am: f6b823141e

Change-Id: Ic1cf8485da1baec8fd329e3e3ff59029140603e2
2018-07-27 19:36:08 -07:00
David Anderson
f792e4163d liblp: Allow building liblp as a shared library.
Bug: 79173901
Test: system image, partition_tools both build
Change-Id: I70f45d4cebfbddc39d03aa3fb3a56b6c48a20d7e
2018-07-27 19:34:56 -07:00
Treehugger Robot
f6b823141e Merge "init: Cleanly shut down subcontext processes" 2018-07-28 02:30:22 +00:00
Jerry Zhang
3051d54902 Merge "Move recovery to /system/bin"
am: 0937a84521

Change-Id: Ic3f3eb82178e6c5af22945e3aaaac3f86beb4ec8
2018-07-27 13:34:11 -07:00
Treehugger Robot
0937a84521 Merge "Move recovery to /system/bin" 2018-07-27 20:25:53 +00:00
Luis Hector Chavez
92c49bcb30 init: Cleanly shut down subcontext processes
This change adds an explicit cleanup for the subcontext processes and
avoids them from respawning, which causes a bunch of LOG(FATAL)s when
the system is going down.

Bug: 80425914
Test: kill -TERM $INIT_PID, no crashes for subcontext inits

Change-Id: I135191d959c1dd921b102af316b24d2bc161d6c9
2018-07-27 11:19:44 -07:00
Treehugger Robot
18be1e2f7e Merge "Add support for /product-services partition." 2018-07-27 17:15:05 +00:00
Tom Cherry
dd62c204da Merge "ueventd: Add dynamic kernel module loading"
am: 8b25b87074

Change-Id: I5163ae98e70cba3e89ea2ae538579f504e03256d
2018-07-26 15:08:21 -07:00
Dario Freni
3613710099 Add support for /product-services partition.
This CL is largely and adaptation of
Ie996def20e25dc1afe0c74af2096af844934b2dc

Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.

Change-Id: I1046dfe19bf874da929c9131b76a1f85422fbb80
Merged-In: I1046dfe19bf874da929c9131b76a1f85422fbb80
2018-07-26 16:27:28 +00:00
Dario Freni
d99a836380 Merge "Add support for /product-services partition." into stage-aosp-master 2018-07-26 16:16:38 +00:00
Andrew F. Davis
9963847419 ueventd: Add dynamic kernel module loading
For some platforms it is not known at build time what devices
will be attached at runtime. Building into the kernel or pre-loading
at init all the modules that could be needed would unnecessary bloat
the kernel. The solution is dynamic kernel module loading.

The kernel will generate uevents when devices are added, userspace
should monitor for these events and load the compatible modules.

The init process already monitors for uevents, add here the ability
to respond to modalias events and preform the correct action.

Adding this to init is preferred over an external program as we
can read and process the module alias and dependency files once,
instead of for each module needing to be loaded.

Test: Run on Beagle-X15, check all needed modules are loaded (lsmod)
Change-Id: I1b57d9aeb0a9770f309207183dc4bc2b7b905f14
Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
2018-07-26 09:42:22 -05:00
Jerry Zhang
5de2be5cd5 Move recovery to /system/bin
Executables should be in /system/bin
rather than sbin. Change lookup paths
in a few places to reflect this.

Test: recovery is in system/bin
Bug: 78793464
Change-Id: Ibcdff7abf1f21e2566e02cad8bdb3c26ee500534
2018-07-24 21:42:23 -07:00
Tom Cherry
4d71e6fb45 Merge "init: fix typo in error message"
am: 2efcb522df

Change-Id: I36cc5ebced34cbd288123a71081997c909361890
2018-07-24 17:55:51 -07:00
Tom Cherry
8c901dda30 init: fix typo in error message
Test: none
Change-Id: Ie8417c7c6e3f6600544006c4a84b5bdfaff9725f
2018-07-24 15:54:33 -07:00
TreeHugger Robot
c67c7f9a3a Merge "Revert "Use more shared libraries in adb and init."" into stage-aosp-master 2018-07-23 19:18:34 +00:00
Hridya Valsaraju
22c2202e75 Revert "Use more shared libraries in adb and init."
This reverts commit fbd79687e6.

Reason for revert: b/111734137

Change-Id: I70e23ed20d16821a555b448d4ac76fe9e130afa5
2018-07-23 17:48:57 +00:00
Dario Freni
4fa866a467 Add support for /product-services partition.
This CL is largely and adaptation of
Ie996def20e25dc1afe0c74af2096af844934b2dc

Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.
Change-Id: I1046dfe19bf874da929c9131b76a1f85422fbb80
2018-07-23 16:14:36 +01:00
Tom Cherry
9ad886c3cb Merge "init: rename init_first_stage"
am: 1d2b29a902

Change-Id: Ic92fae3ca17b0f05eabd8172548f8072d0eb6060
2018-07-20 21:19:13 -07:00
Tom Cherry
3203244471 Merge "init: clean up logging initialization"
am: 258109ce4a

Change-Id: I4918bc14048dc9fed10293b7a15cfb3b059f6181
2018-07-20 21:18:36 -07:00
Tom Cherry
1272c0ec21 Merge "init: removed unused includes"
am: 21d03d83fa

Change-Id: I31669436a744cca21127e8321c39d02967cc81ea
2018-07-20 21:17:59 -07:00
Treehugger Robot
1d2b29a902 Merge "init: rename init_first_stage" 2018-07-21 02:47:36 +00:00
Tom Cherry
258109ce4a Merge "init: clean up logging initialization" 2018-07-21 02:01:14 +00:00
Tom Cherry
f02506938e init: removed unused includes
Test: build
Change-Id: Ie3020491f67f6930acebe6397be6997b59477b96
2018-07-20 22:48:51 +00:00
Tom Cherry
38a11ccdd1 init: rename init_first_stage
In preparation for splitting first stage init from the rest of the
init executable, rename these files which are specifically involved in
first stage mount operations to a more appropriate name.

Test: builds
Change-Id: I8a2d4e8c7e1deea1bab45cc8e738727bc2ceb3e5
2018-07-20 15:31:36 -07:00
Tom Cherry
74069d1734 init: clean up logging initialization
Clean up a few mistakes in logging initialization

1) Only init needs to clear stdout/stderr/stdin, so remove this from
   ueventd, watchdogd, and subcontext init
2) Only init should reboot due to FATAL errors. This was true even
   before this change due to getpid() checks, but there's no reason to
   not just use the DefaultAborter for other processes.
3) It's probably a mistake for FATAL logs in init to try to gracefully
   shutdown the system, so simply call RebootSystem() here.
4) Lastly, remove log.cpp since it's not actually shared code anymore

Test: build
Change-Id: Ic8c323393dc7ee98ed6bb9691361b51d0d915267
2018-07-20 15:30:14 -07:00
Jerry Zhang
fbd79687e6 Use more shared libraries in adb and init.
fs_mgr is used by several different
processes in both system and recovery,
so it makes sense for it to be a shared
library to save space.

libadbd is used by adbd, recovery (as minadbd)
and fastbootd so it should be shared as well.

Bug: 78793464
Test: compiles
Change-Id: I4225f4d1a44e6e5811c68a55595d1f94f0773114
Merged-In: I4225f4d1a44e6e5811c68a55595d1f94f0773114
(cherry picked from commit aacfc68acf)
2018-07-20 17:54:44 +00:00
David Anderson
37716f6c81 Merge "fs_mgr: Remove early prototype code."
am: 881be58f41

Change-Id: I4215c6e183ddbda94cbb0de77f271a68fe21640b
2018-07-19 16:39:56 -07:00
Treehugger Robot
881be58f41 Merge "fs_mgr: Remove early prototype code." 2018-07-19 23:32:33 +00:00
David Anderson
241506b00b Merge "init: Don't look for logical partitions via uevents."
am: 8ab1fd076d

Change-Id: Ic4019cf8dfb24df708104cac4c8d81597e4c1ecc
2018-07-19 14:51:38 -07:00
Treehugger Robot
8ab1fd076d Merge "init: Don't look for logical partitions via uevents." 2018-07-19 21:42:55 +00:00
David Anderson
e0384bbc69 fs_mgr: Remove early prototype code.
This early code is no longer needed now that logical partitions can be
created and flashed normally.

Bug: 79173901
Test: N/A
Change-Id: I393ef23b3d3ce1cd9c80833358051838d0e9f333
2018-07-19 14:38:33 -07:00
David Anderson
ab8414dd6c init: Don't look for logical partitions via uevents.
When using AVB, init's first stage regenerates uevent to find the paths
of block devices for verified partitions. If it can't find them all, it
will panic, causing the device to boot to recovery.

This does not work with logical partitions, since devices for those
partitions are created later in the first stage. In fact, they cannot be
created until uevent regeneration completes, since logical partitions are
are created by finding the "super" partition.

To address this we exclude logical partitions (as marked in fstab) from
the device finding process. Note that partitions moved from GPT to liblp
will no longer appear in by_name_symlink_map_.

Bug: 79173901
Test: AVB 2.0 device boots after deleting the vendor partition,
      creating a super partition, and flashing it with a dynamic
      vendor partition.

Change-Id: I19371b05912240480dc50864a2c04131258a7103
2018-07-19 14:38:27 -07:00
Tom Cherry
e98e1f55be Merge "Fix loading ueventd.${ro.hardware}.rc."
am: 1fefb9f129

Change-Id: I7573922226736ece024e31e15fc1a7b9e2d08a9f
2018-07-19 08:09:29 -07:00
Sen Jiang
d76f174a78 Fix loading ueventd.${ro.hardware}.rc.
Regression introduced in aosp/717324.

Bug: 111543389
Test: device boots further
Change-Id: I4cf57381104aa1a801cf82a42b1c5ae1a2273e89
2018-07-18 18:10:36 -07:00
Tom Cherry
97c0fd5287 Merge "ueventd: add a test for ueventd_parser.cpp"
am: bd130567f8

Change-Id: I7337e84645a9f18ffc263b681eca88285d95b69d
2018-07-18 10:04:04 -07:00
Tom Cherry
5f0198bfbb ueventd: add a test for ueventd_parser.cpp
Test: this unit test
Change-Id: Ib23f23ea5b362bb458adf8208573e5dc80ad6cf0
2018-07-17 15:28:51 -07:00
Tom Cherry
689d86a029 Merge "ueventd: let scripts provide firmware directories"
am: b504f38d7e

Change-Id: I6dd9cfe20b733fad5afb066b07484c33eb599c02
2018-07-16 17:15:18 -07:00
Tom Cherry
b504f38d7e Merge "ueventd: let scripts provide firmware directories" 2018-07-16 23:00:53 +00:00
Tom Cherry
7421fa1aed ueventd: let scripts provide firmware directories
Since some vendors will have firmware in mount points in
/mnt/vendor/..., we extend the ueventd script language to allow
specifying the firmware directories.

Also, move the existing 4 directories to ueventd.rc as a primary user
of this mechanism.

Bug: 111337229
Test: boot sailfish; firmwares load
Change-Id: I0854b0b786ad761e40d2332312c637610432fce2
2018-07-13 15:34:25 -07:00
Tom Cherry
f4657d4b80 Merge "init: actually remount /sys when changing network namespaces"
am: a8df2b95cb

Change-Id: I00330bacd9fd7bcb825298ef72ca54d134206c99
2018-07-13 13:09:53 -07:00
Tom Cherry
9bb0a4de46 init: actually remount /sys when changing network namespaces
Fix a typo from before.

Bug: 73334854
Test: build
Change-Id: I66631a6f251960be0e02d8a119fa0ff7a00fb24c
2018-07-13 11:07:11 -07:00
Bowgo Tsai
7c4bb66d83 Merge "Add /mnt/product rw mount point for product partitions."
am: 35f2704226

Change-Id: I631decdbb3549d72478279da83ec4a5f99023b24
2018-07-02 19:03:38 -07:00
Bowgo Tsai
acc31cee1b Add /mnt/product rw mount point for product partitions.
1. init creates /mnt/product used to mount product-specific rw partitions.
2. If a device tree fstab entry for early mount specifies a mount point
   under /mnt/product e.g. /mnt/product/foo, init will create
   /mnt/product/foo mount point.

Bug: 110808288
Test: change dt fstab entry to mount /mnt/product/foo; mount point is
      created correctly, and partition is mounted in early mount.

Change-Id: I321e314992abe1084fd67a382c205f5c0c92bf3d
2018-06-29 10:36:03 +08:00
Tom Cherry
588391fd69 Merge "init: add unit tests for tokenizer.cpp"
am: 749ee86faf

Change-Id: I64f78aefbd64b4154e776cfe8cd48ca91b93693f
2018-06-27 16:10:34 -07:00
Tom Cherry
749ee86faf Merge "init: add unit tests for tokenizer.cpp" 2018-06-27 23:01:27 +00:00
Tom Cherry
117ea4f45a Merge "init: fix the parse error when meeting escape characters"
am: 78ea17a641

Change-Id: I55967f9ca86d92468dffa3ff5c0488dfe603bba9
2018-06-27 13:50:02 -07:00
Tom Cherry
2a5a4e72f3 init: add unit tests for tokenizer.cpp
Test: this unit test
Change-Id: Iae24f3bf7850dd4b298281f6608bce195096d60a
2018-06-27 13:22:16 -07:00
liwugang
332afef5f4 init: fix the parse error when meeting escape characters
After dealing with some specical escape characters('\n','\r','\t','\\',"\r\n")
it doesn't goto the next position in the next loop, so it process the current
character twice.

For example, when parsing the string "test\ntoken" we expect the
"test'\n'token" but actually we got the "test'\n'ntoken"

Test: have espace characters in init .rc files
Change-Id: I015c087a5c6e5ee9c490f29a83b15b89443f7f81
Signed-off-by: liwugang <liwugang@xiaomi.com>
2018-06-26 13:30:54 +08:00
Christopher Morin
00ac033d6c Merge "init: Don't set ro.serialno when androidboot.serialno is not set"
am: 27eda482be

Change-Id: I5ea45a03ef91395b43fce85ad6a36a59c4cd3839
2018-06-22 13:26:09 -07:00
Chris Morin
39d124b92c init: Don't set ro.serialno when androidboot.serialno is not set
This functionality is useful for improving boottimes on the ARC++
project. Without this change, ro.serialno would be set to the empty
string when androidboot.serialno was unset in the kernel commandline.

Bug: 62039211
Test: boot with androidboot.serialno unset and ensure ro.serialno is
unset

Change-Id: Iaee339dfa3f0c871e5e9c1fc0534347f2b3e8a07
2018-06-21 18:54:28 -07:00
Wei Wang
736d63c7d1 Merge "init: print service name when started waiting"
am: d41a1f9add

Change-Id: I3672fe86c4fb75ca22d4a5862a291d79062822b0
2018-06-21 12:23:54 -07:00
Treehugger Robot
d41a1f9add Merge "init: print service name when started waiting" 2018-06-21 19:17:08 +00:00
Yifan Hong
6dd458a67c Merge "Revert "init: dummy host_init_verifier for mac""
am: 16bb55cb7b

Change-Id: Ibcb16e6a5b297650687c81bee1a8b86852a51fd5
2018-06-20 16:04:28 -07:00
Yifan Hong
16bb55cb7b Merge "Revert "init: dummy host_init_verifier for mac"" 2018-06-20 22:56:39 +00:00
Wei Wang
2c4ee75b1e init: print service name when started waiting
Bug: 110479595
Test: Boot
Change-Id: I448a64cec4c1cd5b736f8b9d04cd26429067bb71
2018-06-20 15:55:10 -07:00
Yifan Hong
3c4aa11cab Revert "init: dummy host_init_verifier for mac"
This reverts commit f567367584.

Reason for revert: mac build

Change-Id: Icd5d08206c50854d6645e07c4fb29705222bd226
2018-06-20 22:49:48 +00:00
Tom Cherry
b3badbac58 Merge "init: dummy host_init_verifier for mac"
am: b0e193c609

Change-Id: I39069f0ae304895751eaeb524f0fb0053cf2b4cc
2018-06-20 14:27:34 -07:00
Treehugger Robot
b0e193c609 Merge "init: dummy host_init_verifier for mac" 2018-06-20 21:19:49 +00:00
Tom Cherry
eedd4cd77a Merge "init: document what host init verifier checks"
am: ab8131f18f

Change-Id: I68d3ffd44b64f5de8608c43e170516fe39479900
2018-06-20 14:10:28 -07:00
Treehugger Robot
ab8131f18f Merge "init: document what host init verifier checks" 2018-06-20 21:00:42 +00:00
Tom Cherry
f567367584 init: dummy host_init_verifier for mac
Let's start by fixing the build, then see how possible this will be to do fully.

Bug: 110477913
Test: n/a
Change-Id: If52e15bd070781a405c5494631ede033c1067903
2018-06-20 12:29:59 -07:00
Tom Cherry
47111aee40 init: document what host init verifier checks
Bug: 36970783
Test: n/a
Change-Id: Ic42a55d7b5bb4fec364ac3b5d9a67bcd38cbcc8d
2018-06-20 10:21:37 -07:00
Tom Cherry
50cc21a9e2 Merge "Don't check permissions bits on init scripts for host_init_verifier"
am: 81101cb216

Change-Id: I2d62e2121a8c2740d893d253f7abedc1ec824ee2
2018-06-20 10:09:28 -07:00
Tom Cherry
81101cb216 Merge "Don't check permissions bits on init scripts for host_init_verifier" 2018-06-20 17:06:11 +00:00
David Anderson
39d0c5bef4 Merge "init: Create logical partitions via liblp."
am: 08839ff904

Change-Id: I8630d57e48a3016173a43b6dbd68ab974e6d5e01
2018-06-19 18:14:39 -07:00
Treehugger Robot
08839ff904 Merge "init: Create logical partitions via liblp." 2018-06-20 01:09:35 +00:00
Jiyong Park
c4e89cde85 Merge "libselinux is dynamically linked from init"
am: 20480a22a1

Change-Id: I0f76ee0fe718cb73818c87cb3938b517f710122b
2018-06-19 17:10:29 -07:00
Treehugger Robot
20480a22a1 Merge "libselinux is dynamically linked from init" 2018-06-20 00:00:38 +00:00
Tom Cherry
d72432de93 Don't check permissions bits on init scripts for host_init_verifier
Also get rid of the copy in parser.  There's no incentive to switch to
a tokenizer that doesn't modify the input, nor is there a reason to
waste cycles making a copy of every init script as its processed.

Bug: 36970783
Test: boot
Change-Id: I8aca9c9d6f1961e1ab35dee50691a6791fc6ec66
2018-06-19 15:18:40 -07:00
David Anderson
6590df2763 init: Create logical partitions via liblp.
Currently, init can create logical partitions by hardcoding them in
fs_mgr or by specifying them in device-tree. This change allows init to
also create logical partitions by using liblp, which stores partition
tables in a physical partition. The current name for this partition is
"android".

Two aspects of this code will change long-term. One, the prototype code
using device-tree will be deleted once fastboot supports logical
partitions. Two, libdm will obsolete most of the code in
fs_mgr_dm_linear.cpp. For now however we preserve how the prototype code
functions and we layer liblp on top of the existing dm_linear logic.

Bug: 79173901
Test: N/A
Change-Id: If014a109da78fa12269bf0df0dda39028ac2d1aa
2018-06-19 14:03:58 -07:00
Jiyong Park
012171d3af libselinux is dynamically linked from init
init is now dynamically linked to libselinux. This gives us about 100KB
extra space, which is valuable in the recovery partition.

Bug: 63673171
Test: m -j
Test: adb reboot recovery
Change-Id: I72c4f886cbbb9ce54f8221f05547f5b9f0e1adb0
2018-06-19 16:55:05 +09:00
Tom Cherry
e33a115a39 Merge "Support oem_#### users/groups for host_init_verifier"
am: fe80d069a0

Change-Id: Ie59394a402c0d8c6cb5d9a3be574ccdb6e71eacc
2018-06-18 09:05:18 -07:00
Tom Cherry
fe80d069a0 Merge "Support oem_#### users/groups for host_init_verifier" 2018-06-18 15:50:52 +00:00
Tom Cherry
831e67192c Merge "Relax host init parser to work with the build system"
am: 4632f4e868

Change-Id: I583443a7e546b7b32454b7cf5ef2e60f3b73cc09
2018-06-15 10:07:13 -07:00
Tom Cherry
4632f4e868 Merge "Relax host init parser to work with the build system" 2018-06-15 17:03:42 +00:00
Tom Cherry
290427b442 Support oem_#### users/groups for host_init_verifier
Bug: 36970783
Test: oem_#### users and groups no longer fail in host_init_verifier
Change-Id: I48174f528994d1b225ed897328cc207bdebf07a8
2018-06-14 21:12:02 +00:00
Tom Cherry
863d808c2e Relax host init parser to work with the build system
It's not going to be possible to safely assume $OUT has the right init
scripts to be parsed at a given point, so instead we fall back to
parsing init scripts individually.

This isn't a full revert of the previous commits.  We retain parsing
correctness of the 'import' statements and we retain using the new
host side property functionality.

Also, fix a bug where main was not actually returning -1 on failure

Bug: 36970783
Test: testing individual files still works correctly
Change-Id: I4ae5620f234caa08993deb2c30825904a75f6654
2018-06-14 14:08:33 -07:00
Wei Wang
fb0500e0aa Merge "Revert "init: Add warning in init first stage mount""
am: 62dbf90225

Change-Id: If44dbd27d97e629ffe101578ed017676dde8a62b
2018-06-14 13:56:18 -07:00
Treehugger Robot
62dbf90225 Merge "Revert "init: Add warning in init first stage mount"" 2018-06-14 20:40:17 +00:00
Wei Wang
37acac49e2 Revert "init: Add warning in init first stage mount"
This reverts commit fdafb3d0ec.

Reason for revert: coldboot time increase
 
Bug: 110210279
Test: Boot

Change-Id: Ibb92c1856f3fc114685c40df67556131409a9231
2018-06-14 18:51:43 +00:00
Jiyong Park
aa39f52a56 Merge changes from topic "sharedlib_in_recovery"
am: 91061985f5

Change-Id: Icaabb1cb46057771f71eb3fa0fad7be49d50dc64
2018-06-13 16:44:02 -07:00
Treehugger Robot
91061985f5 Merge changes from topic "sharedlib_in_recovery"
* changes:
  Build init with shared libraries
  Shared libs are supported in recovery mode
2018-06-13 23:14:29 +00:00
Wei Wang
849ea35725 Merge "init: Add warning in init first stage mount"
am: 4aa8421203

Change-Id: I5f8d12857a40ae68fecb86f5f3c069182e0261ef
2018-06-13 13:51:33 -07:00
Wei Wang
fdafb3d0ec init: Add warning in init first stage mount
init need find required devices and it some times takes a long time due
to rogue drivers. Add a warning if the timing is longer than 50ms.

Bug: 80494921
Test: Reboot
Change-Id: I8f937d7ca7127dc89ed76bb6e5f1781459d5c94a
2018-06-13 11:02:13 -07:00
Tom Cherry
daa054fa11 Merge "ueventd: fix extraneous 'Invalid section' error"
am: 86e65e9cac

Change-Id: Ia317ea6029f9251639c5b8875eaa5536880ae5f2
2018-06-12 15:18:34 -07:00
Tom Cherry
86e65e9cac Merge "ueventd: fix extraneous 'Invalid section' error" 2018-06-12 22:05:48 +00:00
Tom Cherry
6e31a2b9ae Merge "init: Actually check the return value for calls during first stage init"
am: 413bf61e48

Change-Id: I35a8be44f0d59458aaabac5c571f404e6c1fbec2
2018-06-12 14:53:38 -07:00
Tom Cherry
788fc8229c init: Actually check the return value for calls during first stage init
Init never checked the return values of the calls made during first
stage init (since of course they're not going to fail, right?).  But
of course commands can fail and they might not necessarily be obvious
when they do, so let's make it obvious.

Since the kernel log isn't up until later, this creates a list of the
failures that can then be sent to the kernel log once it's ready
(pending of course failures in setting it up...)

Test: boot bullhead, don't see errors
Change-Id: I8c12c61fa12e4368346e8b0e1c0bb0844b5d0377
2018-06-12 11:18:17 -07:00
Tom Cherry
d5d626c9f7 ueventd: fix extraneous 'Invalid section' error
When adding a new error case for host_init_parser, I didn't handle the
individual line callbacks used for ueventd correctly.  This change
fixes that.

Test: bullhead boots without extraneous ueventd warnings
Change-Id: I56cad854b0defd936a7fbcab73fe2f2963c0e2e4
2018-06-12 10:59:12 -07:00
Jiyong Park
787322c55f Build init with shared libraries
recovery partition now supports shared librarys. Therefore, init can now
be built as a dynamic executable both for normal and recovery modes.

To save save in the recovery mode, not all libs are dynamically linked.
Libs that are only used by init in the recovery mode are still
statically linked.

Note: init is still a static executable for legacy devices where
system-as-root is not on, because the dynamic linker and shared libs
which are in /system are not available when init starts.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: device boots to the UI in normal mode.
Test: do that for both walleye (system-as-root) and bullhead (legacy
ramdisk).
Change-Id: I30c84ae6a8e507e507ad0bb71acad281316d9e90
2018-06-10 08:32:33 +09:00
Yifan Hong
7dc09a089d Merge "androidboot.lrap => logical_partitions" am: 05625ab420
am: 8b328e403d

Change-Id: I37a8f05759e060cc7cab26411a822ad7be16a36b
2018-05-31 18:12:13 -07:00
Yifan Hong
05625ab420 Merge "androidboot.lrap => logical_partitions" 2018-05-31 22:05:06 +00:00
Yifan Hong
59bd65bdf6 androidboot.lrap => logical_partitions
Test: boots with prototype
Bug: 79885414
Change-Id: Ia84d052800b71ff9cfa1630def0ce72c57f76b81
2018-05-31 13:08:01 -07:00
Tom Cherry
4fc2cd7caa Merge "init: implement getpwnam for host init verifier" am: 1c15b02b54
am: 83c7fdcc1c

Change-Id: Ia2d557642c3167ca368e72faa137cb9c57592784
2018-05-31 11:37:53 -07:00
Tom Cherry
d1cc7a94d4 Merge "init: handle properties and imports for host init verifier" am: 279de56b3e
am: 758102af2b

Change-Id: I40073678d64544f74706dbb7026798f537aed8cc
2018-05-31 11:31:55 -07:00
Tom Cherry
31525f5cb6 init: implement getpwnam for host init verifier
Bug: 36970783
Test: test bullhead successfully at TOT
Test: create errors and check that they're caught
Test: create uid in passwd and check that it's successful
Change-Id: I237fb8df16a294757fe898bdbbd42e850bcb8301
2018-05-30 15:43:40 -07:00
Tom Cherry
194b5d1da9 init: handle properties and imports for host init verifier
Allow specifying properties on the command line when running host init
verifier.  This is needed particularly for importing files that have a
property expansion in their path.

Handle the import statement on host, basing paths off of the out
directory of Android builds.

Bug: 36970783
Test: verify that bullhead imports the correct files and checks them
Change-Id: I4fe263016b3764a372708b559bc0c739b1b7e5e3
2018-05-30 15:43:32 -07:00
Mark Salyzyn
94d6035077 Merge "init: add keychords_test" am: 680bc0b6b5
am: aac3972dd3

Change-Id: I46dc9bf77569f1c0c39e094b52f96e736306c5b4
2018-05-30 10:47:59 -07:00
Treehugger Robot
680bc0b6b5 Merge "init: add keychords_test" 2018-05-30 17:27:35 +00:00
Mark Salyzyn
654b1e2a02 Merge "init: switch out keychord id with std::vector match of chords" am: e6a878644c
am: b93b91c7ef

Change-Id: I79bd04e2e2c8b1a2a380ea7a79eaad01686b6129
2018-05-30 09:29:04 -07:00
Treehugger Robot
e6a878644c Merge "init: switch out keychord id with std::vector match of chords" 2018-05-30 16:12:36 +00:00
Mark Salyzyn
75b901d4a8 init: add keychords_test
Test: init_tests --gtest_filter=keychords.*
Bug: 64114943
Change-Id: I357d0c1bd56660ac28bc02b76d5632ef1b9328b7
2018-05-30 08:38:11 -07:00
Elliott Hughes
a391213d8a Merge "init; remove dead cruft." am: dfc4ad2a9c
am: 8d69c92b6d

Change-Id: Icb02fb3fa4580fe69cd72fc6f288bc6d92347df9
2018-05-29 21:44:51 -07:00
Elliott Hughes
ba3a589d1e Merge "libbase: add host properties support." am: d580c441ab
am: 10200e4c21

Change-Id: I6577c9f68378f16c9d2e543218c0eab4d54f4d52
2018-05-29 18:01:46 -07:00
Mark Salyzyn
e55e0c3d3d Merge "init: turn keychords into a standalone class" am: 420fe5fe90
am: f29bb19686

Change-Id: If128cedc913065565e9ea367c2a7c34b217ac2a7
2018-05-29 18:01:12 -07:00
Mark Salyzyn
a12e94809c Merge "init: refactor keychord for testing" am: 16dd3582b7
am: 334b4c843e

Change-Id: I8ccebe1a9cd1dd2c6386f4a641a3eb3ea3c13fc1
2018-05-29 18:00:28 -07:00
Elliott Hughes
b0aba0fff9 init; remove dead cruft.
Bug: N/A
Test: builds
Change-Id: Ia38ef6959e8615b4f103b924ae51c19f916daa48
2018-05-29 17:05:56 -07:00
Elliott Hughes
d580c441ab Merge "libbase: add host properties support." 2018-05-29 23:59:50 +00:00
Mark Salyzyn
1385725e09 init: switch out keychord id with std::vector match of chords
Drop all references to keychord_id and id and instead use keycodes_
as the id.  The keycodes are a std::vector<int> with an unique
sorted-order emplacement method added in the parser.  Solves the
academic issue with duplicate keychords and trigger all services
that match rather than first match only.

Test: init_tests
Bug: 64114943
Change-Id: I5582779d81458fda393004c551c0d3c03d9471e0
2018-05-29 15:18:38 -07:00
Mark Salyzyn
06aeb41c16 init: turn keychords into a standalone class
Test: init_tests
Bug: 64114943
Change-Id: Ie760e4a3a661260ed2aabb8a92fe65fc93521cb5
2018-05-29 13:46:12 -07:00
Mark Salyzyn
eca2507634 init: refactor keychord for testing
Move things around so that keychords.cpp is independent of service
and init and can be individually tested with few dependencies.
Permits also rolling out the keychords as a class in a future commit.
Improve parser checking.

Test: init_tests
Bug: 64114943
Change-Id: I82570bc6269ed478db784ec38a8bc916da2be2be
2018-05-29 13:20:19 -07:00
Elliott Hughes
dc80312628 libbase: add host properties support.
Move init and libprocessgroup away from their existing hacks.

Bug: N/A
Test: ran tests
Change-Id: Ifabdd38e0cc4ab2582f1ea59d32159d386f48eb6
2018-05-24 18:04:31 -07:00
Tom Cherry
05063a8715 Merge "init: finer grained permissions for ctl. properties" 2018-05-24 16:28:24 +00:00
Elliott Hughes
3055fb2f36 Merge "Add StdioLogger for command-line tools." am: 98c1b1ccf6
am: db67c344d1

Change-Id: Iab10e8c14926eb81d60606183f2e7faac7c72f32
2018-05-24 07:31:19 -07:00
Elliott Hughes
98c1b1ccf6 Merge "Add StdioLogger for command-line tools." 2018-05-23 23:38:55 +00:00
Elliott Hughes
1be0d1481b Add StdioLogger for command-line tools.
Bug: N/A
Test: ran tests
Change-Id: If366a4ea25aea1becdd3e443eba225e9bd52ebba
2018-05-23 10:06:20 -07:00
Tom Cherry
5ab2e1c8f7 init: finer grained permissions for ctl. properties
Currently, permissions for ctl. property apply to each action verb, so
if a domain has permissions for controlling service 'foo', then it can
start, stop, and restart foo.

This change implements finer grainer permissions such that permission
can be given to strictly start a given service, but not stop or
restart it.  This new permission scheme is mandatory for the new
control functions, sigstop_on, sigstop_off, interface_start,
interface_stop, interface_restart.

Bug: 78511553
Test: see appropriate successes and failures based on permissions
Merged-In: I6ce915ae39954a67eb6fe1795a93cf715c352ae4
Change-Id: I6ce915ae39954a67eb6fe1795a93cf715c352ae4
(cherry picked from commit 1debdcf1cf)
2018-05-22 13:44:34 -07:00
Tom Cherry
2aefe3026f Merge "init: finer grained permissions for ctl. properties" into pi-dev
am: 8b491495a3

Change-Id: Id70e02df338ac419099385de1e84781dd4362ebf
2018-05-22 13:26:28 -07:00
Tom Cherry
8b491495a3 Merge "init: finer grained permissions for ctl. properties" into pi-dev 2018-05-22 20:15:07 +00:00
DuXiao
08ccca6270 Merge "Property: Log errno for socket connect" am: 59976b9bed
am: bf5200ef61

Change-Id: I5abee669341d64da52c60eb63b1e14b58e3ca23e
2018-05-22 10:54:23 -07:00
Treehugger Robot
59976b9bed Merge "Property: Log errno for socket connect" 2018-05-22 17:37:23 +00:00
Tom Cherry
9ad11c0eee Merge "init: allow entering of network namespaces" into pi-dev 2018-05-22 17:13:41 +00:00
Tom Cherry
6532c78536 Merge "init: separate out epoll into a class" am: c5fbf494e7
am: aaab7d69b5

Change-Id: I2c3b9eef33128e8a3e91ae1d2dda988f15080a06
2018-05-22 08:13:36 -07:00
Tom Cherry
1debdcf1cf init: finer grained permissions for ctl. properties
Currently, permissions for ctl. property apply to each action verb, so
if a domain has permissions for controlling service 'foo', then it can
start, stop, and restart foo.

This change implements finer grainer permissions such that permission
can be given to strictly start a given service, but not stop or
restart it.  This new permission scheme is mandatory for the new
control functions, sigstop_on, sigstop_off, interface_start,
interface_stop, interface_restart.

Bug: 78511553
Test: see appropriate successes and failures based on permissions
Change-Id: I6ce915ae39954a67eb6fe1795a93cf715c352ae4
2018-05-22 08:02:35 -07:00
DuXiao
4053359c7f Property: Log errno for socket connect
It's currently not clear that the error no indicating the
failure to invoke the library function. This change introduces
logs at the failing of socket connect, that could be clearly
get the true reason.

Test: Set system property with failed, and socket recv errno
      log will show

Change-Id: I36bf66988811f953e679d1c5a468de0bf1ab0a05
Signed-off-by: Jinguang Dong <dongjinguang@huawei.com>
2018-05-22 10:54:34 +08:00
Mark Salyzyn
6c6ec7240c init: separate out epoll into a class
Test: init_tests
Bug: 64114943
Change-Id: I5f03314773b02b9e30e8e21895b6bdcfd4909e88
2018-05-21 14:58:03 -07:00
Tom Cherry
2fa7451e9b init: allow entering of network namespaces
Add the ability to enter a network namespace when launching a service.
Typical usage of this would be something similar to the below:

on fs
  exec ip netns add namespace_name

service vendor_something /vendor/...
  capabilities <lower than root>
  user not_root
  enter_namespace net /mnt/.../namespace_name

Note changes to the `ip` tool are needed to create the namespace in
the correct directory.

Bug: 73334854
Test: auto team verified
Merged-In: Ifa91c873d36d69db399bb9c04ff2362518a0b07d
Change-Id: Ifa91c873d36d69db399bb9c04ff2362518a0b07d
(cherry picked from commit aead51b418)
2018-05-21 15:52:13 +00:00
Bowgo Tsai
b1b8dac123 Merge "Adds /dev/block/by-name/<partition> symlinks" am: 98214c81d1
am: d91d5ecd8b

Change-Id: Id5e75503a0fcc0df1e823d02fefb6e05db5de154
2018-05-18 19:02:55 -07:00
Treehugger Robot
98214c81d1 Merge "Adds /dev/block/by-name/<partition> symlinks" 2018-05-19 01:45:21 +00:00
Bowgo Tsai
5ee7dae840 Adds /dev/block/by-name/<partition> symlinks
During uevent processing, some "by-name" symlinks will be created.
    /dev/block/<type>/<device>/by-name/<partition>

<type> can be: platform, pci or vbd.
<device> might be: soc.0/f9824900.sdhci, soc.0/f9824900.sdhci, etc.
<partition> might be: system, vendor, system_a, system_b, etc.

e.g., on a non-A/B device:
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/system
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

On a A/B device:
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_b
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_b

However, those symlinks are "device-specific".

This change adds the "generic" symlinks in ueventd, in addition to
the existing symlinks, when the possible "boot devices" are specified
in device tree. e.g.,

    &firmware_android {
	compatible = "android,firmware";
	boot_devices ="soc/1da4000.ufshc,soc.0/f9824900.sdhci";
    }

The following symlinks will then be created on the aforementioned non-A/B
and A/B devices, respectively.

    /dev/block/by-name/system
    /dev/block/by-name/vendor

    /dev/block/by-name/system_a
    /dev/block/by-name/system_b
    /dev/block/by-name/vendor_a
    /dev/block/by-name/vendor_b

Note that both <type> and <device> are skipped in the newly create symlinks.
It assumes there is no more than one devices with the same <partition>,
which is the assumption of current first stage mount flow.

Finally, when 'boot_devices' in DT is absent, it fallbacks to extract
'boot_devices' from fstab settings. e.g., using 'soc/1da4000.ufshc',
'soc.0/f9824900.sdhci' for a fstab with the following content:

   /dev/block/platform/soc/1da4000.ufshc/by-name/system
   /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

Bug: 78613232
Test: adb shell ls /dev/block/by-name
Change-Id: Iec920b5a72409b6a2bdbeeb290f0a3acd2046b5d
Merged-In: Iec920b5a72409b6a2bdbeeb290f0a3acd2046b5d
(cherry picked from commit 8eec38f4e4)
2018-05-19 09:31:35 +08:00
Bowgo Tsai
ff17cc31e5 Removing block device by-num symlinks
The uevent.partition_num easily collides between partitions, for
example:

  Both /dev/block/sda3 and /dev/block/sdd3 will generate the same symlink:
    /dev/block/platform/soc/1da4000.ufshc/by-num/p3

This change remove those by-num symlinks as there seems no effective
user of it.

Bug: 78613232
Test: m init_tests && \
      adb push $OUT/data/nativetest64/init_tests/init_tests /data/. && \
      adb shell /data/init_tests

Change-Id: I8dfa8dc1a2f9fc9296aa30f33e905bf158b501de
Merged-In: I8dfa8dc1a2f9fc9296aa30f33e905bf158b501de
(cherry picked from commit 95591bd00e)
2018-05-19 09:28:42 +08:00
Tom Cherry
4be0c5a21a Merge "init: allow entering of network namespaces" am: 4bfbd8e9a5
am: e2f95984ba

Change-Id: I72f49a3dcd0175fa4a2f0cf363a99846bdacc4b2
2018-05-18 17:36:56 -07:00
Tom Cherry
4bfbd8e9a5 Merge "init: allow entering of network namespaces" 2018-05-19 00:22:58 +00:00
Tom Cherry
aead51b418 init: allow entering of network namespaces
Add the ability to enter a network namespace when launching a service.
Typical usage of this would be something similar to the below:

on fs
  exec ip netns add namespace_name

service vendor_something /vendor/...
  capabilities <lower than root>
  user not_root
  enter_namespace net /mnt/.../namespace_name

Note changes to the `ip` tool are needed to create the namespace in
the correct directory.

Bug: 73334854
Test: not yet
Change-Id: Ifa91c873d36d69db399bb9c04ff2362518a0b07d
2018-05-18 17:19:36 -07:00
Bowgo Tsai
8eec38f4e4 Adds /dev/block/by-name/<partition> symlinks
During uevent processing, some "by-name" symlinks will be created.
    /dev/block/<type>/<device>/by-name/<partition>

<type> can be: platform, pci or vbd.
<device> might be: soc.0/f9824900.sdhci, soc.0/f9824900.sdhci, etc.
<partition> might be: system, vendor, system_a, system_b, etc.

e.g., on a non-A/B device:
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/system
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

On a A/B device:
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_b
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_b

However, those symlinks are "device-specific".

This change adds the "generic" symlinks in ueventd, in addition to
the existing symlinks, when the possible "boot devices" are specified
in device tree. e.g.,

    &firmware_android {
	compatible = "android,firmware";
	boot_devices ="soc/1da4000.ufshc,soc.0/f9824900.sdhci";
    }

The following symlinks will then be created on the aforementioned non-A/B
and A/B devices, respectively.

    /dev/block/by-name/system
    /dev/block/by-name/vendor

    /dev/block/by-name/system_a
    /dev/block/by-name/system_b
    /dev/block/by-name/vendor_a
    /dev/block/by-name/vendor_b

Note that both <type> and <device> are skipped in the newly create symlinks.
It assumes there is no more than one devices with the same <partition>,
which is the assumption of current first stage mount flow.

Finally, when 'boot_devices' in DT is absent, it fallbacks to extract
'boot_devices' from fstab settings. e.g., using 'soc/1da4000.ufshc',
'soc.0/f9824900.sdhci' for a fstab with the following content:

   /dev/block/platform/soc/1da4000.ufshc/by-name/system
   /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

Bug: 78613232
Test: adb shell ls /dev/block/by-name
Change-Id: Iec920b5a72409b6a2bdbeeb290f0a3acd2046b5d
2018-05-19 07:57:35 +08:00
Bowgo Tsai
14c1dea777 Merge "Removing block device by-num symlinks" am: 6aaa3beb39
am: 3a6bf528be

Change-Id: I5cfe9afb233f2b76a5d153d94d40dd992024fbc2
2018-05-17 18:31:30 -07:00
Bowgo Tsai
95591bd00e Removing block device by-num symlinks
The uevent.partition_num easily collides between partitions, for
example:

  Both /dev/block/sda3 and /dev/block/sdd3 will generate the same symlink:
    /dev/block/platform/soc/1da4000.ufshc/by-num/p3

This change remove those by-num symlinks as there seems no effective
user of it.

Bug: 78613232
Test: m init_tests && \
      adb push $OUT/data/nativetest64/init_tests/init_tests /data/. && \
      adb shell /data/init_tests

Change-Id: I8dfa8dc1a2f9fc9296aa30f33e905bf158b501de
2018-05-17 16:29:25 +08:00
David Anderson
b04bc882e6 Merge "init/fs_mgr: prototype first-stage dm-linear support" am: 3e946da535
am: 4bf937157d

Change-Id: I742f493439afa885a54965f3425907fac99253fd
2018-05-15 13:29:01 -07:00
David Anderson
62e5b20b50 init/fs_mgr: prototype first-stage dm-linear support
This adds an API to fs_mgr for reading dm-linear tables out of device trees
and issuing device-mapper ioctls. The device tree code will be
implemented separately. The dm-linear structures in fs_mgr are organized
assuming we may want to pull them from sources other than DT (for
example, text files, binary blobs, or something hardcoded for testing).

File systems which are mounted from these logical partitions have
specific fstab requirements. The block device must be a partition name,
and if Verified Boot is used, that name must match the vbmeta partition name.
Second, the entry must have the "logical" fs_mgr flag. Example fstab
entry:

    vendor  /vendor  ext4  ro  wait,logical

Example fstab entry in device tree:

    vendor {
        compatible = "android,fstab";
        dev = "vendor";
        type = "ext4";
        mnt_flags = "ro";
        fs_mgr_flags = "wait,slotselect,avb,logical";
    };

Bug: 78914864
Test: N/A
Change-Id: I4d8878ea8858f26310119616cadc3ee0dd08566c
2018-05-14 12:43:42 -07:00
Mark Salyzyn
9dd13fa4bb Merge "init: keychord inotify add IN_ONLYDIR" am: c8dd6b74e6
am: 421a05dda4

Change-Id: I9f77324e6ccdf3b67e6779c0a126a3aad9c18fa4
2018-05-14 09:24:52 -07:00
Mark Salyzyn
f187715954 init: keychord inotify add IN_ONLYDIR
some minor cleanup.

Test: manual, boot, check registered chord works
Bug: 64114943
Change-Id: If809075445cfd5b6de0d4debc42cdc9559ddc7c4
2018-05-14 07:18:51 -07:00
Mark Salyzyn
77e59cab82 Merge "init: Add inotify for /dev/input/" am: 7ea8047185
am: 205cf8aefb

Change-Id: Ie108c87d87ee52e83ecaefa042ea9522b1460f35
2018-05-10 13:01:00 -07:00
Mark Salyzyn
44692de855 init: Add inotify for /dev/input/
Since event sources can come and go asynchronously because of delayed
driver instantiation due to initialization or firmware upload, USB
attched devices, kernel module loads, or test automation sources like
monkey, add in inotify on /dev/input/ to support these possibilities.

Test: manual, boot, check registered chord works
Bug: 64114943
Change-Id: Ie598bb6f5bf94b2034ab33cf3be7fa15d3467141
2018-05-10 08:45:24 -07:00
Tom Cherry
ec737fbca3 Merge "Remove unused using statement / host stub" am: 86dade8f6f
am: 841e457494

Change-Id: I1eeefc18fe525dab1e74ba494b5c35650f1f72d7
2018-05-09 17:31:17 -07:00
Treehugger Robot
86dade8f6f Merge "Remove unused using statement / host stub" 2018-05-10 00:07:50 +00:00
Tom Cherry
2fa178a01e Remove unused using statement / host stub
GetIntProperty() isn't used after
Ied46e9346b4ca7931aa4dcf1c9dbc11de0e12d93, so it can be removed.

Test: build
Change-Id: I5736f553db1a615d51b8fe3cbf9b4aee89451076
2018-05-09 15:25:39 -07:00
Steven Moreland
8af3dda509 Merge changes from topic "interface_builtins" am: 4880d44d2a
am: a2404d3029

Change-Id: I6550dc6ae6ec077b7879f1ba640c0f580fd65b63
2018-05-09 12:53:46 -07:00
Steven Moreland
4880d44d2a Merge changes from topic "interface_builtins"
* changes:
  init: ServiceList FindInterface
  builtins: interface_{start, stop, restart}
2018-05-09 19:34:22 +00:00
Mark Salyzyn
e074b8045b Merge changes from topic "b/64114943" am: 98caf20a65
am: 938291c770

Change-Id: I21639c2a682b3005961cba3e342e001ac841e0e5
2018-05-09 10:58:09 -07:00
Steven Moreland
6227e345e7 init: ServiceList FindInterface
FindService can't be used w/ interfaces due
to the fact that multiple interfaces can be
added to any given interface.

Bug: 79418581
Test: boot device, manually use ctl commands
Change-Id: I7c152630462c9b7509473bc190f5b30460fcc2bc
2018-05-08 14:26:44 -07:00
Steven Moreland
612d7a47bd builtins: interface_{start, stop, restart}
e.x.:
interface_start android.hardware.nfc@1.0/default
onrestart interface_restart android.hardware.nfc@1.0/default

Fixes: 79418581
Test: add this to a service, and killing that service, light is restarted
    onrestart interface_restart android.hardware.light@2.0::ILight/default
Change-Id: Ia7ac9380f01038752325cfbe030df1dd4a5665e2
2018-05-08 14:26:22 -07:00
Mark Salyzyn
353bf1f945 init: switch from /dev/keychord to /dev/input/
Replace deprecated /dev/keychord driver with /dev/input/ interface.
Will restrict which nodes are active and relevant, and try to mask
out any unreferenced inputs with EVIOCSMASK if available.

Test: manual, boot, check registered chord works
Bug: 64114943
Change-Id: I2bbf84a6e472d720f02282e10d56795b75ac62d1
2018-05-08 13:19:12 -07:00
Tom Cherry
8ae7375f02 init: use std::function for epoll handling
Also allow unregistering of epoll handlers.

Bug: 64114943
Test: boot
Change-Id: I2abe6a56fd451839931d607dddb91669a7d02ff1
2018-05-08 13:19:12 -07:00
Logan Chien
847ffd6d23 Merge "init: Use sepolicy version instead" am: 751f2fa535
am: 82103ab7d9

Change-Id: I2cf978f20587b7875994777c9154017bf5a3d4aa
2018-05-07 18:57:00 -07:00
Logan Chien
c50144ef1d init: Use sepolicy version instead
This commit uses vendor sepolicy file version (defined in
`/vendor/etc/selinux/plat_sepolicy_vers.txt`) to determine whether the
source context should be set as `u:r:vendor_init:s0`.

Before this commit, the criterion was `ro.vndk.version` >= 28.  However,
the check in `property_service.cpp` will always be true because
`ro.vndk.version` hasn't been loaded from `/vendor/default.prop`.

Furthermore, under some circumstances, `ro.vndk.version` may be
different from `plat_sepolicy_vers.txt` (e.g. O-MR1 vendor does not
define `ro.vndk.version`).

Bug: 78605339  # high-level bug to combine O-MR1 and P GSI
Bug: 79135481  # the usage of `ro.vndk.version` in init
Test: vts-tradefed run vts -m VtsTrebleVintfTest  # tetheroffload
Change-Id: Ied46e9346b4ca7931aa4dcf1c9dbc11de0e12d93
Merged-In: Ied46e9346b4ca7931aa4dcf1c9dbc11de0e12d93
2018-05-04 15:21:14 +08:00
Logan Chien
837b2a4c24 init: Use sepolicy version instead
This commit uses vendor sepolicy file version (defined in
`/vendor/etc/selinux/plat_sepolicy_vers.txt`) to determine whether the
source context should be set as `u:r:vendor_init:s0`.

Before this commit, the criterion was `ro.vndk.version` >= 28.  However,
the check in `property_service.cpp` will always be true because
`ro.vndk.version` hasn't been loaded from `/vendor/default.prop`.

Furthermore, under some circumstances, `ro.vndk.version` may be
different from `plat_sepolicy_vers.txt` (e.g. O-MR1 vendor does not
define `ro.vndk.version`).

Bug: 78605339  # high-level bug to combine O-MR1 and P GSI
Bug: 79135481  # the usage of `ro.vndk.version` in init
Test: vts-tradefed run vts -m VtsTrebleVintfTest  # tetheroffload
Change-Id: Ied46e9346b4ca7931aa4dcf1c9dbc11de0e12d93
2018-05-04 15:21:01 +08:00
android-build-prod (mdb)
a27c8ff6fb Merge changes I809d8c2e,I11265375 am: 1d87ffd3f6
am: 8c61bb63c9

Change-Id: I42b39a7516474e8f36eb080a4523498d70fbd6bb
2018-05-03 16:47:24 -07:00
David Anderson
29954f6062 init: refactor first stage to not require fstab
In order to support dm-linear devices, we need an additional first-stage
step to ensure that required devices are created. This must happen before
setting up dm-verity or mounting any first-stage partitions.

This patch refactors FirstStageMount so that having a compatible fstab
is optional. This will let us use InitRequiredDevices on systems that
would not otherwise perform first-stage mounts.

Bug: 78914864
Test: non-AVB devices still boot
Change-Id: I11265375a9900d983da8cabcc77d32c503ded02e
2018-05-02 12:23:15 -07:00
Bowgo Tsai
0537233531 Merge "First-stage mount: avoid triggering a FATAL error" am: 78393951de
am: d8829d7a4f

Change-Id: I4f8c500e04245bf9be3913be5710d47f635b53e0
2018-05-01 19:35:34 -07:00
Bowgo Tsai
fe92dd0973 First-stage mount: avoid triggering a FATAL error
Related AOSP changes:
  1. https://android-review.googlesource.com/#/c/platform/system/core/+/405009/
  2. https://android-review.googlesource.com/#/c/platform/system/core/+/532637/

The second CL raises a FATAL error when it detects fstab-dt has no content
during first-stage mount. However, with the first CL, the fstab-dt entry
might be "skipped" when bootloader sets the status property to a value
other than "ok"/"okay". (e.g., to skip mounting /vendor on upgrading
devices which have no vendor partition).

Use LOG(INFO) when there is nothing to mount here. The later stages
should trigger a FATAL error when some important files in those
partitions are not available, e.g., SEPolicy files.

Bug: 78441220
Test: boot a device
Change-Id: Iae2f47d455679298bdb067d96b771a30c1a82e6f
Merged-In: Iae2f47d455679298bdb067d96b771a30c1a82e6f
(cherry picked from commit 8fe363f260)
2018-05-02 10:23:16 +08:00
Bowgo Tsai
8fe363f260 First-stage mount: avoid triggering a FATAL error
Related AOSP changes:
  1. https://android-review.googlesource.com/#/c/platform/system/core/+/405009/
  2. https://android-review.googlesource.com/#/c/platform/system/core/+/532637/

The second CL raises a FATAL error when it detects fstab-dt has no content
during first-stage mount. However, with the first CL, the fstab-dt entry
might be "skipped" when bootloader sets the status property to a value
other than "ok"/"okay". (e.g., to skip mounting /vendor on upgrading
devices which have no vendor partition).

Use LOG(INFO) when there is nothing to mount here. The later stages
should trigger a FATAL error when some important files in those
partitions are not available, e.g., SEPolicy files.

Bug: 78441220
Test: boot a device
Change-Id: Iae2f47d455679298bdb067d96b771a30c1a82e6f
2018-05-01 16:39:36 +08:00
Elliott Hughes
da6a06548a Merge "Add test_suites lines." am: 4e6f3d9603
am: d16019bd7d

Change-Id: Ie9535898e31c62e1baa9c70a7257ab39fcddc93e
2018-04-28 09:14:34 -07:00
Elliott Hughes
40fdf3f4ab Add test_suites lines.
Bug: N/A
Test: builds
Change-Id: Ic5e2b9206bcfcb53c774989013b5db6aab462e42
2018-04-27 16:12:06 -07:00
Steven Moreland
aa5b1b93e8 Merge "init: clarify documentation for disabled" am: 9feca7c249
am: 9261ab0080

Change-Id: I691877348cc5e4702584bda41f3d67fbf4365e8c
2018-04-24 18:16:06 -07:00
Steven Moreland
8cb36868a4 init: clarify documentation for disabled
Services can be started by name or interface name now.

Bug: N/A
Test: N/A
Change-Id: I9fef619e7c27d458193311f7cd7fca4dcf8c8e72
2018-04-24 16:24:58 -07:00
Luis Hector Chavez
4ce56af101 Merge "init: Use android::base::boot_clock instead of /proc/uptime" am: 8e73e6f242
am: c12004dd23

Change-Id: I3a5a13cefa2baadfb50771664727712f9dd5b803
2018-04-19 10:59:22 -07:00
Treehugger Robot
8e73e6f242 Merge "init: Use android::base::boot_clock instead of /proc/uptime" 2018-04-19 17:43:07 +00:00
Paul Crowley
6ed4cd9cde Merge "Set property for metadata encryption on first boot" am: def249956c
am: 533870c48f

Change-Id: Ia1e25e29fdb3196a8c6dafd41271c253bd24ce59
2018-04-18 17:32:09 -07:00
Treehugger Robot
def249956c Merge "Set property for metadata encryption on first boot" 2018-04-19 00:17:42 +00:00
Paul Crowley
e383334457 Set property for metadata encryption on first boot
Bug: 77335096
Test: device boots twice with and without metadata encryption
Change-Id: Iaed78288cb37865ba23833721b73b11414e7e862
2018-04-18 14:42:45 -07:00
Paul Crowley
5872cbdf02 Set property for metadata encryption on first boot
Bug: 77335096
Test: device boots twice with and without metadata encryption
Change-Id: Iaed78288cb37865ba23833721b73b11414e7e862
2018-04-18 14:40:54 -07:00
Tri Vo
4640149fd5 Merge "Add /mnt/vendor rw mount point for vendor partitions." 2018-04-18 19:32:32 +00:00
Tom Cherry
8ee01a9d76 Merge "init: add sigstop option for debugging services from their start" am: b41879111d
am: f0d28c85b6

Change-Id: If41c3cbbe761642d4138f8a0670191326c66b449
2018-04-18 07:03:36 -07:00
Tom Cherry
b41879111d Merge "init: add sigstop option for debugging services from their start" 2018-04-18 13:51:15 +00:00
Tom Cherry
8f38048f7d init: add sigstop option for debugging services from their start
Test: the examples in README.md
Change-Id: Idb528ea4017f8f4ce62911928c040f4bc558d196
2018-04-17 14:52:49 -07:00
Tri Vo
5026903c7a Merge "Add /mnt/vendor rw mount point for vendor partitions." into pi-dev
am: b35c019d5c

Change-Id: I9541e3e1dcb941d0dd8a8bfcdb8cc637ffecc229
2018-04-17 13:42:12 -07:00
TreeHugger Robot
e58d713e47 Merge "Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."" into pi-dev 2018-04-17 20:34:14 +00:00
TreeHugger Robot
b35c019d5c Merge "Add /mnt/vendor rw mount point for vendor partitions." into pi-dev 2018-04-17 19:16:55 +00:00
Paul Crowley
08e8aa4e52 Merge "Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."" am: ca10ecb3ae
am: e72619c947

Change-Id: I739a56c5d1a5508b6ccc45710f4f2bc32fefa86e
2018-04-17 12:14:26 -07:00
Tri Vo
0b66969ba0 Add /mnt/vendor rw mount point for vendor partitions.
Changes to init's behavior during early mount:
1. Mounting of tmpfs on /mnt is moved from init stage to early mount.
2. init creates /mnt/vendor used to mount vendor partitions.
3. If a device tree fstab entry for early mount specifies a mount point
under /mnt/vendor e.g. /mnt/vendor/foo, init will create
/mnt/vendor/foo mount point.

Bug: 64905218
Test: change dt fstab entry to mount persist to /mnt/vendor/persist;
mount point is created correctly, and partition is mounted in early
mount. See go/pag/1069774
Test: device boots with /mnt/vendor and previous contents of /mnt present,
and selinux label "mnt_vendor_file" is applied correctly.
Test: cts-tradefed run commandAndExit cts --skip-all-system-status-check
--primary-abi-only --skip-preconditions -m CtsAppSecurityHostTestCases
-t android.appsecurity.cts.PermissionsHostTest
Change-Id: I3739130739eadf508355c7f2531366fcaed74175
Merged-In: I3739130739eadf508355c7f2531366fcaed74175
(cherry picked from commit b511475664)
2018-04-17 11:19:44 -07:00
Tri Vo
b511475664 Add /mnt/vendor rw mount point for vendor partitions.
Changes to init's behavior during early mount:
1. Mounting of tmpfs on /mnt is moved from init stage to early mount.
2. init creates /mnt/vendor used to mount vendor partitions.
3. If a device tree fstab entry for early mount specifies a mount point
under /mnt/vendor e.g. /mnt/vendor/foo, init will create
/mnt/vendor/foo mount point.

Bug: 64905218
Test: change dt fstab entry to mount persist to /mnt/vendor/persist;
mount point is created correctly, and partition is mounted in early
mount. See go/pag/1069774
Test: device boots with /mnt/vendor and previous contents of /mnt present,
and selinux label "mnt_vendor_file" is applied correctly.
Test: cts-tradefed run commandAndExit cts --skip-all-system-status-check
--primary-abi-only --skip-preconditions -m CtsAppSecurityHostTestCases
-t android.appsecurity.cts.PermissionsHostTest
Change-Id: I3739130739eadf508355c7f2531366fcaed74175
2018-04-17 10:15:07 -07:00
Paul Crowley
dc97e3e091 Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."
An earlier such change was reverted in commit e242a97db5.

Bug: 70487538
Test: ensure that angler can boot
Merged-In: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
Change-Id: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
2018-04-17 09:05:39 -07:00
Paul Crowley
c73b21558b Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."
An earlier such change was reverted in commit e242a97db5.

Bug: 70487538
Test: ensure that angler can boot
Merged-In: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
Change-Id: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
2018-04-17 09:03:57 -07:00
Ryan Prichard
bef4ec28c4 Merge "init: use signalfd to catch SIGCHLD" am: 07de83831f
am: 5739bf412f

Change-Id: I5a65a3ec20fd5c14b8cbd5843dabc376124b86b5
2018-04-12 16:07:25 -07:00
Tom Cherry
9223bfdabe Merge "init: do not impose vendor_init restrictions on old vendor images" am: 4396bb85da
am: 1aea110cad

Change-Id: I337819da9e62377a3f47acda0772fa20cb676931
2018-04-12 15:51:22 -07:00
Treehugger Robot
07de83831f Merge "init: use signalfd to catch SIGCHLD" 2018-04-12 22:49:27 +00:00
Tom Cherry
125781255e init: do not impose vendor_init restrictions on old vendor images
Do not restrict vendor_init restrictions on vendor images that were
built before P, as they will not have the correct permissions.

Bug: 77732028
Test: test new devices and see vendor_init still works
Merged-In: I636a07b54fbfb248e1d1a68a8f3c4d047fd5a9e9
Change-Id: I636a07b54fbfb248e1d1a68a8f3c4d047fd5a9e9
(cherry picked from commit a1dbeb8d33)
2018-04-12 15:33:15 -07:00
Treehugger Robot
ee1b5a605e Merge "Allow vendor-init-actionable for vold-related properties" 2018-04-12 22:33:03 +00:00
Tom Cherry
4396bb85da Merge "init: do not impose vendor_init restrictions on old vendor images" 2018-04-12 22:31:02 +00:00