Back to index

glibc  2.9
Functions | Variables
ulimit.c File Reference
#include <errno.h>
#include <stdarg.h>
#include <sysdep.h>
#include <ulimit.h>
#include <unistd.h>
#include <sys/resource.h>

Go to the source code of this file.

Functions

long int ulimit (int cmd,...)

Variables

int _etext

Function Documentation

long int ulimit ( int  cmd,
  ... 
)

Definition at line 38 of file ulimit.c.

{
  struct rlimit limit;
  va_list va;
  long int result = -1;

  va_start (va, cmd);

  switch (cmd)
    {
    case UL_GETFSIZE:
      /* Get limit on file size.  */
      if (getrlimit (RLIMIT_FSIZE, &limit) == 0)
       /* Convert from bytes to 512 byte units.  */
       result = limit.rlim_cur / 512;
      break;

    case UL_SETFSIZE:
      /* Set limit on file size.  */
      {
       long int newlimit = va_arg (va, long int);

       if ((rlim_t) newlimit > RLIM_INFINITY / 512)
         {
           limit.rlim_cur = RLIM_INFINITY;
           limit.rlim_max = RLIM_INFINITY;
         }
       else
         {
           limit.rlim_cur = newlimit * 512;
           limit.rlim_max = newlimit * 512;
         }

       result = setrlimit (RLIMIT_FSIZE, &limit);
      }
      break;

    case __UL_GETMAXBRK:
      /* Get maximum address for `brk'.  */
      if (getrlimit (RLIMIT_DATA, &limit) == 0)
       result = ((long int) &_etext) + limit.rlim_cur;
      break;

    case __UL_GETOPENMAX:
      result = sysconf (_SC_OPEN_MAX);
      break;

    default:
      __set_errno (EINVAL);
    }

  va_end (va);

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation