How to create a directory with 777 permissions?
I want to create directory with permission 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'
1 Answers How to create a directory with 777 permissions?
man 2 mkdir:
modespecifies the mode for the new directory (see 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).
Basically, both your program and your user can veto each permission bit:
- You can say which bits you are comfortable with by passing them to
- The user can say which bits they are comfortable with by setting the
- Only bits that you both agree on will be set on the final directory.
If you run
umask 0000before running your program, your directory will be
If you run
umask 0027your directory will be
If you want to force your directory to be
777against the user's wishes, you have to
chmod("somename", 0777)in a separate step.