History log of /system/core/init/ueventd.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
5ee7dae840eaebdd1aec47632e2a32e1ba7dd90a 16-May-2018 Bowgo Tsai <bowgotsai@google.com> 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 8eec38f4e463d8cd980562ec49432c17972cc5cb)
/system/core/init/ueventd.cpp
b592dd8afff487e5ba73bbd782cfa7501a65e88e 03-Aug-2017 Tom Cherry <tomcherry@google.com> init: use Result<T> for the parsing functions

Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
/system/core/init/ueventd.cpp
c3692b3ea9dffbb1e8c4a48ed780e472568a1064 10-Aug-2017 Tom Cherry <tomcherry@google.com> 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)
/system/core/init/ueventd.cpp
ede0d538501dfc78c741fb3b0645406636d1d1fd 06-Jul-2017 Tom Cherry <tomcherry@google.com> Move Timer from init to libbase

Test: boot bullhead
Test: new libbase unit tests

Change-Id: Ic398a1daa1fe92c10ea7bc1e6ac3f781cee9a5b5
/system/core/init/ueventd.cpp
0f296e06d6a4c26e7886b98964057ddbc9070c6e 30-Jun-2017 Tom Cherry <tomcherry@google.com> 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
/system/core/init/ueventd.cpp
81f5d3ebef2c3789737bf718fc2a2cdd7b9e8b33 22-Jun-2017 Tom Cherry <tomcherry@google.com> init: create android::init:: namespace

With some small fixups along the way

Test: Boot bullhead
Test: init unit tests
Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
/system/core/init/ueventd.cpp
1c3a53f03ca3c2c647f83cd8b8ae7e18c5c7bc69 23-Jun-2017 Tom Cherry <tomcherry@google.com> init: cleanup some string usage

1) property_set() takes const std::string& for both of its arguments,
so stop using .c_str() with its parameters
2) Simplify a few places where StringPrintf() is used to concatenate strings
3) Use std::to_string() instead of StringPrintf() where it's better suited

Test: Boot bullhead
Test: init unit tests
Change-Id: I68ebda0e469f6230c8f9ad3c8d5f9444e0c4fdfd
/system/core/init/ueventd.cpp
4cbedee541d92b408c591e4fc16d88a0653c076c 21-Jun-2017 Sandeep Patil <sspatil@google.com> Revert "Revert "init: poll in first stage mount if required devices are not found""

This reverts commit d6fccea093ebe5a5d929549d721185b0f1b52ac0.

Bug: 62681642
Bug: 62682821
Bug: 62864413

Change-Id: Ic9c27552acbd2ae312e44ea2cdf060dcf493bfe6
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/ueventd.cpp
cd2ba0d184c3fa9bbf0881a5d1fb3d3e205da1f9 21-Jun-2017 Sandeep Patil <sspatil@google.com> Revert "Revert "ueventd: remove PlatformDeviceList""

This reverts commit 516ff99711bbb533c4ca3970882ef376df6b044d.

Bug: 62864413
Bug: 62864413

Change-Id: Ie3980cd536c2c83adace063f0950128f68561105
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/ueventd.cpp
516ff99711bbb533c4ca3970882ef376df6b044d 21-Jun-2017 Tom Cherry <tomcherry@google.com> Revert "ueventd: remove PlatformDeviceList"

Bug: 62864413

This reverts commit c94ce7b130979317d9523ba0d175f0ad369fb1c4.

Change-Id: I014360251e5cda89c87adfec46d8b1e5000f3a9c
/system/core/init/ueventd.cpp
d6fccea093ebe5a5d929549d721185b0f1b52ac0 21-Jun-2017 Tom Cherry <tomcherry@google.com> Revert "init: poll in first stage mount if required devices are not found"

Bug: 62864413

This reverts commit ccf0d39316dcf6cfd7c50d131fd681a1f6c8fd74.

Change-Id: I343e304db4c0e7af2402397ef468cc743a3f08a9
/system/core/init/ueventd.cpp
ccf0d39316dcf6cfd7c50d131fd681a1f6c8fd74 17-Jun-2017 Tom Cherry <tomcherry@google.com> init: poll in first stage mount if required devices are not found

