blob: 74f8efbc06d6e8b3d769c86983d34109b07878f2 [file] [log] [blame]
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +00001#include "defs.h"
2
3#include <sys/utsname.h>
4
5int
6sys_uname(struct tcb *tcp)
7{
8 struct utsname uname;
9
Dmitry V. Levin50e13042015-01-24 22:08:07 +000010 if (entering(tcp))
11 return 0;
12
13 if (syserror(tcp) || !verbose(tcp))
14 tprintf("%#lx", tcp->u_arg[0]);
15 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
16 tprints("{...}");
17 else {
18#define PRINT_UTS_MEMBER(prefix, member) \
19 tprints(prefix #member "="); \
20 print_quoted_string(uname.member, sizeof(uname.member), \
21 QUOTE_0_TERMINATED)
22
23 PRINT_UTS_MEMBER("{", sysname);
24 PRINT_UTS_MEMBER(", ", nodename);
25 if (abbrev(tcp)) {
26 tprints(", ...}");
27 return 0;
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +000028 }
Dmitry V. Levin50e13042015-01-24 22:08:07 +000029 PRINT_UTS_MEMBER(", ", release);
30 PRINT_UTS_MEMBER(", ", version);
31 PRINT_UTS_MEMBER(", ", machine);
32#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
33 PRINT_UTS_MEMBER(", ", domainname);
34#endif
35 tprints("}");
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +000036 }
Dmitry V. Levin50e13042015-01-24 22:08:07 +000037
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +000038 return 0;
39}