1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

LibC: Add realpath

This commit is contained in:
Rok Povsic 2019-08-25 18:17:31 +02:00 committed by Andreas Kling
parent 18fbe4ac83
commit 2ca8158a73
2 changed files with 19 additions and 0 deletions

View file

@ -568,6 +568,24 @@ int umount(const char* mountpoint)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
char* realpath(const char* pathname, char* buffer)
{
size_t size;
if (buffer == nullptr) {
size = PATH_MAX;
buffer = (char*)malloc(size);
} else {
size = sizeof(buffer);
}
int rc = syscall(SC_realpath, pathname, buffer, size);
if (rc < 0) {
errno = -rc;
return nullptr;
}
errno = 0;
return buffer;
}
void dump_backtrace()
{
syscall(SC_dump_backtrace);