2 * Check decoding of prlimit64 syscall.
4 * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
5 * Copyright (c) 2016-2019 The strace developers.
8 * SPDX-License-Identifier: GPL-2.0-or-later
16 # include <inttypes.h>
19 # include <sys/resource.h>
23 # include "xlat/resources.h"
26 sprint_rlim(uint64_t lim)
29 return "RLIM64_INFINITY";
31 static char buf[2][sizeof(lim)*3 + sizeof("*1024")];
34 if (lim > 1024 && lim % 1024 == 0)
35 sprintf(buf[i], "%" PRIu64 "*1024", lim / 1024);
37 sprintf(buf[i], "%" PRIu64, lim);
46 (unsigned long) 0xdefaced00000000ULL | (unsigned) getpid();
47 uint64_t *const rlimit = tail_alloc(sizeof(*rlimit) * 2);
48 const struct xlat_data *xlat;
51 for (xlat = resources->data; i < resources->size; ++xlat, ++i) {
55 unsigned long res = 0xfacefeed00000000ULL | xlat->val;
56 long rc = syscall(__NR_prlimit64, pid, res, 0, rlimit);
58 printf("prlimit64(%d, %s, NULL, %p) = %ld %s (%m)\n",
59 (unsigned) pid, xlat->str, rlimit,
62 printf("prlimit64(%d, %s, NULL"
63 ", {rlim_cur=%s, rlim_max=%s}) = 0\n",
64 (unsigned) pid, xlat->str,
65 sprint_rlim(rlimit[0]),
66 sprint_rlim(rlimit[1]));
69 puts("+++ exited with 0 +++");
75 SKIP_MAIN_UNDEFINED("__NR_prlimit64")