NameDateSize

..04-Jun-20144 KiB

Android.mk04-Jun-20141.4 KiB

bootchart.c04-Jun-20149.5 KiB

bootchart.h04-Jun-20141.1 KiB

builtins.c04-Jun-201418 KiB

devices.c04-Jun-201423.8 KiB

devices.h04-Jun-2014990

grab-bootchart.sh04-Jun-2014550

init.c04-Jun-201431.4 KiB

init.h04-Jun-20144.2 KiB

init_parser.c04-Jun-201424.5 KiB

init_parser.h04-Jun-20141.2 KiB

keychords.c04-Jun-20143.2 KiB

keychords.h04-Jun-2014830

keywords.h04-Jun-20144.2 KiB

log.h04-Jun-2014901

logo.c04-Jun-20143.5 KiB

MODULE_LICENSE_APACHE204-Jun-20140

NOTICE04-Jun-201410.4 KiB

parser.c04-Jun-20144.2 KiB

parser.h04-Jun-20141.1 KiB

property_service.c04-Jun-201416.6 KiB

property_service.h04-Jun-20141.6 KiB

README.BOOTCHART04-Jun-20142.1 KiB

readme.txt04-Jun-20149.2 KiB

signal_handler.c04-Jun-20144.4 KiB

signal_handler.h04-Jun-2014769

ueventd.c04-Jun-20144.3 KiB

ueventd.h04-Jun-2014721

ueventd_parser.c04-Jun-20141.9 KiB

ueventd_parser.h04-Jun-2014827

util.c04-Jun-201412 KiB

util.h04-Jun-20141.6 KiB

watchdogd.c04-Jun-20142 KiB

watchdogd.h04-Jun-2014727

README.BOOTCHART

1This version of init contains code to perform "bootcharting", i.e. generating log
2files that can be later processed by the tools provided by www.bootchart.org.
3
4To activate it, you need to define build 'init' with the INIT_BOOTCHART environment
5variable defined to 'true', for example:
6
7    touch system/init/init.c
8    m INIT_BOOTCHART=true
9
10On the emulator, use the new -bootchart <timeout> option to boot with bootcharting
11activated for <timeout> seconds.
12
13Otherwise, flash your device, and start it. Then create a file on the /data partition
14with a command like the following:
15
16  adb shell 'echo $TIMEOUT > /data/bootchart-start'
17
18Where the value of $TIMEOUT corresponds to the wanted bootcharted period in seconds;
19for example, to bootchart for 2 minutes, do:
20
21  adb shell 'echo 120 > /data/bootchart-start'
22
23Reboot your device, bootcharting will begin and stop after the period you gave.
24You can also stop the bootcharting at any moment by doing the following:
25
26  adb shell 'echo 1 > /data/bootchart-stop'
27
28Note that /data/bootchart-stop is deleted automatically by init at the end of the
29bootcharting. This is not the case of /data/bootchart-start, so don't forget to delete it
30when you're done collecting data:
31
32  adb shell rm /data/bootchart-start
33
34The log files are placed in /data/bootchart/. you must run the script tools/grab-bootchart.sh
35which will use ADB to retrieve them and create a bootchart.tgz file that can be used with
36the bootchart parser/renderer, or even uploaded directly to the form located at:
37
38  http://www.bootchart.org/download.html
39
40NOTE: the bootchart.org webform doesn't seem to work at the moment, you can generate an
41      image on your machine by doing the following:
42
43         1/ download the sources from www.bootchart.org
44         2/ unpack them
45         3/ in the source directory, type 'ant' to build the bootchart program
46         4/ type 'java -jar bootchart.jar /path/to/bootchart.tgz
47
48technical note:
49
50this implementation of bootcharting does use the 'bootchartd' script provided by
51www.bootchart.org, but a C re-implementation that is directly compiled into our init
52program.
53

readme.txt

