mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
Kernel+LibC: Implement readlinkat(2)
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
This commit is contained in:
parent
9850a69cd1
commit
6445a706cf
6 changed files with 16 additions and 6 deletions
|
@ -630,10 +630,16 @@ int sethostname(char const* hostname, ssize_t size)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html
|
||||
ssize_t readlink(char const* path, char* buffer, size_t size)
|
||||
{
|
||||
Syscall::SC_readlink_params params { { path, strlen(path) }, { buffer, size } };
|
||||
return readlinkat(AT_FDCWD, path, buffer, size);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html
|
||||
ssize_t readlinkat(int dirfd, char const* path, char* buffer, size_t size)
|
||||
{
|
||||
Syscall::SC_readlink_params params { { path, strlen(path) }, { buffer, size }, dirfd };
|
||||
int rc = syscall(SC_readlink, ¶ms);
|
||||
// Return the number of bytes placed in the buffer, not the full path size.
|
||||
__RETURN_WITH_ERRNO(rc, min((size_t)rc, size), -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue