History log of /system/core/init/util.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
de6bd50d4238d19ec401127bcf2321dc679d908d 14-Feb-2018 Tom Cherry <tomcherry@google.com> init: add host side parser for init

Create a host side parser for init such that init rc files can be
verified for syntax correctness before being used on the device.

Bug: 36970783
Test: run the parser on init files on host

Change-Id: I7e8772e278ebaff727057308596ebacf28b6fdda
/system/core/init/util.h
d8db7ab80d8a79c89393fa0c4ab343e85312d8d5 18-Aug-2017 Tom Cherry <tomcherry@google.com> init: replace panic() with LOG(FATAL)

Test: boot bullhead
Test: Introduce LOG(FATAL) at various points of init and ensure that
it reboots to the bootloader successfully
Test: Introduce LOG(FATAL) during DoReboot() and ensure that it reboots
instead of recursing infinitely
Test: Ensure that fatal signals reboot to bootloader

Change-Id: I409005b6fab379df2d635e3e33d2df48a1a97df3
/system/core/init/util.h
11a3aeeae3dc887b889d4086d4d26d95c324c08d 03-Aug-2017 Tom Cherry <tomcherry@google.com> init: introduce Result<T> for return values and error handling

init tries to propagate error information up to build context before
logging errors. This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
U output;
std::string calculate_result_err;
if (!CalculateResult(input, &output, &calculate_result_err)) {
*err = "CalculateResult " + input + " failed: " +
calculate_result_err;
return false;
}
UseResult(output);
return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string. If the functional only returns success or a failure with
an error message, Result<Success> may be used. The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T. This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure. ErrnoError()
additionally appends ": " + strerror(errno) to the end of the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
auto output = CalculateResult(input);
if (!output) {
return Error() << "CalculateResult " << input << " failed: "
<< output.error();
}
UseResult(*output);
return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Merged-In: I1e7d3a8820a79362245041251057fbeed2f7979b
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
/system/core/init/util.h
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/util.h
c01022a62e6517b1e7ea7231305a0ab996bd2964 26-Jul-2017 Yu Ning <yu.ning@intel.com> Allow the use of a custom Android DT directory

On platforms that use ACPI instead of Device Tree (DT), such as
Ranchu x86/x86_64, /proc/device-tree/firmware/android/ does not
exist. As a result, Android O is unable to mount /system, etc.
at the first stage of init:

init: First stage mount skipped (missing/incompatible fstab in
device tree)

Those platforms may create another directory that mimics the layout
of the standard DT directory in procfs, and store early mount
configuration there. E.g., Ranchu x86/x86_64 creates one in sysfs
using information encoded in the ACPI tables:

https://android-review.googlesource.com/442472
https://android-review.googlesource.com/443432
https://android-review.googlesource.com/442393
https://android-review.googlesource.com/442395

Therefore, instead of hardcoding the Android DT path, load it from
the kernel command line using a new Android-specific property key
("androidboot.android_dt_dir"). If no such property exists, fall
back to the standard procfs path (so no change is needed for DT-
aware platforms).

Note that init/ and fs_mgr/ each have their own copy of the Android
DT path, because they do not share any global state. A future CL
should remove the duplication by refactoring.

With this CL as well as the above ones, the said warning is gone,
but early mount fails. That is a separate bug, though, and will be
addressed by another CL.

Test: Boot patched sdk_phone_x86-userdebug system image with patched
Goldfish 3.18 x86 kernel in patched Android Emulator, verify
the "init: First stage mount skipped" warning no longer shows
in dmesg.

Change-Id: Ib6df577319503ec1ca778de2b5458cc72ce07415
Signed-off-by: Yu Ning <yu.ning@intel.com>
/system/core/init/util.h
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/util.h
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/util.h
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/util.h
b066fccc5c977f3e464676d58a7fa550d368f426 05-May-2017 Mark Salyzyn <salyzyn@google.com> init: add "+passcred" for socket to set SO_PASSCRED

In the init scripts for socket, the type can have a suffix of
"+passcred" to request that the socket be bound to report SO_PASSCRED
credentials as part of socket transactions.

Test: gTest logd-unit-tests --gtest_filter=logd.statistics right after boot
(fails without logd.rc change)
Bug: 37985222
Change-Id: Ie5b50e99fb92fa9bec9a32463a0e6df26a968bfd
/system/core/init/util.h
2cbbe9f7a35efdc94e8e34ef92eb6f70a85887fe 05-May-2017 Tom Cherry <tomcherry@google.com> init: do not log directly from read_file() and write_file()

Their callers may be able to add more context, so use an error string
to record the error.

Bug: 38038887
Test: boot bullhead
Test: Init unit tests
Change-Id: I46690d1c66e00a4b15cadc6fd0d6b50e990388c3
/system/core/init/util.h
517e1f17cfec2143d4d10a64b1496a550acf3ea2 05-May-2017 Tom Cherry <tomcherry@google.com> init: Check DecodeUid() result and use error string

Check the result of DecodeUid() and return failure when uids/gids are
unable to be decoded.

Also, use an error string instead of logging directly such that more
context can be added when decoding fails.

Bug: 38038887
Test: Boot bullhead
Test: Init unit tests
Change-Id: I84c11aa5a8041bf5d2f754ee9af748344b789b37
/system/core/init/util.h
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/util.h
d262017fef0761e6cf6d1e449fa088338cdc68e6 17-Apr-2017 Bowgo Tsai <bowgotsai@google.com> init: moving early mount logic into init_first_stage.cpp

Also renames "early mount" to "first stage mount" to prevent confusion
with "mount_all --early", which is run in the init second stage.

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

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

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

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

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

Bug: 37413399
Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead
Test: first stage mount /system with without verity on bullhead
Test: first stage mount /vendor with with vboot 1.0 on sailfish
Change-Id: I6584bdf7d832c9fbc8740f97c9b8b94e68a90783
/system/core/init/util.h
060b74baad7c366cb6c74042bf307f1548a8331f 12-Apr-2017 Tom Cherry <tomcherry@google.com> ueventd: convert mkdir_recursive() to std::string

Bug: 36250207

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

Change-Id: I5a2ac369d846e044230b709fd07eb21ad12d47bb
/system/core/init/util.h
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/util.h
53089aa25ca9707e22e45e862f794bfc958d302a 01-Apr-2017 Tom Cherry <tomcherry@google.com> init: Use std::string for write_file()

The content parameter of write_file() previously took a char* that was
then converted to a std::string in WriteStringToFd(). One unfortunate
effect of this, is that it is impossible to write data that contains
'\0' within it, as the new string will only contain characters up
until the '\0'.

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

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

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

Bug: 36726045
Test: Boot bullhead, run unit tests
Change-Id: Idad60e4228ee2de741ab3ab6a4917065b5e63cd8
/system/core/init/util.h
e78ea77f6992013b16fd57c07548b53129cdd12f 24-Mar-2017 James Hawkins <jhawkins@google.com> bootstat: Refactor init/utils/boot_clock into base/chrono_utils.

Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/338325 with a stubbed implementation for Darwin.

This change also has clang_format fixes (automatic).

Bug: 34352037
Test: chrono_utils_test
Change-Id: I72a62a3ca1ccfc0a4ccc6294ff1776c263144686
/system/core/init/util.h
8d01f63f50fb001f41835a0dab636981f2ba76dd 13-Mar-2017 Keun-young Park <keunyoung@google.com> remove emergency shutdown and improve init's reboot logic

- Emergency shutdown just marks the fs as clean while leaving fs
in the middle of any state. Do not use it anymore.

- Changed android_reboot to set sys.powerctl property so that
all shutdown can be done by init.

- Normal reboot sequence changed to
1. Terminate processes (give time to clean up). And wait for
completion based on ro.build.shutdown_timeout.
Default value (when not set) is changed to 3 secs. If it is 0, do not
terminate processes.
2. Kill all remaining services except critical services for shutdown.
3. Shutdown vold using "vdc volume shutdown"
4. umount all emulated partitions. If it fails, just detach.
Wait in step 5 can handle it.
5. Try umounting R/W block devices for up to max timeout.
If it fails, try DETACH.
If umount fails to complete before reboot, it can be detected when
system reboots.
6. Reboot

- Log shutdown time and umount stat to log so that it can be collected after reboot

- To umount emulated partitions, all pending writes inside kernel should
be completed.
- To umount /data partition, all emulated partitions on top of /data should
be umounted and all pending writes should be completed.
- umount retry will only wait up to timeout. If there are too many pending
writes, reboot will discard them and e2fsck after reboot will fix any file system
issues.

bug: 36004738
bug: 32246772

Test: many reboots combining reboot from UI and adb reboot. Check last_kmsg and
fs_stat after reboot.

