Rok Povsic 6 rokov pred
rodič
commit
2ca8158a73
2 zmenil súbory, kde vykonal 19 pridanie a 0 odobranie
  1. 18 0
      Libraries/LibC/unistd.cpp
  2. 1 0
      Libraries/LibC/unistd.h

+ 18 - 0
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);

+ 1 - 0
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,