Skip to content

Commit

Permalink
Move sysinfo parser to a separate file
Browse files Browse the repository at this point in the history
* sysinfo.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* resource.c (sys_sysinfo): Move to sysinfo.c.
  • Loading branch information
ldv-alt committed Sep 29, 2014
1 parent 9f59677 commit 57d45a2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ strace_SOURCES = \
strace.c \
stream.c \
syscall.c \
sysinfo.c \
system.c \
term.c \
time.c \
Expand Down
28 changes: 0 additions & 28 deletions resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,34 +302,6 @@ sys_osf_getrusage(struct tcb *tcp)
}
#endif /* ALPHA */

#include <sys/sysinfo.h>

int
sys_sysinfo(struct tcb *tcp)
{
struct sysinfo si;

if (exiting(tcp)) {
if (syserror(tcp) || !verbose(tcp))
tprintf("%#lx", tcp->u_arg[0]);
else if (umove(tcp, tcp->u_arg[0], &si) < 0)
tprints("{...}");
else {
tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
(long) si.uptime, (long) si.loads[0],
(long) si.loads[1], (long) si.loads[2]);
tprintf("totalram=%lu, freeram=%lu, ",
(long) si.totalram, (long) si.freeram);
tprintf("sharedram=%lu, bufferram=%lu} ",
(long) si.sharedram, (long) si.bufferram);
tprintf("totalswap=%lu, freeswap=%lu, procs=%u}",
(long) si.totalswap, (long) si.freeswap,
(unsigned)si.procs);
}
}
return 0;
}

#include "xlat/priorities.h"

int
Expand Down
28 changes: 28 additions & 0 deletions sysinfo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "defs.h"
#include <sys/sysinfo.h>

int
sys_sysinfo(struct tcb *tcp)
{
struct sysinfo si;

if (exiting(tcp)) {
if (syserror(tcp) || !verbose(tcp))
tprintf("%#lx", tcp->u_arg[0]);
else if (umove(tcp, tcp->u_arg[0], &si) < 0)
tprints("{...}");
else {
tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
(long) si.uptime, (long) si.loads[0],
(long) si.loads[1], (long) si.loads[2]);
tprintf("totalram=%lu, freeram=%lu, ",
(long) si.totalram, (long) si.freeram);
tprintf("sharedram=%lu, bufferram=%lu} ",
(long) si.sharedram, (long) si.bufferram);
tprintf("totalswap=%lu, freeswap=%lu, procs=%u}",
(long) si.totalswap, (long) si.freeswap,
(unsigned)si.procs);
}
}
return 0;
}

0 comments on commit 57d45a2

Please sign in to comment.