Back to index

glibc  2.9
setrlimit.c File Reference
#include <errno.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <sysdep.h>
#include <sys/syscall.h>
#include <shlib-compat.h>
#include <bp-checks.h>
#include <kernel-features.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


int __new_setrlimit (enum __rlimit_resource resource, const struct rlimit *__unboundedrlimits)
 weak_alias (__new_setrlimit, __setrlimit)
 versioned_symbol (libc, __new_setrlimit, setrlimit, GLIBC_2_2)

Function Documentation

int __new_setrlimit ( enum __rlimit_resource  resource,
const struct rlimit __unboundedrlimits 

Definition at line 40 of file setrlimit.c.

  return INLINE_SYSCALL (setrlimit, 2, resource, CHECK_1 (rlimits));
  struct rlimit rlimits_small;

# ifdef __NR_ugetrlimit
  if (__have_no_new_getrlimit == 0)
      /* Check if the new ugetrlimit syscall exists.  We must do this
        first because older kernels don't reject negative rlimit
        values in setrlimit.  */
      int result = INLINE_SYSCALL (ugetrlimit, 2, resource, __ptrvalue (&rlimits_small));
      if (result != -1 || errno != ENOSYS)
       /* The syscall exists.  */
       __have_no_new_getrlimit = -1;
       /* The syscall does not exist.  */
       __have_no_new_getrlimit = 1;
  if (__have_no_new_getrlimit < 0)
    return INLINE_SYSCALL (setrlimit, 2, resource, CHECK_1 (rlimits));
# endif

  /* We might have to correct the limits values.  Since the old values
     were signed the new values might be too large.  */
  rlimits_small.rlim_cur = MIN ((unsigned long int) rlimits->rlim_cur,
                            RLIM_INFINITY >> 1);
  rlimits_small.rlim_max = MIN ((unsigned long int) rlimits->rlim_max,
                            RLIM_INFINITY >> 1);

  /* Use the adjusted values.  */
  return INLINE_SYSCALL (setrlimit, 2, resource, __ptrvalue (&rlimits_small));

Here is the call graph for this function:

versioned_symbol ( libc  ,
__new_setrlimit  ,
setrlimit  ,