Index: sys/dev/null/null.c
===================================================================
RCS file: /usr/CVS-Repository/src/sys/dev/null/null.c,v
retrieving revision 1.31
diff -u -p -r1.31 null.c
--- sys/dev/null/null.c	27 Feb 2005 22:00:45 -0000	1.31
+++ sys/dev/null/null.c	11 Mar 2005 06:37:09 -0000
@@ -43,13 +42,22 @@ __FBSDID("$FreeBSD: src/sys/dev/null/nul
 /* For use with destroy_dev(9). */
 static struct cdev *null_dev;
 static struct cdev *zero_dev;
+static struct cdev *one_dev;
+static struct cdev *deadbeef_dev;
+static struct cdev *eightball_dev;
 
 static d_write_t null_write;
 static d_ioctl_t null_ioctl;
 static d_read_t zero_read;
+static d_read_t one_read;
+static d_read_t deadbeef_read;
+static d_read_t eightball_read;
 
 #define NULL_MINOR	2
 #define ZERO_MINOR	12
+#define ONE_MINOR	13
+#define DEADBEEF_MINOR	13
+#define EIGHTBALL_MINOR	14
 
 static struct cdevsw null_cdevsw = {
 	.d_version =	D_VERSION,
@@ -67,7 +75,56 @@ static struct cdevsw zero_cdevsw = {
 	.d_flags =	D_MMAP_ANON,
 };
 
+static struct cdevsw one_cdevsw = {
+	.d_version =	D_VERSION,
+	.d_read =	one_read,
+	.d_write =	null_write,
+	.d_name =	"one",
+	.d_flags =	D_MMAP_ANON,
+};
+
+static struct cdevsw deadbeef_cdevsw = {
+	.d_version =	D_VERSION,
+	.d_read =	deadbeef_read,
+	.d_write =	null_write,
+	.d_name =	"deadbeef",
+	.d_flags =	D_MMAP_ANON,
+};
+
+static struct cdevsw eightball_cdevsw = {
+	.d_version =	D_VERSION,
+	.d_read =	eightball_read,
+	.d_write =	null_write,
+	.d_name =	"8ball",
+	.d_flags =	D_MMAP_ANON,
+};
+
+static char* eightballwisdom[] = {
+    "Signs point to yes.\n",
+    "Yes.\n",
+    "Reply hazy, try again.\n",
+    "Without a doubt.\n",
+    "My sources say no.\n",
+    "As I see it, yes.\n",
+    "You may rely on it.\n",
+    "Concentrate and ask again.\n",
+    "Outlook not so good.\n",
+    "It is decidedly so.\n",
+    "Better not tell you now.\n",
+    "Very doubtful.\n",
+    "Yes - definitely.\n",
+    "It is certain.\n",
+    "Cannot predict now.\n",
+    "Most likely.\n",
+    "Ask again later.\n",
+    "My reply is no.\n",
+    "Outlook good.\n",
+    "Don't count on it.\n"
+};
+    
 static void *zbuf;
+static void *obuf;
+static void *deadbeefbuf;
 
 /* ARGSUSED */
 static int
@@ -107,23 +164,81 @@ zero_read(struct cdev *dev __unused, str
 
 /* ARGSUSED */
 static int
+one_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+	int error = 0;
+
+	while (uio->uio_resid > 0 && error == 0)
+		error = uiomove(obuf, MIN(uio->uio_resid, PAGE_SIZE), uio);
+
+	return (error);
+}
+
+/* ARGSUSED */
+static int
+deadbeef_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+	int error = 0;
+
+	while (uio->uio_resid > 0 && error == 0)
+		error = uiomove(deadbeefbuf, MIN(uio->uio_resid, PAGE_SIZE), uio);
+
+	return (error);
+}
+
+/* ARGSUSED */
+static int
+eightball_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+	int i, error = 0;
+
+	while (uio->uio_resid > 0 && error == 0) {
+		i = random() % sizeof(eightballwisdom) / sizeof(eightballwisdom[0]);
+		error = uiomove(eightballwisdom[i], MIN(uio->uio_resid, strlen(eightballwisdom[i])), uio);
+	}
+		
+	return (error);
+}
+
+/* ARGSUSED */
+static int
 null_modevent(module_t mod __unused, int type, void *data __unused)
 {
+        int i;
+	uint32_t *beef;
+	
 	switch(type) {
 	case MOD_LOAD:
 		if (bootverbose)
 			printf("null: <null device, zero device>\n");
 		zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO);
+		obuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
+		memset(obuf, 0xff, PAGE_SIZE);
+		deadbeefbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
+		beef = (uint32_t *)deadbeefbuf;
+		for (i = 0; i < PAGE_SIZE / sizeof(uint32_t); i ++)
+		    beef[i] = 0xdeadbeef;
 		null_dev = make_dev(&null_cdevsw, NULL_MINOR, UID_ROOT,
 			GID_WHEEL, 0666, "null");
 		zero_dev = make_dev(&zero_cdevsw, ZERO_MINOR, UID_ROOT,
 			GID_WHEEL, 0666, "zero");
+		one_dev = make_dev(&one_cdevsw, ONE_MINOR, UID_ROOT,
+			GID_WHEEL, 0666, "one");
+		deadbeef_dev = make_dev(&deadbeef_cdevsw, DEADBEEF_MINOR, UID_ROOT,
+			GID_WHEEL, 0666, "deadbeef");
+		eightball_dev = make_dev(&eightball_cdevsw, EIGHTBALL_MINOR, UID_ROOT,
+			GID_WHEEL, 0666, "8ball");
 		break;
 
 	case MOD_UNLOAD:
 		destroy_dev(null_dev);
 		destroy_dev(zero_dev);
+		destroy_dev(one_dev);
+		destroy_dev(deadbeef_dev);
+		destroy_dev(eightball_dev);
 		free(zbuf, M_TEMP);
+		free(obuf, M_TEMP);
+		free(deadbeefbuf, M_TEMP);
 		break;
 
 	case MOD_SHUTDOWN:
