diff --git a/headers/posix/fcntl.h b/headers/posix/fcntl.h index 581d6c8e7d..fa6f0a307d 100644 --- a/headers/posix/fcntl.h +++ b/headers/posix/fcntl.h @@ -66,6 +66,9 @@ #define AT_FDCWD (-1) /* CWD FD for the *at() functions */ +#define AT_SYMLINK_NOFOLLOW 0x1 /* fstatat(), fchmodat(), fchownat(), + utimensat() */ +#define AT_SYMLINK_FOLLOW 0x2 /* linkat() */ /* advisory file locking */ diff --git a/headers/posix/sys/stat.h b/headers/posix/sys/stat.h index fbce1ef98e..530f53e64d 100644 --- a/headers/posix/sys/stat.h +++ b/headers/posix/sys/stat.h @@ -105,14 +105,15 @@ struct stat { extern "C" { #endif -extern int chmod(const char *path, mode_t mode); -extern int fchmod(int fd, mode_t mode); -extern int stat(const char *path, struct stat *st); -extern int fstat(int fd, struct stat *st); -extern int lstat(const char *path, struct stat *st); -extern int mkdir(const char *path, mode_t mode); -extern int mkfifo(const char *path, mode_t mode); -extern mode_t umask(mode_t cmask); +extern int chmod(const char *path, mode_t mode); +extern int fchmod(int fd, mode_t mode); +extern int stat(const char *path, struct stat *st); +extern int fstat(int fd, struct stat *st); +extern int lstat(const char *path, struct stat *st); +extern int fstatat(int fd, const char *path, struct stat *st, int flag); +extern int mkdir(const char *path, mode_t mode); +extern int mkfifo(const char *path, mode_t mode); +extern mode_t umask(mode_t cmask); #ifdef __cplusplus } diff --git a/src/system/libroot/posix/sys/stat.c b/src/system/libroot/posix/sys/stat.c index fa817415a1..15cf9e8e99 100644 --- a/src/system/libroot/posix/sys/stat.c +++ b/src/system/libroot/posix/sys/stat.c @@ -51,6 +51,16 @@ _lstat_current(const char* path, struct stat* stat) } +int +fstatat(int fd, const char *path, struct stat *st, int flag) +{ + int status = _kern_read_stat(fd, path, (flag & AT_SYMLINK_NOFOLLOW) != 0, + st, sizeof(struct stat)); + + RETURN_AND_SET_ERRNO(status); +} + + // #pragma mark - BeOS compatibility