Added readlinkat().

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33978 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-11-10 11:24:46 +00:00
parent fdec1a3f87
commit b189a2014e
2 changed files with 11 additions and 2 deletions

View File

@ -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);

View File

@ -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);
}