Module Name:    src
Committed By:   pgoyette
Date:           Mon Jan 11 01:37:36 UTC 2016

Modified Files:
        src/sys/dev/filemon: filemon.c filemon.h

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

Should fix PR kern/50627


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/filemon/filemon.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/filemon/filemon.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/filemon/filemon.c
diff -u src/sys/dev/filemon/filemon.c:1.27 src/sys/dev/filemon/filemon.c:1.28
--- src/sys/dev/filemon/filemon.c:1.27	Sat Jan  9 07:27:31 2016
+++ src/sys/dev/filemon/filemon.c	Mon Jan 11 01:37:36 2016
@@ -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_open(dev_t dev, int oflags __unu
 
 	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 @@ filemon_close(struct file * fp)
 	 */
 	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 @@ static int
 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 @@ filemon_ioctl(struct file * fp, u_long c
 
 		/* 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;
 		}

Index: src/sys/dev/filemon/filemon.h
diff -u src/sys/dev/filemon/filemon.h:1.8 src/sys/dev/filemon/filemon.h:1.9
--- src/sys/dev/filemon/filemon.h:1.8	Wed Nov 25 07:34:49 2015
+++ src/sys/dev/filemon/filemon.h	Mon Jan 11 01:37:36 2016
@@ -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 @@ struct filemon {
 	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. */

Reply via email to