1 #include "defs.h"
2 
3 #include <sys/utsname.h>
4 
SYS_FUNC(uname)5 SYS_FUNC(uname)
6 {
7 	struct utsname uname;
8 
9 	if (entering(tcp))
10 		return 0;
11 
12 	if (syserror(tcp) || !verbose(tcp))
13 		tprintf("%#lx", tcp->u_arg[0]);
14 	else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
15 		tprints("{...}");
16 	else {
17 #define PRINT_UTS_MEMBER(prefix, member) \
18 		tprints(prefix #member "="); \
19 		print_quoted_string(uname.member, sizeof(uname.member), \
20 				    QUOTE_0_TERMINATED)
21 
22 		PRINT_UTS_MEMBER("{", sysname);
23 		PRINT_UTS_MEMBER(", ", nodename);
24 		if (abbrev(tcp)) {
25 			tprints(", ...}");
26 			return 0;
27 		}
28 		PRINT_UTS_MEMBER(", ", release);
29 		PRINT_UTS_MEMBER(", ", version);
30 		PRINT_UTS_MEMBER(", ", machine);
31 #ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
32 		PRINT_UTS_MEMBER(", ", domainname);
33 #endif
34 		tprints("}");
35 	}
36 
37 	return 0;
38 }
39