Excerpted from "detailed explanation of Android system principles and development points"
Explanation of init. RC Script for the 1st user processes started by Kernel
In
Android uses the startup script init. RC to perform some simple initialization operations during system initialization. This script is directly installed in the root file system of the target system.
Init executableProgramResolution. Init. RC is the startup script executed after init is started. Its Syntax mainly includes the following:
Commands: Command
Actions: Action
Triggers: triggers
Services: Service
Options: Options
Propertise: Properties
(1) commands is some basic operations, such:
Mkdir/sdcard 0000 System
Mkdir/System
Mkdir/Data 0771 System
Mkdir/cached 0770 system cache
Mkdir/config 0500 Root
Mkdir/sqlite_stmt_journals 01777 Root
Mount tmpfs/sqlite_stmt_journals size = 4 m
These commands are parsed In the init executable program, and then relevant functions are called for implementation.
(2) actions (Action) indicates a series of commands, which are usually called in triggers (triggers). The action and trigger condition form is:
On <trigger>
<Command>
<Command>
<Command>
An example is as follows:
On init
Export path/sbin:/system/bin:/system/xbin
Mkdir/System
Init indicates a trigger condition. After this trigger event occurs, setting environment variables and creating directories is called an action"
(3) services usually start an executable program. Options are additional content of the service for use with the service.
Service vold/system/bin/vold
Socket vold stream 0660 root Mount
Service bootsound/system/bin/playmp3
User Media
Group audio
Oneshot
Vold and bootsound are the names of the two services, respectively,/system/bin/vold and/System
/Bin/playmp3 are their corresponding executable programs.
Socket, user, group, and oneshot are the options used with the service. The oneshot option indicates that the service is started only once. If the oneshot option is not available,
This executable program will always exist-if the executable program is killed, it will be restarted.
(4) properties are some values used in the system and can be set and read.
Setprop Ro. foreground_app_mem 1536
Setprop Ro. visible_app_mem 2048
On Property: Ro. kernel. qemu = 1
Start adbd
Setprop is used to set attributes. on property can be used to determine attributes. The attributes here are consistent throughout the Android system.
For the keyword of the init script, refer to the system/CORE/init/keyword. h file of the INIT process.
For how to use init. RC, refer to the instruction file system/CORE/init/readme.txt.
To modify the startup process, you only need to modify the content in init. C (System/CORE/init) or init. RC.