33 lines
962 B
C++
33 lines
962 B
C++
#include <fcntl.h>
|
|
#include <luna/syscall.h>
|
|
#include <stdarg.h>
|
|
#include <stdint.h>
|
|
#include <sys/syscall.h>
|
|
|
|
extern "C"
|
|
{
|
|
int open(const char* pathname, int flags, ...)
|
|
{
|
|
va_list ap;
|
|
va_start(ap, flags);
|
|
long result = __lc_fast_syscall3(SYS_open, pathname, flags, va_arg(ap, unsigned int));
|
|
va_end(ap);
|
|
return (int)result;
|
|
}
|
|
|
|
int creat(const char* pathname, mode_t mode)
|
|
{
|
|
return (int)__lc_fast_syscall3(SYS_open, pathname, O_WRONLY | O_CREAT | O_TRUNC,
|
|
mode); // we don't need to pass this through to open(), we can avoid variadic
|
|
// stuff since we're sure mode exists.
|
|
}
|
|
|
|
int fcntl(int fd, int cmd, ...)
|
|
{
|
|
va_list ap;
|
|
va_start(ap, cmd);
|
|
long result = __lc_fast_syscall3(SYS_fcntl, fd, cmd, va_arg(ap, uintptr_t));
|
|
va_end(ap);
|
|
return (int)result;
|
|
}
|
|
} |