Back to index

glibc  2.9
Defines | Enumerations | Functions
ulimit.h File Reference
#include <features.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define UL_GETFSIZE   UL_GETFSIZE
#define UL_SETFSIZE   UL_SETFSIZE

Enumerations

enum  {
  UL_GETFSIZE = 1, UL_GETFSIZE = 1, UL_SETFSIZE, UL_SETFSIZE,
  __UL_GETMAXBRK, __UL_GETOPENMAX
}

Functions

__BEGIN_DECLS long int ulimit (int __cmd,...) __THROW

Define Documentation

#define UL_GETFSIZE   UL_GETFSIZE

Definition at line 30 of file ulimit.h.

#define UL_SETFSIZE   UL_SETFSIZE

Definition at line 33 of file ulimit.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
UL_GETFSIZE 
UL_GETFSIZE 
UL_SETFSIZE 
UL_SETFSIZE 
__UL_GETMAXBRK 
__UL_GETOPENMAX 

Definition at line 26 of file ulimit.h.

{
  UL_GETFSIZE = 1,                 /* Return limit on the size of a file,
                                      in units of 512 bytes.  */
#define UL_GETFSIZE  UL_GETFSIZE
  UL_SETFSIZE,                            /* Set limit on the size of a file to
                                      second argument.  */
#define UL_SETFSIZE  UL_SETFSIZE
  __UL_GETMAXBRK,                  /* Return the maximum possible address
                                      of the data segment.  */
  __UL_GETOPENMAX                  /* Return the maximum number of files
                                      that the calling process can open.*/
};

Function Documentation

__BEGIN_DECLS 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: