Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | #include <sys/sysinfo.h> |
| 3 | |
| 4 | int |
| 5 | sys_sysinfo(struct tcb *tcp) |
| 6 | { |
| 7 | struct sysinfo si; |
| 8 | |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 9 | 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. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 54 | } |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 55 | |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 56 | return 0; |
| 57 | } |