Desupport pre-FreeBSD 7.1.

This commit is contained in:
David E. O'Brien 2012-10-25 18:39:09 +00:00
parent fef542fe1c
commit ab4ee4bb75

View File

@ -103,47 +103,11 @@ static struct cv access_cv;
static struct thread *access_owner = NULL;
static struct thread *access_requester = NULL;
#if __FreeBSD_version < 701000
static struct clonedevs *filemon_clones;
static eventhandler_tag eh_tag;
#else
static struct cdev *filemon_dev;
#endif
#include "filemon_lock.c"
#include "filemon_wrapper.c"
#if __FreeBSD_version < 701000
static void
filemon_clone(void *arg, struct ucred *cred, char *name, int namelen,
struct cdev **dev)
{
int u = -1;
size_t len;
if (*dev != NULL)
return;
len = strlen(name);
if (len != 7)
return;
if (bcmp(name,"filemon", 7) != 0)
return;
/* Clone the device to the new minor number. */
if (clone_create(&filemon_clones, &filemon_cdevsw, &u, dev, 0) != 0)
/* Create the /dev/filemonNN entry. */
*dev = make_dev_cred(&filemon_cdevsw, u, cred, UID_ROOT,
GID_WHEEL, 0666, "filemon%d", u);
if (*dev != NULL) {
dev_ref(*dev);
(*dev)->si_flags |= SI_CHEAPCLONE;
}
}
#endif
static void
filemon_dtr(void *data)
{
@ -179,11 +143,7 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused,
int error = 0;
struct filemon *filemon;
#if __FreeBSD_version < 701000
filemon = dev->si_drv1;
#else
devfs_get_cdevpriv((void **) &filemon);
#endif
switch (cmd) {
/* Set the output file descriptor. */
@ -238,11 +198,7 @@ filemon_open(struct cdev *dev, int oflags __unused, int devtype __unused,
filemon->pid = curproc->p_pid;
#if __FreeBSD_version < 701000
dev->si_drv1 = filemon;
#else
devfs_set_cdevpriv(filemon, filemon_dtr);
#endif
/* Get exclusive write access. */
filemon_lock_write();
@ -260,14 +216,6 @@ static int
filemon_close(struct cdev *dev __unused, int flag __unused, int fmt __unused,
struct thread *td __unused)
{
#if __FreeBSD_version < 701000
filemon_dtr(dev->si_drv1);
dev->si_drv1 = NULL;
/* Schedule this cloned device to be destroyed. */
destroy_dev_sched(dev);
#endif
return (0);
}
@ -281,16 +229,8 @@ filemon_load(void *dummy __unused)
/* Install the syscall wrappers. */
filemon_wrapper_install();
#if __FreeBSD_version < 701000
/* Enable device cloning. */
clone_setup(&filemon_clones);
/* Setup device cloning events. */
eh_tag = EVENTHANDLER_REGISTER(dev_clone, filemon_clone, 0, 1000);
#else
filemon_dev = make_dev(&filemon_cdevsw, 0, UID_ROOT, GID_WHEEL, 0666,
"filemon");
#endif
}
static int
@ -305,9 +245,7 @@ filemon_unload(void)
if (TAILQ_FIRST(&filemons_inuse) != NULL)
error = EBUSY;
else {
#if __FreeBSD_version >= 701000
destroy_dev(filemon_dev);
#endif
/* Deinstall the syscall wrappers. */
filemon_wrapper_deinstall();
@ -317,19 +255,6 @@ filemon_unload(void)
filemon_unlock_write();
if (error == 0) {
#if __FreeBSD_version < 701000
/*
* Check if there is still an event handler callback registered.
*/
if (eh_tag != 0) {
/* De-register the device cloning event handler. */
EVENTHANDLER_DEREGISTER(dev_clone, eh_tag);
eh_tag = 0;
/* Stop device cloning. */
clone_cleanup(&filemon_clones);
}
#endif
/* free() filemon structs free list. */
filemon_lock_write();
while ((filemon = TAILQ_FIRST(&filemons_free)) != NULL) {