flat assembler
Message board for the users of flat assembler.
Index
> Linux > [solved] Problem with mkdir syscall |
Author |
|
Potato 21 Apr 2020, 08:55
Ok, I tap out, I can't find an example or information on this.
What I am trying to do: create a directory called test Info I found so far, https://filippo.io/linux-syscall-table/ this website seemed to have a list of what registers I needed to update before I made the syscall and gave the relivant number I needed (83). Other than that have not really found anything usefull. This was my first atempt, I am thinking that it needs to be a pointer to the string. Other thoughts were perhaps it needed a terminator (meh - clutching at straws). Perhaps there is a need for a chmod type command before the directory gets created? My next plan is to write a simple program in c and pick apart the output to figure how its done. There has to be a sequence of syscalls to make these directory and file operations happen. Code: format ELF64 executable 3 segment readable executable entry main main: mov rax,83 mov rdi,namen syscall call exit exit: xor rdi,rdi mov rax,60 syscall segment readable writeable namen db 'test',0 |
|||
21 Apr 2020, 08:55 |
|
revolution 21 Apr 2020, 09:37
The syscall for mkdir also needs a mode parameter.
Code: SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode) |
|||
21 Apr 2020, 09:37 |
|
revolution 21 Apr 2020, 10:36
RAX has a return value. It might tell you what went wrong.
|
|||
21 Apr 2020, 10:36 |
|
Potato 21 Apr 2020, 10:56
revolution wrote: RAX has a return value. It might tell you what went wrong. holy moly, it worked! lol I must have not been compiling the program properly, when i used the debuger, I steped through a few times and all the exit codes were 00h so I was thinking 'hmmm thats saying everything is fantastic'.. I looked at the directory and sure enough test was there.. thanks for the help. Code: format ELF64 executable 3 segment readable executable entry main main: mov rax,83 mov rdi,namen mov rsi,0 syscall call exit exit: xor rdi,rdi mov rax,60 syscall segment readable writeable namen db 'test',0 The intresting thing is that its writing the directory with root permision, when you try and access the directory as a normal user its forbiden. - scratch that I was being a Potato and was not setting the chmod correctly. should have been Code: mov rsi,777o everything works! Horray - I couldn't help myself sorry. here is a program to delete the test directory. Code: format ELF64 executable 3 segment readable executable entry main main: mov rax,84 mov rdi,namen syscall call exit exit: xor rdi,rdi mov rax,60 syscall segment readable writeable namen db 'test',0 |
|||
21 Apr 2020, 10:56 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.