[英]How to create a directory with 777 permissions?
I want to create directory with permission 777. 我想创建权限为777的目录。
The code below is creating the directory, but not with permissions I asked for. 下面的代码创建目录,但没有我要求的权限。
section .text
global _start:
_start:
mov rax,83 ;syscall number for directory
mov rdi,chaos ; dir name
mov esi,00777Q ;permissions for directory
syscall
mov rax,60
mov rdi,0
syscall
section .data
chaos:db 'somename'
Here's man 2 mkdir
: 这是
man 2 mkdir
:
The argument
mode
specifies the mode for the new directory (see inode(7)).参数
mode
指定新目录的模式(请参见inode(7))。 It is modified by the process's umask in the usual way: in the absence of a default ACL, the mode of the created directory is(mode & ~umask & 0777)
.它由进程的umask以通常的方式修改:在没有默认ACL的情况下,创建目录的模式为
(mode & ~umask & 0777)
。
Basically, both your program and your user can veto each permission bit: 基本上,您的程序和用户都可以否决每个权限位:
mkdir
mkdir
自己喜欢的位 umask
umask
自己喜欢的位 Therefore: 因此:
If you run umask 0000
before running your program, your directory will be 0777
. 如果在运行程序之前运行
umask 0000
,则目录将为0777
。
If you run umask 0027
your directory will be 0750
. 如果运行
umask 0027
目录将为0750
。
If you want to force your directory to be 777
against the user's wishes, you have to chmod("somename", 0777)
in a separate step. 如果要违反用户的意愿将目录设置为
777
,则必须在单独的步骤中chmod("somename", 0777)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.