Change-Id: I6e74d6c68a21e76e08cc0438573d1586fd9aaee2
/system/core/init/util.h
c8ac0677734270f0b12d85ecf23b1de49054890c 14-Feb-2017 James Hawkins <jhawkins@google.com> Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."

This reverts commit 7c92e484503f239000ef97ef5b067907fbeaa4a6.

Mac sdk still broken (despite testing locally).

Change-Id: I7d9206e15997cd0efe081bd3fa17d53d2b20ec32
/system/core/init/util.h
7c92e484503f239000ef97ef5b067907fbeaa4a6 14-Feb-2017 James Hawkins <jhawkins@google.com> bootstat: Refactor init/utils/boot_clock into base/chrono_utils.

Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/332854 with a fix for Darwin.

Bug: 34352037
Test: chrono_utils_test
Change-Id: Ib2567d8df0e460ab59753ac1c053dd7f9f1008a7
/system/core/init/util.h
0e3167e203ae89817cc30ba4a5a2d328716b4826 08-Feb-2017 James Hawkins <jhawkins@google.com> Revert "bootstat: Remove custom uptime parser in favor of elapsedRealtime."

This reverts commit 26f40c04c3ad80e2bc449990010d39d1c1b9a5f0.

This change broke the Darwin SDK target.

Test: none
Change-Id: Ia54fe2c31da8d8fa2825e023b035fb8321dcd457
/system/core/init/util.h
26f40c04c3ad80e2bc449990010d39d1c1b9a5f0 06-Feb-2017 James Hawkins <jhawkins@google.com> bootstat: Remove custom uptime parser in favor of elapsedRealtime.

Refactored init/utils/boot_clock into base/chrono_utils.

Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
/system/core/init/util.h
27c052263c827150b1d371c72abee5974c000ac2 26-Jan-2017 James Hawkins <jhawkins@google.com> boottime/init: Report ro.boottime.init* properties in milliseconds.

* Nanosecond precision ended up being harder to grok.
* This change modifies the Timer class to have duration_ms instead of
duration_ns.

Bug: 34466121
Test: adb logcat | grep bootstat
Change-Id: Ibd1c27dc3cb29d838a956e342281b2fb98d752a6
/system/core/init/util.h
77f0e9fda8839a21a4d360f128fe9af820b8819c 28-Dec-2016 Jorge Lucangeli Obes <jorgelo@google.com> init: Make 'write_file' return bool to match 'read_file'.

The mismatch of return values makes reasoning about the correctness of
CLs like https://android-review.googlesource.com/317923 quite hard.

Bug: 33941660
Test: Init builds, HiKey boots.
Change-Id: Ia4b8a9af420682997b154a594892740181980921
/system/core/init/util.h
978fd0ea254f11f84e38b41a74bbe70c81edc197 02-Dec-2016 Mark Salyzyn <salyzyn@google.com> init: service file command only opens existing files

Mixing open or create, along with attribute(MAC) and permissions(DAC)
is a security and confusion issue.

Fix an issue where fcntl F_SETFD was called to clear O_NONBLOCK, when
it should have been F_SETFL. Did not present a problem because the
current user of this feature does writes and control messages only.

Test: gTest logd-unit-tests and check dmesg for logd content.
Bug: 32450474
Bug: 33242020
Change-Id: I23cb9a9be5ddb7e8e9c58c79838bc07536e766e6
/system/core/init/util.h
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/util.h
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/util.h
d1d3bdd16fbaae87e0cfdb8d412f226e4aa390cf 16-Jul-2016 Jeff Sharkey <jsharkey@android.com> Only restorecon CE storage after unlocked.

On FBE devices, the filenames inside credential-encrypted directories
are mangled until the key is installed. This means the initial
restorecon at boot needs to skip these directories until the keys
are installed.

This CL changes the implementation of the "restorecon_recursive"
built-in command to use the new SKIPCE flag to avoid labeling files
in CE directories. vold will request a restorecon when the keys
are actually installed.

(cherrypicked from commit 1635afe83d1ebd6b5f1fac1e9c6c6b5cd1c93204)

Bug: 30126557
Test: Cherry-picked from master
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
/system/core/init/util.h
9605a945f7a497c0307b512b9cd762f2d23973ca 11-Nov-2016 Elliott Hughes <enh@google.com> init start time tracking.

