linuxassemblydirectoryx86-64umask

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'

Solution

  • 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:

    Therefore: