summaryrefslogtreecommitdiffstats
path: root/init/init.cpp
Commit message (Collapse)AuthorAgeFilesLines
* init: Fix possible open file pointerMichael W2016-11-131-1/+3
| | | | | | | In error case the file is not closed properly. Add close() before return Change-Id: Ie1755987859a576045c786105404957d94f0b39d
* Revert "Revert "init: Temporarily increase coldboot timeout to 5s""Gabriele M2016-04-111-1/+1
| | | | | | | | | 1 second might not be enough for some devices to complete the coldboot phase, so bring the timeout back to 5 seconds. This reverts commit c9e804ffd8d4108806eb8162fe7cf35f179b0596. Change-Id: If10cd4bb1ea66d1c98cdd16f5bfbdae7a04b52e8
* Add vendor hook to handle_control_messageAaron Kling2016-01-011-0/+4
| | | | | | | | | | | | This is needed for Nvidia Shield devices to handle a 'restart consolemode' request from a blobbed stock app. The vendor function is expected to return non-0 if it did not handle the message and 0 if it did (or wants it ignored). Forward port of 119414. Change-Id: Ia8e4ba0bbf561f29f72862cd986f1660d7b501da
* init: Allow targets to ignore the ro.revision propertyChristopher N. Hesse2015-11-291-0/+2
| | | | Change-Id: I789879cde2797474b9303fd5bbf10d4760e6b822
* init: fix logic for determining charger modeDan Pasanen2015-11-071-1/+1
| | | | Change-Id: Ib4dd630b760303f26c794997aee3a5920cbeaaf5
* init: Bring back support for arbitrary chargermode cmdlinesRicardo Cerqueira2015-11-071-1/+10
| | | | | | | | This was accidentally removed while debugging the init breakage fixed in change I8ef5c932efcd5e7f8d6f6fce0915683d84c3ee11. Put it back Change-Id: Iaacc30abff0bcd9fa49f98b158b293fa363d9ea3
* init: Allow devices to use user-space tools to set ro.serialnoChristopher R. Palmer2015-11-071-0/+2
| | | | | | | | | | | | | | | CUrrently, init will always set a ro.serialno value which means that the kernel is the only option for configuring the serial number. The zenfone2 stores the serial number in a file-system that is mounted during the boot process and provides tools that pull the factory configuration from there. To support this, we need to allow init to opt-out of setting the serial number for us. Change-Id: I9c307d91bb8d3cb1c881213dd28e4f76e6eae14f
* init: add detection of charging modePawit Pornkitprasan2015-11-051-1/+20
| | | | | | | | | | | | | | | | | | Based on Prashant Somashekar's patch which is in turn based on techomancer's patch http://goo.gl/I19GG. When BOARD_CHARGING_MODE_BOOTING_LPM is set, init will read that value (usually from /sys) and enable charging mode when set to 1. This differs from the original patch in that Samsung-specific lpm.rc is not loaded, but instead, init.rc is loaded using the "charger" class, which is how AOSP devices handle charging. The change is because the either the SELinux or the init.rc changes is causing lpm.rc to not work, and porting lpm.rc to the Android system is easier than trying to fix it. Change-Id: Ice7a074da7e982f9a64aaa97de28bfcbccdc8b91
* Revert "init: Temporarily increase coldboot timeout to 5s"David Ng2015-10-061-1/+1
| | | | | | | Increased coldboot timeout delay is no longer needed; revert. This reverts commit 4b6578901b4a9f4d3306d83ee1fefb80f95226a9. Change-Id: I3afaec458b5f7d05e5cefbd8e8fcd72d87270fe7
* init: Add support for fast factory boot mode(ffbm)Ameya Thakur2015-10-061-0/+3
| | | | | | | We now boot into ffbm mode based on the value of the ro.bootmode property. Change-Id: Id1cd3d13182479cc9272bb4b3fb74a99083a3cff
* init: Temporarily increase coldboot timeout to 5sDavid Ng2015-10-061-1/+1
| | | | | | | | | | Temporarily increase coldboot timeout to 5s to account for slower initialization during new hardware bring-up. This change will need to be reverted once the bring-up process is complete. Change-Id: I8816ed909b8758274078f15f1d8bc420098b57bf
* init support for cgroups.Elliott Hughes2015-06-171-0/+10
| | | | | | | | | | This adds the "writepid" option that instructs init to write the child's pid to the given filenames (such as /dev/cpuctl/bg_non_interactive/cgroup.procs and/or /dev/cpuset/foreground/cgroup.procs). Bug: http://b/21163745 Change-Id: I121bb22aa208bc99c4fb334eb552fdd5bcc47c1a (cherry picked from commit d62f0608d9d67bf647cf15debbd163e84584fe44)
* init: change exec parsing to make SECLABEL optionalMark Salyzyn2015-06-021-1/+2
| | | | | | | | (cherry pick from commit 17fff893c04971b519d25d52b07f51111353cba5) Allow SECLABEL to be - to denote default Change-Id: I58cdc6c805dc6e50dc42b7e13e72d0eaf4864f11
* Reduce the coldboot timeout to 1s.Elliott Hughes2015-05-151-1/+4
| | | | | | | | | | | | | | 5s was already a ridiculously long time to delay booting, and some OEMs are trying to make it even more insane: https://www.codeaurora.org/cgit/quic/la/platform/system/core/commit/?h=lp&id=fd23edd48272976d2fb333f377242173f92aa343 Let's at least ensure that Nexus and Android One devices don't take forever to boot... Bug: http://b/19899875 Change-Id: I9680c166a759360f34118e51cd0645e12b6bd5c8 (cherry picked from commit c7331d02d1c6b1e51b3a1210506f38fd61819495)
* init: get rid of the remaining double mountsNick Kralevich2015-04-251-40/+45
| | | | | | | | | | | | | | | 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
* Merge "init: don't double mount /proc and /sys"Nick Kralevich2015-04-251-3/+8
|\
| * init: don't double mount /proc and /sysNick Kralevich2015-04-251-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | The first stage init mounts /proc and /sys, and then the second stage init also mounts /proc and /sys on top of the existing mount. Only mount these two directories once, in the first stage init. Not yet fixed: the double mounting of /dev. Removing the double mounting doesn't work right now because both init stages are trying to create a property space, and if the double mount of /dev goes away, the property service in the second stage init fails to work. Change-Id: I13719027a47526d074390c2b1a605ad99fb43a8f
* | init: fix write_file checkreqprot logic errorNick Kralevich2015-04-251-6/+4
|/ | | | | | | | | write_file() returned -errno on error, not -1. Callers who check for -1 would falsely believe that the write was successful when it wasn't. Fixup write_file so that it return -1 on error consistent with other functions. Change-Id: Ic51aaf8678d8d97b2606bd171f11b3b11f642e39
* init: remove mkdir /dev /proc /sysNick Kralevich2015-04-251-4/+0
| | | | | | | These directories are already present in the initial ramdisk, and these mkdir calls are no-ops. Change-Id: I528f9e96a3471de904845a2f9e09c1b6ff83a708
* Switch init to epoll.Elliott Hughes2015-04-241-35/+25
| | | | | | | | | | | Not just because it's what the cool kids are doing --- it also lets us simplify the inner loop and decouple it from whatever systems want to be woken to perform some activity if there's data to be read on some fd. Currently this is just used to clean up the existing signal handling, keychord, and property service code. Change-Id: I4d7541a2c4386957ad877df69e3be08b96a7dec5
* Clean up property service initialization.Elliott Hughes2015-04-241-36/+20
| | | | | | | | | | | All the code that was being delayed does is create a socket. We can do that straight away, avoid the overhead, and simplify our main loop. The keychord fd, on the other hand, seems a little tricky. It looks like /dev/keychord isn't immediately available, at least not on N9; we have to wait for ueventd to set us up the bomb. Change-Id: I020e75b8e4b233497707f0a3cbbb6038b714161f
* Clean up init signal handling a little.Elliott Hughes2015-04-241-21/+3
| | | | | | | We can set it up earlier, and error reporting like this helped me find the SELinux problem with the last change to this code. Change-Id: If0f38bc5ff0465c4030e2d39d34f31f49b2d8487
* Merge "Setup signal handler before any exec command"Elliott Hughes2015-04-251-1/+3
|\
| * Setup signal handler before any exec commandJohan Redestig2015-04-181-1/+3
| | | | | | | | | | | | | | | | | | | | | | Fixes init deadlock when an exec command was called in an on-init section. The exec command handling relies on that the signal handler mechanism is working to know when to continue executing commands. Change-Id: Ib0ce75ffad7cf3bf926c93d0506b2fe3e5a92630
* | Revert "Revert "Make init re-exec itself for its SELinux domain transition.""Elliott Hughes2015-04-241-14/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4217374611ada50f33aee544f015f6f9dfbf7ced. It turns out that the kernel passes any unrecognized arguments on to init, and (at least) N6 and N9 have such arguments. My lazy check of argc was thus insufficient to recognize what stage of init we were in, so we'd skip to stage 2 and not set up SELinux. And apparently you can get a very long way with SELinux off... We'll fix that in a later change. Bug: 19702273 Change-Id: I43b3fb722fed35dd217cb529cbcac9a29aff4e4b
* | Revert "Make init re-exec itself for its SELinux domain transition."Nick Kralevich2015-04-241-45/+14
| | | | | | | | | | | | | | | | shamu isn't booting. This reverts commit adf0d1bbfa4bc560c2106f14afa8258a11c48bf6. Change-Id: I89d568838cebbe14cc4a8ae3843f0f1ac54987af
* | Make init re-exec itself for its SELinux domain transition.Elliott Hughes2015-04-231-14/+45
|/ | | | Change-Id: I38adabe5789d671e3f7d21936071a758ec8cea8a
* Log more timing information from init.Elliott Hughes2015-03-281-55/+47
| | | | | | | | | | | | | | | | | 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
* Clean up property setting code.Elliott Hughes2015-03-201-3/+1
| | | | | | In particular, ensure that all property_set failures are reported. Change-Id: Iab94a28bcba2346868c0f39bcfe26e55a2c55562
* Lose bootmode and console globals.Elliott Hughes2015-03-201-42/+17
| | | | | | | Also remove some code marked "TODO: these are obsolete. We should delete them". Change-Id: I6255cee4cb6680bfcbc5b46366990309cba95037
* Parse boot properties from device treeRom Lemarchand2015-03-191-5/+48
| | | | | | | | | - Make sure compatible DT node is "android,firmware" - Set ro.boot.* properties from firmware/android/ DT node (cherry-pick of cbcbea27c70846a96f4bba2f7cb245f937de4d3f.) Change-Id: If3d0716831516cb3d3fde1f75d57e2691d42d054
* Merge "Remove /proc/cpuinfo parsing"Elliott Hughes2015-03-191-14/+2
|\
| * Remove /proc/cpuinfo parsingRom Lemarchand2015-03-141-14/+2
| | | | | | | | | | | | | | | | | | | | - 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
* | Remove useless memset from init.Elliott Hughes2015-03-181-1/+0
| | | | | | | | Change-Id: Ia880810bb2c9a976dceeb0ffdba0cb98e69e3c6d
* | Switch init over to _PATH_DEFPATH.Elliott Hughes2015-03-171-0/+3
|/ | | | | Bug: 19564110 Change-Id: I343b4a360b10319dca13ab01f2d411ff940e9052
* Fix a printf format string (caught by clang but not GCC).Elliott Hughes2015-03-111-1/+1
| | | | Change-Id: I665756615eef74b05ef92f5865d910f29ead0695
* Implement exec.Elliott Hughes2015-02-251-92/+94
| | | | Change-Id: I20329bc9b378479d745b498d6a00eca0872cd5ab
* Move sprintf to snprintf.Yabin Cui2015-02-171-1/+1
| | | | | Bug: 19340053 Change-Id: Id0d866e6195ed4752b4be6081eeb2aab8b1dbe9a
* bootchart: fix bootchart can not be triggered problemYongqin Liu2015-02-121-60/+12
| | | | | | | | | | | | | | | | | bootchart uses a file on the data partition to decide if it should collect data for bootchart, but the data partition will be mounted by the mount_all command in the "on fs" section, and it will be only added into the action queue when command "trigger fs" is executed, but that's after the bootchart_init action (late_init). This change makes bootchart_init a builtin command of init, and make it executed as the first command of "on post-fs" section which will be triggered after the "on fs" section. This change also refactors the bootchart code to all be in bootchart.cpp. Change-Id: Ia74aa34ca5b785f51fcffdd383075a549b2a99d9 Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
* Clean up reading and writing in init.Elliott Hughes2015-02-061-3/+1
| | | | | | | | | | | | | 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
* Stop using #if for conditional compilation.Elliott Hughes2015-02-041-67/+61
| | | | | | | | Use regular 'if' to prevent bitrot. Also remove remaining typedefs. Change-Id: I2e6ca928e2db29b88b643cf990ff05cfb0be94a6
* Build init as C++.Elliott Hughes2015-02-041-0/+1187
This is just the minimal change to keep it building. Change-Id: I245c5b8413a1db114576c81462eb5737f5ffcef2