With this change, init sets a property "init.start" to show the
CLOCK_BOOTTIME time at which init itself started, and for each service
an "init.svc.<name>.start" property to show the CLOCK_BOOTTIME time at
which that service was most recently started.

These times can be used by tools like bootstat to track boot time.

As part of this change, move init over to std::chrono. Also, rather than
make the command-line argument handling more complex, I've switched to
using an environment variable for communication between first- and
second-stage init, and added another environment variable to pass the
start time of the first stage through to the second stage.

Bug: http://b/32780225
Test: manual
Change-Id: Ia65a623e1866ea688b9a5433d6507926ce301dfe
/system/core/init/util.h
62767fe29f8aaf62470781a3cf419ba11187d178 27-Oct-2016 Mark Salyzyn <salyzyn@google.com> init: service file keyword

Solve one more issue where privilege is required to open a file and
we do not want to grant such to the service. This is the service side
of the picture, android_get_control_file() in libcutils is the client.
The file's descriptor is placed into the environment as
"ANDROID_FILE_<path>". For socket and files where non-alpha and
non-numeric characters in the <name/path> are replaced with _. There
was an accompanying change in android_get_control_socket() to match
in commit 'libcutils: add android_get_control_socket() test'

Add a gTest unit test for this that tests create_file and
android_get_control_file().

Test: gTest init_tests --gtest_filter=util.create_file
Bug: 32450474
Change-Id: I96eb970c707db6d51a9885873329ba1cb1f23140
/system/core/init/util.h
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/util.h
8f7b9e3d39cdae8363816aa7bcbab0d79fd70cea 28-Jul-2016 Chih-Hung Hsieh <chh@google.com> Fix clang-tidy performance warnings in syste/core.

* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
/system/core/init/util.h
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/util.h
f86b5a6b90619e02d1d034ef7b0adc3b439f4abb 25-Jun-2016 Elliott Hughes <enh@google.com> Move init to libbase logging.

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

Bug: http://b/29250988
Change-Id: I38ab263192944e4ff291fd91b25db163a8848d75
/system/core/init/util.h
cdb2ca5d9f4fe4c3ac1d930394f088aed5d944ac 10-Jun-2016 Chih-Hung Hsieh <chh@google.com> Fix misc-macro-parentheses warnings in system/core.

Add parentheses around macro arguments used beside operators.
Bug: 28705665

Change-Id: I9226f319e283be640eddc31687f75b51a8ef0ac6
/system/core/init/util.h
cda81d01c6d8df84c67e5a2391356bb8407921dc 01-Sep-2015 Tom Cherry <tomcherry@google.com> am 54c70ca1: Merge "init: Use classes for parsing and clean up memory allocations"

* commit '54c70ca15660529466b5b4e091209a20a3e75dff':
init: Use classes for parsing and clean up memory allocations
b7349902a945903f9e36a569051f5131beb0bc24 26-Aug-2015 Tom Cherry <tomcherry@google.com> init: Use classes for parsing and clean up memory allocations

Create a Parser class that uses multiple SectionParser interfaces to
handle parsing the different sections of an init rc.

Create an ActionParser and ServiceParser that implement SectionParser
and parse the sections corresponding to Action and Service
classes.

Remove the legacy keyword structure and replace it with std::map's
that map keyword -> (minimum args, maximum args, function pointer) for
Commands and Service Options.

Create an ImportParser that implements SectionParser and handles the
import 'section'.

Clean up the unsafe memory handling of the Action class by using
std::unique_ptr.

Change-Id: Ic5ea5510cb956dbc3f78745a35096ca7d6da7085
/system/core/init/util.h
42f669a144e2b92ff7473f802af66cd65dfd2a68 28-Jul-2015 Lee Campbell <leecam@google.com> am f75b5ff1: am fe39394e: Merge "init: Adding support to import directories"

* commit 'f75b5ff17529e3eb163b9c7c49fc49842d443126':
init: Adding support to import directories
f13b1b31399aa501514eb9beeef303d1ae2e0e14 25-Jul-2015 Lee Campbell <leecam@google.com> init: Adding support to import directories

Support added so init scripts can now import directories.

BUG: 22721249
Change-Id: I02b566bfb50ea84469f1ea0c6ad205435a1df286
TEST: Tested importing a folder on arm64 emulator
/system/core/init/util.h
b7f8b91040cc0910ca12b51ad7318515595705af 09-May-2015 Andres Morales <anmorales@google.com> am 86aeb11e: Merge "load ro.recovery_id property from recovery partition" into mnc-dev

