2 * Check decoding of sethostname syscall.
4 * Copyright (c) 2016 Fei Jie <feij.fnst@cn.fujitsu.com>
5 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
6 * Copyright (c) 2016-2019 The strace developers.
9 * SPDX-License-Identifier: GPL-2.0-or-later
15 #ifdef __NR_sethostname
20 # ifdef HAVE_LINUX_UTSNAME_H
21 # include <linux/utsname.h>
24 # ifndef __NEW_UTS_LEN
25 # define __NEW_UTS_LEN 64
35 rc = syscall(__NR_sethostname, 0, len);
36 printf("sethostname(NULL, %u) = %s\n",
37 (unsigned) len, sprintrc(rc));
39 if (F8ILL_KULONG_MASK) {
40 len |= F8ILL_KULONG_MASK;
41 rc = syscall(__NR_sethostname, 0, len);
42 printf("sethostname(NULL, %u) = %s\n",
43 (unsigned) len, sprintrc(rc));
46 len = __NEW_UTS_LEN + 1;
47 void *const p = tail_alloc(len);
48 rc = syscall(__NR_sethostname, p, len);
49 printf("sethostname(%p, %u) = %s\n",
50 p, (unsigned) len, sprintrc(rc));
52 puts("+++ exited with 0 +++");
58 SKIP_MAIN_UNDEFINED("__NR_sethostname")