Move sysinfo parser to a separate file
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 29 Sep 2014 23:13:05 +0000 (23:13 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 29 Sep 2014 23:13:05 +0000 (23:13 +0000)
* sysinfo.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* resource.c (sys_sysinfo): Move to sysinfo.c.

Makefile.am
resource.c
sysinfo.c [new file with mode: 0644]

index b76c979698f32eea4d42b5ad7ed4fbdc78167713..703f4da16b2e5d99869537971857f2b605b3ebad 100644 (file)
@@ -51,6 +51,7 @@ strace_SOURCES =      \
        strace.c        \
        stream.c        \
        syscall.c       \
+       sysinfo.c       \
        system.c        \
        term.c          \
        time.c          \
index 8054c7bf90af3ae25331e1c31c3a6d3efe0fafab..57ce17e0023f88ec009b44e9f8106e87961887d1 100644 (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
diff --git a/sysinfo.c b/sysinfo.c
new file mode 100644 (file)
index 0000000..e37c4a2
--- /dev/null
+++ b/sysinfo.c
@@ -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;
+}