Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/filemon If a second call to the SET_FD ioctl occurs, ...



details:   https://anonhg.NetBSD.org/src/rev/132e45fc95ce
branches:  trunk
changeset: 341751:132e45fc95ce
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Nov 21 07:45:30 2015 +0000

description:
If a second call to the SET_FD ioctl occurs, release the reference we
hold on the earlier outout file.

diffstat:

 sys/dev/filemon/filemon.c |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r f7230394cc61 -r 132e45fc95ce sys/dev/filemon/filemon.c
--- a/sys/dev/filemon/filemon.c Sat Nov 21 07:41:29 2015 +0000
+++ b/sys/dev/filemon/filemon.c Sat Nov 21 07:45:30 2015 +0000
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.16 2015/11/21 03:34:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.17 2015/11/21 07:45:30 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -294,6 +294,12 @@
        switch (cmd) {
        case FILEMON_SET_FD:
                /* Set the output file descriptor. */
+
+               /* First, release any current output file descriptor */
+               if (filemon->fm_fp)
+                       fd_putfile(filemon->fm_fd);
+
+               /* Now set up the new one */
                filemon->fm_fd = *((int *) data);
                if ((filemon->fm_fp = fd_getfile(filemon->fm_fd)) == NULL) {
                        rw_exit(&filemon->fm_mtx);



Home | Main Index | Thread Index | Old Index