Commit Graph

2346 Commits

Author SHA1 Message Date
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
Treehugger Robot 881be58f41 Merge "fs_mgr: Remove early prototype code." 2018-07-19 23:32:33 +00: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
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 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 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 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 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 749ee86faf Merge "init: add unit tests for tokenizer.cpp" 2018-06-27 23:01:27 +00: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
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
Treehugger Robot d41a1f9add Merge "init: print service name when started waiting" 2018-06-21 19:17:08 +00: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
Treehugger Robot b0e193c609 Merge "init: dummy host_init_verifier for mac" 2018-06-20 21:19:49 +00: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 81101cb216 Merge "Don't check permissions bits on init scripts for host_init_verifier" 2018-06-20 17:06:11 +00:00
Treehugger Robot 08839ff904 Merge "init: Create logical partitions via liblp." 2018-06-20 01:09:35 +00: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 fe80d069a0 Merge "Support oem_#### users/groups for host_init_verifier" 2018-06-18 15:50:52 +00: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
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
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 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 86e65e9cac Merge "ueventd: fix extraneous 'Invalid section' error" 2018-06-12 22:05:48 +00: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 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 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
Treehugger Robot 680bc0b6b5 Merge "init: add keychords_test" 2018-05-30 17:27:35 +00:00