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 { |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 16 | tprintf("{uptime=%llu" |
| 17 | ", loads=[%llu, %llu, %llu]" |
| 18 | ", totalram=%llu" |
| 19 | ", freeram=%llu" |
| 20 | ", sharedram=%llu" |
| 21 | ", bufferram=%llu" |
| 22 | ", totalswap=%llu" |
| 23 | ", freeswap=%llu" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 24 | ", procs=%u" |
| 25 | #ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 26 | ", totalhigh=%llu" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 27 | #endif |
| 28 | #ifdef HAVE_STRUCT_SYSINFO_FREEHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 29 | ", freehigh=%llu" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 30 | #endif |
| 31 | #ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT |
| 32 | ", mem_unit=%u" |
| 33 | #endif |
| 34 | "}", |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 35 | (unsigned long long) si.uptime |
| 36 | , (unsigned long long) si.loads[0] |
| 37 | , (unsigned long long) si.loads[1] |
| 38 | , (unsigned long long) si.loads[2] |
| 39 | , (unsigned long long) si.totalram |
| 40 | , (unsigned long long) si.freeram |
| 41 | , (unsigned long long) si.sharedram |
| 42 | , (unsigned long long) si.bufferram |
| 43 | , (unsigned long long) si.totalswap |
| 44 | , (unsigned long long) si.freeswap |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 45 | , (unsigned) si.procs |
| 46 | #ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 47 | , (unsigned long long) si.totalhigh |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 48 | #endif |
| 49 | #ifdef HAVE_STRUCT_SYSINFO_FREEHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 50 | , (unsigned long long) si.freehigh |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 51 | #endif |
| 52 | #ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT |
| 53 | , si.mem_unit |
| 54 | #endif |
| 55 | ); |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 56 | } |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 57 | |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 58 | return 0; |
| 59 | } |