blob: 8990e381d10331b036caa289bf5d4edd50b86761 [file] [log] [blame]
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +00001#include "defs.h"
2
3#include <sys/utsname.h>
4
Dmitry V. Levina0bd3742015-04-07 01:36:50 +00005SYS_FUNC(uname)
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +00006{
7 struct utsname uname;
8
Dmitry V. Levin50e13042015-01-24 22:08:07 +00009 if (entering(tcp))
10 return 0;
11
Dmitry V. Levin9809e3a2015-07-15 09:25:34 +000012 if (!umove_or_printaddr(tcp, tcp->u_arg[0], &uname)) {
Dmitry V. Levin50e13042015-01-24 22:08:07 +000013#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. Levin58dd2cf2014-12-11 19:25:02 +000023 }
Dmitry V. Levin50e13042015-01-24 22:08:07 +000024 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. Levin58dd2cf2014-12-11 19:25:02 +000031 }
Dmitry V. Levin50e13042015-01-24 22:08:07 +000032
Dmitry V. Levin58dd2cf2014-12-11 19:25:02 +000033 return 0;
34}