setrlimit64.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Linux setrlimit64 implementation (64 bits off_t).
  2. Copyright (C) 2010-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <errno.h>
  16. #include <sys/types.h>
  17. #include <shlib-compat.h>
  18. /* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T
  19. linking setrlimit64 to {__}setrlimit does not throw a type error. */
  20. #undef setrlimit
  21. #undef __setrlimit
  22. #define setrlimit setrlimit_redirect
  23. #define __setrlimit __setrlimit_redirect
  24. #include <sys/resource.h>
  25. #undef setrlimit
  26. #undef __setrlimit
  27. /* Set the soft and hard limits for RESOURCE to *RLIMITS.
  28. Only the super-user can increase hard limits.
  29. Return 0 if successful, -1 if not (and sets errno). */
  30. int
  31. __setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
  32. {
  33. return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
  34. }
  35. /* Alpha defines a versioned setrlimit{64}. */
  36. #ifndef USE_VERSIONED_RLIMIT
  37. weak_alias (__setrlimit64, setrlimit64)
  38. #endif
  39. #if __RLIM_T_MATCHES_RLIM64_T
  40. strong_alias (__setrlimit64, __setrlimit)
  41. # ifndef USE_VERSIONED_RLIMIT
  42. weak_alias (__setrlimit64, setrlimit)
  43. # endif
  44. # ifdef SHARED
  45. __hidden_ver1 (__setrlimit64, __GI___setrlimit, __setrlimit64);
  46. # endif
  47. #endif