Module Name: src
Committed By: sjg
Date: Mon Jun 15 18:11:36 UTC 2015
Modified Files:
src/sys/dev/filemon: filemon_wrapper.c
Log Message:
Latest clang uses openat, filemon thus needs to handle it.
For the simple cases where path is absolute or dirfd is for cwd
we can handle this just like open.
For the remaining case we output an 'A' record to offer a clue that
a search for open dir is needed (earlier in the trace).
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/filemon/filemon_wrapper.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/filemon/filemon_wrapper.c
diff -u src/sys/dev/filemon/filemon_wrapper.c:1.5 src/sys/dev/filemon/filemon_wrapper.c:1.6
--- src/sys/dev/filemon/filemon_wrapper.c:1.5 Thu Mar 27 18:27:34 2014
+++ src/sys/dev/filemon/filemon_wrapper.c Mon Jun 15 18:11:36 2015
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon_wrapper.c,v 1.5 2014/03/27 18:27:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon_wrapper.c,v 1.6 2015/06/15 18:11:36 sjg Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -160,6 +160,51 @@ filemon_wrapper_open(struct lwp * l, str
}
static int
+filemon_wrapper_openat(struct lwp * l, struct sys_openat_args * uap,
+ register_t * retval)
+{
+ int ret;
+ int error;
+ size_t done;
+ struct filemon *filemon;
+
+ if ((ret = sys_openat(l, uap, retval)) == 0) {
+ filemon = filemon_lookup(curproc);
+
+ if (filemon) {
+ error = copyinstr(SCARG(uap, path), filemon->fm_fname1,
+ sizeof(filemon->fm_fname1), &done);
+ if (error == 0) {
+ if (filemon->fm_fname1[0] != '/' &&
+ SCARG(uap, fd) != AT_FDCWD) {
+ /*
+ * Rats we cannot just treat like open.
+ * Output an 'A' record as a clue.
+ */
+ filemon_printf(filemon,
+ "A %d %s\n",
+ curproc->p_pid,
+ filemon->fm_fname1);
+ }
+ if (SCARG(uap, oflags) & O_RDWR) {
+ /* we want a separate R record */
+ filemon_printf(filemon,
+ "R %d %s\n",
+ curproc->p_pid,
+ filemon->fm_fname1);
+ }
+ filemon_printf(filemon,
+ "%c %d %s\n",
+ (SCARG(uap, oflags) & O_ACCMODE) ? 'W' : 'R',
+ curproc->p_pid, filemon->fm_fname1);
+ }
+ rw_exit(&filemon->fm_mtx);
+ }
+ }
+ return (ret);
+}
+
+static int
filemon_wrapper_rename(struct lwp * l, struct sys_rename_args * uap,
register_t * retval)
{
@@ -311,6 +356,7 @@ filemon_wrapper_install(void)
sv_table[SYS_fork].sy_call = (sy_call_t *) filemon_wrapper_fork;
sv_table[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
sv_table[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
+ sv_table[SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
sv_table[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
sv_table[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
sv_table[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
@@ -330,6 +376,7 @@ filemon_wrapper_deinstall(void)
sv_table[SYS_fork].sy_call = (sy_call_t *) sys_fork;
sv_table[SYS_link].sy_call = (sy_call_t *) sys_link;
sv_table[SYS_open].sy_call = (sy_call_t *) sys_open;
+ sv_table[SYS_openat].sy_call = (sy_call_t *) sys_openat;
sv_table[SYS_rename].sy_call = (sy_call_t *) sys_rename;
sv_table[SYS_symlink].sy_call = (sy_call_t *) sys_symlink;
sv_table[SYS_unlink].sy_call = (sy_call_t *) sys_unlink;