Commit graph

51 commits

Author SHA1 Message Date
Elliott Hughes
171a829c39 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.
2016-06-29 16:16:41 -07:00
Elliott Hughes
3195116e97 Remove MTD cruft from init.
Bug: http://b/29250988
Change-Id: I38ab263192944e4ff291fd91b25db163a8848d75
2016-06-24 18:26:30 -07:00
Hung-ying Tyan
66277db8d0 Merge "Add -f to insmod" 2016-06-24 04:34:56 +00:00
Hung-ying Tyan
bfa6d75c60 Add -f to insmod
When the flag is on, insmod will bypass vermagic and symbol version
checking in the kernel. This is to make it possible to update kernel
without recompiling kernel modules.

BUG=28803994

Change-Id: Ib4be6999ef52baefd4210ee0d242360e43318907
2016-06-24 11:10:46 +08:00
Vitalii Tomkiv
081705c258 Add process priority to service definition.
This change allows to set prioirrity of the process to be set through
*.rc file.

Bug: 28866384
Change-Id: If0108ef05c8a151749c43d2d7de1187653255ce8
2016-06-08 13:22:14 -07:00
Viorel Suman
70daa67062 Multiple consoles
This CL allows enabling of multiple consoles. A service can be
mapped to a specific console by providing the optional argument,
IE "tty0", to "console" service attribute as follows:

service fbconsole /system/bin/sh
    class core
    console tty0
    disabled
    user shell
    group shell log readproc
    seclabel u:r:shell:s0

Bug: None
Change-Id: I3b24e7f6848bbe5c6475f11334c04ec536e6af88
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
2016-03-21 08:50:01 -07:00
Viorel Suman
efc7275172 Revert "Enable multiple consoles"
This reverts commit caafe5c620.

Bug: None
Change-Id: Iea2a80003d996ce542393242f87dc658ac6d01c9
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
2016-03-21 11:21:19 +02:00
Viorel Suman
caafe5c620 Enable multiple consoles
This CL allows enabling of multiple consoles. The expected format
of "androidboot.console" kernel parameter is a list of available
consoles, as follows:

  androidboot.console=tty0:ttyS0

A service can be mapped to a specific console by providing the
optional argument, IE "tty0", to "console" service attribute as follows:

service fbconsole /system/bin/sh
    class core
    console tty0
    disabled
    user shell
    group shell log readproc
    seclabel u:r:shell:s0

Bug: None
Change-Id: I3f8556425c8651bd121995869700f18b23365d55
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
2016-03-17 21:00:15 +02:00
Tom Cherry
1fb20b8377 init: Update readme.txt to reflect recent changes to init
Best practice for services that reside on the system, vendor, and odm
partitions is to have a corresponding init .rc file in the
/{system,vendor,odm}/etc/init directory, which contains its service
entry and any related actions.

Change-Id: I26204f9a0f09ce8069f3791ccd9ee61d164a048f
2016-01-23 05:23:39 +00:00
Hung-ying Tyan
dc738eaf15 Allow paths of .rc files to be specified at mount_all
In current implementation, the mount_all command imports all .rc files
under /{system,vendor,odm}/etc/init/ after mouting filesystems is complete.
There's a need from ODMs to import different .rc files under different boot
modes (e.g., factory mode). Without this support, they will have to fiddle
around the init implementation.

This commit makes mount_all import the .rc files/directories specified
as additional arguments. If no path is given, the original ones are applied
the same way as the current implementation.

BUG: 26549689
Change-Id: Ie67ce13dde4c440ff8bf534826bc392c882a433f
2016-01-21 09:35:43 +08:00
Tom Cherry
dbddb40c95 Update init documentation to reflect fs_config changes
Change-Id: I00296d90c44af369a51ecb5cbb667567328f0053
2015-12-11 13:20:38 -08:00
Tom Cherry
3be66edc59 init: Update readme.txt to reflect recent changes to init.
Updates are as follows:

A detailed explanation of event triggers and property triggers
including how they can now be used

A new section describing .rc files, their locations, and the
intentions for each of these locations

A new section describing the import keyword and how it is not a
command but rather its own section

