From 14d1496a7f498440983381e0391b026e666726a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 24 Sep 2004 00:16:51 +0000 Subject: [PATCH] sysconf(), pathconf(), and fpathconf() now at least do marginally useful things. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9053 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/unistd/conf.c | 70 +++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/src/kernel/libroot/posix/unistd/conf.c b/src/kernel/libroot/posix/unistd/conf.c index cde62249a3..58a63755a4 100644 --- a/src/kernel/libroot/posix/unistd/conf.c +++ b/src/kernel/libroot/posix/unistd/conf.c @@ -1,12 +1,12 @@ /* -** Copyright 2002, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. +** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. */ #include -#include #include +#include #include @@ -24,7 +24,31 @@ getdtablesize(void) long sysconf(int name) { - // ToDo: implement sysconf() + // This is about what BeOS does, better POSIX conformance would be nice, though + + switch (name) { + case _SC_ARG_MAX: + return ARG_MAX; + case _SC_CHILD_MAX: + return CHILD_MAX; + case _SC_CLK_TCK: + return CLK_TCK; + case _SC_JOB_CONTROL: + return 1; + case _SC_NGROUPS_MAX: + return NGROUPS_MAX; + case _SC_OPEN_MAX: + return OPEN_MAX; + case _SC_SAVED_IDS: + return 1; + case _SC_STREAM_MAX: + return STREAM_MAX; + case _SC_TZNAME_MAX: + return TZNAME_MAX; + case _SC_VERSION: + return _POSIX_VERSION; + } + return -1; } @@ -32,7 +56,40 @@ sysconf(int name) long fpathconf(int fd, int name) { - // ToDo: implement fpathconf() + switch (name) { + // ToDo: out of what stupidity have those been defined differently? + case _PC_CHOWN_RESTRICTED: + case _POSIX_CHOWN_RESTRICTED: + return 1; + + case _PC_MAX_CANON: + return MAX_CANON; + + case _PC_MAX_INPUT: + return MAX_INPUT; + + case _PC_NAME_MAX: + return NAME_MAX; + + case _PC_NO_TRUNC: + case _POSIX_NO_TRUNC: + return 0; + + case _PC_PATH_MAX: + return PATH_MAX; + + case _PC_PIPE_BUF: + return 4096; + + case _PC_LINK_MAX: + return LINK_MAX; + + // _PC_VDISABLE + // _POSIX_VDISABLE + // _POSIX_JOB_CONTROL + // _POSIX_SAVED_IDS + } + return -1; } @@ -40,7 +97,6 @@ fpathconf(int fd, int name) long pathconf(const char *path, int name) { - // ToDo: implement pathconf() - return -1; + return fpathconf(-1, name); }