Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jan 2012 15:00:16 +0000 (UTC)
From:      "George V. Neville-Neil" <gnn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r229965 - head/sys/dev/null
Message-ID:  <201201111500.q0BF0Gda064528@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gnn
Date: Wed Jan 11 15:00:16 2012
New Revision: 229965
URL: http://svn.freebsd.org/changeset/base/229965

Log:
  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
  MFC after:	1 week

Modified:
  head/sys/dev/null/null.c

Modified: head/sys/dev/null/null.c
==============================================================================
--- head/sys/dev/null/null.c	Wed Jan 11 14:24:03 2012	(r229964)
+++ head/sys/dev/null/null.c	Wed Jan 11 15:00:16 2012	(r229965)
@@ -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;



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