Introduction

Recently I met some problems with android system's directories, so I have to modify init.rc to implement some functions. But I didn't know much about how to write android's init.rc. Some colleagues who have known it helped me fix the problem. But I still don't understand these instructions from "init.rc", I look up some references on the internet to understand them, then this essay is here.

The instructions from the scenario

The below is the instructions we should interprete in the essay:

mkdir /cores 0777 system systemmount tmpfs tmpfs /cores mode=0777,uid=1000,gid=1000restorecon_recursive /cores

Let's analyze them one by one:

1 mkdir /cores 0777 system system

We can see that it's different as the Linux command, mkdir /cores is the normal command in linux, but what the hell the latter three things are? This is the special syntax of android init language. From the reference, I have known mkdir has the syntax below:

mkdir [mode] [owner] [group]

Create a directory at path, optionally with the given mode, owner, and
group. If not provided, the directory is created with permissions 755 and
owned by the root user and root group. If provided, the mode, owner and group
will be updated if the directory exists already.

Now we can know this instruction's mean is:

  1. Create a directory with the given mode 0777.
  2. And the the owner user and the group user are both system.

2 mount tmpfs tmpfs /cores mode=0777,uid=1000,gid=1000

mount

[ \* ] []

Attempt to mount the named device at the directory dir
_flag_s include "ro", "rw", "remount", "noatime", ...
options include "barrier=1", "noauto_da_alloc", "discard", ... as
a comma separated string, eg: barrier=1,noauto_da_alloc

It is well known for Linux developers that the command "mount" is used to connect the real file system to the directory path. This instruction tells us that it will mount the "tmpfs" filesystem to the directory path "/cores". The other three options are the same as the last section.

3 restorecon_recursive /cores

This instruction is strongly related to SELinux. Firstly we should know the command "restorecon", I think that the "restorecon_recursive" command is the recursive version of the command "restorecon". After referencing the android source official site, I guess this command can restore the security settings from SELinux for some objects(Files or Directories) after doing some filesystem's actions, such as "mount". These filesystem's operations may destroy SELinux's security settings.

References

  1. Android Init Language
  2. tmpfs

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 使用NID修改DBID和DBNAME实验
  2. WORKAREA_SIZE_POLICY参数引起的ORA-0403
  3. SET UNUSED列可以恢复吗?
  4. 侵害10亿用户隐私,QQ、小米金融、搜狐新闻
  5. dom元素的增删改查
  6. [DUBBO] publishProvider interfaceName
  7. 通过lua将nginx请求状态码转变为自定义状
  8. JavaScript注释及命名规范
  9. 反射机制
  10. autofac for mvc