trying to emulate linux command in x86_64 assembly
I really need your help. so i am basicly trying to emulate Linux rm* command using assembly language :
when i ran strace on the command this is what i've got: Code:
execve("/bin/rm", ["rm", "test1", "test2"], 0x7ffc85aaee50 /* 56 vars */) = 0 Code:
global _start |
Welcome to LQ!
Please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls. |
The asterisk in rm * is interpreted by the shell. The shell performs a directory lookup, and you are right: It's probably getdents. You will have to open the current directory and use the file descriptor thus obtained to make the call to getdents. Then loop over the getdents results and unlink the names.
The getdents man page (see link above) contains a sample C program. I will leave it up to you to turn that into assembly code. |
pointer to a filename in linux x86_64 assembly
So i am trying to make a program that loops through directory, and deletes every file in it, so i am using getdents64 system call to do this. and since getdents returns number of bytes read from directory. i cannot loop through it. so i obviously need to point to the filename in a directory. but i really don't know how to do it,
this code will not work, when you run strace on it you will get this output, obiously i have put the output of a program running without a loop, you can guess what happens when i run it in a loop strace output: Code:
execve("./whiper", ["./whiper"], 0x7ffe7ac97400 /* 58 vars */) = 0 Code:
global _start |
Please post your thread only once. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being merged with your previous thread of same subject.
|
All times are GMT -5. The time now is 11:20 AM. |