Luna/libc/src/fcntl.cpp
apio bab9600be5
Some checks failed
continuous-integration/drone/push Build is failing
libc: Add creat()
2023-03-19 19:21:36 +01:00

27 lines
519 B
C++

#include <bits/errno-return.h>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
int open(const char* path, int flags, ...)
{
va_list ap;
va_start(ap, flags);
mode_t mode = (mode_t)va_arg(ap, int);
long rc = syscall(SYS_open, path, flags, mode);
va_end(ap);
__errno_return(rc, int);
}
int creat(const char* path, mode_t mode)
{
return open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
}
}