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>
12 extern long int ulimit(int cmd, long arg);
13 _syscall2(long, ulimit, int, cmd, long, arg)
20 #include <sys/resource.h>
23 long int ulimit(int cmd, ...)
30 /* Get limit on file size. */
32 if (getrlimit(RLIMIT_FSIZE, &limit) == 0)
33 result = limit.rlim_cur / 512; /* bytes to 512 byte blocksize */
35 /* Set limit on file size. */
37 result = va_arg (va, long int);
38 if ((rlim_t) result > RLIM_INFINITY / 512) {
39 limit.rlim_cur = RLIM_INFINITY;
40 limit.rlim_max = RLIM_INFINITY;
42 limit.rlim_cur = result * 512;
43 limit.rlim_max = result * 512;
45 result = setrlimit(RLIMIT_FSIZE, &limit);
48 result = sysconf(_SC_OPEN_MAX);