I am trying to create a file using some file operations system call in x86_64 Linux assembly code, but I am unable to get the permissions correct. I am tring to set the permission 0777 that is every one can read write and execute but the permissions I am getting on the file are None for owner, group, and others.
What am I missing?
The assembler I am using is nasm.
%macro print 2
mov rax,1
mov rdi,0
mov rsi,%1
mov rdx,%2
syscall
%endmacro
section .data
errmsg db "Incorrect argument count",10
errmsglen equ $-errmsg
section .bss
temp resb 8
sourcefile resb 8
global _start
section .text
_start:
pop rdx
cmp rdx, 03h
jne error
menu:
;------------Extract filename-------------
pop rdx
pop rdx
mov rsi, sourcefile
mov rax, [rdx]
mov [rsi], rax
;------------Open File---------
mov rax,85
mov rdi,sourcefile
mov rsi,2
mov rdx,0777
syscall
jmp exit
error:
print errmsg,errmsglen
jmp exit
exit:
mov rax,60
mov rdi,0
syscall