Index: head/sys/dev/filemon/filemon.c =================================================================== --- head/sys/dev/filemon/filemon.c (nonexistent) +++ head/sys/dev/filemon/filemon.c (revision 236592) @@ -0,0 +1,377 @@ +/*- + * Copyright (c) 2011, David E. O'Brien. + * Copyright (c) 2009-2011, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JUNIPER NETWORKS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __FreeBSD_version >= 900041 +#include +#endif + +#include "filemon.h" + +#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32) +#include +#include + +extern struct sysentvec ia32_freebsd_sysvec; +#endif + +extern struct sysentvec elf32_freebsd_sysvec; +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, + .d_close = filemon_close, + .d_ioctl = filemon_ioctl, + .d_open = filemon_open, + .d_name = "filemon", +}; + +MALLOC_DECLARE(M_FILEMON); +MALLOC_DEFINE(M_FILEMON, "filemon", "File access monitor"); + +struct filemon { + TAILQ_ENTRY(filemon) link; /* Link into the in-use list. */ + struct mtx mtx; /* Lock mutex for this filemon. */ + struct cv cv; /* Lock condition variable for this + filemon. */ + struct file *fp; /* Output file pointer. */ + struct thread *locker; /* Ptr to the thread locking this + filemon. */ + pid_t pid; /* The process ID being monitored. */ + char fname1[MAXPATHLEN]; /* Temporary filename buffer. */ + char fname2[MAXPATHLEN]; /* Temporary filename buffer. */ + char msgbufr[1024]; /* Output message buffer. */ +}; + +static TAILQ_HEAD(, filemon) filemons_inuse = TAILQ_HEAD_INITIALIZER(filemons_inuse); +static TAILQ_HEAD(, filemon) filemons_free = TAILQ_HEAD_INITIALIZER(filemons_free); +static int n_readers = 0; +static struct mtx access_mtx; +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) +{ + struct filemon *filemon = data; + + if (filemon != NULL) { + struct file *fp = filemon->fp; + + /* Get exclusive write access. */ + filemon_lock_write(); + + /* Remove from the in-use list. */ + TAILQ_REMOVE(&filemons_inuse, filemon, link); + + filemon->fp = NULL; + filemon->pid = -1; + + /* Add to the free list. */ + TAILQ_INSERT_TAIL(&filemons_free, filemon, link); + + /* Give up write access. */ + filemon_unlock_write(); + + if (fp != NULL) + fdrop(fp, curthread); + } +} + +static int +filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused, + struct thread *td) +{ + 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. */ + case FILEMON_SET_FD: +#if __FreeBSD_version < 900041 +#define FGET_WRITE(a1, a2, a3) fget_write((a1), (a2), (a3)) +#else +#define FGET_WRITE(a1, a2, a3) fget_write((a1), (a2), CAP_WRITE | CAP_SEEK, (a3)) +#endif + if ((error = FGET_WRITE(td, *(int *)data, &filemon->fp)) == 0) + /* Write the file header. */ + filemon_comment(filemon); + break; + + /* Set the monitored process ID. */ + case FILEMON_SET_PID: + filemon->pid = *((pid_t *) data); + break; + + default: + error = EINVAL; + break; + } + + return (error); +} + +static int +filemon_open(struct cdev *dev, int oflags __unused, int devtype __unused, + struct thread *td __unused) +{ + struct filemon *filemon; + + /* Get exclusive write access. */ + filemon_lock_write(); + + if ((filemon = TAILQ_FIRST(&filemons_free)) != NULL) + TAILQ_REMOVE(&filemons_free, filemon, link); + + /* Give up write access. */ + filemon_unlock_write(); + + if (filemon == NULL) { + filemon = malloc(sizeof(struct filemon), M_FILEMON, + M_WAITOK | M_ZERO); + + filemon->fp = NULL; + + mtx_init(&filemon->mtx, "filemon", "filemon", MTX_DEF); + cv_init(&filemon->cv, "filemon"); + } + + 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(); + + /* Add to the in-use list. */ + TAILQ_INSERT_TAIL(&filemons_inuse, filemon, link); + + /* Give up write access. */ + filemon_unlock_write(); + + return (0); +} + +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); +} + +static void +filemon_load(void *dummy __unused) +{ + mtx_init(&access_mtx, "filemon", "filemon", MTX_DEF); + cv_init(&access_cv, "filemon"); + + /* 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 +filemon_unload(void) +{ + struct filemon *filemon; + int error = 0; + + /* Get exclusive write access. */ + filemon_lock_write(); + + 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(); + } + + /* Give up write access. */ + 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) { + TAILQ_REMOVE(&filemons_free, filemon, link); + mtx_destroy(&filemon->mtx); + cv_destroy(&filemon->cv); + free(filemon, M_FILEMON); + } + filemon_unlock_write(); + + mtx_destroy(&access_mtx); + cv_destroy(&access_cv); + } + + return (error); +} + +static int +filemon_modevent(module_t mod __unused, int type, void *data) +{ + int error = 0; + + switch (type) { + case MOD_LOAD: + filemon_load(data); + break; + + case MOD_UNLOAD: + error = filemon_unload(); + break; + + case MOD_SHUTDOWN: + break; + + default: + error = EOPNOTSUPP; + break; + + } + + return (error); +} + +DEV_MODULE(filemon, filemon_modevent, NULL); +MODULE_VERSION(filemon, 1); Property changes on: head/sys/dev/filemon/filemon.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/dev/filemon/filemon.h =================================================================== --- head/sys/dev/filemon/filemon.h (nonexistent) +++ head/sys/dev/filemon/filemon.h (revision 236592) @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2011, David E. O'Brien. + * Copyright (c) 2009-2011, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JUNIPER NETWORKS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#define FILEMON_SET_FD _IOWR('S', 1, int) +#define FILEMON_SET_PID _IOWR('S', 2, pid_t) + +#define FILEMON_VERSION 4 /* output format + (bump when adding record types) */ Property changes on: head/sys/dev/filemon/filemon.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/dev/filemon/filemon_lock.c =================================================================== --- head/sys/dev/filemon/filemon_lock.c (nonexistent) +++ head/sys/dev/filemon/filemon_lock.c (revision 236592) @@ -0,0 +1,122 @@ +/*- + * Copyright (c) 2009-2011, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JUNIPER NETWORKS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +static void +filemon_filemon_lock(struct filemon *filemon) +{ + mtx_lock(&filemon->mtx); + + while (filemon->locker != NULL && filemon->locker != curthread) + cv_wait(&filemon->cv, &filemon->mtx); + + filemon->locker = curthread; + + mtx_unlock(&filemon->mtx); +} + +static void +filemon_filemon_unlock(struct filemon *filemon) +{ + mtx_lock(&filemon->mtx); + + if (filemon->locker == curthread) + filemon->locker = NULL; + + /* Wake up threads waiting. */ + cv_broadcast(&filemon->cv); + + mtx_unlock(&filemon->mtx); +} + +static void +filemon_lock_read(void) +{ + mtx_lock(&access_mtx); + + while (access_owner != NULL || access_requester != NULL) + cv_wait(&access_cv, &access_mtx); + + n_readers++; + + /* Wake up threads waiting. */ + cv_broadcast(&access_cv); + + mtx_unlock(&access_mtx); +} + +static void +filemon_unlock_read(void) +{ + mtx_lock(&access_mtx); + + if (n_readers > 0) + n_readers--; + + /* Wake up a thread waiting. */ + cv_broadcast(&access_cv); + + mtx_unlock(&access_mtx); +} + +static void +filemon_lock_write(void) +{ + mtx_lock(&access_mtx); + + while (access_owner != curthread) { + if (access_owner == NULL && + (access_requester == NULL || + access_requester == curthread)) { + access_owner = curthread; + access_requester = NULL; + } else { + if (access_requester == NULL) + access_requester = curthread; + + cv_wait(&access_cv, &access_mtx); + } + } + + mtx_unlock(&access_mtx); +} + +static void +filemon_unlock_write(void) +{ + mtx_lock(&access_mtx); + + /* Sanity check that the current thread actually has the write lock. */ + if (access_owner == curthread) + access_owner = NULL; + + /* Wake up a thread waiting. */ + cv_broadcast(&access_cv); + + mtx_unlock(&access_mtx); +} Property changes on: head/sys/dev/filemon/filemon_lock.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/dev/filemon/filemon_wrapper.c =================================================================== --- head/sys/dev/filemon/filemon_wrapper.c (nonexistent) +++ head/sys/dev/filemon/filemon_wrapper.c (revision 236592) @@ -0,0 +1,746 @@ +/*- + * Copyright (c) 2011, David E. O'Brien. + * Copyright (c) 2009-2011, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JUNIPER NETWORKS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#if __FreeBSD_version > 800032 +#define FILEMON_HAS_LINKAT +#endif + +#if __FreeBSD_version < 900044 /* r225617 (2011-09-16) failed to bump + __FreeBSD_version. This really should + be based on "900045". "900044" is r225469 + (2011-09-10) so this code is broken for + 9-CURRENT September 10th-16th. */ +#define sys_chdir chdir +#define sys_execve execve +#define sys_fork fork +#define sys_link link +#define sys_open open +#define sys_rename rename +#define sys_stat stat +#define sys_symlink symlink +#define sys_unlink unlink +#define sys_vfork vfork +#define sys_sys_exit sys_exit +#ifdef FILEMON_HAS_LINKAT +#define sys_linkat linkat +#endif +#endif /* __FreeBSD_version */ + +static void +filemon_output(struct filemon *filemon, char *msg, size_t len) +{ + struct uio auio; + struct iovec aiov; + + if (filemon->fp == NULL) + return; + + aiov.iov_base = msg; + aiov.iov_len = len; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_resid = len; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_td = curthread; + auio.uio_offset = (off_t) -1; + + bwillwrite(); + + fo_write(filemon->fp, &auio, curthread->td_ucred, 0, curthread); +} + +static struct filemon * +filemon_pid_check(struct proc *p) +{ + struct filemon *filemon; + + TAILQ_FOREACH(filemon, &filemons_inuse, link) { + if (p->p_pid == filemon->pid) + return (filemon); + } + + if (p->p_pptr == NULL) + return (NULL); + + return (filemon_pid_check(p->p_pptr)); +} + +static void +filemon_comment(struct filemon *filemon) +{ + int len; + struct timeval now; + + /* Load timestamp before locking. Less accurate but less contention. */ + getmicrotime(&now); + + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + /* 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); + + /* Release the read lock. */ + filemon_unlock_read(); +} + +static int +filemon_wrapper_chdir(struct thread *td, struct chdir_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_chdir(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "C %d %s\n", + curproc->p_pid, filemon->fname1); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static int +filemon_wrapper_execve(struct thread *td, struct execve_args *uap) +{ + char fname[MAXPATHLEN]; + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + copyinstr(uap->fname, fname, sizeof(fname), &done); + + if ((ret = sys_execve(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "E %d %s\n", + curproc->p_pid, fname); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32) +static int +filemon_wrapper_freebsd32_execve(struct thread *td, + struct freebsd32_execve_args *uap) +{ + char fname[MAXPATHLEN]; + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + copyinstr(uap->fname, fname, sizeof(fname), &done); + + if ((ret = freebsd32_execve(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "E %d %s\n", + curproc->p_pid, fname); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} +#endif + +static int +filemon_wrapper_fork(struct thread *td, struct fork_args *uap) +{ + int ret; + size_t len; + struct filemon *filemon; + + if ((ret = sys_fork(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "F %d %ld\n", + curproc->p_pid, (long)curthread->td_retval[0]); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static int +filemon_wrapper_open(struct thread *td, struct open_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_open(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + + if (uap->flags & O_RDWR) { + /* + * We'll get the W record below, but need + * to also output an R to distingish from + * O_WRONLY. + */ + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "R %d %s\n", + curproc->p_pid, filemon->fname1); + filemon_output(filemon, filemon->msgbufr, len); + } + + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "%c %d %s\n", + (uap->flags & O_ACCMODE) ? 'W':'R', + curproc->p_pid, filemon->fname1); + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static int +filemon_wrapper_rename(struct thread *td, struct rename_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_rename(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->from, filemon->fname1, + sizeof(filemon->fname1), &done); + copyinstr(uap->to, filemon->fname2, + sizeof(filemon->fname2), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "M %d '%s' '%s'\n", + curproc->p_pid, filemon->fname1, filemon->fname2); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static int +filemon_wrapper_link(struct thread *td, struct link_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_link(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + copyinstr(uap->link, filemon->fname2, + sizeof(filemon->fname2), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "L %d '%s' '%s'\n", + curproc->p_pid, filemon->fname1, filemon->fname2); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static int +filemon_wrapper_symlink(struct thread *td, struct symlink_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_symlink(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + copyinstr(uap->link, filemon->fname2, + sizeof(filemon->fname2), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "L %d '%s' '%s'\n", + curproc->p_pid, filemon->fname1, filemon->fname2); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +#ifdef FILEMON_HAS_LINKAT +static int +filemon_wrapper_linkat(struct thread *td, struct linkat_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_linkat(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path1, filemon->fname1, + sizeof(filemon->fname1), &done); + copyinstr(uap->path2, filemon->fname2, + sizeof(filemon->fname2), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "L %d '%s' '%s'\n", + curproc->p_pid, filemon->fname1, filemon->fname2); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} +#endif + +static int +filemon_wrapper_stat(struct thread *td, struct stat_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_stat(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "S %d %s\n", + curproc->p_pid, filemon->fname1); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32) +static int +filemon_wrapper_freebsd32_stat(struct thread *td, + struct freebsd32_stat_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = freebsd32_stat(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "S %d %s\n", + curproc->p_pid, filemon->fname1); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} +#endif + +static void +filemon_wrapper_sys_exit(struct thread *td, struct sys_exit_args *uap) +{ + size_t len; + struct filemon *filemon; + struct timeval now; + + /* Get timestamp before locking. */ + getmicrotime(&now); + + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr), + "X %d %d\n", curproc->p_pid, uap->rval); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Check if the monitored process is about to exit. */ + if (filemon->pid == curproc->p_pid) { + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), + "# Stop %ju.%06ju\n# Bye bye\n", + (uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec); + + filemon_output(filemon, filemon->msgbufr, len); + } + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + + sys_sys_exit(td, uap); +} + +static int +filemon_wrapper_unlink(struct thread *td, struct unlink_args *uap) +{ + int ret; + size_t done; + size_t len; + struct filemon *filemon; + + if ((ret = sys_unlink(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + copyinstr(uap->path, filemon->fname1, + sizeof(filemon->fname1), &done); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "D %d %s\n", + curproc->p_pid, filemon->fname1); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static int +filemon_wrapper_vfork(struct thread *td, struct vfork_args *uap) +{ + int ret; + size_t len; + struct filemon *filemon; + + if ((ret = sys_vfork(td, uap)) == 0) { + /* Grab a read lock on the filemon inuse list. */ + filemon_lock_read(); + + if ((filemon = filemon_pid_check(curproc)) != NULL) { + /* Lock the found filemon structure. */ + filemon_filemon_lock(filemon); + + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), "F %d %ld\n", + curproc->p_pid, (long)curthread->td_retval[0]); + + filemon_output(filemon, filemon->msgbufr, len); + + /* Unlock the found filemon structure. */ + filemon_filemon_unlock(filemon); + } + + /* Release the read lock. */ + filemon_unlock_read(); + } + + return (ret); +} + +static void +filemon_wrapper_install(void) +{ +#if defined(__i386__) + struct sysent *sv_table = elf32_freebsd_sysvec.sv_table; +#elif defined(__amd64__) + struct sysent *sv_table = elf64_freebsd_sysvec.sv_table; +#else +#error Machine type not supported +#endif + + sv_table[SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir; + sv_table[SYS_exit].sy_call = (sy_call_t *) filemon_wrapper_sys_exit; + sv_table[SYS_execve].sy_call = (sy_call_t *) filemon_wrapper_execve; + sv_table[SYS_fork].sy_call = (sy_call_t *) filemon_wrapper_fork; + sv_table[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open; + sv_table[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename; + sv_table[SYS_stat].sy_call = (sy_call_t *) filemon_wrapper_stat; + sv_table[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink; + sv_table[SYS_vfork].sy_call = (sy_call_t *) filemon_wrapper_vfork; + sv_table[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link; + sv_table[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink; +#ifdef FILEMON_HAS_LINKAT + sv_table[SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat; +#endif + +#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32) + sv_table = ia32_freebsd_sysvec.sv_table; + + sv_table[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir; + sv_table[FREEBSD32_SYS_exit].sy_call = (sy_call_t *) filemon_wrapper_sys_exit; + sv_table[FREEBSD32_SYS_freebsd32_execve].sy_call = (sy_call_t *) filemon_wrapper_freebsd32_execve; + sv_table[FREEBSD32_SYS_fork].sy_call = (sy_call_t *) filemon_wrapper_fork; + sv_table[FREEBSD32_SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open; + sv_table[FREEBSD32_SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename; + sv_table[FREEBSD32_SYS_freebsd32_stat].sy_call = (sy_call_t *) filemon_wrapper_freebsd32_stat; + sv_table[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink; + sv_table[FREEBSD32_SYS_vfork].sy_call = (sy_call_t *) filemon_wrapper_vfork; + sv_table[FREEBSD32_SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link; + sv_table[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink; +#ifdef FILEMON_HAS_LINKAT + sv_table[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat; +#endif +#endif /* COMPAT_ARCH32 */ +} + +static void +filemon_wrapper_deinstall(void) +{ +#if defined(__i386__) + struct sysent *sv_table = elf32_freebsd_sysvec.sv_table; +#elif defined(__amd64__) + struct sysent *sv_table = elf64_freebsd_sysvec.sv_table; +#else +#error Machine type not supported +#endif + + sv_table[SYS_chdir].sy_call = (sy_call_t *)sys_chdir; + sv_table[SYS_exit].sy_call = (sy_call_t *)sys_sys_exit; + sv_table[SYS_execve].sy_call = (sy_call_t *)sys_execve; + sv_table[SYS_fork].sy_call = (sy_call_t *)sys_fork; + sv_table[SYS_open].sy_call = (sy_call_t *)sys_open; + sv_table[SYS_rename].sy_call = (sy_call_t *)sys_rename; + sv_table[SYS_stat].sy_call = (sy_call_t *)sys_stat; + sv_table[SYS_unlink].sy_call = (sy_call_t *)sys_unlink; + sv_table[SYS_vfork].sy_call = (sy_call_t *)sys_vfork; + sv_table[SYS_link].sy_call = (sy_call_t *)sys_link; + sv_table[SYS_symlink].sy_call = (sy_call_t *)sys_symlink; +#ifdef FILEMON_HAS_LINKAT + sv_table[SYS_linkat].sy_call = (sy_call_t *)sys_linkat; +#endif + +#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32) + sv_table = ia32_freebsd_sysvec.sv_table; + + sv_table[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *)sys_chdir; + sv_table[FREEBSD32_SYS_exit].sy_call = (sy_call_t *)sys_sys_exit; + sv_table[FREEBSD32_SYS_freebsd32_execve].sy_call = (sy_call_t *)freebsd32_execve; + sv_table[FREEBSD32_SYS_fork].sy_call = (sy_call_t *)sys_fork; + sv_table[FREEBSD32_SYS_open].sy_call = (sy_call_t *)sys_open; + sv_table[FREEBSD32_SYS_rename].sy_call = (sy_call_t *)sys_rename; + sv_table[FREEBSD32_SYS_freebsd32_stat].sy_call = (sy_call_t *)freebsd32_stat; + sv_table[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *)sys_unlink; + sv_table[FREEBSD32_SYS_vfork].sy_call = (sy_call_t *)sys_vfork; + sv_table[FREEBSD32_SYS_link].sy_call = (sy_call_t *)sys_link; + sv_table[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *)sys_symlink; +#ifdef FILEMON_HAS_LINKAT + sv_table[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *)sys_linkat; +#endif +#endif /* COMPAT_ARCH32 */ +} Property changes on: head/sys/dev/filemon/filemon_wrapper.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/modules/Makefile =================================================================== --- head/sys/modules/Makefile (revision 236591) +++ head/sys/modules/Makefile (revision 236592) @@ -1,833 +1,835 @@ # $FreeBSD$ .include # Modules that include binary-only blobs of microcode should be selectable by # MK_SOURCELESS_UCODE option (see below). SUBDIR= ${_3dfx} \ ${_3dfx_linux} \ ${_aac} \ accf_data \ accf_dns \ accf_http \ acl_nfs4 \ acl_posix1e \ ${_acpi} \ ae \ ${_aesni} \ age \ ${_agp} \ aha \ ${_ahb} \ ahci \ ${_aic} \ aic7xxx \ aio \ alc \ ale \ alq \ ${_amdsbwd} \ ${_amdtemp} \ amr \ ${_an} \ ${_aout} \ ${_apm} \ ${_arcmsr} \ ${_arcnet} \ ${_asmc} \ ${_asr} \ ata \ ath \ ath_pci \ ${_auxio} \ ${_bce} \ bfe \ bge \ ${_bxe} \ ${_bios} \ ${_bktr} \ ${_bm} \ bridgestp \ bwi \ bwn \ cam \ ${_canbepm} \ ${_canbus} \ ${_cardbus} \ ${_carp} \ cas \ ${_cbb} \ cc \ cd9660 \ cd9660_iconv \ ${_ce} \ ${_cfi} \ ${_ciss} \ ${_cm} \ ${_cmx} \ coda \ coda5 \ ${_coff} \ ${_coretemp} \ ${_cp} \ ${_cpuctl} \ ${_cpufreq} \ ${_crypto} \ ${_cryptodev} \ ${_cs} \ ${_ctau} \ ${_cxgb} \ cxgbe \ ${_cyclic} \ dc \ dcons \ dcons_crom \ de \ ${_dpms} \ ${_dpt} \ ${_drm} \ ${_drm2} \ ${_dtrace} \ dummynet \ ${_ed} \ ${_elink} \ ${_em} \ en \ ${_ep} \ ${_epic} \ esp \ ${_et} \ ${_ex} \ ${_exca} \ ${_ext2fs} \ ${_fatm} \ fdc \ fdescfs \ ${_fe} \ + ${_filemon} \ firewire \ firmware \ ${_fxp} \ gem \ geom \ ${_glxiic} \ ${_glxsb} \ hatm \ hifn \ hme \ ${_hpt27xx} \ ${_hptiop} \ ${_hptmv} \ ${_hptrr} \ hwpmc \ ${_i2c} \ ${_ibcs2} \ ${_ichwd} \ ${_ida} \ ${_ie} \ if_bridge \ if_disc \ if_edsc \ if_ef \ if_epair \ if_faith \ if_gif \ ${_if_gre} \ if_lagg \ ${_if_ndis} \ if_stf \ if_tap \ if_tun \ if_vlan \ ${_igb} \ ${_iir} \ ${_io} \ ${_ipdivert} \ ${_ipfilter} \ ${_ipfw} \ ipfw_nat \ ${_ipmi} \ ip_mroute_mod \ ${_ips} \ ${_ipw} \ ${_ipwfw} \ ${_isci} \ iscsi \ isp \ ${_ispfw} \ ${_iwi} \ ${_iwifw} \ ${_iwn} \ ${_iwnfw} \ ${_ixgb} \ ${_ixgbe} \ jme \ joy \ kbdmux \ kgssapi \ kgssapi_krb5 \ khelp \ krpc \ ksyms \ le \ lge \ libalias \ libiconv \ libmbpool \ libmchain \ ${_lindev} \ ${_linprocfs} \ ${_linsysfs} \ ${_linux} \ lmc \ lpt \ mac_biba \ mac_bsdextended \ mac_ifoff \ mac_lomac \ mac_mls \ mac_none \ mac_partition \ mac_portacl \ mac_seeotheruids \ mac_stub \ mac_test \ malo \ mcd \ md \ mem \ mfi \ mii \ mlx \ ${_mlx4} \ ${_mlx4ib} \ ${_mlxen} \ ${_mly} \ mmc \ mmcsd \ mps \ mpt \ mqueue \ msdosfs \ msdosfs_iconv \ ${_mse} \ msk \ ${_mthca} \ mvs \ mwl \ ${_mwlfw} \ mxge \ my \ ${_nandfs} \ ${_nandsim} \ ${_ncp} \ ${_ncv} \ ${_ndis} \ ${_netgraph} \ ${_nfe} \ nfs_common \ nfscl \ nfsclient \ nfscommon \ nfsd \ nfslock \ nfslockd \ nfsserver \ nfssvc \ nge \ nmdm \ ${_nsp} \ ntfs \ ntfs_iconv \ nullfs \ ${_nve} \ ${_nvram} \ ${_nwfs} \ ${_nxge} \ ${_opensolaris} \ oce \ ${_padlock} \ patm \ ${_pccard} \ ${_pcfclock} \ pcn \ ${_pf} \ ${_pflog} \ ${_pfsync} \ plip \ ${_pmc} \ portalfs \ ppbus \ ppc \ ppi \ pps \ procfs \ pseudofs \ ${_pst} \ pty \ puc \ ${_qlxgb} \ ral \ ${_ralfw} \ ${_random} \ rc4 \ ${_rdma} \ re \ reiserfs \ rl \ ${_runfw} \ ${_s3} \ ${_safe} \ ${_sbni} \ scc \ scd \ ${_scsi_low} \ sdhci \ sem \ send \ ${_sf} \ ${_sfxge} \ sge \ siba_bwn \ siftr \ siis \ sis \ sk \ ${_smbfs} \ ${_sn} \ ${_snc} \ snp \ ${_sound} \ ${_speaker} \ ${_splash} \ ${_sppp} \ ste \ ${_stg} \ stge \ ${_streams} \ ${_svr4} \ ${_sym} \ ${_syscons} \ sysvipc \ ${_ti} \ tl \ tmpfs \ ${_tpm} \ trm \ ${_twa} \ twe \ tws \ tx \ ${_txp} \ uart \ ubsec \ udf \ udf_iconv \ ufs \ unionfs \ usb \ utopia \ ${_vesa} \ ${_virtio} \ vge \ ${_viawd} \ vkbd \ ${_vpo} \ vr \ vte \ vx \ ${_vxge} \ wb \ ${_wbwd} \ ${_wi} \ wlan \ wlan_acl \ wlan_amrr \ wlan_ccmp \ wlan_rssadapt \ wlan_tkip \ wlan_wep \ wlan_xauth \ ${_wpi} \ ${_wpifw} \ ${_x86bios} \ ${_xe} \ xfs \ xl \ ${_zfs} \ zlib \ .if ${MACHINE_CPUARCH} != "powerpc" && ${MACHINE_CPUARCH} != "arm" && \ ${MACHINE_CPUARCH} != "mips" +_filemon= filemon _syscons= syscons _vpo= vpo .endif .if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" # no BUS_SPACE_UNSPECIFIED # No barrier instruction support (specific to this driver) _sym= sym # intr_disable() is a macro, causes problems .if ${MK_SOURCELESS_UCODE} != "no" _cxgb= cxgb .endif .endif .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) .if exists(${.CURDIR}/../opencrypto) _crypto= crypto _cryptodev= cryptodev .endif .if exists(${.CURDIR}/../crypto) _random= random .endif .endif .if (${MK_INET_SUPPORT} != "no" || ${MK_INET6_SUPPORT} != "no") || \ defined(ALL_MODULES) _carp= carp .endif .if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES) _if_gre= if_gre .endif .if ${MK_IPFILTER} != "no" || defined(ALL_MODULES) _ipfilter= ipfilter .endif .if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES) _ipdivert= ipdivert _ipfw= ipfw .endif .if ${MK_NAND} != "no" || defined(ALL_MODULES) _nandfs= nandfs _nandsim= nandsim .endif .if ${MK_NETGRAPH} != "no" || defined(ALL_MODULES) _netgraph= netgraph .endif .if (${MK_PF} != "no" && (${MK_INET_SUPPORT} != "no" || \ ${MK_INET6_SUPPORT} != "no")) || defined(ALL_MODULES) _pf= pf _pflog= pflog .if ${MK_INET_SUPPORT} != "no" _pfsync= pfsync .endif .endif .if ${MK_SOURCELESS_UCODE} != "no" _bce= bce _fatm= fatm _fxp= fxp _ispfw= ispfw _mwlfw= mwlfw _ralfw= ralfw _runfw= runfw _sf= sf _sn= sn _ti= ti _txp= txp .endif .if ${MACHINE_CPUARCH} == "i386" # XXX some of these can move to the general case when de-i386'ed # XXX some of these can move now, but are untested on other architectures. _3dfx= 3dfx _3dfx_linux= 3dfx_linux _agp= agp _aic= aic _an= an _aout= aout _apm= apm _arcnet= arcnet _bktr= bktr _bxe= bxe _cardbus= cardbus _cbb= cbb .if ${MK_SOURCELESS_UCODE} != "no" _ce= ce .endif _coff= coff .if ${MK_SOURCELESS_UCODE} != "no" _cp= cp .endif _cpuctl= cpuctl _cpufreq= cpufreq _cs= cs .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _cyclic= cyclic .endif _dpms= dpms _drm= drm _drm2= drm2 .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _dtrace= dtrace .endif _ed= ed _elink= elink _em= em _ep= ep _et= et _exca= exca _ext2fs= ext2fs _fe= fe _glxiic= glxiic _glxsb= glxsb _i2c= i2c _ibcs2= ibcs2 _ie= ie _if_ndis= if_ndis _igb= igb _io= io _lindev= lindev _linprocfs= linprocfs _linsysfs= linsysfs _linux= linux _mse= mse .if ${MK_OFED} != "no" || defined(ALL_MODULES) _mlx4= mlx4 _mlx4ib= mlx4ib _mlxen= mlxen _mthca= mthca .endif .if ${MK_NCP} != "no" _ncp= ncp .endif _ncv= ncv _ndis= ndis _nsp= nsp .if ${MK_NCP} != "no" _nwfs= nwfs .endif .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _opensolaris= opensolaris .endif _pccard= pccard _pcfclock= pcfclock _pst= pst _rdma= rdma _safe= safe _sbni= sbni _scsi_low= scsi_low _smbfs= smbfs _sound= sound _speaker= speaker _splash= splash _sppp= sppp _stg= stg _streams= streams _svr4= svr4 _vxge= vxge _wbwd= wbwd _wi= wi _xe= xe .if ${MK_ZFS} != "no" || defined(ALL_MODULES) _zfs= zfs .endif .if ${MACHINE} == "i386" _aac= aac _acpi= acpi .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) _aesni= aesni .endif _ahb= ahb _amdsbwd= amdsbwd _amdtemp= amdtemp _arcmsr= arcmsr _asmc= asmc _asr= asr _bios= bios _ciss= ciss _cm= cm _cmx= cmx _coretemp= coretemp .if ${MK_SOURCELESS_UCODE} != "no" _ctau= ctau .endif _dpt= dpt _ex= ex .if ${MK_SOURCELESS_HOST} != "no" _hpt27xx= hpt27xx .endif _hptiop= hptiop .if ${MK_SOURCELESS_HOST} != "no" _hptmv= hptmv _hptrr= hptrr .endif _ichwd= ichwd _ida= ida _iir= iir _ipmi= ipmi _ips= ips _ipw= ipw .if ${MK_SOURCELESS_UCODE} != "no" _ipwfw= ipwfw .endif _isci= isci _iwi= iwi .if ${MK_SOURCELESS_UCODE} != "no" _iwifw= iwifw .endif _iwn= iwn .if ${MK_SOURCELESS_UCODE} != "no" _iwnfw= iwnfw .endif _ixgb= ixgb _ixgbe= ixgbe _mly= mly _nfe= nfe .if ${MK_SOURCELESS_HOST} != "no" _nve= nve .endif _nvram= nvram _nxge= nxge _tpm= tpm _viawd= viawd _wpi= wpi .if ${MK_SOURCELESS_UCODE} != "no" _wpifw= wpifw .endif .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) _padlock= padlock .endif _s3= s3 _twa= twa _vesa= vesa _virtio= virtio _x86bios= x86bios .elif ${MACHINE} == "pc98" _canbepm= canbepm _canbus= canbus _pmc= pmc _snc= snc .endif .endif .if ${MACHINE_CPUARCH} == "amd64" _aac= aac _aout= aout _acpi= acpi .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) _aesni= aesni .endif _agp= agp _an= an _amdsbwd= amdsbwd _amdtemp= amdtemp _arcmsr= arcmsr _asmc= asmc _bktr= bktr _bxe= bxe _cardbus= cardbus _cbb= cbb _cmx= cmx _ciss= ciss _coretemp= coretemp _cpuctl= cpuctl _cpufreq= cpufreq .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _cyclic= cyclic .endif _dpms= dpms _drm= drm _drm2= drm2 .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _dtrace= dtrace .endif _ed= ed _et= et _em= em _exca= exca _ext2fs= ext2fs .if ${MK_SOURCELESS_HOST} != "no" _hpt27xx= hpt27xx .endif _hptiop= hptiop .if ${MK_SOURCELESS_HOST} != "no" _hptmv= hptmv _hptrr= hptrr .endif _i2c= i2c _ichwd= ichwd _ida= ida _if_ndis= if_ndis _igb= igb _iir= iir _io= io _ipmi= ipmi _ips= ips _ipw= ipw .if ${MK_SOURCELESS_UCODE} != "no" _ipwfw= ipwfw .endif _isci= isci _iwi= iwi .if ${MK_SOURCELESS_UCODE} != "no" _iwifw= iwifw .endif _iwn= iwn .if ${MK_SOURCELESS_UCODE} != "no" _iwnfw= iwnfw .endif _ixgb= ixgb _ixgbe= ixgbe _lindev= lindev _linprocfs= linprocfs _linsysfs= linsysfs _linux= linux _mly= mly .if ${MK_OFED} != "no" || defined(ALL_MODULES) _mlx4= mlx4 _mlx4ib= mlx4ib _mlxen= mlxen _mthca= mthca .endif _ndis= ndis _nfe= nfe .if ${MK_SOURCELESS_HOST} != "no" _nve= nve .endif _nvram= nvram _nxge= nxge .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _opensolaris= opensolaris .endif .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) _padlock= padlock .endif _pccard= pccard _qlxgb= qlxgb _rdma= rdma _s3= s3 _safe= safe _scsi_low= scsi_low _sfxge= sfxge _smbfs= smbfs _sound= sound _speaker= speaker _splash= splash _sppp= sppp _tpm= tpm _twa= twa _vesa= vesa _viawd= viawd _virtio= virtio _vxge= vxge _x86bios= x86bios _wbwd= wbwd _wi= wi _wpi= wpi .if ${MK_SOURCELESS_UCODE} != "no" _wpifw= wpifw .endif .if ${MK_ZFS} != "no" || defined(ALL_MODULES) _zfs= zfs .endif .endif .if ${MACHINE_CPUARCH} == "arm" _cfi= cfi .endif .if ${MACHINE_CPUARCH} == "ia64" _aac= aac _aic= aic _an= an _arcnet= arcnet _asr= asr _bktr= bktr _cardbus= cardbus _cbb= cbb _ciss= ciss _cm= cm _cmx= cmx _coff= coff _cpufreq= cpufreq _dpt= dpt _em= em _ep= ep _et= et _exca= exca _fe= fe _hptiop= hptiop _ida= ida _igb= igb _iir= iir _ips= ips _mly= mly _pccard= pccard _scsi_low= scsi_low _smbfs= smbfs _sound= sound _splash= splash _sppp= sppp _streams= streams _tpm= tpm _twa= twa _wi= wi _xe= xe .endif .if ${MACHINE_CPUARCH} == "powerpc" _agp= agp _an= an _bm= bm _cardbus= cardbus _cbb= cbb _cfi= cfi _cpufreq= cpufreq _exca= exca _nvram= powermac_nvram _pccard= pccard _smbfs= smbfs _sound= sound .endif .if ${MACHINE_ARCH} == "powerpc64" .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _opensolaris= opensolaris .endif .if ${MK_ZFS} != "no" || defined(ALL_MODULES) _zfs= zfs .endif .endif .if ${MACHINE_CPUARCH} == "sparc64" _auxio= auxio _em= em _epic= epic _i2c= i2c _igb= igb .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _opensolaris= opensolaris .endif _smbfs= smbfs _sound= sound .if ${MK_ZFS} != "no" || defined(ALL_MODULES) _zfs= zfs .endif .endif .if defined(MODULES_OVERRIDE) && !defined(ALL_MODULES) SUBDIR=${MODULES_OVERRIDE} .endif .for reject in ${WITHOUT_MODULES} SUBDIR:= ${SUBDIR:N${reject}} .endfor # Calling kldxref(8) for each module is expensive. .if !defined(NO_XREF) .MAKEFLAGS+= -DNO_XREF afterinstall: @if type kldxref >/dev/null 2>&1; then \ ${ECHO} kldxref ${DESTDIR}${KMODDIR}; \ kldxref ${DESTDIR}${KMODDIR}; \ fi .endif .include Index: head/sys/modules/filemon/Makefile =================================================================== --- head/sys/modules/filemon/Makefile (nonexistent) +++ head/sys/modules/filemon/Makefile (revision 236592) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +MAINTAINER= obrien@FreeBSD.org + +.PATH: ${.CURDIR}/../../dev/filemon + +KMOD= filemon +SRCS= ${KMOD}.c +SRCS+= vnode_if.h opt_compat.h opt_capsicum.h + +.include Property changes on: head/sys/modules/filemon/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property