Removal of deprecated or incorrect text

Change-Id: If0a37375ac92a857900f3303ada4ba742360daff
2015-09-01 15:32:33 -07:00
Yasuhiro Matsuda
f93db4b827 Introduce a mechanism to trace boot sequence.
This CL adds a trigger and a service so that Systrace can be used
for tracing events during boot.
persist.debug.atrace.boottrace property is used for switching on
and off tracing during boot. /data/misc/boottrace/categories
file is used for specifying the categories to be traced.
These property and file are rewritten by Systrace when the newly
added option --boot is specified.

Here is an example of tracing events of am and wm catetories
during boot.

$ external/chromium-trace/systrace am wm --boot

This command will cause the device to reboot. Once the device has
booted up, the trace report is created by hitting Ctrl+C.

As written in readme.txt, this mechanism relies on persistent
property, so tracing events that are emitted before that are not
recorded. This is enough for tracing events after zygote is
launched though.
This only works on userdebug or eng build for security reason.

BUG: 21739901
Change-Id: I03f2963d77a678f47eab5e3e29fc7e91bc9ca3a4
2015-07-29 12:53:05 +09:00
Lee Campbell
f13b1b3139 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
2015-07-27 14:56:03 -07:00
Elliott Hughes
d62f0608d9 init support for cgroups.
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
2015-06-17 14:42:40 -07:00
Ben Cheng
50bbde0e60 Compare two bootcharts and list timestamps for selected processes.
Usage: system/core/init/compare-bootcharts.py base_bootchart_dir
       exp_bootchart_dir

For example, here is the output where the bootanimation is changed
from "d 0 0 part2" to "c 0 0 part2":

--

process: baseline experiment (delta)
 - Unit is ms (a jiffy is 10 ms on the system)
------------------------------------
/init: 50 40 (-10)
/system/bin/surfaceflinger: 4320 4470 (+150)
/system/bin/bootanimation: 6980 6990 (+10)
zygote64: 10410 10640 (+230)
zygote: 10410 10640 (+230)
system_server: 15350 15150 (-200)
bootanimation ends at: 33790 31230 (-2560)

--

In this example bootanimation is finished (estimated) 2.56 seconds sooner.

Change-Id: I39d59897c8c53d7d662676813e884b9d58feec3c
2015-06-15 15:57:02 +08:00
Mark Salyzyn
17fff893c0 init: change exec parsing to make SECLABEL optional
Allow SECLABEL to be - to denote default

Change-Id: I58cdc6c805dc6e50dc42b7e13e72d0eaf4864f11
2015-06-02 15:17:52 -07:00
Elliott Hughes
c7ca9dd6c8 Revert "Revert "Remove now-unusable 'setcon' command.""
This reverts commit b862bd00a4.

This change was fine but an earlier change it depended on was broken.
That change has been fixed and resubmitted.

Bug: http://b/19702273
Change-Id: I17e565721026e48e2a73526f729f2481d4d6edb5
2015-04-24 12:41:47 -07:00
Nick Kralevich
b862bd00a4 Revert "Remove now-unusable 'setcon' command."
Temporarily revert because device isn't booting.

This reverts commit 7b15ac99f3.

Change-Id: Ice986bac62e20c70f7bedf1744a617b97392ae8c
2015-04-24 16:55:16 +00:00
Elliott Hughes
7b15ac99f3 Remove now-unusable 'setcon' command.
Bug: http://b/19702273
Change-Id: Icd340c80ba074476dcc63f1c1dd5c61a5c768893
2015-04-23 20:54:46 -07:00
Elliott Hughes
e2837a9107 Remove execonce.
Use 'exec' instead.

Change-Id: I1320d1971f7cd8b23753c27aa87089006e112a11
2015-04-03 09:06:52 -07:00
Elliott Hughes
59abac27cb Clarify a few things about bootcharts.
Make it clearer in dmesg when we're deliberately not doing
bootcharting, and explain in the documentation that the output
for init is quite misleading (and, as far as I can tell, not
within our power to fix).

