MKDIR在init.rc [英] mkdir in init.rc

查看:925
本文介绍了MKDIR在init.rc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Init.rc

号线-264 --- 的mkdir /数据/其它/收音机0770电台收音

Line No-264---mkdir /data/misc/radio 0770 radio radio

我要改变/数据/其它/收音机的许可0775.

I want to change permission of /data/misc/radio to 0775.

我写这下上面一行:
号线-265 --- 搭配chmod 0775 /数据/其它/收音机

如果我更改线路264本--- 的mkdir /数据/其它/收音机0775电台收音 ..

If I change line 264 to this ---mkdir /data/misc/radio 0775 radio radio..

这有什么线的问题?
有人说,如果失败的mkdir(如果目录已经EXIS),那么将允许不能设置为0775.所以,如果失败的mkdir我们在不同的线路书面chmod命令来确保权限更改为0775。

what is problem with this line? Someone says that if mkdir fails(In case directory exis already) then permission will not be set to 0775. So to make sure that permission changes to 0775 if mkdir fails we have written chmod command in different line.

但是,有正在用不同的权限,不同的目录中那么多的mkdir命令,这样的话,如果我们去了上面的场景那么我们就应该在对应于每个mkdir命令提供不同的chmod命令?

But there are so many mkdir commands which is making different directories with different permissions,so then if we go by above scenario then we should provide different chmod command in correspond to each mkdir command?

推荐答案

在初始化执行的init.rc脚本中的mkdir会使目录,如果它不是present与您提供的权限,如果该目录存在则权限根据mkdir命令设置的。

When init executes the the init.rc script the mkdir will make the directory if it is not present with the permissions you provide, if the directory does exist then the permissions are set according to the mkdir command.

从AOSP系统/核心/初始化/在功能builtins.c do_mkdir()

from aosp system/core/init/builtins.c in the function do_mkdir()

ret = make_dir(args[1], mode);
/* chmod in case the directory already exists */
if (ret == -1 && errno == EEXIST) {
    ret = _chmod(args[1], mode);
}
if (ret == -1) {
    return -errno;
}

这篇关于MKDIR在init.rc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