Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | #include <sys/utsname.h> |
| 4 | |
| 5 | int |
| 6 | sys_uname(struct tcb *tcp) |
| 7 | { |
| 8 | struct utsname uname; |
| 9 | |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 10 | 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. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 28 | } |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 29 | 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. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 36 | } |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 37 | |
Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 38 | return 0; |
| 39 | } |