1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibC: Move stat(), lstat() and fstat() to <sys/stat.h>

Dr. POSIX says that's where they belong.
This commit is contained in:
Andreas Kling 2020-08-11 18:56:41 +02:00
parent 9e55162e9b
commit 3a13c749cd
4 changed files with 30 additions and 31 deletions

View file

@ -69,4 +69,31 @@ int mkfifo(const char* pathname, mode_t mode)
{
return mknod(pathname, mode | S_IFIFO, 0);
}
static int do_stat(const char* path, struct stat* statbuf, bool follow_symlinks)
{
if (!path) {
errno = EFAULT;
return -1;
}
Syscall::SC_stat_params params { { path, strlen(path) }, statbuf, follow_symlinks };
int rc = syscall(SC_stat, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int lstat(const char* path, struct stat* statbuf)
{
return do_stat(path, statbuf, false);
}
int stat(const char* path, struct stat* statbuf)
{
return do_stat(path, statbuf, true);
}
int fstat(int fd, struct stat* statbuf)
{
int rc = syscall(SC_fstat, fd, statbuf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}