1. init.rc File Structure
File Location:
init.c:/system/core/init
init.rc:/system/core/rootdir
First, the init.rc file is in modules, each module content is executed together, the module is divided into 3 types: on, service,Import.
we can look at how the Init.rc file is written:
1.Import
Import/init.usb.rc
Import/init.${ro.hardware}.rc
Import/init.trace.rc
The above content is easy to understand, is to import other. rc files, so when you add the product in the Android source and to add the boot entry, you can add it here.
2. on
the general on type is to do some chown, mkdir, write, Export, symlink and other simple shell instructions
and init.rc itself with some comments, compare understood.
On Post-fs-data
# We Chown/chmod/data again so because Mount is run as root + defaults
Chown System System/data
chmod 0771/data
3.Service
A module of service type represents an executable program, for example:
Service Bootanim/system/bin/bootanimation
Class Main
User Graphics
Group Graphics
Disabled
OneShot
Bootanim for Module name
/system/bin/bootanimation The path to the executable file
The lines for class, user, group, and Onrestart are used to describe some of the service's characteristics. , different service has different characteristics.
The structure of init.rc is probably the case, so how does this init.rc work? This is going to look at the init.c file.
first we know that each on module has its own name, such as the top post-fs-data. Then you can find this in the init.c:
Action_for_each_trigger ("Post-fs-data", action_add_queue_tail);
This adds all the commands in a section starting with "on Post-fs-data" to an execution queue, which executes the command in the queue at some point in the future, so call Action_for_each_trigger () has decided the order of execution.
when will the service be executed?
there will be a command in an on module."Class_start", such as:
Class_start Core
Class_start Main
On nonencrypted
Class_start Late_start
The service module will be called when it is executed here.
Finally about Init.c is not analyzed, interested friends should be able to through the function of the name and the comments are good understanding of what the content is to do.
Original Android_fans
Original link: http://forum.cubietech.com/forum.php?mod=viewthread&tid=1118&extra=page%3D1