For Android, modify ramdisk. IMG and init. RC & set/Data permission to 770 after Android is started.

Source: Internet
Author: User

Sometimes you want to do something after startup, such as creating directories on sdcard and modifying/Data Access Permissions, which can be put in init. how can I do this in RC? recently, due to the need of my work, I have made some research in this area for your reference.

The following example shows how to implement a function: After the Android system is started, modify the/data access permission to 770.

4 steps in total: 1. Decompress ramdisk. IMG 2. Use the C language to complete the functions required. 3. Modify init. RC and start the executable program in C language. 4. Create ramdisk. IMG.

1. Unzip ramdisk. IMG:

Manually decompress and modify ramdisk. IMG of Android:

Copy ramdisk.imgto another directory, change its name to ramdisk.img.gz, and run the command

Gunzip ramdisk.img.gz

Create a folder named ramdisk.
Cpio-I-f ../ramdisk. img
Now you can see and operate the content in ramdisk.

This step can be referred to: http://blog.csdn.net/liushaogeng/archive/2010/10/14/5941259.aspx

2. Complete a C program chpermission. C to modify permissions. The Code is as follows:

# Include <stdlib. h>

Int main ()

{

System ("chmod 700/Data ");

Return 0;

 

}

Then compile this program, but need to compile the android executable program, can refer to my blog: http://blog.csdn.net/liushaogeng/archive/2010/09/01/5855925.aspx, using the blog introduced in the two methods can be.After compilation, push the executable file to the/data directory of the simulator:# ADB push chpermission/Data

3. Modify the init. RC file in the ramdisk directory to start the chpermission program and add the following code:

# Add by me on 2010-10-18
Service chpermission/data/chpermission
Oneshot

It is used to start chpermission and complete the corresponding function-modify data permissions.

Init. RC syntax can refer to blog: http://blog.csdn.net/liushaogeng/archive/2010/10/18/5949244.aspx

4. Create ramdisk. IMG,

After modifying init. RC, you can use the following command to repackage it into an image:
Cpio-I-t-f ../ramdisk. img> List
Cpio-o-h NEWC-o lk. IMG <list
The LK. IMG generated in the current directory is our new image.

Refer to blog: http://blog.csdn.net/liushaogeng/archive/2010/10/14/5941259.aspx

Copy ramdisk. IMG to the directory pointed to by the SDK.

All OK. Restart your simulator and check whether the data permission is 770.

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.