Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/filemon Take a reference on the (activity log) file ...



details:   https://anonhg.NetBSD.org/src/rev/893288d45818
branches:  trunk
changeset: 342852:893288d45818
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Jan 11 01:37:36 2016 +0000

description:
Take a reference on the (activity log) file itself, and not on the
descriptor.

Should fix PR kern/50627

diffstat:

 sys/dev/filemon/filemon.c |  14 +++++++-------
 sys/dev/filemon/filemon.h |   3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)

diffs (75 lines):

diff -r fb2b3827bf2d -r 893288d45818 sys/dev/filemon/filemon.c
--- a/sys/dev/filemon/filemon.c Mon Jan 11 01:34:39 2016 +0000
+++ b/sys/dev/filemon/filemon.c Mon Jan 11 01:37:36 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: filemon.c,v 1.27 2016/01/09 07:27:31 pgoyette Exp $ */
+/*      $NetBSD: filemon.c,v 1.28 2016/01/11 01:37:36 pgoyette Exp $ */
 /*
  * Copyright (c) 2010, Juniper Networks, Inc.
  *
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.27 2016/01/09 07:27:31 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.28 2016/01/11 01:37:36 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -227,7 +227,6 @@
 
        filemon = kmem_alloc(sizeof(struct filemon), KM_SLEEP);
        rw_init(&filemon->fm_mtx);
-       filemon->fm_fd = -1;
        filemon->fm_fp = NULL;
        filemon->fm_pid = curproc->p_pid;
 
@@ -270,7 +269,7 @@
         */
        rw_enter(&filemon->fm_mtx, RW_WRITER);
        if (filemon->fm_fp) {
-               fd_putfile(filemon->fm_fd);     /* release our reference */
+               closef(filemon->fm_fp); /* release our reference */
                filemon->fm_fp = NULL;
        }
        rw_exit(&filemon->fm_mtx);
@@ -284,6 +283,7 @@
 filemon_ioctl(struct file * fp, u_long cmd, void *data)
 {
        int error = 0;
+       int fd;
        struct filemon *filemon;
        struct proc *tp;
 
@@ -306,11 +306,11 @@
 
                /* First, release any current output file descriptor */
                if (filemon->fm_fp)
-                       fd_putfile(filemon->fm_fd);
+                       closef(filemon->fm_fp);
 
                /* Now set up the new one */
-               filemon->fm_fd = *((int *) data);
-               if ((filemon->fm_fp = fd_getfile(filemon->fm_fd)) == NULL) {
+               fd = *((int *) data);
+               if ((filemon->fm_fp = fd_getfile2(curproc, fd)) == NULL) {
                        error = EBADF;
                        break;
                }
diff -r fb2b3827bf2d -r 893288d45818 sys/dev/filemon/filemon.h
--- a/sys/dev/filemon/filemon.h Mon Jan 11 01:34:39 2016 +0000
+++ b/sys/dev/filemon/filemon.h Mon Jan 11 01:37:36 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: filemon.h,v 1.8 2015/11/25 07:34:49 pgoyette Exp $ */
+/* $NetBSD: filemon.h,v 1.9 2016/01/11 01:37:36 pgoyette Exp $ */
 /*
  * Copyright (c) 2010, Juniper Networks, Inc.
  *
@@ -41,7 +41,6 @@
        char fm_fname1[MAXPATHLEN];/* Temporary filename buffer. */
        char fm_fname2[MAXPATHLEN];/* Temporary filename buffer. */
        char fm_msgbufr[32 + 2 * MAXPATHLEN];   /* Output message buffer. */
-       int fm_fd;                      /* Output fd */
        struct file *fm_fp;     /* Output file pointer. */
        krwlock_t fm_mtx;               /* Lock mutex for this filemon. */
        TAILQ_ENTRY(filemon) fm_link;   /* Link into the in-use list. */



Home | Main Index | Thread Index | Old Index