mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
LibC: Add realpath
This commit is contained in:
parent
18fbe4ac83
commit
2ca8158a73
2 changed files with 19 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue