Reputation: 35
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'
Upvotes: 1
Views: 2250
Reputation: 123680
Here's man 2 mkdir
:
The argument
mode
specifies 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:
mkdir
umask
Therefore:
If you run umask 0000
before running your program, your directory will be 0777
.
If you run umask 0027
your directory will be 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.
Upvotes: 4