aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/filemon
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2016-01-27 21:14:09 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2016-01-27 21:14:09 +0000
commit64c368a48832917430d2b38c051c99e2e83f102c (patch)
tree632988583fc101e7d3c41b022a7cca268ab5213c /sys/dev/filemon
parente8c87a09dc53c500c3f68aa1f473eae2102e9c5f (diff)
downloadsrc-64c368a48832917430d2b38c051c99e2e83f102c.tar.gz
src-64c368a48832917430d2b38c051c99e2e83f102c.zip
filemon_ioctl: Lock the associated filemon handle before writing to it.
Reported by: mjg MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division
Notes
Notes: svn path=/head/; revision=294952
Diffstat (limited to 'sys/dev/filemon')
-rw-r--r--sys/dev/filemon/filemon.c3
-rw-r--r--sys/dev/filemon/filemon_wrapper.c7
2 files changed, 3 insertions, 7 deletions
diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c
index e16ad08ab836..90cf586e4515 100644
--- a/sys/dev/filemon/filemon.c
+++ b/sys/dev/filemon/filemon.c
@@ -146,6 +146,8 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused,
if ((error = devfs_get_cdevpriv((void **) &filemon)) != 0)
return (error);
+ filemon_filemon_lock(filemon);
+
switch (cmd) {
/* Set the output file descriptor. */
case FILEMON_SET_FD:
@@ -177,6 +179,7 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused,
break;
}
+ filemon_filemon_unlock(filemon);
return (error);
}
diff --git a/sys/dev/filemon/filemon_wrapper.c b/sys/dev/filemon/filemon_wrapper.c
index d107a40892f6..7ba843dcf1ea 100644
--- a/sys/dev/filemon/filemon_wrapper.c
+++ b/sys/dev/filemon/filemon_wrapper.c
@@ -115,21 +115,14 @@ filemon_comment(struct filemon *filemon)
int len;
struct timeval now;
- /* Load timestamp before locking. Less accurate but less contention. */
getmicrotime(&now);
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr),
"# filemon version %d\n# Target pid %d\n# Start %ju.%06ju\nV %d\n",
FILEMON_VERSION, curproc->p_pid, (uintmax_t)now.tv_sec,
(uintmax_t)now.tv_usec, FILEMON_VERSION);
filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
}
static int