blob: ab5044b2b01c8eedd4e0fa1108fd493a8b6df836 [file] [log] [blame]
Dmitry V. Levin57d45a22014-09-29 23:13:05 +00001#include "defs.h"
2#include <sys/sysinfo.h>
3
4int
5sys_sysinfo(struct tcb *tcp)
6{
7 struct sysinfo si;
8
Dmitry V. Levin82a528d2014-09-29 23:29:56 +00009 if (entering(tcp))
10 return 0;
11
12 if (syserror(tcp) || !verbose(tcp) ||
13 umove(tcp, tcp->u_arg[0], &si) < 0) {
14 tprintf("%#lx", tcp->u_arg[0]);
15 } else {
16 tprintf("{uptime=%lu"
17 ", loads=[%lu, %lu, %lu]"
18 ", totalram=%lu"
19 ", freeram=%lu"
20 ", sharedram=%lu"
21 ", bufferram=%lu"
22 ", totalswap=%lu"
23 ", freeswap=%lu"
24 ", procs=%u"
25#ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
26 ", totalhigh=%lu"
27#endif
28#ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
29 ", freehigh=%lu"
30#endif
31#ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
32 ", mem_unit=%u"
33#endif
34 "}",
35 si.uptime
36 , si.loads[0], si.loads[1], si.loads[2]
37 , si.totalram
38 , si.freeram
39 , si.sharedram
40 , si.bufferram
41 , si.totalswap
42 , si.freeswap
43 , (unsigned) si.procs
44#ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
45 , si.totalhigh
46#endif
47#ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
48 , si.freehigh
49#endif
50#ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
51 , si.mem_unit
52#endif
53 );
Dmitry V. Levin57d45a22014-09-29 23:13:05 +000054 }
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000055
Dmitry V. Levin57d45a22014-09-29 23:13:05 +000056 return 0;
57}