diff --git a/src/kernel/libroot/posix/sys/Jamfile b/src/kernel/libroot/posix/sys/Jamfile index a33d5272ec..d9f6cd7492 100644 --- a/src/kernel/libroot/posix/sys/Jamfile +++ b/src/kernel/libroot/posix/sys/Jamfile @@ -1,12 +1,17 @@ SubDir OBOS_TOP src kernel libroot posix sys ; KernelMergeObject posix_sys.o : - <$(SOURCE_GRIST)>chmod.c - <$(SOURCE_GRIST)>stat.c - <$(SOURCE_GRIST)>mkdir.c - <$(SOURCE_GRIST)>select.c - <$(SOURCE_GRIST)>sysctl.c - <$(SOURCE_GRIST)>gettimeofday.c - <$(SOURCE_GRIST)>wait.c + chmod.c + getrusage.c + gettimeofday.c + itimer.c + mkdir.c + mkfifo.c + rlimit.c + select.c + stat.c + sysctl.c + umask.c + wait.c : -fPIC -DPIC ; diff --git a/src/kernel/libroot/posix/sys/getrusage.c b/src/kernel/libroot/posix/sys/getrusage.c new file mode 100644 index 0000000000..81f307cc25 --- /dev/null +++ b/src/kernel/libroot/posix/sys/getrusage.c @@ -0,0 +1,19 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include +#include +#include + + +int +getrusage(int who, struct rusage *rusage) +{ + // ToDo: implement me! + errno = B_BAD_VALUE; + return -1; +} + diff --git a/src/kernel/libroot/posix/sys/itimer.c b/src/kernel/libroot/posix/sys/itimer.c new file mode 100644 index 0000000000..bd72789f61 --- /dev/null +++ b/src/kernel/libroot/posix/sys/itimer.c @@ -0,0 +1,50 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include + +#include +#include + + +#define USEC_PER_SECOND 1000000 + + +int +getitimer(int which, struct itimerval *value) +{ + // ToDo: implement me! + return -1; +} + + +int +setitimer(int which, const struct itimerval *value, struct itimerval *oldValue) +{ + // ToDo: implement me properly! + // We probably need a better internal set_alarm() implementation to do this + + bigtime_t interval = value->it_interval.tv_sec * USEC_PER_SECOND + value->it_interval.tv_usec; + if (interval != 0) + set_alarm(interval, B_PERIODIC_ALARM); + else { + bigtime_t timeout = value->it_value.tv_sec * USEC_PER_SECOND + value->it_value.tv_usec; + if (timeout != 0) + set_alarm(timeout, B_ONE_SHOT_RELATIVE_ALARM); + else { + // cancel alarm + set_alarm(B_INFINITE_TIMEOUT, B_PERIODIC_ALARM); + } + } + + // whatever set_alarm() returns (not documented in the BeBook, and I haven't + // investigated this yet), maybe we can maintain the oldValue with it. + + memset(oldValue, 0, sizeof(struct itimerval)); + + return 0; +} + diff --git a/src/kernel/libroot/posix/sys/mkfifo.c b/src/kernel/libroot/posix/sys/mkfifo.c new file mode 100644 index 0000000000..3b7c52e786 --- /dev/null +++ b/src/kernel/libroot/posix/sys/mkfifo.c @@ -0,0 +1,25 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include +#include +#include + + +#define RETURN_AND_SET_ERRNO(err) \ + if (err < 0) { \ + errno = err; \ + return -1; \ + } \ + return err; + + +int +mkfifo(const char *path, mode_t mode) +{ + // ToDo: implement me for real! + RETURN_AND_SET_ERRNO(B_BAD_VALUE); +} diff --git a/src/kernel/libroot/posix/sys/rlimit.c b/src/kernel/libroot/posix/sys/rlimit.c new file mode 100644 index 0000000000..d759e39775 --- /dev/null +++ b/src/kernel/libroot/posix/sys/rlimit.c @@ -0,0 +1,36 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include +#include +#include + + +#define RETURN_AND_SET_ERRNO(err) \ + if (err < 0) { \ + errno = err; \ + return -1; \ + } \ + return err; + + +int +getrlimit(int resource, struct rlimit *rlimit) +{ + int status = _kern_getrlimit(resource, rlimit); + + RETURN_AND_SET_ERRNO(status); +} + + +int +setrlimit(int resource, const struct rlimit *rlimit) +{ + int status = _kern_setrlimit(resource, rlimit); + + RETURN_AND_SET_ERRNO(status); +} + diff --git a/src/kernel/libroot/posix/sys/umask.c b/src/kernel/libroot/posix/sys/umask.c new file mode 100644 index 0000000000..9192f549aa --- /dev/null +++ b/src/kernel/libroot/posix/sys/umask.c @@ -0,0 +1,24 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include +#include +#include + + +mode_t __gUmask = 022; + // this must be made available to open() and friends + + +mode_t +umask(mode_t newMask) +{ + mode_t oldMask = __gUmask; + __gUmask = newMask; + + return oldMask; +} +