2023-06-11 00:54:04 +03:00
|
|
|
#include <errno.h>
|
2023-06-05 14:36:17 +03:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2024-07-31 23:25:11 +03:00
|
|
|
mode_t __umask = 0;
|
|
|
|
|
2023-10-25 02:35:37 +03:00
|
|
|
int chmod(const char* path, mode_t mode)
|
|
|
|
{
|
|
|
|
return syscall(SYS_CHMOD, path, mode);
|
|
|
|
}
|
|
|
|
|
2023-06-11 00:54:04 +03:00
|
|
|
int fstat(int fildes, struct stat* buf)
|
|
|
|
{
|
|
|
|
return syscall(SYS_FSTAT, fildes, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, int flag)
|
|
|
|
{
|
2023-09-08 11:46:53 +03:00
|
|
|
return syscall(SYS_FSTATAT, fd, path, buf, flag);
|
2023-06-11 00:54:04 +03:00
|
|
|
}
|
|
|
|
|
2023-06-05 14:36:17 +03:00
|
|
|
int lstat(const char* __restrict path, struct stat* __restrict buf)
|
|
|
|
{
|
2023-09-08 11:46:53 +03:00
|
|
|
return syscall(SYS_STAT, path, buf, AT_SYMLINK_NOFOLLOW);
|
2023-06-05 14:36:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int stat(const char* __restrict path, struct stat* __restrict buf)
|
|
|
|
{
|
2023-09-08 11:46:53 +03:00
|
|
|
return syscall(SYS_STAT, path, buf, 0);
|
2023-06-05 14:36:17 +03:00
|
|
|
}
|
2023-10-25 19:45:18 +03:00
|
|
|
|
2024-07-31 23:25:11 +03:00
|
|
|
mode_t umask(mode_t cmask)
|
|
|
|
{
|
|
|
|
mode_t old = __umask;
|
|
|
|
__umask = cmask;
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2023-10-25 19:45:18 +03:00
|
|
|
int mkdir(const char* path, mode_t mode)
|
|
|
|
{
|
2024-07-31 23:25:11 +03:00
|
|
|
return syscall(SYS_CREATE_DIR, path, __UMASKED_MODE(mode));
|
2023-10-25 19:45:18 +03:00
|
|
|
}
|