linux mkdir 功能无法授权完全权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8719867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
linux mkdir function can't authorize full permission
提问by manuzhang
I am testing the mkdir
function to create a new directory:
我正在测试mkdir
创建新目录的功能:
folder = mkdir("./linux", 511);
or
或者
folder = mkdir("./linux", 0777);
or
或者
folder = mkdir("./linux", S_IRWXU | S_IRWXG | S_IRWXO);
As you can see, I try to authorize the full permission to the directory but here's what comes up with ls -l | grep linux
:
如您所见,我尝试授予对目录的完全权限,但结果ls -l | grep linux
如下:
drwxr-xr-x 2 manuzhang manuzhang 4096 2012-01-04 06:53 linux
why can't I authorize write permission for group and others?
为什么我不能为组和其他人授予写权限?
Updates:
weird thing, as you guys told me I tried umask
. It works with either umask(S_IWGRP)
or umask(S_IWOTH)
but failswith umask(S_IWGRP | S_IWOTH)
, any ideas?
更新:
奇怪的事情,正如你们告诉我的那样,我试过了umask
。它与两种umask(S_IWGRP)
或umask(S_IWOTH)
但未能有umask(S_IWGRP | S_IWOTH)
任何想法?
回答by sbenitezb
Check the umask function: man 2 umask
检查 umask 功能:man 2 umask
回答by duskwuff -inactive-
回答by Kristian Glass
From man 2 mkdir
:
来自man 2 mkdir
:
The argument mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created directory are (mode & ~umask & 0777).
参数 mode 指定要使用的权限。它以通常的方式由进程的 umask 修改:创建的目录的权限为 (mode & ~umask & 0777)。
I suggest you look at your umask - it is probably set to 0022
. Try a chmod
post-mkdir
.
我建议你看看你的 umask - 它可能设置为0022
. 尝试chmod
后 - mkdir
。