* commit '86aeb11ed047b3698948c4eee8fbaccd20131ecb':
load ro.recovery_id property from recovery partition
cb3fce80fafa2848fd4962d9f242c21eef3d82f9 08-May-2015 Andres Morales <anmorales@google.com> load ro.recovery_id property from recovery partition

Change-Id: I9dc1f325e353375d9c1c8ed949636e2404601076
(cherry picked from commit db5f5d43679546ecde2b85151c0a8b8ccd605b07)
/system/core/init/util.h
db5f5d43679546ecde2b85151c0a8b8ccd605b07 08-May-2015 Andres Morales <anmorales@google.com> load ro.recovery_id property from recovery partition

Change-Id: I9dc1f325e353375d9c1c8ed949636e2404601076
/system/core/init/util.h
fdf2546ae7f5a58a0f846acd17c943cd9a2dadd8 07-May-2015 Elliott Hughes <enh@google.com> am a5aa7a11: am 55c2e1f4: Merge "Clean up init /proc/cmdline handling."

* commit 'a5aa7a11266f1d407275b78981fc864c6c863358':
Clean up init /proc/cmdline handling.
e5ce30fed81d1918a259be092dcd8bfffc3c2649 07-May-2015 Elliott Hughes <enh@google.com> Clean up init /proc/cmdline handling.

Helped debug a problem where the N9 bootloader incorrectly
concatenated the various command lines.

Bug: http://b/20906691
Change-Id: I0580b06f4185129c7eedf0bdf74b5ce17f88bf9c
/system/core/init/util.h
eab1e21996884fb1918e696efd21c175d96f6195 27-Apr-2015 Nick Kralevich <nnk@google.com> am ecf184c9: am 9c9280d8: Merge "init: get rid of the remaining double mounts"

* commit 'ecf184c901b78994773d687763c1478752e9375e':
init: get rid of the remaining double mounts
ada332e4a01a3bb290be26f8a5b67993bd10af14 26-Apr-2015 Nick Kralevich <nnk@google.com> am ecf184c9: am 9c9280d8: Merge "init: get rid of the remaining double mounts"

* commit 'ecf184c901b78994773d687763c1478752e9375e':
init: get rid of the remaining double mounts
f667a3247a7e814355feedbc08c6bbc92a9409b5 26-Apr-2015 Nick Kralevich <nnk@google.com> init: get rid of the remaining double mounts

Don't double mount /dev and its subdirectories anymore. Instead, the
first stage init is solely responsible for mounting it.

Don't have init prepare the property space. This is the responsibility
of the second stage init.

Don't have SELinux use the property space to determine how we should
be running. Instead, create a new function and extract the data we
need directly from /proc/cmdline. SELinux needs this information in
the first stage init process where the property service isn't available.

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

Change-Id: I24c60a2747931917a3ea09b953905ce0f4145280
79f338465213885900cea5a39f3aeeea083bbe51 05-Sep-2013 Chris Fries <cfries@motorola.com> fs_mgr: introduce fs_mgr_format to format wiped partitions

Move fastboot's format logic into fs_mgr, to consolidate the knowledge
about how to do this (and when to wipe metadata).

Try to format these formattable paritions if they are wiped.

If formatting fails, we will fall out to let recovery mode handle it.

Bug: 20082763
Change-Id: I397cc197550e78d932e8a154fd234695c46dbe7b
/system/core/init/util.h
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/util.h
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/util.h
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/util.h
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/util.h
a016c42b4f7122625a417929afa0e9379ffa4887 25-Nov-2014 Andreas Gampe <agampe@google.com> Init: Remove unused variables

For build-system CFLAGS clean-up, fix unused variables.

Use a #define instead of static variable in a header file.

Change-Id: Id47bf38e51644b61a9f3ac1893a16553695f1aac
/system/core/init/util.h
ae76f6dbcf3dfd6eda223911f91f4a1316433771 12-Jul-2013 Nick Kralevich <nnk@google.com> init: call restorecon on /sys

Not all files on /sys are not getting labeled properly. Fix them.

Change-Id: I9dcff76354e7f50d41f1b6e702836cfbbc149278
/system/core/init/util.h
b69f863455261a656da02343e8b9d55110ecd45f 24-Aug-2013 Colin Cross <ccross@android.com> am 0cbaed42: am a8ba1f2f: Merge "Add support for socket security context specification."

