[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE : open syscall wrapper - is this bug free ?
Ted Unangst wrote:
>Hi folks.
>
>Sorry for this OT, but this list is the closer i get!
>
>I am in need for writing an open syscall wrapper. Since i do not want
to
>deal with stdargs my approach went like this:
>[...]
Hello,
I have had the same problem, and i have fixed it with this on i386/*BSD:
http://folays.nerim.net/my_call.s
So, I can do this:
int apx_open(const char *path, int flags, mode_t mode)
{
int ret;
if ((ret = my_call(open)) == -1)
exit(-1)
else
return (ret);
}
In fact, my_call() copy the current stack frame into a new one, and then
call the function in the first arg. So, the arg in apx_open() will be
unchanged after the my_call() call.
When open() return, we can get this value by the return of my_call().