diff --git a/bin/systrace/register.c b/bin/systrace/register.c index 569abca08ed3..9e747ffae420 100644 --- a/bin/systrace/register.c +++ b/bin/systrace/register.c @@ -1,4 +1,4 @@ -/* $NetBSD: register.c,v 1.9 2003/06/03 04:33:44 provos Exp $ */ +/* $NetBSD: register.c,v 1.10 2005/05/07 15:11:02 provos Exp $ */ /* $OpenBSD: register.c,v 1.11 2002/08/05 14:49:27 provos Exp $ */ /* * Copyright 2002 Niels Provos @@ -167,6 +167,8 @@ systrace_initcb(void) X(intercept_register_sccb("netbsd", "kill", trans_cb, NULL)); intercept_register_translation("netbsd", "kill", 0, &ic_pidname); intercept_register_translation("netbsd", "kill", 1, &ic_signame); + X(intercept_register_sccb("netbsd", "fcntl", trans_cb, NULL)); + intercept_register_translation("netbsd", "fcntl", 1, &ic_fcntlcmd); #else X(intercept_register_gencb(gen_cb, NULL)); X(intercept_register_sccb("native", "open", trans_cb, NULL)); @@ -271,6 +273,8 @@ systrace_initcb(void) X(intercept_register_sccb("native", "kill", trans_cb, NULL)); intercept_register_translation("native", "kill", 0, &ic_pidname); intercept_register_translation("native", "kill", 1, &ic_signame); + X(intercept_register_sccb("native", "fcntl", trans_cb, NULL)); + intercept_register_translation("native", "fcntl", 1, &ic_fcntlcmd); #endif #if !(defined(__NetBSD__) && !defined(HAVE_LINUX_FCNTL_H)) diff --git a/bin/systrace/systrace-translate.c b/bin/systrace/systrace-translate.c index db653a252065..0bfde8df37df 100644 --- a/bin/systrace/systrace-translate.c +++ b/bin/systrace/systrace-translate.c @@ -1,4 +1,4 @@ -/* $NetBSD: systrace-translate.c,v 1.11 2003/03/25 23:15:22 provos Exp $ */ +/* $NetBSD: systrace-translate.c,v 1.12 2005/05/07 15:11:02 provos Exp $ */ /* $OpenBSD: systrace-translate.c,v 1.10 2002/08/01 20:50:17 provos Exp $ */ /* * Copyright 2002 Niels Provos @@ -72,6 +72,7 @@ static int print_number(char *, size_t, struct intercept_translate *); static int print_uname(char *, size_t, struct intercept_translate *); static int print_pidname(char *, size_t, struct intercept_translate *); static int print_signame(char *, size_t, struct intercept_translate *); +static int print_fcntlcmd(char *, size_t, struct intercept_translate *); static int get_argv(struct intercept_translate *, int, pid_t, void *); static int print_argv(char *, size_t, struct intercept_translate *); @@ -388,6 +389,50 @@ print_signame(char *buf, size_t buflen, struct intercept_translate *tl) return (0); } +static int +print_fcntlcmd(char *buf, size_t buflen, struct intercept_translate *tl) +{ + int cmd = (intptr_t)tl->trans_addr; + char *name; + + switch (cmd) { + case F_DUPFD: + name = "F_DUPFD"; + break; + case F_GETFD: + name = "F_GETFD"; + break; + case F_SETFD: + name = "F_SETFD"; + break; + case F_GETFL: + name = "F_GETFL"; + break; + case F_SETFL: + name = "F_SETFL"; + break; + case F_GETOWN: + name = "F_GETOWN"; + break; + case F_SETOWN: + name = "F_SETOWN"; + break; + case F_CLOSEM: + name = "F_CLOSEM"; + break; + case F_MAXFD: + name = "F_MAXFD"; + break; + default: + snprintf(buf, buflen, ": %d", cmd); + return (0); + } + + snprintf(buf, buflen, "%s", name); + return (0); +} + + static int get_argv(struct intercept_translate *trans, int fd, pid_t pid, void *addr) { @@ -500,3 +545,8 @@ struct intercept_translate ic_signame = { "signame", NULL, print_signame, }; + +struct intercept_translate ic_fcntlcmd = { + "cmd", + NULL, print_fcntlcmd, +}; diff --git a/bin/systrace/systrace.h b/bin/systrace/systrace.h index 0a6c900fe9b1..04711006250d 100644 --- a/bin/systrace/systrace.h +++ b/bin/systrace/systrace.h @@ -1,4 +1,4 @@ -/* $NetBSD: systrace.h,v 1.17 2004/12/01 03:30:07 provos Exp $ */ +/* $NetBSD: systrace.h,v 1.18 2005/05/07 15:11:02 provos Exp $ */ /* $OpenBSD: systrace.h,v 1.14 2002/08/05 23:27:53 provos Exp $ */ /* * Copyright 2002 Niels Provos @@ -232,6 +232,7 @@ extern struct intercept_translate ic_sockdom; extern struct intercept_translate ic_socktype; extern struct intercept_translate ic_pidname; extern struct intercept_translate ic_signame; +extern struct intercept_translate ic_fcntlcmd; extern struct intercept_translate ic_linux_oflags;