* commit '0cbaed4211b514dd2aaa4d28f8936ba58e83c6a5':
Add support for socket security context specification.
8348d279c7ce1a2453965ba7f05a7b818d58886c 13-May-2013 Stephen Smalley <sds@tycho.nsa.gov> Add support for socket security context specification.

Add an optional argument to the socket option for specifying
a SELinux security context for the socket. Normally the socket
security context is automatically computed from the service security
context or set using the seclabel option, but this facility allows
dealing with two scenarios that cannot be addressed using the existing
mechanisms:
1) Use of logwrapper to wrap a service.
In this case, init cannot determine the service security context
as it does not directly execute it and we do not want logwrapper
to run in the same domain as the service.

2) Situations where a service has multiple sockets and we want to
label them distinctly.

Change-Id: I7ae9088c326a2140e56a8044bfb21a91505aea11
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
/system/core/init/util.h
f29c533c49ab1c90eae612b1c454f2c6879a6658 12-Jul-2013 Nick Kralevich <nnk@google.com> init: call restorecon on /sys

Not all files on /sys are not getting labeled properly. Fix them.

Change-Id: I9dcff76354e7f50d41f1b6e702836cfbbc149278
/system/core/init/util.h
e096e36e50b4b66638ebc4d3c09c2ee35f538dfa 11-Jun-2012 Stephen Smalley <sds@tycho.nsa.gov> Set the SELinux security label on new directories.

Automatically set the SELinux security label on directories created
by init.rc. This avoids the need to separately call restorecon on
each such directory from the init.rc file. Also restorecon /dev
and /dev/socket after initial policy load so that they are labeled
correctly before any other dev nodes or sockets are created.

Change-Id: If6af6c4887cdead949737cebdd673957e9273ead
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
/system/core/init/util.h
2b99543cef1b8b0aa8cca39544939910035117b0 28-Sep-2011 Vladimir Chtchetkine <vchtchetkine@google.com> Pick up on androidboot.hardware kernel cmd option

x86 emulator passes hardware name through the androidboot.hardware kernel cmd option, and
ueventd must pick up on it to locate proper ueventd.rc file for that hardware.

Change-Id: Id61c5b67fe6275a15c7aa62556e0b89eda7968f8
/system/core/init/util.h
44b65d047cc39baf30e21bfd8dd438f6bc1f77f5 20-Apr-2010 Colin Cross <ccross@android.com> init: Add ueventd.rc parsing to ueventd

Change-Id: Iea53050d6c10e8cabf563e5d80e84eaf78873695
/system/core/init/util.h
f83d0b9af5cbe4440cc41ceaa8a7806a13c86282 21-Apr-2010 Colin Cross <ccross@android.com> init: Move uevent handling to an external ueventd process

Change-Id: Iea6c56013062ade633a1754f7bcf8cf09b3dedc1
/system/core/init/util.h
cd0f173e2790ee068fd2a20bcfc6c20468e97e51 20-Apr-2010 Colin Cross <ccross@android.com> init: Add wait command and mount wait flag

Change-Id: I6b4c10f8f246095a7fb7342388ec4f6ff97d5733
/system/core/init/util.h
b0ab94b7d5a888f0b6920b156e5c6a075fa0741a 09-Apr-2010 Colin Cross <ccross@android.com> init: create symlinks to block device nodes

eMMC block device names may change based on the detection order of
the eMMC device and any other SD bus devices, such as a removable SD
card.

This patch adds support to init for:
* Symlinks to block devices. When a block device uevent is
processed, if it starts with "/devices/platform", the platform
driver name is parsed out, and symlinks to the block device are
created in /dev/block/platform/<platform driver>/
* Symlinks based on partition name and number. If the uevent for
a block device contains information on the partition name or
number, symlinks are created under
/dev/block/platform/<platform driver>/by-num/p<partition>
and
/dev/block/platform/<platform driver>/by-name/<partition name>

init.rc can then use a device path like the following to mount an
eMMC device:
/dev/block/platform/<platform>/by-name/system /system ro

Change-Id: Id11bb7cdf1e2ada7752a5bd671cbf87237b34ae2
/system/core/init/util.h
3899e9fc01cf608f19f716749c54cc5c4d17e766 14-Apr-2010 Colin Cross <ccross@android.com> init: Move prototypes for util.c into util.h

Change-Id: I46a91849ce5297eb2597dd6134412f817564ec24
/system/core/init/util.h