2022-10-10 20:45:26 +02:00
|
|
|
#include <fcntl.h>
|
2022-10-27 17:42:00 +02:00
|
|
|
#include <luna/syscall.h>
|
2022-10-15 11:16:34 +02:00
|
|
|
#include <stdarg.h>
|
2022-10-16 17:27:15 +02:00
|
|
|
#include <stdint.h>
|
2022-10-10 20:45:26 +02:00
|
|
|
#include <sys/syscall.h>
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2022-10-27 07:52:57 +02:00
|
|
|
int open(const char* pathname, int flags, ...)
|
2022-10-10 20:45:26 +02:00
|
|
|
{
|
2022-10-27 07:52:57 +02:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, flags);
|
2022-10-27 17:42:00 +02:00
|
|
|
long result = __lc_fast_syscall3(SYS_open, pathname, flags, va_arg(ap, unsigned int));
|
2022-10-27 07:52:57 +02:00
|
|
|
va_end(ap);
|
|
|
|
return (int)result;
|
2022-10-10 20:45:26 +02:00
|
|
|
}
|
2022-10-15 11:16:34 +02:00
|
|
|
|
2022-11-12 14:12:49 +01:00
|
|
|
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.
|
|
|
|
}
|
|
|
|
|
2022-10-15 11:16:34 +02:00
|
|
|
int fcntl(int fd, int cmd, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, cmd);
|
2022-10-27 17:42:00 +02:00
|
|
|
long result = __lc_fast_syscall3(SYS_fcntl, fd, cmd, va_arg(ap, uintptr_t));
|
2022-10-15 11:16:34 +02:00
|
|
|
va_end(ap);
|
|
|
|
return (int)result;
|
|
|
|
}
|
2022-10-10 20:45:26 +02:00
|
|
|
}
|