Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  2. #include <errno.h>
  3. #include <stddef.h>
  4. #include <sys/resource.h>
  5.  
  6. extern struct rlimit __libc_limits[];
  7.  
  8. int
  9. setrlimit (int rltype, const struct rlimit *rlimitp)
  10. {
  11.   /* check argument range */
  12.   if (rlimitp->rlim_cur > rlimitp->rlim_max || rlimitp == NULL)
  13.     {
  14.       errno = EINVAL;
  15.       return -1;
  16.     }
  17.  
  18.   switch (rltype)
  19.     {
  20.     case RLIMIT_CPU:
  21.     case RLIMIT_FSIZE:
  22.     case RLIMIT_DATA:
  23.     case RLIMIT_STACK:
  24.     case RLIMIT_CORE:
  25.     case RLIMIT_RSS:
  26.     case RLIMIT_MEMLOCK:
  27.     case RLIMIT_NPROC:
  28.     case RLIMIT_NOFILE:
  29.       /* not supported */
  30.       errno = EPERM;
  31.       return -1;
  32.     default:
  33.       errno = EINVAL;
  34.       return -1;
  35.     }
  36.  
  37.   return 0;
  38. }
  39.