Browse Source

LibC: Add LINK_MAX and _PC_LINK_MAX

LINK_MAX was set arbitrarily to 4096, this is not an actual system
limit.
Peter Elliott 4 năm trước cách đây
mục cha
commit
f16aba405f

+ 2 - 0
Userland/Libraries/LibC/limits.h

@@ -80,6 +80,8 @@
 
 #define SSIZE_MAX 2147483647
 
+#define LINK_MAX 4096
+
 #ifdef __USE_POSIX
 #    include <bits/posix1_lim.h>
 #endif

+ 5 - 1
Userland/Libraries/LibC/unistd.cpp

@@ -619,7 +619,7 @@ int mknod(const char* pathname, mode_t mode, dev_t dev)
     __RETURN_WITH_ERRNO(rc, rc, -1);
 }
 
-long fpathconf([[maybe_unused]] int fd, [[maybe_unused]] int name)
+long fpathconf([[maybe_unused]] int fd, int name)
 {
     switch (name) {
     case _PC_NAME_MAX:
@@ -628,6 +628,8 @@ long fpathconf([[maybe_unused]] int fd, [[maybe_unused]] int name)
         return PATH_MAX;
     case _PC_VDISABLE:
         return _POSIX_VDISABLE;
+    case _PC_LINK_MAX:
+        return LINK_MAX;
     }
 
     VERIFY_NOT_REACHED();
@@ -642,6 +644,8 @@ long pathconf([[maybe_unused]] const char* path, int name)
         return PATH_MAX;
     case _PC_PIPE_BUF:
         return PIPE_BUF;
+    case _PC_LINK_MAX:
+        return LINK_MAX;
     }
 
     VERIFY_NOT_REACHED();

+ 2 - 1
Userland/Libraries/LibC/unistd.h

@@ -121,7 +121,8 @@ enum {
     _PC_NAME_MAX,
     _PC_PATH_MAX,
     _PC_PIPE_BUF,
-    _PC_VDISABLE
+    _PC_VDISABLE,
+    _PC_LINK_MAX
 };
 
 #define _POSIX_MONOTONIC_CLOCK 200112L