etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / getrlimit.c
blob1df733b565d0059e7c7b675f695ef06a704e349f
1 /* getrlimit Author: Erik van der Kouwe
2 * query resource consumtion limits 4 December 2009
4 * Based on these specifications:
5 * http://www.opengroup.org/onlinepubs/007908775/xsh/getdtablesize.html
6 * http://www.opengroup.org/onlinepubs/007908775/xsh/getrlimit.html
7 */
9 #include <sys/cdefs.h>
10 #include "namespace.h"
12 #include <errno.h>
13 #include <limits.h>
14 #include <sys/resource.h>
15 #include <unistd.h>
17 int getrlimit(int resource, struct rlimit *rlp)
19 rlim_t limit;
21 switch (resource)
23 case RLIMIT_CPU:
24 case RLIMIT_FSIZE:
25 case RLIMIT_DATA:
26 case RLIMIT_STACK:
27 case RLIMIT_CORE:
28 case RLIMIT_RSS:
29 case RLIMIT_MEMLOCK:
30 case RLIMIT_SBSIZE:
31 case RLIMIT_AS:
32 /* case RLIMIT_VMEM: Same as RLIMIT_AS */
33 case RLIMIT_NTHR:
34 /* no limit enforced (however architectural limits
35 * may apply)
36 */
37 limit = RLIM_INFINITY;
38 break;
40 case RLIMIT_NPROC:
41 limit = CHILD_MAX;
42 break;
44 case RLIMIT_NOFILE:
45 limit = OPEN_MAX;
46 break;
48 default:
49 errno = EINVAL;
50 return -1;
53 /* return limit */
54 rlp->rlim_cur = limit;
55 rlp->rlim_max = limit;
56 return 0;