1
2Android Init Language
3---------------------
4
5The Android Init Language consists of four broad classes of statements,
6which are Actions, Commands, Services, and Options.
7
8All of these are line-oriented, consisting of tokens separated by
9whitespace.  The c-style backslash escapes may be used to insert
10whitespace into a token.  Double quotes may also be used to prevent
11whitespace from breaking text into multiple tokens.  The backslash,
12when it is the last character on a line, may be used for line-folding.
13
14Lines which start with a # (leading whitespace allowed) are comments.
15
16Actions and Services implicitly declare a new section.  All commands
17or options belong to the section most recently declared.  Commands
18or options before the first section are ignored.
19
20Actions and Services have unique names.  If a second Action or Service
21is declared with the same name as an existing one, it is ignored as
22an error.  (??? should we override instead)
23
24
25Actions
26-------
27Actions are named sequences of commands.  Actions have a trigger which
28is used to determine when the action should occur.  When an event
29occurs which matches an action's trigger, that action is added to
30the tail of a to-be-executed queue (unless it is already on the
31queue).
32
33Each action in the queue is dequeued in sequence and each command in
34that action is executed in sequence.  Init handles other activities
35(device creation/destruction, property setting, process restarting)
36"between" the execution of the commands in activities.
37
38Actions take the form of:
39
40on <trigger>
41   <command>
42   <command>
43   <command>
44
45
46Services
47--------
48Services are programs which init launches and (optionally) restarts
49when they exit.  Services take the form of:
50
51service <name> <pathname> [ <argument> ]*
52   <option>
53   <option>
54   ...
55
56
57Options
58-------
59Options are modifiers to services.  They affect how and when init
60runs the service.
61
62critical
63   This is a device-critical service. If it exits more than four times in
64   four minutes, the device will reboot into recovery mode.
65
66disabled
67   This service will not automatically start with its class.
68   It must be explicitly started by name.
69
70setenv <name> <value>
71   Set the environment variable <name> to <value> in the launched process.
72
73socket <name> <type> <perm> [ <user> [ <group> ] ]
74   Create a unix domain socket named /dev/socket/<name> and pass
75   its fd to the launched process.  <type> must be "dgram", "stream" or "seqpacket".
76   User and group default to 0.
77
78user <username>
79   Change to username before exec'ing this service.
80   Currently defaults to root.  (??? probably should default to nobody)
81   Currently, if your process requires linux capabilities then you cannot use
82   this command. You must instead request the capabilities in-process while
83   still root, and then drop to your desired uid.
84
85group <groupname> [ <groupname> ]*
86   Change to groupname before exec'ing this service.  Additional
87   groupnames beyond the (required) first one are used to set the
88   supplemental groups of the process (via setgroups()).
89   Currently defaults to root.  (??? probably should default to nobody)
90
91seclabel <securitycontext>
92  Change to securitycontext before exec'ing this service.
93  Primarily for use by services run from the rootfs, e.g. ueventd, adbd.
94  Services on the system partition can instead use policy-defined transitions
95  based on their file security context.
96  If not specified and no transition is defined in policy, defaults to the init context.
97
98oneshot
99   Do not restart the service when it exits.
100
101class <name>
102   Specify a class name for the service.  All services in a
103   named class may be started or stopped together.  A service
104   is in the class "default" if one is not specified via the
105   class option.
106
107onrestart
108    Execute a Command (see below) when service restarts.
109
110Triggers
111--------
112   Triggers are strings which can be used to match certain kinds
113   of events and used to cause an action to occur.
114
115boot
116   This is the first trigger that will occur when init starts
117   (after /init.conf is loaded)
118
119<name>=<value>
120   Triggers of this form occur when the property <name> is set
121   to the specific value <value>.
122
123device-added-<path>
124device-removed-<path>
125   Triggers of these forms occur when a device node is added
126   or removed.
127
128service-exited-<name>
129   Triggers of this form occur when the specified service exits.
130
131
132Commands
133--------
134
135exec <path> [ <argument> ]*
136   Fork and execute a program (<path>).  This will block until
137   the program completes execution.  It is best to avoid exec
138   as unlike the builtin commands, it runs the risk of getting
139   init "stuck". (??? maybe there should be a timeout?)
140
141export <name> <value>
142   Set the environment variable <name> equal to <value> in the
143   global environment (which will be inherited by all processes
144   started after this command is executed)
145
146ifup <interface>
147   Bring the network interface <interface> online.
148
149import <filename>
150   Parse an init config file, extending the current configuration.
151
152hostname <name>
153   Set the host name.
154
155chdir <directory>
156   Change working directory.
157
158chmod <octal-mode> <path>
159   Change file access permissions.
160
161chown <owner> <group> <path>
162   Change file owner and group.
163
164chroot <directory>
165  Change process root directory.
166
167class_start <serviceclass>
168   Start all services of the specified class if they are
169   not already running.
170
171class_stop <serviceclass>
172   Stop all services of the specified class if they are
173   currently running.
174
175domainname <name>
176   Set the domain name.
177
178insmod <path>
179   Install the module at <path>
180
181mkdir <path> [mode] [owner] [group]
182   Create a directory at <path>, optionally with the given mode, owner, and
183   group. If not provided, the directory is created with permissions 755 and
184   owned by the root user and root group.
185
186mount <type> <device> <dir> [ <mountoption> ]*
187   Attempt to mount the named device at the directory <dir>
188   <device> may be of the form mtd@name to specify a mtd block
189   device by name.
190   <mountoption>s include "ro", "rw", "remount", "noatime", ...
191
192restorecon <path>
193   Restore the file named by <path> to the security context specified
194   in the file_contexts configuration.
195   Not required for directories created by the init.rc as these are
196   automatically labeled correctly by init.
197
198setcon <securitycontext>
199   Set the current process security context to the specified string.
200   This is typically only used from early-init to set the init context
201   before any other process is started.
202
203setenforce 0|1
204   Set the SELinux system-wide enforcing status.
205   0 is permissive (i.e. log but do not deny), 1 is enforcing.
206
207setkey
208   TBD
209
210setprop <name> <value>
211   Set system property <name> to <value>.
212
213setrlimit <resource> <cur> <max>
214   Set the rlimit for a resource.
215
216setsebool <name> <value>
217   Set SELinux boolean <name> to <value>.
218   <value> may be 1|true|on or 0|false|off
219
220start <service>
221   Start a service running if it is not already running.
222
223stop <service>
224   Stop a service from running if it is currently running.
225
226symlink <target> <path>
227   Create a symbolic link at <path> with the value <target>
228
229sysclktz <mins_west_of_gmt>
230   Set the system clock base (0 if system clock ticks in GMT)
231
232trigger <event>
233   Trigger an event.  Used to queue an action from another
234   action.
235
236wait <path> [ <timeout> ]
237  Poll for the existence of the given file and return when found,
238  or the timeout has been reached. If timeout is not specified it
239  currently defaults to five seconds.
240
241write <path> <string> [ <string> ]*
242   Open the file at <path> and write one or more strings
243   to it with write(2)
244
245
246Properties
247----------
248Init updates some system properties to provide some insight into
249what it's doing:
250
251init.action 
252   Equal to the name of the action currently being executed or "" if none
253
254init.command
255   Equal to the command being executed or "" if none.
256
257init.svc.<name>
258   State of a named service ("stopped", "running", "restarting")
259
260
261Example init.conf
262-----------------
263
264# not complete -- just providing some examples of usage
265#
266on boot
267   export PATH /sbin:/system/sbin:/system/bin
268   export LD_LIBRARY_PATH /system/lib
269
270   mkdir /dev
271   mkdir /proc
272   mkdir /sys
273
274   mount tmpfs tmpfs /dev
275   mkdir /dev/pts
276   mkdir /dev/socket
277   mount devpts devpts /dev/pts
278   mount proc proc /proc
279   mount sysfs sysfs /sys
280
281   write /proc/cpu/alignment 4
282
283   ifup lo
284
285   hostname localhost
286   domainname localhost
287
288   mount yaffs2 mtd@system /system
289   mount yaffs2 mtd@userdata /data
290
291   import /system/etc/init.conf
292
293   class_start default
294
295service adbd /sbin/adbd
296   user adb
297   group adb
298
299service usbd /system/bin/usbd -r
300   user usbd
301   group usbd
302   socket usbd 666
303
304service zygote /system/bin/app_process -Xzygote /system/bin --zygote
305   socket zygote 666
306
307service runtime /system/bin/runtime
308   user system
309   group system
310
311on device-added-/dev/compass
312   start akmd
313
314on device-removed-/dev/compass
315   stop akmd
316
317service akmd /sbin/akmd
318   disabled
319   user akmd
320   group akmd
321
322Debugging notes
323---------------
324By default, programs executed by init will drop stdout and stderr into
325/dev/null. To help with debugging, you can execute your program via the
326Andoird program logwrapper. This will redirect stdout/stderr into the
327Android logging system (accessed via logcat).
328
329For example
330service akmd /system/bin/logwrapper /sbin/akmd
331