Kernel/LibC: Implement all stat family functions with fstatat
This patch gets rid of 2 unnecessary syscalls!
This commit is contained in:
@@ -20,7 +20,6 @@ __BEGIN_DECLS
|
||||
O(SYS_EXEC, exec) \
|
||||
O(SYS_SLEEP, sleep) \
|
||||
O(SYS_WAIT, wait) \
|
||||
O(SYS_FSTAT, fstat) \
|
||||
O(SYS_READ_DIR, readdir) \
|
||||
O(SYS_SET_UID, setuid) \
|
||||
O(SYS_SET_GID, setgid) \
|
||||
@@ -47,7 +46,6 @@ __BEGIN_DECLS
|
||||
O(SYS_FCNTL, fcntl) \
|
||||
O(SYS_NANOSLEEP, nanosleep) \
|
||||
O(SYS_FSTATAT, fstatat) \
|
||||
O(SYS_STAT, stat) \
|
||||
O(SYS_SYNC, sync) \
|
||||
O(SYS_MMAP, mmap) \
|
||||
O(SYS_MUNMAP, munmap) \
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <BAN/Assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
@@ -20,7 +19,7 @@ int fchmod(int fildes, mode_t mode)
|
||||
|
||||
int fstat(int fildes, struct stat* buf)
|
||||
{
|
||||
return syscall(SYS_FSTAT, fildes, buf);
|
||||
return fstatat(fildes, nullptr, buf, 0);
|
||||
}
|
||||
|
||||
int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, int flag)
|
||||
@@ -30,12 +29,12 @@ int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, in
|
||||
|
||||
int lstat(const char* __restrict path, struct stat* __restrict buf)
|
||||
{
|
||||
return syscall(SYS_STAT, path, buf, AT_SYMLINK_NOFOLLOW);
|
||||
return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW);
|
||||
}
|
||||
|
||||
int stat(const char* __restrict path, struct stat* __restrict buf)
|
||||
{
|
||||
return syscall(SYS_STAT, path, buf, 0);
|
||||
return fstatat(AT_FDCWD, path, buf, 0);
|
||||
}
|
||||
|
||||
mode_t umask(mode_t cmask)
|
||||
|
||||
Reference in New Issue
Block a user