svn commit: r230320 - stable/9/sys/dev/null

George V. Neville-Neil gnn at FreeBSD.org
Wed Jan 18 21:54:34 UTC 2012


Author: gnn
Date: Wed Jan 18 21:54:34 2012
New Revision: 230320
URL: http://svn.freebsd.org/changeset/base/230320

Log:
  MFC: 229965
  
  Fix for PR 138526.
  
  Add the ability for /dev/null and /dev/zero to accept
  being set into non blocking mode via fcntl().  This
  brings the code into compliance with IEEE Std 1003.1-2001
  as referenced in another PR, 94729.
  
  Reviewed by:	jhb

Modified:
  stable/9/sys/dev/null/null.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)

Modified: stable/9/sys/dev/null/null.c
==============================================================================
--- stable/9/sys/dev/null/null.c	Wed Jan 18 21:51:56 2012	(r230319)
+++ stable/9/sys/dev/null/null.c	Wed Jan 18 21:54:34 2012	(r230320)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/priv.h>
 #include <sys/disk.h>
 #include <sys/bus.h>
+#include <sys/filio.h>
 
 #include <machine/bus.h>
 #include <machine/vmparam.h>
@@ -49,6 +50,7 @@ static struct cdev *zero_dev;
 
 static d_write_t null_write;
 static d_ioctl_t null_ioctl;
+static d_ioctl_t zero_ioctl;
 static d_read_t zero_read;
 
 static struct cdevsw null_cdevsw = {
@@ -63,6 +65,7 @@ static struct cdevsw zero_cdevsw = {
 	.d_version =	D_VERSION,
 	.d_read =	zero_read,
 	.d_write =	null_write,
+	.d_ioctl =	zero_ioctl,
 	.d_name =	"zero",
 	.d_flags =	D_MMAP_ANON,
 };
@@ -82,17 +85,50 @@ null_ioctl(struct cdev *dev __unused, u_
     int flags __unused, struct thread *td)
 {
 	int error;
+	error = 0;
 
-	if (cmd != DIOCSKERNELDUMP)
-		return (ENOIOCTL);
-	error = priv_check(td, PRIV_SETDUMPER);
-	if (error)
-		return (error);
-	return (set_dumper(NULL));
+	switch (cmd) {
+	case DIOCSKERNELDUMP:
+		error = priv_check(td, PRIV_SETDUMPER);
+		if (error == 0)
+			error = set_dumper(NULL);
+		break;
+	case FIONBIO:
+		break;
+	case FIOASYNC:
+		if (*(int *)data != 0)
+			error = EINVAL;
+		break;
+	default:
+		error = ENOIOCTL;
+	}
+	return (error);
 }
 
 /* ARGSUSED */
 static int
+zero_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused,
+	   int flags __unused, struct thread *td)
+{
+	int error;
+	error = 0;
+
+	switch (cmd) {
+	case FIONBIO:
+		break;
+	case FIOASYNC:
+		if (*(int *)data != 0)
+			error = EINVAL;
+		break;
+	default:
+		error = ENOIOCTL;
+	}
+	return (error);
+}
+
+
+/* ARGSUSED */
+static int
 zero_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
 {
 	void *zbuf;


More information about the svn-src-stable-9 mailing list