mkdir in init.rc

南楼画角 提交于 2019-12-24 06:46:02

问题


Init.rc

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

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

I have written this next to above line: Line No-265---chmod 0775 /data/misc/radio.

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

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.

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?


回答1:


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.

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;
}


来源:https://stackoverflow.com/questions/12559056/mkdir-in-init-rc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!