First stage mount in init currently attempts to regenerate uevents for
specific devices to create the corresponding dev nodes. However, this
is racy as first stage mount happens early in the boot process and
it's possible that some of these devices have not yet been created by
the kernel.

To fix this issue, init will poll on the uevent socket for up to 10
seconds waiting for the kernel to create the required device. It will
return false and panic if this 10 second timeout passes.

Note that the same uevent socket is used in the uevent regeneration
and the polling code, so there is no race if the device is created
after the uevent regeneration and before polling starts; the first
poll will pick up the device.

Bug: 62681642
Bug: 62682821
Test: Boot bullhead
Test: Boot sailfish
Test: Boot hikey + hotplug/unplug sdcard
Change-Id: I4a6ff043eb7115b729ca4954ebc6c9e000132993
/system/core/init/ueventd.cpp
137ee511bdb756e966d244e7e3dec1ab547e3c09 20-Jun-2017 Tom Cherry <tomcherry@google.com> Merge "ueventd: remove PlatformDeviceList"
c94ce7b130979317d9523ba0d175f0ad369fb1c4 17-Jun-2017 Tom Cherry <tomcherry@google.com> ueventd: remove PlatformDeviceList

In order to create symlinks for USB and block devices, the path for
their parent platform device must be known.

Previously, ueventd would save each platform device that it encounters
to a list and query this list when creating the symlinks. That,
however, is racy because the uevent socket does not differentiate
uevents from RegenerateUevents() and uevents sent by the kernel when
probing a device first the first time. The below scenario is the
faulty case:

1) Kernel probes parent platform device for a block device
2) ueventd calls RegenerateUevents() and starts processing uevents
3) Kernel probes block device and sends its uevents
4) ueventd picks up the block device uevent during its uevent processing,
without yet regenerating the platform device uevent, causing improper
symlinks to be created.

This change stops storing the platform devices in a list, and instead
traverses up the directory structure for each USB or block device
until it reaches a platform device, defined as one whose subsystem is
the platform bus. This fixes the race and simplifies the ueventd
code.

Bug: 62436493
Bug: 62681642
Test: Boot bullhead
Test: Boot sailfish
Test: Init unit tests
Test: Boot hikey + hotplug/unplug sdcard
Change-Id: I21636355d8e434f30e0cba568598a6cf139e67f9
/system/core/init/ueventd.cpp
d2fd54e0ffb377ec07f5fc87907356644ec0fdf6 07-Jun-2017 Tom Cherry <tomcherry@google.com> Move restorecon() of /sys from init to ueventd.

ueventd already does restorecon() for /sys/{block,class,devices}, so
instead of duplicating this effort with init, move the restorecon()
that init does for all of /sys to ueventd.

Bug: 62420036
Change-Id: I6125f8ff5316a0cf45872d1100d089d71802958f
Merged-In: I6125f8ff5316a0cf45872d1100d089d71802958f
Test: Boot sailfish, bullhead
/system/core/init/ueventd.cpp
c583305ed7b459604ce619a6c5d44c4a377fcdfe 17-May-2017 Tom Cherry <tomcherry@google.com> ueventd: parallelize uevent handling

fork() subprocesses to handle uevents in parallel.

This reduces coldboot time on bullhead from ~446ms to ~230ms.
This reduces coldboot time on sailfish from ~690ms to ~360ms.
This reduces coldboot time on ryu from ~187ms to ~122ms.

Bug: 33785894

Test: boot bullhead x40, observe no major differences in /dev and /sys
Test: boot sailfish x40, observe no major differences in /dev and /sys
Test: boot ryu x40, observe no major differences in /dev and /sys
Test: boottime tests on bullhead and sailfish
Test: init unit tests

Change-Id: Ie2f63e000b8af78d187477d31fe109f20304d749
/system/core/init/ueventd.cpp
ed506f7356346b74eabcf45e207f9afe54b63089 26-May-2017 Tom Cherry <tomcherry@google.com> ueventd: Break devices.cpp into discrete classes

