Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Mar 2016 19:50:35 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r296575 - in head: share/man/man4 sys/dev/filemon
Message-ID:  <201603091950.u29JoZJr040689@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Wed Mar  9 19:50:35 2016
New Revision: 296575
URL: https://svnweb.freebsd.org/changeset/base/296575

Log:
  FILEMON_SET_FD: Disallow changing the fd.
  
  MFC after:	1 week
  Suggested by:	mjg
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/share/man/man4/filemon.4
  head/sys/dev/filemon/filemon.c

Modified: head/share/man/man4/filemon.4
==============================================================================
--- head/share/man/man4/filemon.4	Wed Mar  9 19:36:25 2016	(r296574)
+++ head/share/man/man4/filemon.4	Wed Mar  9 19:50:35 2016	(r296575)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 28, 2016
+.Dd March 9, 2016
 .Dt FILEMON 4
 .Os
 .Sh NAME
@@ -125,6 +125,19 @@ function returns the value 0 if successf
 otherwise the value \-1 is returned and the global variable
 .Va errno
 is set to indicate the error.
+.Sh ERRORS
+The
+.Fn ioctl
+system call
+with
+.Dv FILEMON_SET_FD
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EEXIST
+The
+.Nm
+handle is already associated with a file descriptor.
+.El
 .Sh FILES
 .Bl -tag -width ".Pa /dev/filemon"
 .It Pa /dev/filemon

Modified: head/sys/dev/filemon/filemon.c
==============================================================================
--- head/sys/dev/filemon/filemon.c	Wed Mar  9 19:36:25 2016	(r296574)
+++ head/sys/dev/filemon/filemon.c	Wed Mar  9 19:50:35 2016	(r296575)
@@ -163,8 +163,10 @@ filemon_ioctl(struct cdev *dev, u_long c
 	switch (cmd) {
 	/* Set the output file descriptor. */
 	case FILEMON_SET_FD:
-		if (filemon->fp != NULL)
-			fdrop(filemon->fp, td);
+		if (filemon->fp != NULL) {
+			error = EEXIST;
+			break;
+		}
 
 		error = fget_write(td, *(int *)data,
 		    cap_rights_init(&rights, CAP_PWRITE),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603091950.u29JoZJr040689>