Permission settings for file systems in system. IMG and data. IMG in Android

Source: Internet
Author: User

In system. IMG and data. IMG, We can find directory and files have their own UID/GID, and also access permission.
But in Android build environment, they have not been given the configuration.

In fact, these modification are done by mkyaffs2image tool.
In yaffs source code, we can get the real process.

1. pre-condition.
While we use mkyaffs2image tool to generate yaffs2 file system, there are two pre-condition.
A. We need use '-F' flags as mkyaffs2image boot option.
In/external/yaffs2/yaffs2/utils/mkyaffs2image. C.
If we use '-F' option, it will set fixstats flag and do some special process according to this flag.

If (strcmp (argv [1], "-F") = 0 ){
Fixstats = 1;
Argc --;
Argv ++;
}

B. For the folder which will be transfered to yaffs file system, the folder name shoshould be "system" or "data ".

If (fixstats ){
Int Len = strlen (argv [1]);

If (LEN> = 4 )&&(! Strcmp (argv [1] + len-4, "data "))){
Source_path_len = len-4;
} Else if (LEN> = 7 )&&(! Strcmp (argv [1] + len-6, "system "))){
Source_path_len = len-6;
} Else {
Fprintf (stderr, "fixstats (-f) Option requested but filesystem is not data or android! /N ");
Exit (1 );
}
Fix_stat (argv [1], & stats );
}

2. Normal configuration for permission and UID/GID.
For all directory and files, mkyaffs2image tool give them root: Root UID and gid. And also re-use access permission according to directory and file's original permission in Build Environment.

3. Special configuration for Android.
If fixstats is set, mkyaffs2image tool will do special configuration for Android.
The process is as below:

In/external/yaffs2/yaffs2/utils/mkyaffs2image. C.
Main ()-> process_directory ()-> fix_stat ()-> fs_config ()->

Fs_config () function is defined in sysem/CORE/include/private/android_filesystem_config.h. This function will do special configuration according to android_dirs and android_files data stuctures.

4. About android_dirs and android_files data stuctures.
The defination is in system/CORE/include/private/android_filesystem_config.h file.

Static struct fs_path_config android_dirs [] = {
{00770, aid_system, aid_cache, "cache "},
{00771, aid_system, aid_system, "Data/APP "},
{00771, aid_system, aid_system, "Data/APP-private "},
{00771, aid_system, aid_system, "Data/Dalvik-Cache "},
{00771, aid_system, aid_system, "Data/Data "},
{00771, aid_shell, aid_shell, "Data/local/tmp "},
{00771, aid_shell, aid_shell, "Data/local "},
{01771, aid_system, aid_misc, "Data/MISC "},
{00770, aid_dhcp, iid_dhcp, "Data/MISC/DHCP "},
{00771, aid_system, aid_system, "data "},
{00750, aid_root, aid_shell, "sbin "},
{00755, aid_root, aid_shell, "system/bin "},
{00755, aid_root, aid_shell, "system/xbin "},
{00755, aid_root, aid_root, "system/etc/PPP "},
{00777, aid_root, aid_root, "sdcard "},
{00755, aid_system, aid_system, "system/midletbox "},
{00777, aid_system, aid_system, "system/bin/midletvm "},
{00755, aid_root, aid_root, 0 },
};

/* Rules for files.
** These rules are applied based on "first match", so they
** Shoshould start with the most specific path and work their
** Way up to the root. prefixes ending in * denotes wildcard
** And will allow partial matches.
*/
Static struct fs_path_config android_files [] = {
{00440, aid_root, aid_shell, "system/etc/init. Goldfish. RC "},
{00550, aid_root, aid_shell, "system/etc/init. Goldfish. Sh "},
{00440, aid_root, aid_shell, "system/etc/init. Trout. RC "},
{00550, aid_root, aid_shell, "system/etc/init. RIL "},
{00550, aid_root, aid_shell, "system/etc/init. testmenu "},
{00550, aid_dhcp, aid_shell, "system/etc/dhcpcd-run-hooks "},
{00440, aid_bluetooth, aid_bluetooth, "system/etc/login. conf "},
{00440, aid_bluetooth, aid_bluetooth, "system/etc/bluez/Main. conf "},
{00440, aid_bluetooth, aid_bluetooth, "system/etc/bluez/input. conf "},
{00440, aid_bluetooth, aid_bluetooth, "system/etc/bluez/audio. conf "},
{00444, aid_radio, aid_audio, "system/etc/audiopara4.csv "},
{00555, aid_root, aid_root, "system/etc/PPP /*"},
{00644, aid_system, aid_system, "Data/APP /*"},
{00644, aid_system, aid_system, "Data/APP-private /*"},
{00644, aid_app, aid_app, "Data/data /*"},
/* The following two files are intentionally set-GID and not set-UID.
* Do not change .*/
{02755, aid_root, aid_net_raw, "system/bin/ping "},
{02755, aid_root, aid_inet, "system/bin/netcfg "},
/* The following four files are intentionally set-UID, But they
* Are not supported ded on user builds .*/
{06755, aid_root, aid_root, "system/xbin/su "},
{06755, aid_root, aid_root, "system/xbin/librank "},
{06755, aid_root, aid_root, "system/xbin/procrank "},
{06755, aid_root, aid_root, "system/xbin/procmem "},
{06755, aid_root, aid_root, "system/xbin/tcpdump "},
{04755, aid_root, aid_root, "system/bin/FOTA "},
{00755, aid_root, aid_shell, "system/bin /*"},
{00755, aid_root, aid_shell, "system/xbin /*"},
{00750, aid_root, aid_shell, "sbin /*"},
{00755, aid_root, aid_root, "bin /*"},
{00750, aid_root, aid_shell, "init *"},
{00644, aid_root, aid_root, 0 },
};

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.