For files opened O_RDWR, output an R record as well as W

so that clients that only care about files read can ignore W.
Bump version.
This commit is contained in:
sjg 2011-09-24 18:08:15 +00:00
parent 3680431868
commit 053773f1f4
2 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: filemon.h,v 1.2 2011/07/04 23:37:30 sjg Exp $ */
/* $NetBSD: filemon.h,v 1.3 2011/09/24 18:08:15 sjg Exp $ */
/*
* Copyright (c) 2010, Juniper Networks, Inc.
*
@ -31,7 +31,7 @@
#define FILEMON_SET_FD _IOWR('S', 1, int)
#define FILEMON_SET_PID _IOWR('S', 2, pid_t)
#define FILEMON_VERSION 3
#define FILEMON_VERSION 4
#ifdef _KERNEL
struct filemon {

View File

@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: filemon_wrapper.c,v 1.2 2011/03/13 21:26:31 sjg Exp $");
__KERNEL_RCSID(0, "$NetBSD: filemon_wrapper.c,v 1.3 2011/09/24 18:08:15 sjg Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -164,6 +164,17 @@ filemon_wrapper_open(struct lwp * l, struct sys_open_args * uap,
error = copyinstr(SCARG(uap, path), filemon->fm_fname1,
sizeof(filemon->fm_fname1), &done);
if (error == 0) {
if (SCARG(uap, flags) & O_RDWR) {
/* we want a separate R record */
len = snprintf(filemon->fm_msgbufr,
sizeof(filemon->fm_msgbufr),
"R %d %s\n",
curproc->p_pid,
filemon->fm_fname1);
filemon_output(filemon,
filemon->fm_msgbufr, len);
}
len = snprintf(filemon->fm_msgbufr,
sizeof(filemon->fm_msgbufr),
"%c %d %s\n",