0

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

1 Answers1

2

A leading 0 doesn’t indicate octal in nasm. Use 0o777 or 777o.

How to represent octal numbers in Assembly?

prl
  • 11,716
  • 2
  • 13
  • 31