From ff29e9c4d697353734f9a2d72c8d815361d0daee Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 28 Jul 2025 14:56:37 +0300 Subject: [PATCH] LibC: Implement {,f}pathconf This just return minimum values specified by posix --- userspace/libraries/LibC/unistd.cpp | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/userspace/libraries/LibC/unistd.cpp b/userspace/libraries/LibC/unistd.cpp index 19d9a8ce..0025343e 100644 --- a/userspace/libraries/LibC/unistd.cpp +++ b/userspace/libraries/LibC/unistd.cpp @@ -882,7 +882,35 @@ size_t confstr(int name, char* buf, size_t len) return 0; } -long pathconf(const char* path, int name); +long fpathconf(int fd, int name) +{ + (void)fd; + switch (name) + { +#define LIMIT_CASE(name) case _PC_##name: return name; + LIMIT_CASE(LINK_MAX) + LIMIT_CASE(MAX_CANON) + LIMIT_CASE(MAX_INPUT) + LIMIT_CASE(NAME_MAX) + LIMIT_CASE(PATH_MAX) + LIMIT_CASE(PIPE_BUF) +#undef LIMIT_CASE +#define POSIX_CASE(name) case _PC_##name: return _POSIX_##name; + POSIX_CASE(CHOWN_RESTRICTED) + POSIX_CASE(NO_TRUNC) + POSIX_CASE(VDISABLE) +#undef POSIX_CASE + } + + errno = EINVAL; + return 0; +} + +long pathconf(const char* path, int name) +{ + (void)path; + return fpathconf(0, name); +} long sysconf(int name) {