Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | #include <sys/utsname.h> |
| 4 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 5 | SYS_FUNC(uname) |
Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 6 | { |
| 7 | struct utsname uname; |
| 8 | |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 9 | if (entering(tcp)) |
| 10 | return 0; |
| 11 | |
Dmitry V. Levin | 9809e3a | 2015-07-15 09:25:34 +0000 | [diff] [blame] | 12 | if (!umove_or_printaddr(tcp, tcp->u_arg[0], &uname)) { |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 13 | #define PRINT_UTS_MEMBER(prefix, member) \ |
| 14 | tprints(prefix #member "="); \ |
| 15 | print_quoted_string(uname.member, sizeof(uname.member), \ |
| 16 | QUOTE_0_TERMINATED) |
| 17 | |
| 18 | PRINT_UTS_MEMBER("{", sysname); |
| 19 | PRINT_UTS_MEMBER(", ", nodename); |
| 20 | if (abbrev(tcp)) { |
| 21 | tprints(", ...}"); |
| 22 | return 0; |
Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 23 | } |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 24 | PRINT_UTS_MEMBER(", ", release); |
| 25 | PRINT_UTS_MEMBER(", ", version); |
| 26 | PRINT_UTS_MEMBER(", ", machine); |
| 27 | #ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME |
| 28 | PRINT_UTS_MEMBER(", ", domainname); |
| 29 | #endif |
| 30 | tprints("}"); |
Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 31 | } |
Dmitry V. Levin | 50e1304 | 2015-01-24 22:08:07 +0000 | [diff] [blame] | 32 | |
Dmitry V. Levin | 58dd2cf | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 33 | return 0; |
| 34 | } |