diff --git a/headers/posix/unistd.h b/headers/posix/unistd.h index 778a109f6f..3b9c55c4e7 100644 --- a/headers/posix/unistd.h +++ b/headers/posix/unistd.h @@ -138,6 +138,8 @@ extern int unlink(const char *name); extern int rmdir(const char *path); extern ssize_t readlink(const char *path, char *buffer, size_t bufferSize); +extern ssize_t readlinkat(int fd, const char *path, char *buffer, + size_t bufferSize); extern int symlink(const char *from, const char *to); extern int ftruncate(int fd, off_t newSize); diff --git a/src/system/libroot/posix/unistd/link.c b/src/system/libroot/posix/unistd/link.c index 6db0fff161..9925154aa1 100644 --- a/src/system/libroot/posix/unistd/link.c +++ b/src/system/libroot/posix/unistd/link.c @@ -19,9 +19,16 @@ ssize_t readlink(const char *path, char *buffer, size_t bufferSize) +{ + return readlinkat(AT_FDCWD, path, buffer, bufferSize); +} + + +ssize_t +readlinkat(int fd, const char *path, char *buffer, size_t bufferSize) { size_t linkLen = bufferSize; - status_t status = _kern_read_link(-1, path, buffer, &linkLen); + status_t status = _kern_read_link(fd, path, buffer, &linkLen); if (status < B_OK) { errno = status; return -1; @@ -49,7 +56,7 @@ int unlink(const char *path) { int status = _kern_unlink(-1, path); - + RETURN_AND_SET_ERRNO(status); }