/System/CORE/init/readme.txt explanation of init. RC

Source: Internet
Author: User
Tags unix domain socket

 

Init. RC consists of many actions and services.

Each statement occupies one row and each keyword is separated by spaces. The backslash (for example,/n) in the C Specification will be ignored (backslash escapes) and is considered as a space. Double quotation marks are used to ensure that spaces do not divide a text string into multiple keywords. The backslash at the end of the row is used as a continuation.

The Rows starting from # (with spaces allowed before) are comments)

The beginning of an actions or services implicitly declares a new segment. All commands or options are recent declarations. Commands or options before the first segment are ignored.

Each actions and service has different names. If the name is the same as the name above, the name after the name will be ignored or considered an error.

 

 

Actions is actually a group of named command sequences. Actions has a trigger condition that determines when an action is executed. When an event matches the trigger condition of the action, the action is added to the end of the pre-execution Queue (unless it is already in the queue)

Commands in each action are executed sequentially. The INIT process is responsible for executing these command sequences between other activities (such as device creation/destruction, Property setting, and process restart.

The format of each action is as follows:

On <trigger>

<Command>

<Command>

...

 

Trigger is an action-triggered condition. There are several types of triggers:

1. boot

It occurs when init is started and/init. conf is loaded.

2. <name >=< value>

This occurs when the value of the <Name> attribute is set to <value>.

3. device-added-<path>/device-removed-<path>

When a device node is added or deleted.

4. Service-Exited-<Name> when a service exits.

 

Command has the following types:

1. Exec <path> [<argument>] *

Fork and execute a program under the path <path> until the program is executed, init will continue. Avoid using this command whenever possible, which may cause init blocking. Other commands do not have this problem.

2. Export <Name> <value>

Set the value of the global environment variable <Name> to <value>. All processes started after this command is executed will inherit this global variable.

3. IFUP <interface>

Bring the network interface <interface> online. (open a NIC)

4. Import <FILENAME>

Parse an init config file, extending the current configuration.

5. hostname <Name>

Set the host name.

6. class_start <serviceclass>

If a certain type of services are not running, start them.

7. class_stop <serviceclass>

If a certain type of services are running, stop them.

8. domainname <Name>

Set the domain name.

9. insmod <path>

The installation path <path> specifies the module.

10. mkdir <path>

Create a folder that is represented by <path> and can only be created layer by layer.

11. Mount <type> <device> <dir> [<mountoption>] *

Mount <device> to the <dir> directory of the <type> file system. <Device> the form of MTD @ name may exist, representing the MTD block device named name.

12. setkey

Undefined

13. setprop <Name> <value>

Set system properties.

14. setrlimit <resource> <cur> <max>

Set the rlimit for a resource.

15. Start <service>

If the service is not running, start it.

16. Stop <service>

If the service is running, stop it.

17. symlink <target> <path>

Link <target> to the directory <path>.

18. Write <path> <string> [<string>] *

Open the file <path> and write <string>.

 

For details about 3, 5, and 8, see

On Boot

# Basic network init

IFUP Lo

Hostname localhost

Domainname localdomain

For more information, see

# Set rlimit_nice to allow priorities from 19 to-20

Setrlimit 13 40 40

 

 

Services are some programs started by init and restarted (if necessary). Of course, these programs exist.

The format of each service is as follows:

Service <Name> <pathname> [<argument>] *

<Option>

<Option>

...

Options is the modifier of the service, used to tell init how and when to start the service. There are several types:

1. diabled

This service cannot be started by starting a type of service. It can only be started by name.

2. Socket <type> <Name> <perm> [<user> [<group>]

Create a Unix domain socket named/dev/socket/<Name> and pass its FD to the loading process. <Type> the value is dgram or stream. The default values of user and group are 0.

Note: When using socket in init. RC, <type> is placed after <Name>.

 

During the running process, the INIT program may set several special attribute values to tell other programs what it is doing. These attributes are:

1. init. Action

The name of the action currently being executed. If not, it is "".

2. init. Command

The name of the Command currently being executed. If not, it is "".

3. init. SVC. <Name>

The status of a service. Possible values: "STOPPED", "running", "Restarting"

4. User <username>

Switch the user name to <username> before starting the service. The default value is root.

5. group <groupname> [<groupname>] *

Switch the group name to <groupname> before starting the service. A service may belong to multiple groups.

6. capability [<capability>] +

Set Linux capability before exec 'ing this service

7. oneshot

Once the service runs, it will not restart after exiting.

8. Class <Name>

Set a category for a service. A service in a category can be started or stopped at the same time. If this attribute is not available, the default category of the service is "default"

9. Console

Stdio of the service is redirected to/dev/console, instead of the default/dev/null

 

By default, programs started through init will direct stdout and stderr to/dev/null. Sometimes, to facilitate debugging, you can start a program through the android logwrapper program. In this way, stdout and stderr are directed to the log system of Android, which can be viewed through logcat.

For example:

Service akmd/system/bin/logwraper/sbin/akmd

 

 

Refer:

 

Linux Kernel Vivi partition and kernel MTD Partition

Http://blogold.chinaunix.net/u2/66601/showart_1010926.html

Android init. RC syntax Standard

Http://blog.csdn.net/liushaogeng/archive/2010/10/18/5949244.aspx

Http://www.kandroid.org/android_pdk/bring_up.html

 

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.