devices.cpp handles too many things for creating one class. This
change breaks it up into various files and classes.

* Parsing is moved to ueventd_parser.cpp
* Reading from the uevent socket and Cold booting is moved to a
UeventListener class, in uevent_listener.cpp
* Firmware handling is moved to firmware_handler.cpp
* The remaining contents form a DeviceHandler class within devices.cpp

Bug: 33785894

Test: boot bullhead x40, observe no major differences in /dev and /sys
Test: boot sailfish x40, observe no major differences in /dev and /sys
Test: init unit tests

Change-Id: I846a2e5995fbb344c7a8e349065c18a934fa6aba
/system/core/init/ueventd.cpp
f51c66b23b675bd2198e3793090f8ef9e8eb8ef0 01-May-2017 Tom Cherry <tomcherry@google.com> ueventd: fix typo from previous patchset

An forward declaration for a function that was removed in later
patchsets was merged anyway. Since it's not used anywhere, this CL
removes it.

Test: build bullhead
Change-Id: Ie7223f7d23305b71438cb063b64a574ce32f96bb
/system/core/init/ueventd.cpp
fe062055cb11fcb1a6178b046173fc0361ad5b96 25-Apr-2017 Tom Cherry <tomcherry@google.com> 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
/system/core/init/ueventd.cpp
cc054c9da830b8b33b850c633324867c68488cac 06-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: create classes for dev and sys permissions

Create classes for dev and sys permissions and store these permissions
in std::vector instead of the C list.

Test: boot bullhead
Test: init unit tests

Change-Id: I874039a3db29b4c70149506da8e407123ab7eca2
/system/core/init/ueventd.cpp
3f5eaae526413a29de899270714469c76dc91ec8 07-Apr-2017 Tom Cherry <tomcherry@google.com> init: more header cleanup

Remove includes of "log.h" that really want <android-base/logging.h>
Fix header include order
Remove headers included in .cpp files that their associated .h already includes
Remove some unused headers

Test: boot bullhead
Change-Id: I2b415adfe86a5c8bbe4fb1ebc53c7b0ee2253824
/system/core/init/ueventd.cpp
fd72bbe91fc8cdc0eb3d9f3b0531e9c30ed45f06 04-Apr-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "Make ueventd error messages indicate where the error is in ueventd script"
7d3e2c4d4ee0747bb2836747411d154b5b9738c5 29-Mar-2017 Christopher Desjardins <christopher.desjardins@tomtom.com> Make ueventd error messages indicate where the error is in ueventd script

Test: Boot bullhead
Test: Observe errors with file and line number with faulty ueventd.rc

Change-Id: Ieae6151e253f1e6437dfdebd14da4e1e04a45fae
/system/core/init/ueventd.cpp
ccf23537eeacfa47e5f18dd3b75089886d177c1b 29-Mar-2017 Tom Cherry <tomcherry@google.com> init: replace property_get with its android::base equivalent

Slowly try to decouple property_service.cpp from the rest of init.

Test: Boot bullhead
Change-Id: I267ae0b057bca0bf657b97cb8bfbb18199282729
/system/core/init/ueventd.cpp
bf298e6d0c8e1a20df7af7f856d9ca6781c9ed44 03-Feb-2017 Sandeep Patil <sspatil@google.com> ueventd: source ueventd configs from vendor and odm

While keeping the old /ueventd.$ro.hardware.rc configuration for devices
without early mount or vendor,odm split

b/34967636

Test: Boot angler and sailfish without regressions

Change-Id: I8d671911fd23fb1c0b5624ae209bad86137c88b7
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/ueventd.cpp
09bd41d097b15421a6dd7b547fadbb46928b9150 16-Nov-2016 Ting-Yuan Huang <laszio@google.com> init: fix memory leaks

It's possible that node is not freed before return.

Test: make WITH_TIDY=1 mmma system/core/init

