2 * Check decoding of setrlimit syscall.
4 * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <asm/unistd.h>
15 # include "xgetrlimit.c"
20 kernel_ulong_t *const rlimit = tail_alloc(sizeof(*rlimit) * 2);
21 const struct xlat *xlat;
23 for (xlat = resources; xlat->str; ++xlat) {
24 unsigned long res = 0xfacefeed00000000ULL | xlat->val;
25 long rc = syscall(__NR_setrlimit, res, 0);
26 printf("setrlimit(%s, NULL) = %s\n", xlat->str, sprintrc(rc));
28 struct rlimit libc_rlim = {};
29 if (getrlimit((int) res, &libc_rlim))
31 rlimit[0] = libc_rlim.rlim_cur;
32 rlimit[1] = libc_rlim.rlim_max;
34 rc = syscall(__NR_setrlimit, res, rlimit);
35 const char *errstr = sprintrc(rc);
36 printf("setrlimit(%s, {rlim_cur=%s, rlim_max=%s}) = %s\n",
38 sprint_rlim(rlimit[0]), sprint_rlim(rlimit[1]),
42 puts("+++ exited with 0 +++");
48 SKIP_MAIN_UNDEFINED("__NR_setrlimit")