File: hostname.c

package info (click to toggle)
strace 5.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 49,332 kB
  • sloc: ansic: 113,177; sh: 8,831; makefile: 3,108; awk: 364; perl: 267; sed: 9
file content (45 lines) | stat: -rw-r--r-- 717 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2014-2018 The strace developers.
 * All rights reserved.
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "defs.h"

#ifdef HAVE_LINUX_UTSNAME_H
# include <linux/utsname.h>
#endif

#ifndef __NEW_UTS_LEN
# define __NEW_UTS_LEN 64
#endif

SYS_FUNC(sethostname)
{
	unsigned int len = tcp->u_arg[1];

	if (len > __NEW_UTS_LEN) {
		printaddr(tcp->u_arg[0]);
	} else {
		printstrn(tcp, tcp->u_arg[0], len);
	}

	tprintf(", %u", len);

	return RVAL_DECODED;
}

#if defined(ALPHA)
SYS_FUNC(gethostname)
{
	if (exiting(tcp)) {
		if (syserror(tcp))
			printaddr(tcp->u_arg[0]);
		else
			printstr(tcp, tcp->u_arg[0]);
		tprintf(", %" PRI_klu, tcp->u_arg[1]);
	}
	return 0;
}
#endif /* ALPHA */