summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/posix/pathconf.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/ape/lib/ap/posix/pathconf.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/ape/lib/ap/posix/pathconf.c')
-rwxr-xr-xsys/src/ape/lib/ap/posix/pathconf.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/sys/src/ape/lib/ap/posix/pathconf.c b/sys/src/ape/lib/ap/posix/pathconf.c
new file mode 100755
index 000000000..9fdf47684
--- /dev/null
+++ b/sys/src/ape/lib/ap/posix/pathconf.c
@@ -0,0 +1,55 @@
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <sys/limits.h>
+
+long
+pathconf(const char *path, int name)
+{
+#pragma ref path
+
+ switch(name)
+ {
+ case _PC_LINK_MAX:
+ return LINK_MAX;
+ case _PC_MAX_CANON:
+ return MAX_CANON;
+ case _PC_MAX_INPUT:
+ return MAX_INPUT;
+ case _PC_NAME_MAX:
+ return NAME_MAX;
+ case _PC_PATH_MAX:
+ return PATH_MAX;
+ case _PC_PIPE_BUF:
+ return PIPE_BUF;
+ case _PC_CHOWN_RESTRICTED:
+#ifdef _POSIX_CHOWN_RESTRICTED
+ return _POSIX_CHOWN_RESTRICTED;
+#else
+ return -1;
+#endif
+ case _PC_NO_TRUNC:
+#ifdef _POSIX_NO_TRUNC
+ return _POSIX_NO_TRUNC;
+#else
+ return -1;
+#endif
+ case _PC_VDISABLE:
+#ifdef _POSIX_VDISABLE
+ return _POSIX_VDISABLE;
+#else
+ return -1;
+#endif
+ }
+ errno = EINVAL;
+ return -1;
+}
+
+long
+fpathconf(int fd, int name)
+{
+#pragma ref fd
+
+ return pathconf(0, name);
+}
+