svn commit: r296575 - in head: share/man/man4 sys/dev/filemon

Bryan Drewery bdrewery at FreeBSD.org
Wed Mar 9 19:50:36 UTC 2016


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),


More information about the svn-src-all mailing list