Change-Id: I648eea9dda006d2b2239e169785190817ad31352
/system/core/init/ueventd.cpp
171a829c39d9298432505fe943ad7128aeefe2b2 30-Jun-2016 Elliott Hughes <enh@google.com> Make klog_fd thread-safe and make klog_init a no-op.

I'll come back and remove klog_init when I've removed other calls to it.

Change-Id: Iad7fd26d853b4ddc54e9abd44516b6f138cbbfcb
Test: booted N9, looked at "adb shell dmesg" output.
/system/core/init/ueventd.cpp
f86b5a6b90619e02d1d034ef7b0adc3b439f4abb 25-Jun-2016 Elliott Hughes <enh@google.com> Move init to libbase logging.

Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
/system/core/init/ueventd.cpp
3195116e9718a4159f4149bcdc0d2a85339fcbf5 25-Jun-2016 Elliott Hughes <enh@google.com> Remove MTD cruft from init.

Bug: http://b/29250988
Change-Id: I38ab263192944e4ff291fd91b25db163a8848d75
/system/core/init/ueventd.cpp
5b5a8ace61e089a207036115b73da8f27f0fba04 07-Apr-2016 William Roberts <william.c.roberts@intel.com> ueventd: convert to use pwd family of functions

Switch ueventd to use the grp.h and pwd.h family of
functions for converting strings to uids. This removes the
need for using android_filesystem_config.h.

Change-Id: I25a6f536bb11683d5cd69a0d7b348d25a272dd3b
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
/system/core/init/ueventd.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/init/ueventd.cpp
74edcea90e31a3795e58aa1b2bbe96032f0bcd61 24-Jul-2015 Yabin Cui <yabinc@google.com> init: Let property_get return std::string.

Bug: 22654233

Change-Id: Id6091f58432f75e966b9871256049fbe17766c10
/system/core/init/ueventd.cpp
da40c00137f75543a69972f1be506e2d14a41845 28-Mar-2015 Elliott Hughes <enh@google.com> Log more timing information from init.

Also make important events in init's life NOTICE rather than INFO,
and ensure that NOTICE events actually make it to the kernel log.

Also fix the logging so that if you have a printf format string
error, the compiler now catches it.

Also give messages from init, ueventd, and watchdogd distinct tags.
(Previously they'd all call themselves "init", and dmesg doesn't
include pids, so you couldn't untangle them.)

Also include the tag in SELinux messages.

Bug: 19544788
Change-Id: Ica6daea065bfdb80155c52c0b06f346a7df208fe
/system/core/init/ueventd.cpp
74b34f3cb79aa8f2c5ba6a9dcc46d0dd84cdac86 28-Feb-2015 Rom Lemarchand <romlem@android.com> Remove /proc/cpuinfo parsing

- Clean up the paths for ro.revision and ro.hardware parsing
- Use ro.hardwre in ueventd instead of parsing the kernel command line

(cherry-pick of 38b340a52f8e864650db8bae1eb88d5c00485db0.)

Bug: 19366018
Change-Id: I018a293f3d46e736a8b65132b5b00b0f7c20edae
/system/core/init/ueventd.cpp
c0e919c92062360a69b771722677d041c9998403 04-Feb-2015 Elliott Hughes <enh@google.com> Stop using #if for conditional compilation.

Use regular 'if' to prevent bitrot.

Also remove remaining typedefs.

Change-Id: I2e6ca928e2db29b88b643cf990ff05cfb0be94a6
/system/core/init/ueventd.cpp
2145779c871d4a9f632a8afbfc2adc5bea185a45 04-Feb-2015 Elliott Hughes <enh@google.com> Fix clang "ueventd.cpp:111:1: error: no return statement in function returning non-void".

Change-Id: I69c9e5534975bffa0fbf98ca4af50400f6b94aa0
/system/core/init/ueventd.cpp
f3cf438714aa1284d8a58e2f3b108ba93f6d3abb 04-Feb-2015 Elliott Hughes <enh@google.com> Build init as C++.

This is just the minimal change to keep it building.

Change-Id: I245c5b8413a1db114576c81462eb5737f5ffcef2
/system/core/init/ueventd.cpp