Move sysinfo parser to a separate file

* sysinfo.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* resource.c (sys_sysinfo): Move to sysinfo.c.
This commit is contained in:
Дмитрий Левин 2014-09-29 23:13:05 +00:00
parent 9f59677e75
commit 57d45a2b3a
3 changed files with 29 additions and 28 deletions

View File

@ -51,6 +51,7 @@ strace_SOURCES = \
strace.c \
stream.c \
syscall.c \
sysinfo.c \
system.c \
term.c \
time.c \

View File

@ -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

28
sysinfo.c Normal file
View File

@ -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;
}