diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2016-03-12 19:07:21 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2016-03-12 19:07:21 +0000 |
commit | bb2a228f2d0bce046c9af1a32b6173d4ac522efe (patch) | |
tree | af5127e0b21705eccee6983fbf2572828f5e507f /sys/dev/filemon/filemon.c | |
parent | c677bff3bc0b0ee4a63ab8fca32643e0eb945358 (diff) | |
download | FreeBSD-src-bb2a228f2d0bce046c9af1a32b6173d4ac522efe.zip FreeBSD-src-bb2a228f2d0bce046c9af1a32b6173d4ac522efe.tar.gz |
MFC r296286,r296470,r296472,r296473,r296575:
r296286:
Remove filemon->lock wrappers.
r296470:
Only call bwillwrite() for logging to vnodes, as other fo_write() calls do.
r296472:
Require kldunload -f to unload.
r296473:
Add missing break for r296472.
r296575:
FILEMON_SET_FD: Disallow changing the fd.
Diffstat (limited to 'sys/dev/filemon/filemon.c')
-rw-r--r-- | sys/dev/filemon/filemon.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c index 352f682..e33536f 100644 --- a/sys/dev/filemon/filemon.c +++ b/sys/dev/filemon/filemon.c @@ -71,8 +71,6 @@ extern struct sysentvec elf64_freebsd_sysvec; static d_close_t filemon_close; static d_ioctl_t filemon_ioctl; static d_open_t filemon_open; -static int filemon_unload(void); -static void filemon_load(void *); static struct cdevsw filemon_cdevsw = { .d_version = D_VERSION, @@ -130,7 +128,7 @@ filemon_dtr(void *data) /* Follow same locking order as filemon_pid_check. */ filemon_lock_write(); - filemon_filemon_lock(filemon); + sx_xlock(&filemon->lock); /* Remove from the in-use list. */ TAILQ_REMOVE(&filemons_inuse, filemon, link); @@ -143,7 +141,7 @@ filemon_dtr(void *data) TAILQ_INSERT_TAIL(&filemons_free, filemon, link); /* Give up write access. */ - filemon_filemon_unlock(filemon); + sx_xunlock(&filemon->lock); filemon_unlock_write(); if (fp != NULL) @@ -165,13 +163,15 @@ 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); + sx_xlock(&filemon->lock); switch (cmd) { /* Set the output file descriptor. */ case FILEMON_SET_FD: - if (filemon->fp != NULL) - fdrop(filemon->fp, td); + if (filemon->fp != NULL) { + error = EEXIST; + break; + } error = fget_write(td, *(int *)data, #if __FreeBSD_version >= 900041 @@ -198,7 +198,7 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused, break; } - filemon_filemon_unlock(filemon); + sx_xunlock(&filemon->lock); return (error); } @@ -308,6 +308,14 @@ filemon_modevent(module_t mod __unused, int type, void *data) error = filemon_unload(); break; + case MOD_QUIESCE: + /* + * The wrapper implementation is unsafe for reliable unload. + * Require forcing an unload. + */ + error = EBUSY; + break; + case MOD_SHUTDOWN: break; |