Change-Id: I0b22a56f83521d64c6d176dc423c81f7ea86b23c
2015-03-28 12:12:51 -07:00
Elliott Hughes
91a3be547c Ensure all init commands are documented.
Change-Id: I21ef4d88b33337093396e14d792e1ff1fe0bfa17
2015-03-20 16:59:59 -07:00
Elliott Hughes
7010301933 Remove chroot from init.
This is not obviously useful. Let's wait until we have an actual need.

Change-Id: I2c75c96314b281e89df25b6ed202b3dd5dfdaf15
2015-03-18 12:41:54 -07:00
Elliott Hughes
641d3e8ea0 Remove chdir from init.
Change-Id: Ib2880c6cb18db613deac04ee3b06b9719f5248b9
2015-03-15 10:52:20 -07:00
Johan Redestig
0b42ba24ac Document mkdir behavioural change
Since 27164dc mkdir will update mode, owner and group even
if the directory exists already

Change-Id: Ic37975d118a87afded5bfade775cb3d0d3b19892
2015-03-15 17:47:36 +01:00
Niklas Tibbling
bc3f69f190 Document the mount option string in the readme.txt
also make a distinction between flag and option.

Change-Id: Ia872bc8dc98b3459f9c1e992d096c115699357af
2015-03-15 16:20:44 +00:00
Elliott Hughes
5878aa92cd Remove obsolete setkey.
It's undocumented and unused.

Change-Id: I685dc900adbc14f2e8b4eeebb1e4d111782f141d
2015-03-13 15:37:54 -07:00
Stephen Smalley
d4b2d8923f Remove getsebool/setsebool from init and toolbox.
These were leftovers from the SELinux boolean support that
was originally merged.  Since Android prohibits SELinux policy
booleans, we can just drop it.

Change-Id: I02f646a7d8db65e153702205b082b87a73f60d73
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-03-13 14:01:58 -04:00
Nick Kralevich
cee683e290 builtins: remove setenforce command
Adding "setenforce 0" to init.rc isn't a supported way to turn off
SELinux, and doesn't work with AOSP SELinux policy. Remove the code
from init.

Change-Id: If8c8149560789c9a7ba518a0a100e6033bb68898
2015-03-11 17:48:45 -07:00
Elliott Hughes
8d82ea05cb Implement exec.
Change-Id: I20329bc9b378479d745b498d6a00eca0872cd5ab
2015-02-25 17:55:34 -08:00
Mark Salyzyn
d4e5c32af7 init: grab-bootchart.sh: run bootchart and display results
- KISS as all options are now passed to adb for better or worse
- runs bootchart and immediately displays the results

Bug: 19485335
Bug: 18390773
Change-Id: Id32930031371d0368e605810f0c998232a1d4f16
2015-02-24 13:56:43 -08:00
Elliott Hughes
841b263fae Further refactoring of the bootchart code.
Change-Id: Ifed6ae8d481b605139fd27799574de4c2d0f5908
2015-02-13 15:15:11 -08:00
Elliott Hughes
f682b4786a 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
2015-02-06 14:20:30 -08:00
Elliott Hughes
d3e37d14e7 Trivial cleanup of recent changes.
A typo in the documentation for one, and a couple of signed/unsigned warnings
in the implementation of the other.

Change-Id: I8fb4b7448ac901c543dea7420aabcedf13ec1bd8
2015-02-02 16:43:32 -08:00
San Mehat
429721c5c4 init: Implement 'exec' command.
(cherry-pick of d05ab3952ec0e38f33a0e80ce6b9eb45b0064ba4.)

Change-Id: Id6d9bb32e51a0ad090ed8240cc505dc45b57b35d
2015-02-02 16:22:56 -08:00
Badhri Jagan Sridharan
0b41512a2e init: Add support "&&" operator in property triggers
"&&" operator can now be used to test the validity
of two of more properties.

For example:

on property:test.a=1 && property:test.b=1
    setprop test.c 1

The above stub sets the test.c to 1 only when
both test.a=1 and test.b=1

(cherry-pick of 162f7d797c67019a7a3f08c3b0f0ffc91d548ddc.)

