2023-04-23 14:32:37 +03:00
|
|
|
#include <fcntl.h>
|
2023-07-10 15:08:30 +03:00
|
|
|
#include <stdarg.h>
|
2023-04-23 14:32:37 +03:00
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2023-10-25 19:45:18 +03:00
|
|
|
int creat(const char* path, mode_t mode)
|
|
|
|
{
|
2024-09-17 15:55:53 +03:00
|
|
|
return open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
2023-10-25 19:45:18 +03:00
|
|
|
}
|
|
|
|
|
2023-04-23 14:32:37 +03:00
|
|
|
int open(const char* path, int oflag, ...)
|
|
|
|
{
|
2023-07-10 15:08:30 +03:00
|
|
|
va_list args;
|
|
|
|
va_start(args, oflag);
|
|
|
|
mode_t mode = va_arg(args, mode_t);
|
|
|
|
va_end(args);
|
|
|
|
|
2024-09-17 16:16:47 +03:00
|
|
|
return openat(AT_FDCWD, path, oflag, mode);
|
2023-04-23 14:32:37 +03:00
|
|
|
}
|
2023-06-11 03:27:56 +03:00
|
|
|
|
|
|
|
int openat(int fd, const char* path, int oflag, ...)
|
|
|
|
{
|
2023-07-10 15:08:30 +03:00
|
|
|
va_list args;
|
|
|
|
va_start(args, oflag);
|
|
|
|
mode_t mode = va_arg(args, mode_t);
|
|
|
|
va_end(args);
|
|
|
|
|
2024-07-31 23:25:11 +03:00
|
|
|
return syscall(SYS_OPENAT, fd, path, oflag, __UMASKED_MODE(mode));
|
2023-06-11 03:27:56 +03:00
|
|
|
}
|
2023-09-04 12:57:09 +03:00
|
|
|
|
|
|
|
int fcntl(int fildes, int cmd, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
va_start(args, cmd);
|
|
|
|
int extra = va_arg(args, int);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return syscall(SYS_FCNTL, fildes, cmd, extra);
|
2024-01-24 14:43:46 +02:00
|
|
|
}
|