feat(userspace/libc): implement fstat()

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-02-20 02:12:02 +02:00
parent 08319ef4c7
commit c83c542f5b
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
2 changed files with 20 additions and 2 deletions

View File

@ -87,7 +87,7 @@ extern "C"
int chmod(const char *, mode_t); int chmod(const char *, mode_t);
int fchmod(int, mode_t); int fchmod(int, mode_t);
int fchmodat(int, const char *, mode_t, int); int fchmodat(int, const char *, mode_t, int);
int fstat(int, struct stat *); int fstat(int fildes, struct stat *buf);
int fstatat(int, const char *restrict, struct stat *restrict, int); int fstatat(int, const char *restrict, struct stat *restrict, int);
int futimens(int, const struct timespec[2]); int futimens(int, const struct timespec[2]);
int lstat(const char *restrict, struct stat *restrict); int lstat(const char *restrict, struct stat *restrict);

View File

@ -22,7 +22,25 @@
export int chmod(const char *, mode_t); export int chmod(const char *, mode_t);
export int fchmod(int, mode_t); export int fchmod(int, mode_t);
export int fchmodat(int, const char *, mode_t, int); export int fchmodat(int, const char *, mode_t, int);
export int fstat(int, struct stat *);
export int fstat(int fildes, struct stat *buf)
{
if (fildes < 0)
{
errno = EBADF;
return -1;
}
int result = call_fstat(fildes, buf);
if (result == -1)
{
errno = result;
return -1;
}
return 0;
}
export int fstatat(int, const char *restrict, struct stat *restrict, int); export int fstatat(int, const char *restrict, struct stat *restrict, int);
export int futimens(int, const struct timespec[2]); export int futimens(int, const struct timespec[2]);
export int lstat(const char *restrict, struct stat *restrict); export int lstat(const char *restrict, struct stat *restrict);