Android startup analysis-init process & init. rc

Source: Internet
Author: User
Init. rc parsing and chmod changing file attributes are useless.

From: http://h1372865100.blog.163.com/blog/static/2104291032012929114132327/

The init. rc Syntax of android is unique. It can be said that it is a language.

The init. rc syntax is dividedActions, commands, services, and options(Options).

Category

Name

Description

Section On Trigger Condition
Same as above .. Service Resolution Service
Command Chdir Change current working directory
Same as above .. Chroot Change the reference root directory location
.. Class_start Start a service with the class name set
.. Class_stop Stop a service with the class name set
.. Domainname Domain Name
.. Exec Call the program and transfer the process
.. Export Submit variable
.. Hostname Host Name
.. Ifup Activate Nic
.. Insmod Mount Module
.. Import Introduce configuration, such as some rc files under etc, which is similar to the import in java
.. Mkdir Create directory
.. Mount Mount a File System
.. Setkey From the source code, it should be the keyword abbreviation for setting a command. For example, you can map domainname to dn.
.. Setprop Set an attribute
.. Setrlimit

Set the maximum number of files that can be opened by the current program to the maximum number of files that can be opened by the system.

.. Start Start the service
.. Stop Stop Service
.. Trigger Is it a Custom trigger?
.. Symlink Create a symbolic link
.. Sysclktz

Set Reference time

.. Wait Waiting for the file to be ready? In Linux, this is a process scheduling function.
.. Write Write something to a file or device. It must not be the wirte that transmits the message.
.. Copy Not explained
.. Chown Change owner
.. Chmod Change permissions
.. Loglevel Log output level. If the Log output level is lower than this level
.. Restart Restart service
Option Capability Capability, that is, the system controls the permissions of processes.
Same as above .. Class Set Class Name
.. Console Enable Console
.. Critical Is it critical, that is, restart more than 4 times within 4 minutes, and then enter the recovery mode
.. Disabled Not automatically started with Class
.. Group Group owner
.. Keycodes I don't understand .....
.. Oneshot Start only once. Do not restart after unexpected exit
.. Onrestart Restart
.. Setenv Add environment variable
.. Socket Apply for socket Resources
.. User User attribution
.. Ioprio Io scheduling priority

(Many Attributes and command usage are different from those of the same name in Linux.)

Init parses init. rc By section. You can view the keyword definition in keywords. h. What mark does init use to parse init. rc in segments? Combined with the content of init. rc, we can see that the segment tag is marked by on and service. The following is a detailed description.

What should I do?

On is an action.

OnEarly-init

Run the command before init and after loading all rc files. In the miui rom, init. rc executes start ueventd in early-init according to keywords. h. start is a COMMAND ).

Here, by the way, ueventd, the underlying (usually the driver) in android notifies the upper-layer events, using uevent. the java layer is implemented through the observer mode and the class used isUeventobserver, UseIntentThe native layer usesAndroid_ OS _ueventobserver.cpp, UseUevent. cPassSocketTransfer. Of course, this is the framework and the following layers, which are not frequently used in development. What's more, these classes are not exposed.

OnInit

Run the command before loading the properties files of propety. It is in the init stage before init is changed to propety service.

OnEarly-boot

After the Attribute service is started, it is executed.

OnBoot

Run the command during boot.

OnProperty: XXXXX = x

This parameter is executed when an attribute is set to an expected value.

 

For init. rc, we can see a lot in combination with the/src/system/core/init/* source code and the init. rc file.

 

==========

Sometimes you need to add your own files to the root, and then find it useless to modify the file attributes in init. rc. I also spent a long time, and I saw a post on the Internet:

Create a script somewhere, for example,/system/bin/mymod. rc
#! /System/bin/sh
Chmod 0777/dev/mynode

Add the following in/init. RC:
Service mymod/system/bin/mymod. RC
Oneshot

(Note that the location/system/bin/is the system directory for generating the file system, not the system directory under the root account)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.