• Home
Name Date Size #Lines LOC

..--

Android.mkD03-May-20241.5 KiB6446

MODULE_LICENSE_APACHE2D03-May-20240

NOTICED03-May-202410.4 KiB191158

README.BOOTCHARTD03-May-20242.1 KiB5335

bootchart.cD03-May-20249.5 KiB379293

bootchart.hD03-May-20241.1 KiB3714

builtins.cD03-May-202417.1 KiB821648

devices.cD03-May-202423.3 KiB917717

devices.hD03-May-2024990 2910

grab-bootchart.shD03-May-2024550 2312

init.cD03-May-202427.3 KiB1,027782

init.hD03-May-20244.1 KiB14692

init_parser.cD03-May-202424.2 KiB864757

init_parser.hD03-May-20241.2 KiB3715

keychords.cD03-May-20243.5 KiB13091

keychords.hD03-May-2024830 288

keywords.hD03-May-20244 KiB104101

log.hD03-May-2024901 298

logo.cD03-May-20243.5 KiB164121

parser.cD03-May-20244.2 KiB184166

parser.hD03-May-20241.1 KiB4221

property_service.cD03-May-202416.5 KiB630456

property_service.hD03-May-20241.1 KiB3414

readme.txtD03-May-20248.1 KiB305222

signal_handler.cD03-May-20244.2 KiB156110

signal_handler.hD03-May-2024769 256

ueventd.cD03-May-20244.3 KiB183124

ueventd.hD03-May-2024721 234

ueventd_parser.cD03-May-20241.9 KiB7653

ueventd_parser.hD03-May-2024827 266

util.cD03-May-202411.5 KiB515402

util.hD03-May-20241.6 KiB4523

watchdogd.cD03-May-20242 KiB7848

watchdogd.hD03-May-2024727 234

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
91oneshot
92   Do not restart the service when it exits.
93
94class <name>
95   Specify a class name for the service.  All services in a
96   named class may be started or stopped together.  A service
97   is in the class "default" if one is not specified via the
98   class option.
99
100onrestart
101    Execute a Command (see below) when service restarts.
102
103Triggers
104--------
105   Triggers are strings which can be used to match certain kinds
106   of events and used to cause an action to occur.
107
108boot
109   This is the first trigger that will occur when init starts
110   (after /init.conf is loaded)
111
112<name>=<value>
113   Triggers of this form occur when the property <name> is set
114   to the specific value <value>.
115
116device-added-<path>
117device-removed-<path>
118   Triggers of these forms occur when a device node is added
119   or removed.
120
121service-exited-<name>
122   Triggers of this form occur when the specified service exits.
123
124
125Commands
126--------
127
128exec <path> [ <argument> ]*
129   Fork and execute a program (<path>).  This will block until
130   the program completes execution.  It is best to avoid exec
131   as unlike the builtin commands, it runs the risk of getting
132   init "stuck". (??? maybe there should be a timeout?)
133
134export <name> <value>
135   Set the environment variable <name> equal to <value> in the
136   global environment (which will be inherited by all processes
137   started after this command is executed)
138
139ifup <interface>
140   Bring the network interface <interface> online.
141
142import <filename>
143   Parse an init config file, extending the current configuration.
144
145hostname <name>
146   Set the host name.
147
148chdir <directory>
149   Change working directory.
150
151chmod <octal-mode> <path>
152   Change file access permissions.
153
154chown <owner> <group> <path>
155   Change file owner and group.
156
157chroot <directory>
158  Change process root directory.
159
160class_start <serviceclass>
161   Start all services of the specified class if they are
162   not already running.
163
164class_stop <serviceclass>
165   Stop all services of the specified class if they are
166   currently running.
167
168domainname <name>
169   Set the domain name.
170
171insmod <path>
172   Install the module at <path>
173
174mkdir <path> [mode] [owner] [group]
175   Create a directory at <path>, optionally with the given mode, owner, and
176   group. If not provided, the directory is created with permissions 755 and
177   owned by the root user and root group.
178
179mount <type> <device> <dir> [ <mountoption> ]*
180   Attempt to mount the named device at the directory <dir>
181   <device> may be of the form mtd@name to specify a mtd block
182   device by name.
183   <mountoption>s include "ro", "rw", "remount", "noatime", ...
184
185setkey
186   TBD
187
188setprop <name> <value>
189   Set system property <name> to <value>.
190
191setrlimit <resource> <cur> <max>
192   Set the rlimit for a resource.
193
194start <service>
195   Start a service running if it is not already running.
196
197stop <service>
198   Stop a service from running if it is currently running.
199
200symlink <target> <path>
201   Create a symbolic link at <path> with the value <target>
202
203sysclktz <mins_west_of_gmt>
204   Set the system clock base (0 if system clock ticks in GMT)
205
206trigger <event>
207   Trigger an event.  Used to queue an action from another
208   action.
209
210wait <path> [ <timeout> ]
211  Poll for the existence of the given file and return when found,
212  or the timeout has been reached. If timeout is not specified it
213  currently defaults to five seconds.
214
215write <path> <string> [ <string> ]*
216   Open the file at <path> and write one or more strings
217   to it with write(2)
218
219
220Properties
221----------
222Init updates some system properties to provide some insight into
223what it's doing:
224
225init.action
226   Equal to the name of the action currently being executed or "" if none
227
228init.command
229   Equal to the command being executed or "" if none.
230
231init.svc.<name>
232   State of a named service ("stopped", "running", "restarting")
233
234
235Example init.conf
236-----------------
237
238# not complete -- just providing some examples of usage
239#
240on boot
241   export PATH /sbin:/system/sbin:/system/bin
242   export LD_LIBRARY_PATH /system/lib
243
244   mkdir /dev
245   mkdir /proc
246   mkdir /sys
247
248   mount tmpfs tmpfs /dev
249   mkdir /dev/pts
250   mkdir /dev/socket
251   mount devpts devpts /dev/pts
252   mount proc proc /proc
253   mount sysfs sysfs /sys
254
255   write /proc/cpu/alignment 4
256
257   ifup lo
258
259   hostname localhost
260   domainname localhost
261
262   mount yaffs2 mtd@system /system
263   mount yaffs2 mtd@userdata /data
264
265   import /system/etc/init.conf
266
267   class_start default
268
269service adbd /sbin/adbd
270   user adb
271   group adb
272
273service usbd /system/bin/usbd -r
274   user usbd
275   group usbd
276   socket usbd 666
277
278service zygote /system/bin/app_process -Xzygote /system/bin --zygote
279   socket zygote 666
280
281service runtime /system/bin/runtime
282   user system
283   group system
284
285on device-added-/dev/compass
286   start akmd
287
288on device-removed-/dev/compass
289   stop akmd
290
291service akmd /sbin/akmd
292   disabled
293   user akmd
294   group akmd
295
296Debugging notes
297---------------
298By default, programs executed by init will drop stdout and stderr into
299/dev/null. To help with debugging, you can execute your program via the
300Andoird program logwrapper. This will redirect stdout/stderr into the
301Android logging system (accessed via logcat).
302
303For example
304service akmd /system/bin/logwrapper /sbin/akmd
305