Implementation of getrlimit and getdtablesize
[minix.git] / lib / other / rlimit.c
blob77fd8c2de293f0baa1dbdba4e9798a9ba75463f4
1 /* getdtablesize, 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 <errno.h>
10 #include <limits.h>
11 #include <sys/resource.h>
12 #include <unistd.h>
14 int getdtablesize(void)
16 return OPEN_MAX;
19 int getrlimit(int resource, struct rlimit *rlp)
21 rlim_t limit;
23 switch (resource)
25 case RLIMIT_CORE:
26 /* no core currently produced */
27 limit = 0;
28 break;
30 case RLIMIT_CPU:
31 case RLIMIT_DATA:
32 case RLIMIT_FSIZE:
33 case RLIMIT_STACK:
34 case RLIMIT_AS:
35 /* no limit enforced (however architectural limits
36 * may apply)
37 */
38 limit = RLIM_INFINITY;
39 break;
41 case RLIMIT_NOFILE:
42 limit = OPEN_MAX;
43 break;
45 default:
46 errno = EINVAL;
47 return -1;
50 /* return limit */
51 rlp->rlim_cur = limit;
52 rlp->rlim_max = limit;
53 return 0;