67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
#include <bits/errno-return.h>
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/syscall.h>
|
|
#include <unistd.h>
|
|
|
|
extern "C"
|
|
{
|
|
int mkdir(const char* path, mode_t mode)
|
|
{
|
|
long rc = syscall(SYS_mkdir, path, mode);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int chmod(const char* path, mode_t mode)
|
|
{
|
|
long rc = syscall(SYS_fchmodat, AT_FDCWD, path, mode, 0);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int fchmod(int fd, mode_t mode)
|
|
{
|
|
long rc = syscall(SYS_fchmodat, fd, "", mode, AT_EMPTY_PATH);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int stat(const char* path, struct stat* st)
|
|
{
|
|
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, 0);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int lstat(const char* path, struct stat* st)
|
|
{
|
|
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, AT_SYMLINK_NOFOLLOW);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int fstat(int fd, struct stat* st)
|
|
{
|
|
long rc = syscall(SYS_fstatat, fd, "", st, AT_EMPTY_PATH);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int fstatat(int dirfd, const char* path, struct stat* st, int flags)
|
|
{
|
|
long rc = syscall(SYS_fstatat, dirfd, path, st, flags);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
mode_t umask(mode_t mask)
|
|
{
|
|
return (mode_t)syscall(SYS_umask, mask);
|
|
}
|
|
|
|
int utimensat(int dirfd, const char* path, const struct timespec* times, int flags)
|
|
{
|
|
long rc = syscall(SYS_utimensat, dirfd, path, times, flags);
|
|
__errno_return(rc, int);
|
|
}
|
|
|
|
int futimens(int fd, const struct timespec* times, int flags)
|
|
{
|
|
return utimensat(fd, "", times, flags | AT_EMPTY_PATH);
|
|
}
|
|
}
|