diff options
Diffstat (limited to 'sys/dev/filemon/filemon.c')
-rw-r--r-- | sys/dev/filemon/filemon.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c index 352f682..cd40c5a 100644 --- a/sys/dev/filemon/filemon.c +++ b/sys/dev/filemon/filemon.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/file.h> #include <sys/systm.h> #include <sys/buf.h> +#include <sys/capsicum.h> #include <sys/condvar.h> #include <sys/conf.h> #include <sys/fcntl.h> @@ -52,10 +53,6 @@ __FBSDID("$FreeBSD$"); #include <sys/sysproto.h> #include <sys/uio.h> -#if __FreeBSD_version >= 900041 -#include <sys/capsicum.h> -#endif - #include "filemon.h" #if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32) @@ -71,8 +68,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 +125,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 +138,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) @@ -158,25 +153,23 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused, int error = 0; struct filemon *filemon; struct proc *p; -#if __FreeBSD_version >= 900041 cap_rights_t rights; -#endif 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 cap_rights_init(&rights, CAP_PWRITE), -#endif &filemon->fp); if (error == 0) /* Write the file header. */ @@ -198,7 +191,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 +301,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; |