History log of /system/core/init/devices.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/devices.cpp
ff17cc31e5aa49fc8cce1693f813d150a7343ab5 17-May-2018 Bowgo Tsai <bowgotsai@google.com> 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 95591bd00e653826f25bfa705c3f50545f6b06a3)
/system/core/init/devices.cpp
579e682628805dd9c3f8c96765c0beb3f56f1494 20-Dec-2017 Elliott Hughes <enh@google.com> Add std::string StartsWith*/EndsWith* overloads.

We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.

Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
/system/core/init/devices.cpp
9c8d6dd7de6e436542d40ae1cd635ce13b89162f 17-Aug-2017 Tom Cherry <tomcherry@google.com> ueventd: fix subsystem list logic issues

1) Check subsystems list before doing usb subsystem logic. This allows
developers to handle usb* subsystems in ueventd.rc files.
2) Fix a bug where each subsystem_ instance is not reinitialized, but
rather only the name_ member was set.

Test: boot bullhead
Test: check that multiple uevent_devname subsystems work when
specified in ueventd.rc
Change-Id: Ifcac04763afcaf72a3b14ef5f3a6cb89981b51a1
/system/core/init/devices.cpp
0c8d6d27304d1d6e5f8f0a3feb1f60872ac278f2 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
/system/core/init/devices.cpp
b4dd881ffd2c2b50b5ffd323264b3c0bfd7bffe7 23-Jun-2017 Tom Cherry <tomcherry@google.com> ueventd: remove character device symlinks (/dev/usb/*)

While refactoring ueventd, I was looking for code the character device
symlinks (/dev/usb/*) that ueventd creates, such that I could test it
on a real device. I found none in our tree, and history showing Xoom,
which was last supported years ago, was the last user. If this code
is in fact obsolete, let's remove it.

Test: boot bullhead
Test: init unit tests

Change-Id: I601f7165eb06d36b31b6dcf69ee9e0a449d81a96
/system/core/init/devices.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/devices.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/devices.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/devices.cpp
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/devices.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/devices.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/devices.cpp
51056c49d2ebc2c4934d303fb810f905d68bba03 18-May-2017 Elliott Hughes <enh@google.com> init should #include <sys/sysmacros.h>

Bug: https://github.com/android-ndk/ndk/issues/398
Test: builds
Change-Id: I6428a6344a3ce649bd03ff9e9b0f156425c67f0c
/system/core/init/devices.cpp
482f36cf74c0461bbad4a33df27d1b8e72ccc2d2 08-May-2017 Tom Cherry <tomcherry@google.com> init: remove restorecon() from util.cpp

restorecon() has become nothing more than a small wrapper around
selinux_android_restore(). This itself isn't super problematic, but
it is an obstacle for compiling util.cpp on the host as that function
is not available on the host.

Bug: 36970783
Test: Boot bullhead
Merged-In: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
Change-Id: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
/system/core/init/devices.cpp
e7656b7200d934d6f77df422d6d3dee469230dea 02-May-2017 Tom Cherry <tomcherry@google.com> ueventd: do not reference init's sehandle

Init exposes a global 'sehandle' that ueventd references as part of
devices.cpp and util.cpp. This is particularly dangerous in
device_init() in which both uevent and init write to this global.

This change creates a separate local copy for devices.cpp and puts
restrictions on where init.h can be included to make sure the global
used by init is not reference by non-init code. Future changes to
init should remove this global.

Test: Boot bullhead

Change-Id: Ifefa9e1932e9d647d06cca2618f5c8e5a7a85460
/system/core/init/devices.cpp
6daf5144483d66384a61649ed6225a4e07b72650 01-May-2017 Tom Cherry <tomcherry@google.com> ueventd: remove leftovers of the SELinux policy update mechanism

Reloading sepolicy has been removed from the system, so this support
code can also now be removed.

Bug: 26544104
Test: Boot bullhead
Change-Id: If9dbc9d540d9a69340c1dd6a483c1f8fe5feb287
/system/core/init/devices.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/devices.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/devices.cpp
1ab8f55344f1456aec8d6aa1c7450020acd2d0d6 06-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: convert platform_names from C list to std::vector

Also simplify this code a bit.

There's only one consumer that removes the /devices/platform prefix,
so have them handle it instead of storing two copies of the string.

Remove an unneeded search for '/' in get_character_device_symlinks()
as a / will always be the next character after a parent path, by
nature of FindPlatformDevice().

Test: boot bullhead
Test: init unit tests

Change-Id: I9d0482d137b1342ae7509ae993ff99198be814f0
/system/core/init/devices.cpp
e3e48214b718d5c6bb76d50c56344b222a23a234 11-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: replace char* with std::string in struct uevent

Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ib82833bea56bdafbe1d7a045126aaa91a8725d98
/system/core/init/devices.cpp
3fa467338fbf3462ed7617efd95bb1a048d1bdbf 11-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: Fix up string handling in handle_*_device_event()

Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ie5ec609a3f74bb03f5920734ada4d7de57508de4
/system/core/init/devices.cpp
780a71e779e8e41681c3f0ee12d7f559dc52b7a7 05-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: move subsystem logic from code to ueventd.rc

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: I690137b584fcc2b9cd2dd932a2678f75a56d6737
/system/core/init/devices.cpp
120add07ab2aa03cb7c073ef7629817b41643dc1 12-Apr-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "ueventd: remove /dev/log"
d4ff8d83d3fcc23c07d928f8d463a54aa584e739 11-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: remove /dev/log

This was marked deprecated in 2014 and removed in 2015, let's remove
the uevent rule now too.

Test: see that logging still works on bullhead
Change-Id: Idaf3f49a1afe7046eba6c976628b9f1c8b3ec094
/system/core/init/devices.cpp
2e344f9d228f3900987654bd4a085a6cb484cd0c 05-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: replace char** links with std::vector<std::string>

Additionally replace the associated C string parsing with C++ and write
unit tests.

Bug: 33785894
Bug: 36250207
Test: Boot bullhead + unit tests
Change-Id: Iee1f72d248bca3bd2e1227045628935b3dd6195a
/system/core/init/devices.cpp
ab5ab1ebd4b3bce1a7c95077bdaed8557f4071ab 07-Apr-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "init: more header cleanup"
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/devices.cpp
c44f6a4073f2c7fbcf72cabb170255163c3a0d42 06-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: Write tests for the get_*_symlinks() functions

Bug: 33785894
Bug: 36250207
Test: Boot bullhead + new unit tests
Change-Id: Ia0f290542eb1cffce5ae876dfedb453dde960253
/system/core/init/devices.cpp
937309d3e305c699fb1264f2561bf3ee4daa697d 03-Mar-2017 Jeremy Compostella <jeremy.compostella@intel.com> ueventd: support by-name symlinks for virtual block devices

This patch makes ueventd create by-name symlinks for virtual block
devices when Android is running as a Xen guest OS.

The symlinks will be created under /dev/block/vbd/. For example:
/dev/block/vbd/768/by-name/

Change-Id: Id45da560d13f641d7c8419511c154de9ae8a4ec9
Test: manual
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
/system/core/init/devices.cpp
0506b18a3655562ad32ee279ba394f9869faf995 23-Feb-2017 Tom Cherry <tomcherry@google.com> Check setegid() return values

The clang static analyzer is complaining that we are not checking the
setegid() return value, so let's add these checks. We should never
fail to return to AID_ROOT, so fail hard in this case.

Bug: 26962034
Test: Boot bullhead
Test: export WITH_STATIC_ANALYZER=1 and run 'mm' in the project directory
Change-Id: I62e95b045c5734305c71502871b6cf17f152edbc
/system/core/init/devices.cpp
971a460c5b573b0e22780579daed242f4879626d 15-Feb-2017 Sandeep Patil <sspatil@google.com> init: refactor to allow successive device_init calls

device_init opens the uevent socket and sehandle when called.
For early_mount however, depending on the fs_mgr flags we may call this
in order to run coldboot for device mapper, dm-verity devices etc.
So the change makes sure we don't try to re-open the uevent socket,
file context handle and selinux status on successive calls to
device_init from within the same process.

b/27805372

Test: Boot saifish successfully

Change-Id: Ifa0e665403211684183efb9be66e4e8d0d86a206
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/devices.cpp
35403ebaf85aa229973275be9f5229d453799811 09-Feb-2017 Sandeep Patil <sspatil@google.com> init: early_mount: add support to mount non-verity partitions early

This is done by parsing 'androidboot.fstab=<fstab>' kernel cmdline
option to get the fstab file that *only* specifies partitions to be
mounted early (i.e. in init's first stage).

Note that, the same fstab file may not be used as an argument to
mount_all later in the boot as that will cause fs_mgr to fail with
EBUSY.

TODO:
- Possibly add a new mount_mode so the same fstab can be used for
early_mount, 'mount_all --early/--late' etc.
- Add support for dm-verity enabled partitions to mount early.
- Add support for getting fstab arguments through DT instead of kernel
cmdline.

Bug: 27805372

Test:
Boot angler by passing a seperate fstab file using the kernel
cmdline option to mount vendor partition early, remove the vendor
partition entry from the main fstab file for the test.

Boot sailfish by passing a seperate fstab entry via device tree
to mount vendor partition early. Remove vendor partition entry from
the main fstab file for the test

Change-Id: I18785b893c54c8cee960ab44d5e8f83e5d624aa8
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/devices.cpp
44a3ee2cd1d73e8577d5612285c9000b47e848b6 09-Feb-2017 Sandeep Patil <sspatil@google.com> init: remove the existing early_mount code

keeps parts of the code that are still needed for the fs_mgr
+ dt based implementation

b/27805372

Test: boot angler, sailfish without regressions

Change-Id: I1b08f8b7b4f2e67118d328443a5011c0f5ead919
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/devices.cpp
957e4ab0b5c5f0ed006a287ba7cc387ce7db4d27 08-Feb-2017 Sandeep Patil <sspatil@google.com> init: refactor: add support for doing early coldboot

We don't want to spend time creating devices that are unncessesary
during early (init first-stage) mount. So, refactor the devices code
tha allows us to call into coldboot and has the

- ability to only create devices that are specified by the caller
- ability to stop coldboot cycle when all devices that the caller is
interested in
- ability to run coldboot for a specific syspath
- ability to run ueventd code unmodified

Test: Tested boot on angler, sailfish

Change-Id: Id8f3492380696760414eadc20d624d300c904f8e
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/devices.cpp
ea23983a9c84db151478c0c5a8b41f7d0c4c3fde 03-Feb-2017 Sandeep Patil <sspatil@google.com> ueventd: make selinux labeling optional for device creation

This is to setup a way for us to run coldboot during init first stage
and also at ueventd startup. We do not have all of the file context
during the first stage, so the "early" coldboot needs to proceed without
labelling the device nodes. However, the follow up in ueventd must label
these nodes. This change allows us to do both.

b/27805372

Test: Boot angler successfully and compare do before/after comparison of
the output of 'ls -AclpqRZ /dev' to ensure there are no differences.

Change-Id: I5e88bd7da8a1d2cc41e3abba30dda463ecbde32e
Signed-off-by: Sandeep Patil <sspatil@google.com>
/system/core/init/devices.cpp
331cf2fb7c16b5b25064f8d2f00284105a9b413f 29-Nov-2016 Elliott Hughes <enh@google.com> Replace the "coldboot" timeout with a property.

Also rename init's existing boot-time related properties so they're
all "ro.*" properties.

Example result:

# Three properties showing when init started...
[ro.boottime.init]: [5294587604]
# ...how long it waited for ueventd...
[ro.boottime.init.cold_boot_wait]: [646956470]
# ...and how long SELinux initialization took...
[ro.boottime.init.selinux]: [45742921]

# Plus one property for each service, showing when it first started.
[ro.boottime.InputEventFind]: [10278767840]
[ro.boottime.adbd]: [8359267180]
[ro.boottime.atfwd]: [10338554773]
[ro.boottime.audioserver]: [10298157478]
[ro.boottime.bootanim]: [9323670089]
[ro.boottime.cameraserver]: [10299402321]
[ro.boottime.cnd]: [10335931856]
[ro.boottime.debuggerd]: [7001352774]
[ro.boottime.debuggerd64]: [7002261785]
[ro.boottime.drm]: [10301082113]
[ro.boottime.fingerprintd]: [10331443314]
[ro.boottime.flash-nanohub-fw]: [6995265534]
[ro.boottime.gatekeeperd]: [10340355242]
[ro.boottime.healthd]: [7856893380]
[ro.boottime.hwservicemanager]: [7856051088]
[ro.boottime.imscmservice]: [10290530758]
[ro.boottime.imsdatadaemon]: [10358136702]
[ro.boottime.imsqmidaemon]: [10289084872]
[ro.boottime.installd]: [10303296020]
[ro.boottime.irsc_util]: [10279807632]
[ro.boottime.keystore]: [10305034093]
[ro.boottime.lmkd]: [7863506714]
[ro.boottime.loc_launcher]: [10324525241]
[ro.boottime.logd]: [6526221633]
[ro.boottime.logd-reinit]: [7850662702]
[ro.boottime.mcfg-sh]: [10337268315]
[ro.boottime.media]: [10312152687]
[ro.boottime.mediacodec]: [10306852530]
[ro.boottime.mediadrm]: [10308707999]
[ro.boottime.mediaextractor]: [10310681177]
[ro.boottime.msm_irqbalance]: [7862451974]
[ro.boottime.netd]: [10313523104]
[ro.boottime.netmgrd]: [10285009351]
[ro.boottime.oem_qmi_server]: [10293329092]
[ro.boottime.per_mgr]: [7857915776]
[ro.boottime.per_proxy]: [8335121605]
[ro.boottime.perfd]: [10283443101]
[ro.boottime.qcamerasvr]: [10329644772]
[ro.boottime.qmuxd]: [10282346643]
[ro.boottime.qseecomd]: [6855708593]
[ro.boottime.qti]: [10286196851]
[ro.boottime.ril-daemon]: [10314933677]
[ro.boottime.rmt_storage]: [7859105047]
[ro.boottime.servicemanager]: [7864555881]
[ro.boottime.ss_ramdump]: [8337634938]
[ro.boottime.ssr_setup]: [8336268324]
[ro.boottime.surfaceflinger]: [7866921402]
[ro.boottime.thermal-engine]: [10281249924]
[ro.boottime.time_daemon]: [10322006542]
[ro.boottime.ueventd]: [5618663938]
[ro.boottime.vold]: [7003493920]
[ro.boottime.wificond]: [10316641073]
[ro.boottime.wpa_supplicant]: [18959816881]
[ro.boottime.zygote]: [10295295029]
[ro.boottime.zygote_secondary]: [10296637269]

Bug: http://b/31800756
Test: boots
Change-Id: I094cce0c1bab9406d950ca94212689dc2e15dba5
/system/core/init/devices.cpp
a8d8434c42b27f0186be7ecd78c2acc9d459b068 15-Nov-2016 Paul Lawrence <paullawrence@google.com> Add flags to restorecon_recursive to traverse filesystems

Use to solve the problem of tracefs conditionally being mounted
under debugfs and needing restorecon'd without boot performance
penalty.

Also move skip-ce to a flag for consistency.

Test: Check that trace_mount has correct attributes after boot
Bug: 32849675
Change-Id: Ib6731f502b6afc393ea5ada96fa95b339f14da49
/system/core/init/devices.cpp
a73ba879b1bac25ce0b93cbeb895b05c796fc9ec 16-Nov-2016 Treehugger Robot <treehugger-gerrit@google.com> Merge "init: fix memory leaks"
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/devices.cpp
290a228fdca935ab2e702db77516758314900c3a 15-Nov-2016 Elliott Hughes <enh@google.com> Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for.

Bug: http://b/32878766
Test: boots
Change-Id: Ie0ddfb7e60f2da5f6eefbb10c83a92e88c137ae3
/system/core/init/devices.cpp
632e99a0d48823b6f73f89db105493bdd682e3b0 12-Nov-2016 Elliott Hughes <enh@google.com> Switch ueventd to sendfile(2).

Bug: http://b/32826495
Test: booted and checked dmesg
Change-Id: Idfd813dfe6f512fdbc05b1411c7960e950e2f59b
/system/core/init/devices.cpp
a285dac9c0b95a0351dfa98dde60c74a1445dc57 04-Oct-2016 Wei Wang <wvw@google.com> Modify log level for service and ueventd

Bug: 31938558
Test: flash and take a boot log
Change-Id: I5c6823614e1df760128519dfb294f3a44efa6bac
/system/core/init/devices.cpp
f39f7f14281c1b98524c740cd8f50905da86cdb9 31-Aug-2016 Elliott Hughes <enh@google.com> Use android::base::Readlink in init.

Bug: http://b/30988271
Change-Id: Ia0000e9dd7883c31ccbd54fc01bf585c3f8b3fa7
/system/core/init/devices.cpp
99c4a8a6b3852c33828b03cbd0aef0c625957a39 01-Feb-2016 Hung-ying Tyan <tyanh@google.com> Mount /vendor and /odm early

Right now these two partitions are mounted in the fs stage of the init
process. As a result, many vendor/ODM files needed earlier in the boot
process (e.g., init.<hardware>.rc, fstab.<hardware>.rc,
uevent.<hardware>.rc, SELinux policy files etc) can only live on the root
partition.

To prevent vendors/ODMs from polluting the root partition, this patch makes
it possible to mount the vendor and ODM partitions in the first stage of the
init process. The fstab info of both partitions to be mounted early is
composed from new kernel cmdline arguments android.early.prefix and
android.early.fstab.

For example, with:
android.early.prefix=/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/
android.early.fstab=mmcblk0p10+/odm+ext4+ro+verify\nmmcblk0p09+/vendor+ext4+ro+verify

the final fstab string will be:
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p10 /odm ext4 ro verify
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p09 /vendor ext4 ro verify

The android.early.prefix is optional. When it is missing, the final fstab
string will be directly converted from android.early.fstab.

This patch also makes sure that the early mounted partitions are dm-verity
enabled so that they are trust worthy to store system files.

BUG=27805372

Change-Id: I3cf32482a5ec65445ba3aedab2164c7ba8f12694
/system/core/init/devices.cpp
7eed474db429e88bcc6808a438ccc2cb18e210f6 28-Jul-2016 Dmitry Shmidt <dimitrysh@google.com> ueventd: Remove verbose restorecon_recursive: message

Bug: 30478300

Change-Id: Ife69bb5644c3f65f3a256dc042ae1c7fbfb77729
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
/system/core/init/devices.cpp
f86b5a6b90619e02d1d034ef7b0adc3b439f4abb 25-Jun-2016 Elliott Hughes <enh@google.com> Move init to libbase logging.

Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
/system/core/init/devices.cpp
397de1494f6b622292f474f7e174ddefb2220040 02-Jun-2016 William Roberts <william.c.roberts@intel.com> ueventd: only relabel devices if there's a delta

Since commit: 24a3cbfa732dc14c1a559f4ad79e1700fbae888f
ueventd is attempting to relabel devices on calls to
make_device() when the device already exists. However, it
should only be called if the contexts for relabelfrom and
relabelto are different.

When this condition occurs, one will see denials like this:

[ 14.409448] type=1400 audit(978307239.225:26): avc: denied { relabelfrom } for pid=1572 comm="ueventd" name="ttyS0" dev="tmpfs" ino=9613 scontext=u:r:ueventd:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1
[ 14.428107] type=1400 audit(978307239.225:27): avc: denied { relabelto } for pid=1572 comm="ueventd" name="ttyS0" dev="tmpfs" ino=9613 scontext=u:r:ueventd:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1

Bug: 29106809

Change-Id: I2105b169206f0b26420f3c4b0ba5c49aeb98da92
Signed-off-by: William Roberts <william.c.roberts@intel.com>
/system/core/init/devices.cpp
6de783af07bddaccfa75a08286425eeaef453ac9 06-May-2016 Rob Herring <robh@kernel.org> init: support matching sysfs class paths in ueventd.rc

Currently, ueventd.rc files only support /sys/devices/... paths
and don't support symlinked paths, specifically /sys/class/...
Supporting the class paths is necessary to have non-hardware
dependent paths. Some subsystems like IIO use /sys/bus/iio/, so
support that as well.

Change-Id: I29f3bf67b41664d1d75ac1820c46e13afe336d56
Signed-off-by: Rob Herring <robh@kernel.org>
/system/core/init/devices.cpp
e5636a3fcea9ee5e34f839aa72be5c507f6c93fa 06-May-2016 Rob Herring <robh@kernel.org> init: rework fixup_sys_perms to use perm_path_matches

fixup_sys_perms does the same matching as the function perm_path_matches
other than the leading '/sys'. Adjust the path and use the common
matching function. Replace the fixed length C strings with std::string.

Change-Id: Ic09d91aa4ac1f1096018617537d782b82ee9ef63
Signed-off-by: Rob Herring <robh@kernel.org>
/system/core/init/devices.cpp
24a3cbfa732dc14c1a559f4ad79e1700fbae888f 25-Apr-2016 Mihai Serban <mihai.serban@intel.com> ueventd: relabel block devices nodes when processing subsequent add events

There is a race in ueventd's coldboot procedure that permits creation
of device block nodes before platform devices are registered. This happens
when the kernel sends events for adding block devices during ueventd's
coldboot /sys walk.
In this case the device node links used to compute the SELinux context
are not known and the node is created under the generic context:
u:object_r:block_device:s0.
A second add event for block device nodes is triggered after the platform
devices are handled by ueventd and the SELinux context is correctly computed
but the mknod call fails because the node already exists. This patch handles
this error case and updates the node's security context.

The race is introduced by the uevent sent from the sdcard device probe
function. The issue appears when this uevent is triggered during ueventd's
coldboot procedure but before the /sys/devices recursive walk reached the
corresponding sdcard platform device path.
The backtrace looks something like:
1. ueventd_main()
2. device_init()
3. coldboot("/sys/devices");
4. do_coldboot()
5. handle_device_fd()
6. handle_device_event()
6.1 handle_block_device_event()
6.2 handle_platform_device_event()

Because handle_device_fd() reads all events from the netlink socket it may
handle the add events for the sdcard partition nodes send occasionally by the
kernel during coldboot /sys walk procedure.
If handle_device_event() continues with handle_block_device_event()
before handle_platform_device_event() registers the sdcard platform device then
handle_block_device_event() will create device nodes without knowing all block
device symlinks (get_block_device_symlinks()):
1. handle_device(path=/dev/block/mmcblk0p3, links = NULL)
2. make_device(path=/dev/block/mmcblk0p3, links = NULL)
3. selabel_lookup_best_match(path=/dev/block/mmcblk0p3, links = NULL)
returns the default context (u:object_r:block_device:s0) for
/dev/block/mmcblk0p3 instead of more specific context like:
u:object_r:boot_block_device:s0
4. setfscreatecon(u:object_r:block_device:s0)
5. mknod(/dev/block/mmcblk0p3)

So the node is create with the wrong context. Afterwards the coldboot /sys walk
continues and make_device() will be called with correct path and links.
But even if the secontext is computed correctly this time it will not be
applied to the device node because mknod() fails.
I see this issue randomly appearing (one time in 10 reboots) on a Minnoboard
Turbot with external sdcard as the boot device.

BUG=28388946

Change-Id: I96e239af29d82b753e5d349b3ecefaad09edee87
Signed-off-by: Mihai Serban <mihai.serban@intel.com>
/system/core/init/devices.cpp
60b976db85f009b39b0daad9389d675966aa25b8 28-Mar-2016 Dan Austin <danielaustin@google.com> Address const issues in preparation for libcxx rebase.

Change-Id: If9bf6c3ee57c3476a5661401853506551e2150cb
/system/core/init/devices.cpp
588a2cad7faee54bfb16050d0c7398709f304fea 18-Feb-2016 James Hawkins <jhawkins@google.com> system/core: Cleanup direct calls to opendir by containing in a
std::unique_ptr.

Bug: 26643633
Change-Id: Ia3491fdbff086558da694ae949cf08e4c89d0307
/system/core/init/devices.cpp
dc848566a17eb62109b0e682e8c62628e420ea19 28-Jan-2016 Biao Lu <biao.lu@intel.com> init: Fix load_firmware error

In function 'load_firmware', parameter 'buf' passed to 'write'
is wrong. To fix it, use android::base::WriteFully to replace.

Change-Id: I13f79bdc9be9e5eb669f6bd975535b1dce965ef0
Signed-off-by: Biao Lu <biao.lu@intel.com>
/system/core/init/devices.cpp
746d5cd66ae3c5c6ee422d45be08dcd4403b6d24 13-Jun-2015 Nick Kralevich <nnk@google.com> am a27dca0f: am 60c5a460: Merge "Remove calls to is_selinux_enabled()"

* commit 'a27dca0f7a5d6c1f79aaf213a6b26428e4ad855e':
Remove calls to is_selinux_enabled()
4d87095ebfefdb9e641492462f0a0e21d5b96ecf 13-Jun-2015 Nick Kralevich <nnk@google.com> Remove calls to is_selinux_enabled()

d34e407aeb5898f19d4f042b7558420bbb3a1817 removed support for
running with SELinux completely disabled. SELinux must either be
in permissive or enforcing mode now.

Remove unnecessary calls to is_selinux_enabled(). It always returns
true now.

Change-Id: Ife3156b74b13b2e590afe4accf716fc7776567e5
/system/core/init/devices.cpp
17560f8884a01f12ac3bea15246d10c4eea19638 24-Apr-2015 Tom Cherry <tomcherry@google.com> am 92b82635: am 10936d1f: Merge "init: consider all platform devices for find_platform_device"

* commit '92b826357692988407018c5754584ef2da9e390e':
init: consider all platform devices for find_platform_device
1225a61f0aec6bff340e84ac05bd77ba39151884 23-Apr-2015 Tom Cherry <tomcherry@google.com> init: consider all platform devices for find_platform_device

Certain platforms list their platform devices with a path other than
the current /devices or /devices/platform. Additionally, sometimes
these paths are a platform device themselves. An example are devices
with a path /devices/soc.0/... where /devices/soc.0 is also a platform
devices.

Instead of continuing to special case these path prefixes, we can
consider the entire path, given that no mmc or usb devices create
platform devices as subdevices, which they should not by their very
nature.

This keeps the symlinks for block devices named identically for
current platform devices and places them in /dev/block/<full path to
device> for devices in locations other than /devices or
/devices/platform, eg /dev/block/platform/soc.0/7824900.sdhci

This keeps the symlinks for character deviced named identically for
all cases.

Change-Id: Ifc8eedf1086db1826dbc8f7e96cdfcfa5da876b3
/system/core/init/devices.cpp
438443e742d9cfb91c1193144a3b41744ffad34b 14-Apr-2015 Ed Tam <etam@google.com> resolved conflicts for merge of 79f33846 to lmp-mr1-dev-plus-aosp

Change-Id: I24c60a2747931917a3ea09b953905ce0f4145280
56a0656ed91a01fdf09f9704a1f8a8aeb5d9f3b7 28-Mar-2015 Elliott Hughes <enh@google.com> Further cleanup of the logic in device_init.

Change-Id: I96e4b11894926b50792b9b7d7cfa0fe8392abef6
/system/core/init/devices.cpp
747383649c28198457aa2cbb5b93743fac837f06 28-Mar-2015 Elliott Hughes <enh@google.com> Fix clang build by removing unused locals.

Also don't manually set FD_CLOEXEC on a socket that's always opened
with SOCK_CLOEXEC. (None of the other callers to the function do this.)

Also move locals to where they're first used to help prevent more of this
kind of breakage.

Change-Id: I1ba7cd9400f53508dffb51a2bbf9d491ae647f26
/system/core/init/devices.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/devices.cpp
cd67f00e18de1c8d48ddb082ecb902fc42c2bacc 21-Mar-2015 Elliott Hughes <enh@google.com> Always use strerror to report errno.

Change-Id: Icd18e4bd7dc093c18967f45b99cd451359457b03
/system/core/init/devices.cpp
d1d9602f89f5c7c0307a1f55e66401173f48f07e 20-Mar-2015 Daniel Rosenberg <drosen@google.com> init: refactor firmware loading locations into table

Change-Id: I3ce8f9d237bf783335ae85540306aa539a8da568
Signed-off-by: Daniel Rosenberg <drosen@google.com>
/system/core/init/devices.cpp
e2d63af002a3b494f6bd464f2652b6e1997e7a52 18-Feb-2015 Yabin Cui <yabinc@google.com> Move sprintf to snprintf.

Bug: 19340053
Change-Id: Id0d866e6195ed4752b4be6081eeb2aab8b1dbe9a
/system/core/init/devices.cpp
f682b4786a4093efb23bf80d69bf80eb274b145b 06-Feb-2015 Elliott Hughes <enh@google.com> Clean up reading and writing in init.

This isn't particularly useful in and of itself, but it does introduce the
first (trivial) unit test, improves the documentation (including details
about how to debug init crashes), and made me aware of how unpleasant the
existing parser is.

I also fixed a bug in passing --- unless you thought the "peboot" and "pm"
commands were features...

Bug: 19217569
Change-Id: I6ab76129a543ce3ed3dab52ef2c638009874c3de
/system/core/init/devices.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/devices.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/devices.cpp