Hadoop 文件系统 mkdirs() 在传递 777 时创建具有 755 权限的目录
Hadoop FileSystem mkdirs() creates directory with 755 permission when passed 777
以下代码段中使用的文件系统对象已通过 org.apache.hadoop.fs.FileSystem.get(Configuration conf)
获得。
下面传递的FsPermission对象已经通过FsPermission.getDefault()
获得,即777。
public int mkdirs(Path f, FsPermission permission) {
try {
return fileSystem.mkdirs(f, permission) ? 0 : 1;
} catch (IOException e) {
LOG.error("Failed to execute 'mkdirs': " + e.getMessage());
}
return 1;
}
然而,即使通过 777,创建的结果目录也具有 755 权限。
这里有什么问题吗?
几乎可以肯定 process umask
设置为 022
并屏蔽了这些位。
Per the Wikipedia entry on umask
:
In computing, umask is a command that determines the settings of a
mask that controls how file permissions are set for newly created
files. It also may refer to a function that sets the mask, or it may
refer to the mask itself, which is formally known as the file mode
creation mask. The mask is a grouping of bits, each of which restricts
how its corresponding permission is set for newly created files. The
bits in the mask may be changed by invoking the umask command.
In UNIX, each file has a set of attributes which control who can read,
write or execute it. When a program creates a file, UNIX requires that
the file permissions be set to an initial setting. The mask restricts
permission settings. If the mask has a bit set to "1", it means the
corresponding initial file permission will be disabled. A bit set to
"0" in the mask means that the corresponding permission will be
determined by the program and the system. In other words, the mask
acts as a last-stage filter that strips away permissions as a file is
created; each bit that is set to a "1" strips away its corresponding
permission. Permissions may be changed later by users and programs
using chmod.
Each program (technically called a process) has its own mask, and is
able to change its settings using a function call. ...
将 umask
设置为 022
(八进制),创建请求权限为 0777
的内容将导致最终权限为 0755
.
以下代码段中使用的文件系统对象已通过 org.apache.hadoop.fs.FileSystem.get(Configuration conf)
获得。
下面传递的FsPermission对象已经通过FsPermission.getDefault()
获得,即777。
public int mkdirs(Path f, FsPermission permission) {
try {
return fileSystem.mkdirs(f, permission) ? 0 : 1;
} catch (IOException e) {
LOG.error("Failed to execute 'mkdirs': " + e.getMessage());
}
return 1;
}
然而,即使通过 777,创建的结果目录也具有 755 权限。
这里有什么问题吗?
几乎可以肯定 process umask
设置为 022
并屏蔽了这些位。
Per the Wikipedia entry on umask
:
In computing, umask is a command that determines the settings of a mask that controls how file permissions are set for newly created files. It also may refer to a function that sets the mask, or it may refer to the mask itself, which is formally known as the file mode creation mask. The mask is a grouping of bits, each of which restricts how its corresponding permission is set for newly created files. The bits in the mask may be changed by invoking the umask command.
In UNIX, each file has a set of attributes which control who can read, write or execute it. When a program creates a file, UNIX requires that the file permissions be set to an initial setting. The mask restricts permission settings. If the mask has a bit set to "1", it means the corresponding initial file permission will be disabled. A bit set to "0" in the mask means that the corresponding permission will be determined by the program and the system. In other words, the mask acts as a last-stage filter that strips away permissions as a file is created; each bit that is set to a "1" strips away its corresponding permission. Permissions may be changed later by users and programs using chmod.
Each program (technically called a process) has its own mask, and is able to change its settings using a function call. ...
将 umask
设置为 022
(八进制),创建请求权限为 0777
的内容将导致最终权限为 0755
.