#include #include #include #include #include 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_openat, AT_FDCWD, 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); } int fcntl(int fd, int cmd, ...) { va_list ap; va_start(ap, cmd); uintptr_t arg = (uintptr_t)va_arg(ap, uintptr_t); long rc = syscall(SYS_fcntl, fd, cmd, arg); va_end(ap); __errno_return(rc, int); } }