`
globaldev
  • 浏览: 34649 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

关于Android系统中system.img和data.img中文件系统的权限设置

阅读更多
关于Android系统中system.img和data.img中文件系统的权限设置【转】
2010-07-06 09:33
转自:http://blog.chinaunix.net/u3/103613/showart_2218437.html

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 should 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,   AID_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
** should 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/dhcpcd-run-hooks" },
    { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/dbus.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 included 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 },
};
分享到:
评论

相关推荐

    解压和生成system.img方法【ext4格式】

    目前越来越多的Android手机放弃了nand, 更多采用了emmc为内部存储设备。...以emmc为存储设备的android手机,其文件系统(/system,/data两个分区)一般采用ext4格式。 下面讲述如何解压和生成 system.img。

    windows下bootimg解包工具,支持dt.img和mtk

    unpack yafffs 解开 yafffs(包括data img及system img) updata app的话就输入bootimg unpack updata 下面一一说明功能中的参数 unpack updata [文件] [文件]为空时 默认使用UPDATA APP 解开后 会有四个...

    一键请把BOOT.IMG, SYSTEM.IMG, userdata.IMG解压到这个文件夹里面,手机必须先解锁

    请把BOOT.IMG, SYSTEM.IMG, userdata.IMG解压到这个文件夹里面,手机必须先解锁

    androidstudio.docx

    在设置网络访问时候会出现,无非就是url的问题,和权限问题。 当出现No address 失败时候,我是忘记配置权限了。 ![在AndroidManfest,xml中添加这个权限就可以了。]...

    platform-tools-latest-windows

    Android系统的分区为:system分区对应的目录 /system ,userdata分区对应 /data ,cache分区对应 /cache , 可用ADB 或超级终端 通过命令查看系统分区,命令如下: su cat /proc/mtd 假设mtd1对应 boot分区,mtd...

    解包官方updata.app文件的bootimg.exe工具

    --unpack-yafffs, 解开 yafffs(包括data.img及system.img) ps:下面的这些参数就算看不懂也没关系,我们的小u可以不用加参数,直接用默认的就行,如解包 updata.app的话就输入bootimg --unpack-updata就好。 ...

    android adb shell 命令大全

    Linux(~/.android/avd) Windows(C:\Documents and Settings\Administrator\.android\avd) 8. 启动DDMS: ddms 9. 显示当前运行的全部模拟器: adb devices 10. 对某一模拟器执行命令: abd -s 模拟器编号 ...

    新版Android开发教程.rar

    Android 是一个专门针对移动设备的软件集,它包括一个操作系统,中间件和一些重要的应用程序。 Beta 版 的 Android SDK 提供了在 Android 平台上使用 JaVa 语言进行 Android 应用开发必须的工具和 API 接口。 特性 ...

    解压和生成 img文件方法【yaffs2格式】

    做为一名Android手机用户, 拿到system.img和data.img不是件难事 有这两个image可以做什么呢? ^_^可以做很多事,比如删除一些不想用的系统应用(/system/app目录下) 这里介绍的方法是针对image为yaffs2格式,也就是...

    dfu驱动.zip

    Dload mode:76XXU-109805-USNSKOL go to armprg 未发现设备 ...下载system.img.ext4 下载userdata.img.ext4 未发现设备 FTM mode:76XXU-USNSKPLYM-109805 writing FTM nv453=0 writing FTM nv453=0 OK

    fastboot-LT18i

    创建一个包含boot.img, system.img和recovery.img的zip压缩包,并且运行: $ fastboot update {update.zip} 6.刷自定义开机画面:(替代默认的白色"T-Mobile G1"画面): $ fasboot flash splash1 mysplash.rgb565...

    U880 Bin包制作工具

    3、点击“解包 U880.bin”按钮,会从 bin 中提取出 logo.img、ramdisk.img、recovery.img、system.img、data.img 文件 4、(可选)修改分区大小等选项 5、(可选)点击“生成 logo.img”按钮选择 bmp 文件或将 bmp ...

    Android 源码如何编译调试

    android提供的工具链和开发工具比较完善,因此它的开发环境的搭建比较简单,相信许多朋友都已经搭建好环境,并编写了HelloActivity入门程序了。这里先看几个问题:  1、android的文件系统结构是怎样的,我们安装的...

    ADB-FASTBOOT工具箱

    我们所说的刷机也仅仅是boot.img引导分区加上system.img系统分区、 那么很多同学卡在第一屏,白屏。或者recovery无法进入(有时候涉及到系统文件不完整,一般都是未刷入第三方recovery) 都是因为boot系统内核(引导...

    Android filesystem 3 image解釋

    在網路上蒐集的資料,其中有很多自己的話,主要在認清data.img system.img ramdisk.img 的大略內容

    bootimg解包工具

    --unpack-yafffs, 解开 yafffs(包括data.img及system.img) ps:下面的这些参数就算看不懂也没关系,我们的小u可以不用加参数,直接用默认的就行,如解包 updata.app的话就输入bootimg --unpack-updata就好。 ...

    图片上传并按比例缩小

    在ASP.NET中上传图片并生成缩略图的C#源码 <FONT size=4><FONT size=4><FONT size=4>using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using ...

    SharpMap + ZedGraph 饼图实例,可生成各种统计图

    System.Drawing.Bitmap img = (System.Drawing.Bitmap)map.GetMap(); //Stream the image to the client context.Response.ContentType = "image/png"; System.IO.MemoryStream MS = new System.IO....

    生成二维码应用程序

    1、首先将ThoughtWorks.QRCode.dll引用到项目中。 2、using ThoughtWorks.QRCode.Codec; //在需要调用的界面引用命名空间 /// /// 根据用户名返回一个二进制数组 /// /// <returns></returns> public byte[]...

    Garmin Unlocker 6.02

    从MapData folder 取出一个名为 gmapprom.img 的档案. 3. GarminUnlockerAlternativev6.02.rar 4. 解压以上, 在它的MAP Locked 放上欲要破解的 gmapprom.img 档案. 5. .运行 UnLock Map Directory.exe 进行破解....

Global site tag (gtag.js) - Google Analytics