diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index 1991dbf45d..9c8f7e07aa 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -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); diff --git a/Libraries/LibC/unistd.h b/Libraries/LibC/unistd.h index 30fac6c00c..08cadfb408 100644 --- a/Libraries/LibC/unistd.h +++ b/Libraries/LibC/unistd.h @@ -103,6 +103,7 @@ int halt(); int reboot(); int mount(const char* device, const char* mountpoint, const char* fstype); int umount(const char* mountpoint); +char* realpath(const char* pathname, char* buffer); enum { _PC_NAME_MAX,