Possible duplicate:
Inline Assembler for shell function does not work for some reason
I need to write a wrapper function for read , write , close , open & fork.
I wrote 4 wrapper functions for read , write , close , open.
My questions:
How to write a wrapper function for forkusing the 4 wrapper functions that I wrote for read , write , close & open?
How to check if the wrapper is spelled correctly? Here is the code for the wrapping function read- called my_read:
ssize_t my_read(int fd, void *buf, size_t count)
{
ssize_t res;
__asm__ volatile(
"int $0x80"
: "=a" (res),
"+b" (fd),
"+c" (buf),
"+d" (count)
: "a" (5)
: "memory", "cc");
if (-125 <= res && res < 0)
{
errno = -res;
res = -1;
}
return res;
}
Notes : I am not allowed to use commands directly open ,close ,read , write & fork.
I can attach the rest of the code of the other 3 wrappers if necessary. The above shell for read.
Yours faithfully
Ron