2 * Check decoding of prlimit64 syscall.
4 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <asm/unistd.h>
15 # include <inttypes.h>
18 # include <sys/resource.h>
22 # include "xlat/resources.h"
25 sprint_rlim(uint64_t lim)
28 return "RLIM64_INFINITY";
30 static char buf[2][sizeof(lim)*3 + sizeof("*1024")];
33 if (lim > 1024 && lim % 1024 == 0)
34 sprintf(buf[i], "%" PRIu64 "*1024", lim / 1024);
36 sprintf(buf[i], "%" PRIu64, lim);
45 (unsigned long) 0xdefaced00000000ULL | (unsigned) getpid();
46 uint64_t *const rlimit = tail_alloc(sizeof(*rlimit) * 2);
47 const struct xlat *xlat;
49 for (xlat = resources; xlat->str; ++xlat) {
50 unsigned long res = 0xfacefeed00000000ULL | xlat->val;
51 long rc = syscall(__NR_prlimit64, pid, res, 0, rlimit);
53 printf("prlimit64(%d, %s, NULL, %p) = %ld %s (%m)\n",
54 (unsigned) pid, xlat->str, rlimit,
57 printf("prlimit64(%d, %s, NULL"
58 ", {rlim_cur=%s, rlim_max=%s}) = 0\n",
59 (unsigned) pid, xlat->str,
60 sprint_rlim(rlimit[0]),
61 sprint_rlim(rlimit[1]));
64 puts("+++ exited with 0 +++");
70 SKIP_MAIN_UNDEFINED("__NR_prlimit64")