Android init


After init getting started by the kernel, it reads its configuration files and starts all the daemons and services that bring up the entire Android user-space.

If init is invoked through /sbin/ueventd symbolic link to /init, init will run as ueventd.
Otherwise, init will create and mount /dev, /proc, and /sys.
Then, init reads /init.rc and /init..rc files, parses their content into its internal structures and proceeds to initialize the system based on the configuration and rules.
Once all initialization is done, init then enter an infinite loop.
init extract the from /proc/cpuinfo and converts it to lowercase .

init's .rc files contain a series of declarations of two types: actions and services.
Each declaration starts with a keyword identifying the type of declaration:
* actions
  on
       
       
        ....

* services
  service [ ]
   
   
    ....

The scope of declaration is that a given declaration ends whenever the next on or service keyword appears.
Only an action results in the execution of commands, service declarations don't actually start anything.

There are two type of action triggers:
* pre-defined triggers

  • early-init
  • init
  • early-fs
  • fs
  • post-fs
  • early-boot
  • boot

* property-based triggers: activated on property-value change
    on property:=

Android's global properties provides a way of sharing important values globally among all parts of the stack.
init maintains a property service and it is exposed to the system by two ways:
* /dev/socket/property_service
    The process can use this Unix domain socket to talk to the property service to set/change the value of global properties.
* /dev/__properties__
   




留言

熱門文章