Change-Id: I72c19f7aa92231372a416193618ee6c7fd368141
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
2015-02-02 16:21:05 -08:00
Stephen Smalley
d9c19b0c15 Remove obsolete warning from restorecon_recursive documentation.
We originally included a warning to not invoke restorecon_recursive
with a path leading to a shell-writable or app-writable directory
due to concerns about the potential for mischief with symlinks during
the restorecon_recursive.  However, this warning was never necessary for
calling restorecon_recursive during system initialization before an adb
shell or app can run, and we have further prohibited init from
reading/following symlinks that can be created by shell or apps in
policy, so this warning is superfluous.  It also contradicts current
usage of restorecon_recursive in rootdir/init.rc, since it is called
there on /data.

Change-Id: I28a635e0b5991ced8adcef93e7a04f9d9e5634fd
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-09-02 09:34:53 -04:00
Trevor Drake
d028394a27 remove examples of unimplemented triggers ( device-added device-removed )
from init/readme.txt

Change-Id: I16e226d8f563a223ae20044fff30498883bc4ae2
2014-08-29 20:07:28 +01:00
Trevor Drake
d4a497714a Remove descriptions of unimplemented triggers.
device-added, device-removed and service-exited were described but
never implemented.

Change-Id: I6fbd05a85576d18d6741fc6dd549acc9132b0531
2014-08-28 15:38:52 +01:00
Elliott Hughes
afc08ce392 Clarify init's write command.
Bug: https://code.google.com/p/android/issues/detail?id=73996
Change-Id: I4f8d3927d17a4021a2436c2859aa732479c5a118
2014-07-25 14:57:47 -07:00
JP Abgrall
3beec7e55f init: add 'enable <service>' to negate "service <service>... disabled"
enable <servicename>
   Turns a disabled service into an enabled one as if the service did not
   specify disabled in the rc file.
   It will also start the service if needed.

Bug: 14472973
Change-Id: Id0b49cc687a2bc74f6f92e066c617724cc94908d
Signed-off-by: JP Abgrall <jpa@google.com>
2014-05-03 00:14:59 -07:00
Stephen Smalley
726e8f7a8f Add a restorecon_recursive built-in command to init.
Functionally equivalent to the restorecon -R toolbox command.
A use case is given by:
I48eaa2b9901ac8c978192c14493ba1058a089423

Also, fix error handling and documentation for restorecon command.

Change-Id: Ia7fbcc82645baf52c6bff0490d3492f458881cbb
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-10-10 14:09:19 -04:00
Stephen Smalley
8348d279c7 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>
2013-08-23 08:35:43 -04:00
Stephen Smalley
0e23fee505 Change setsebool syntax to be consistent with other init built-ins.
Change setsebool syntax from name=value to name value.
This is to make it consistent with setprop and similar commands.
Update both the init built-in command and the toolbox command
for consistency.

Change-Id: I2c8e016ba26731c4a2ad4a49ae3b89362bf8f8a8
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-12-13 15:41:53 -05:00
Stephen Smalley
3fb6110830 Document the SELinux extensions to the Android init language.
Change-Id: I9b066e0789c93e5147c28a60baeed91c44dd9359
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-11-02 15:22:34 -04:00
Patrick McCormick
96d0a4dda8 Extend and document the "wait" command
The wait command was currently implemented but
undocumented and only used internally. This change
adds a second option toi (optionally) override the default
timeout of 5 seconds.

The wait command can be used to wait for a file to appear
during the boot process, for example a disk or other device,
and is a better alternative than an unconditional sleep.

Change-Id: Ia11d8419c0ea84deec0e1bf5adfca5bc76ff38b7
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2012-07-24 10:31:49 -07:00
Mike Lockwood
912ff85b03 init: Add support for SOCK_SEQPACKET socket type
Change-Id: Ib264ecf9beb2685b070436d2bdec9655c7a31b47
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-10-01 08:20:36 -04:00
Jay Freeman (saurik)
e7cb137f32 added chdir/chroot commands to init for mount switching/pivoting 2009-08-27 07:43:28 -07:00
The Android Open Source Project
35237d1358 Code drop from //branches/cupcake/...@124589 2008-12-17 18:08:08 -08:00