gpt4 book ai didi

Hadoop 文件系统 mkdirs() 在传递 777 时创建具有 755 权限的目录

转载 作者:可可西里 更新时间:2023-11-01 14:51:50 25 4
gpt4 key购买 nike

下面代码段中使用的文件系统对象已通过 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

关于Hadoop 文件系统 mkdirs() 在传递 777 时创建具有 755 权限的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42000592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com