1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 #include <sys/syscall.h>
13 #include <sys/resource.h>
16 long int ulimit(int cmd, ...)
23 /* Get limit on file size. */
25 if (getrlimit(RLIMIT_FSIZE, &limit) == 0)
26 result = limit.rlim_cur / 512; /* bytes to 512 byte blocksize */
28 /* Set limit on file size. */
30 result = va_arg (va, long int);
31 if ((rlim_t) result > RLIM_INFINITY / 512) {
32 limit.rlim_cur = RLIM_INFINITY;
33 limit.rlim_max = RLIM_INFINITY;
35 limit.rlim_cur = result * 512;
36 limit.rlim_max = result * 512;
38 result = setrlimit(RLIMIT_FSIZE, &limit);
41 result = sysconf(_SC_OPEN_MAX);