Home | History | Annotate | only in /system/core/init
Up to higher level directory
NameDateSize
Android.mk03-Dec-20141.6K
bootchart.c03-Dec-20149.5K
bootchart.h03-Dec-20141.1K
builtins.c03-Dec-201420.6K
devices.c03-Dec-201427.6K
devices.h03-Dec-20141K
grab-bootchart.sh03-Dec-2014550
init.c03-Dec-201432.5K
init.h03-Dec-20144.2K
init_parser.c03-Dec-201424.8K
init_parser.h03-Dec-20141.2K
keychords.c03-Dec-20143.2K
keychords.h03-Dec-2014830
keywords.h03-Dec-20144.5K
log.h03-Dec-2014888
MODULE_LICENSE_APACHE203-Dec-20140
NOTICE03-Dec-201410.4K
parser.c03-Dec-20144.2K
parser.h03-Dec-20141.1K
property_service.c03-Dec-201415.3K
property_service.h03-Dec-20141.6K
README.BOOTCHART03-Dec-20142.1K
readme.txt03-Dec-201410.1K
signal_handler.c03-Dec-20144.8K
signal_handler.h03-Dec-2014769
ueventd.c03-Dec-20144.8K
ueventd.h03-Dec-2014999
ueventd_keywords.h03-Dec-2014356
ueventd_parser.c03-Dec-20146.1K
ueventd_parser.h03-Dec-2014925
util.c03-Dec-201412.2K
util.h03-Dec-20141.6K
watchdogd.c03-Dec-20142K
watchdogd.h03-Dec-2014727

README.BOOTCHART

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

readme.txt

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