This diff removes the Linux emulation support from the systrace command. The changes are very much mechanical. This is the last userland part that references compat/linux.
Also, these files bin/systrace/linux-translate.c bin/systrace/linux-translate.h bin/systrace/linux_socketcall.h can be removed. (Not part of the patch.) I don't really use systrace. Building a simple port with USE_SYSTRACE=yes still works. Index: bin/systrace/Makefile =================================================================== RCS file: /cvs/src/bin/systrace/Makefile,v retrieving revision 1.15 diff -u -p -r1.15 Makefile --- bin/systrace/Makefile 2 Jul 2006 12:34:15 -0000 1.15 +++ bin/systrace/Makefile 28 Feb 2016 20:42:41 -0000 @@ -9,7 +9,7 @@ DPADD+= ${LIBEVENT} LDADD+= -levent SRCS= cradle.c filter.c intercept-translate.c intercept.c \ - linux-translate.c openbsd-syscalls.c util.c \ + openbsd-syscalls.c util.c \ policy.c systrace-errno.h systrace-error.c \ systrace-translate.c systrace.c alias.c register.c \ parse.y lex.l Index: bin/systrace/openbsd-syscalls.c =================================================================== RCS file: /cvs/src/bin/systrace/openbsd-syscalls.c,v retrieving revision 1.46 diff -u -p -r1.46 openbsd-syscalls.c --- bin/systrace/openbsd-syscalls.c 9 Dec 2015 19:36:17 -0000 1.46 +++ bin/systrace/openbsd-syscalls.c 28 Feb 2016 20:47:19 -0000 @@ -32,8 +32,6 @@ #include <sys/syscall.h> -#include <compat/linux/linux_syscall.h> - #define KTRACE #define PTRACE #define NFSCLIENT @@ -42,8 +40,6 @@ #define SYSVMSG #define SYSVSHM #include <kern/syscalls.c> - -#include <compat/linux/linux_syscalls.c> #undef KTRACE #undef PTRACE #undef NFSCLIENT @@ -76,7 +72,6 @@ struct emulation { static struct emulation emulations[] = { { "native", syscallnames, SYS_MAXSYSCALL }, - { "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL }, { NULL, NULL, 0 } }; Index: bin/systrace/register.c =================================================================== RCS file: /cvs/src/bin/systrace/register.c,v retrieving revision 1.26 diff -u -p -r1.26 register.c --- bin/systrace/register.c 24 Jun 2015 03:38:51 -0000 1.26 +++ bin/systrace/register.c 28 Feb 2016 20:46:40 -0000 @@ -39,7 +39,6 @@ #include "intercept.h" #include "systrace.h" -#include "linux-translate.h" #define X(x) if ((x) == -1) \ err(1, "%s:%d: intercept failed", __func__, __LINE__) @@ -268,72 +267,6 @@ systrace_initcb(void) &ic_translate_unlinknameatflag); intercept_register_translation("native", "linkat", 3, &ic_translate_unlinknameat); - - X(intercept_register_sccb("linux", "open", trans_cb, NULL)); - tl = intercept_register_translink("linux", "open", 0); - intercept_register_translation("linux", "open", 1, &ic_linux_oflags); - alias = systrace_new_alias("linux", "open", "linux", "fswrite"); - systrace_alias_add_trans(alias, tl); - - X(intercept_register_sccb("linux", "stat", trans_cb, NULL)); - tl = intercept_register_translink("linux", "stat", 0); - alias = systrace_new_alias("linux", "stat", "linux", "fsread"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "lstat", trans_cb, NULL)); - tl = intercept_register_translink("linux", "lstat", 0); - alias = systrace_new_alias("linux", "lstat", "linux", "fsread"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "execve", trans_cb, NULL)); - intercept_register_translink("linux", "execve", 0); - X(intercept_register_sccb("linux", "access", trans_cb, NULL)); - tl = intercept_register_translink("linux", "access", 0); - alias = systrace_new_alias("linux", "access", "linux", "fsread"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "symlink", trans_cb, NULL)); - intercept_register_transstring("linux", "symlink", 0); - intercept_register_translink("linux", "symlink", 1); - X(intercept_register_sccb("linux", "link", trans_cb, NULL)); - intercept_register_translink("linux", "link", 0); - intercept_register_translink("linux", "link", 1); - X(intercept_register_sccb("linux", "readlink", trans_cb, NULL)); - tl = intercept_register_translink("linux", "readlink", 0); - alias = systrace_new_alias("linux", "readlink", "linux", "fsread"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "rename", trans_cb, NULL)); - intercept_register_translink("linux", "rename", 0); - intercept_register_translink("linux", "rename", 1); - X(intercept_register_sccb("linux", "mkdir", trans_cb, NULL)); - tl = intercept_register_translink("linux", "mkdir", 0); - alias = systrace_new_alias("linux", "mkdir", "linux", "fswrite"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "rmdir", trans_cb, NULL)); - tl = intercept_register_translink("linux", "rmdir", 0); - alias = systrace_new_alias("linux", "rmdir", "linux", "fswrite"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "unlink", trans_cb, NULL)); - tl = intercept_register_translink("linux", "unlink", 0); - alias = systrace_new_alias("linux", "unlink", "linux", "fswrite"); - systrace_alias_add_trans(alias, tl); - X(intercept_register_sccb("linux", "chmod", trans_cb, NULL)); - intercept_register_translink("linux", "chmod", 0); - intercept_register_translation("linux", "chmod", 1, &ic_modeflags); - - X(intercept_register_sccb("linux", "socketcall", trans_cb, NULL)); - alias = systrace_new_alias("linux", "socketcall", "linux", "_socketcall"); - tl = intercept_register_translation("linux", "socketcall", 1, &ic_linux_socket_sockdom); - systrace_alias_add_trans(alias, tl); - tl = intercept_register_translation("linux", "socketcall", 1, &ic_linux_socket_socktype); - systrace_alias_add_trans(alias, tl); - tl = intercept_register_translation("linux", "socketcall", 1, &ic_linux_connect_sockaddr); - systrace_alias_add_trans(alias, tl); - tl = intercept_register_translation("linux", "socketcall", 1, &ic_linux_bind_sockaddr); - systrace_alias_add_trans(alias, tl); - tl = intercept_register_translation("linux", "socketcall", 0, &ic_linux_socketcall_catchall); - systrace_alias_add_trans(alias, tl); - - X(intercept_register_sccb("linux", "kill", trans_cb, NULL)); - intercept_register_translation("linux", "kill", 0, &ic_pidname); - intercept_register_translation("linux", "kill", 1, &ic_signame); X(intercept_register_execcb(execres_cb, NULL)); X(intercept_register_pfreecb(policyfree_cb, NULL)); Index: bin/systrace/systrace-translate.c =================================================================== RCS file: /cvs/src/bin/systrace/systrace-translate.c,v retrieving revision 1.25 diff -u -p -r1.25 systrace-translate.c --- bin/systrace/systrace-translate.c 16 Jan 2015 00:19:12 -0000 1.25 +++ bin/systrace/systrace-translate.c 28 Feb 2016 20:44:13 -0000 @@ -46,9 +46,6 @@ #include <pwd.h> #include <err.h> -#include "../../sys/compat/linux/linux_types.h" -#include "../../sys/compat/linux/linux_fcntl.h" - #include "intercept.h" #include "systrace.h" @@ -58,7 +55,6 @@ } while (0) static int print_oflags(char *, size_t, struct intercept_translate *); -static int linux_print_oflags(char *, size_t, struct intercept_translate *); static int print_modeflags(char *, size_t, struct intercept_translate *); static int print_number(char *, size_t, struct intercept_translate *); static int print_uname(char *, size_t, struct intercept_translate *); @@ -115,49 +111,6 @@ print_oflags(char *buf, size_t buflen, s } static int -linux_print_oflags(char *buf, size_t buflen, struct intercept_translate *tl) -{ - char str[32], *p; - int flags = (intptr_t)tl->trans_addr; - int isread = 0; - - p = str; - switch (flags & LINUX_O_ACCMODE) { - case LINUX_O_RDONLY: - strlcpy(p, "ro", str + sizeof str - p); - isread = 1; - break; - case LINUX_O_WRONLY: - strlcpy(p, "wo", str + sizeof str - p); - break; - case LINUX_O_RDWR: - strlcpy(p, "rw", str + sizeof str - p); - break; - default: - strlcpy(p, "--", str + sizeof str - p); - break; - } - - /* XXX - Open handling of alias */ - if (isread) - systrace_switch_alias("linux", "open", "linux", "fsread"); - else - systrace_switch_alias("linux", "open", "linux", "fswrite"); - - p += 2; - - FL(LINUX_O_APPEND, 'a'); - FL(LINUX_O_CREAT, 'c'); - FL(LINUX_O_TRUNC, 't'); - - *p = '\0'; - - strlcpy(buf, str, buflen); - - return (0); -} - -static int print_modeflags(char *buf, size_t buflen, struct intercept_translate *tl) { int mode = (intptr_t)tl->trans_addr; @@ -353,11 +306,9 @@ print_signame(char *buf, size_t buflen, case SIGWINCH: name = "SIGWINCH"; break; -#ifndef __linux__ case SIGINFO: name = "SIGINFO"; break; -#endif /* !__linux__ */ case SIGUSR1: name = "SIGUSR1"; break; @@ -422,32 +373,6 @@ print_fcntlcmd(char *buf, size_t buflen, return (0); } -struct linux_i386_mmap_arg_struct { - unsigned long addr; - unsigned long len; - unsigned long prot; - unsigned long flags; - unsigned long fd; - unsigned long offset; -}; - -static int -get_linux_memprot(struct intercept_translate *trans, int fd, pid_t pid, - void *addr) -{ - struct linux_i386_mmap_arg_struct arg; - size_t len = sizeof(arg); - extern struct intercept_system intercept; - - if (intercept.io(fd, pid, INTERCEPT_READ, addr, - (void *)&arg, len) == -1) - return (-1); - - trans->trans_addr = (void *)arg.prot; - - return (0); -} - static int print_memprot(char *buf, size_t buflen, struct intercept_translate *tl) { @@ -620,11 +545,6 @@ struct intercept_translate ic_oflags = { NULL, print_oflags, }; -struct intercept_translate ic_linux_oflags = { - "oflags", - NULL, linux_print_oflags, -}; - struct intercept_translate ic_modeflags = { "mode", NULL, print_modeflags, @@ -678,11 +598,6 @@ struct intercept_translate ic_fcntlcmd = struct intercept_translate ic_memprot = { "prot", NULL, print_memprot, -}; - -struct intercept_translate ic_linux_memprot = { - "prot", - get_linux_memprot, print_memprot, }; struct intercept_translate ic_fileflags = { Index: bin/systrace/systrace.h =================================================================== RCS file: /cvs/src/bin/systrace/systrace.h,v retrieving revision 1.27 diff -u -p -r1.27 systrace.h --- bin/systrace/systrace.h 2 Jul 2006 12:34:15 -0000 1.27 +++ bin/systrace/systrace.h 28 Feb 2016 20:47:52 -0000 @@ -243,10 +243,7 @@ extern struct intercept_translate ic_pid extern struct intercept_translate ic_signame; extern struct intercept_translate ic_fcntlcmd; extern struct intercept_translate ic_memprot; -extern struct intercept_translate ic_linux_memprot; extern struct intercept_translate ic_fileflags; - -extern struct intercept_translate ic_linux_oflags; int requestor_start(char *, int); -- Christian "naddy" Weisgerber na...@mips.inka.de