]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 2018-2021 Free Software Foundation, Inc. |
0d0bc784 AJ |
2 | This file is part of the GNU C Library. |
3 | ||
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 | ||
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | Lesser General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
15 | License along with the GNU C Library; if not, see | |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
0d0bc784 | 17 | |
8e900969 AJ |
18 | #define USE_VERSIONED_RLIMIT |
19 | #include <sysdeps/unix/sysv/linux/setrlimit64.c> | |
20 | versioned_symbol (libc, __setrlimit, setrlimit, GLIBC_2_27); | |
21 | versioned_symbol (libc, __setrlimit64, setrlimit64, GLIBC_2_27); | |
0d0bc784 | 22 | |
8e900969 | 23 | #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27) |
0d0bc784 AJ |
24 | /* RLIM64_INFINITY was supposed to be a glibc convention rather than |
25 | anything seen by the kernel, but it ended being passed to the kernel | |
26 | through the prlimit64 syscall. Given that a lot of binaries with | |
27 | the wrong constant value are in the wild, provide a wrapper function | |
28 | fixing the value before the syscall. */ | |
8e900969 | 29 | # define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL |
0d0bc784 AJ |
30 | |
31 | int | |
8e900969 AJ |
32 | attribute_compat_text_section |
33 | __old_setrlimit64 (enum __rlimit_resource resource, | |
34 | const struct rlimit64 *rlimits) | |
0d0bc784 AJ |
35 | { |
36 | struct rlimit64 krlimits; | |
37 | ||
8e900969 AJ |
38 | if (rlimits->rlim_cur == OLD_RLIM64_INFINITY) |
39 | krlimits.rlim_cur = RLIM64_INFINITY; | |
0d0bc784 AJ |
40 | else |
41 | krlimits.rlim_cur = rlimits->rlim_cur; | |
8e900969 AJ |
42 | if (rlimits->rlim_max == OLD_RLIM64_INFINITY) |
43 | krlimits.rlim_max = RLIM64_INFINITY; | |
0d0bc784 AJ |
44 | else |
45 | krlimits.rlim_max = rlimits->rlim_max; | |
46 | ||
8e900969 | 47 | return __setrlimit64 (resource, &krlimits); |
0d0bc784 AJ |
48 | } |
49 | ||
8e900969 AJ |
50 | strong_alias (__old_setrlimit64, __old_setrlimit) |
51 | compat_symbol (libc, __old_setrlimit, setrlimit, GLIBC_2_0); | |
52 | compat_symbol (libc, __old_setrlimit64, setrlimit64, GLIBC_2_1); | |
0d0bc784 | 53 | #endif |