linux mkdir 功能无法授权完全权限 [英] linux mkdir function can't authorize full permission
问题描述
我正在测试 mkdir
函数来创建一个新目录:
I am testing the mkdir
function to create a new directory:
folder = mkdir("./linux", 511);
或
folder = mkdir("./linux", 0777);
或
folder = mkdir("./linux", S_IRWXU | S_IRWXG | S_IRWXO);
如您所见,我尝试授予对目录的完全权限,但这是 ls -l | 的结果.grep linux
:
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
:
drwxr-xr-x 2 manuzhang manuzhang 4096 2012-01-04 06:53 linux
为什么我不能为组和其他人授予写权限?
why can't I authorize write permission for group and others?
更新:
奇怪的事情,正如你们告诉我的,我尝试了 umask
.它适用于 umask(S_IWGRP)
或 umask(S_IWOTH)
但失败与 umask(S_IWGRP | S_IWOTH)
,有什么想法吗?
Updates:
weird thing, as you guys told me I tried umask
. It works with either umask(S_IWGRP)
or umask(S_IWOTH)
but fails with umask(S_IWGRP | S_IWOTH)
, any ideas?
推荐答案
来自 man 2 mkdir
:
参数 mode 指定要使用的权限.由进程的 umask 以通常的方式修改:创建的目录的权限为 (mode & ~umask & 0777).
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).
我建议您查看您的 umask - 它可能设置为 0022
.尝试 chmod
后 mkdir
.
I suggest you look at your umask - it is probably set to 0022
. Try a chmod
post-mkdir
.
这篇关于linux mkdir 功能无法授权完全权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!