Luna/libs/libc/src/fcntl.cpp

26 lines
568 B
C++
Raw Normal View History

#include <fcntl.h>
#include <stdarg.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
int open(const char* pathname, int flags)
{
return (int)syscall(SYS_open, pathname, flags);
}
int fcntl(int fd, int cmd, ...)
{
va_list ap;
va_start(ap, cmd);
long result;
switch (cmd)
{
case F_DUPFD: result = syscall(SYS_fcntl, fd, cmd, va_arg(ap, int)); break;
default: result = syscall(SYS_fcntl, fd, cmd, 0); break;
}
va_end(ap);
return (int)result;
}
}