From 58dd2cf352e660f8bcfcde251e2044366f68b601 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 11 Dec 2014 19:25:02 +0000 Subject: [PATCH] process.c: move uname parser to a separate file * uname.c: New file. * Makefile.am (strace_SOURCES): Add it. * process.c (sys_uname): Move to uname.c. --- Makefile.am | 1 + process.c | 29 ----------------------------- uname.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 uname.c diff --git a/Makefile.am b/Makefile.am index 93421237..ba5e23a7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -90,6 +90,7 @@ strace_SOURCES = \ truncate.c \ umask.c \ umount.c \ + uname.c \ util.c \ utime.c \ utimes.c \ diff --git a/process.c b/process.c index 05362278..89ce0aad 100644 --- a/process.c +++ b/process.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #ifdef HAVE_ELF_H # include @@ -826,34 +825,6 @@ sys_waitid(struct tcb *tcp) return 0; } -int -sys_uname(struct tcb *tcp) -{ - struct utsname uname; - - if (exiting(tcp)) { - if (syserror(tcp) || !verbose(tcp)) - tprintf("%#lx", tcp->u_arg[0]); - else if (umove(tcp, tcp->u_arg[0], &uname) < 0) - tprints("{...}"); - else if (!abbrev(tcp)) { - tprintf("{sysname=\"%s\", nodename=\"%s\", ", - uname.sysname, uname.nodename); - tprintf("release=\"%s\", version=\"%s\", ", - uname.release, uname.version); - tprintf("machine=\"%s\"", uname.machine); -#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME - tprintf(", domainname=\"%s\"", uname.domainname); -#endif - tprints("}"); - } - else - tprintf("{sys=\"%s\", node=\"%s\", ...}", - uname.sysname, uname.nodename); - } - return 0; -} - #include "xlat/ptrace_cmds.h" #include "xlat/ptrace_setoptions_flags.h" #include "xlat/nt_descriptor_types.h" diff --git a/uname.c b/uname.c new file mode 100644 index 00000000..d1b195e2 --- /dev/null +++ b/uname.c @@ -0,0 +1,31 @@ +#include "defs.h" + +#include + +int +sys_uname(struct tcb *tcp) +{ + struct utsname uname; + + if (exiting(tcp)) { + if (syserror(tcp) || !verbose(tcp)) + tprintf("%#lx", tcp->u_arg[0]); + else if (umove(tcp, tcp->u_arg[0], &uname) < 0) + tprints("{...}"); + else if (!abbrev(tcp)) { + tprintf("{sysname=\"%s\", nodename=\"%s\", ", + uname.sysname, uname.nodename); + tprintf("release=\"%s\", version=\"%s\", ", + uname.release, uname.version); + tprintf("machine=\"%s\"", uname.machine); +#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME + tprintf(", domainname=\"%s\"", uname.domainname); +#endif + tprints("}"); + } + else + tprintf("{sys=\"%s\", node=\"%s\", ...}", + uname.sysname, uname.nodename); + } + return 0; +} -- 2.40.0