Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2009 04:18:22 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 159987 for review
Message-ID:  <200903300418.n2U4IMZW002522@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=159987

Change 159987 by marcel@marcel_fbsdvm on 2009/03/30 04:17:29

	WIP flush.

Affected files ...

.. //depot/projects/nand/sys/geom/geom_nandsim.c#2 edit
.. //depot/projects/nand/sys/geom/geom_nandsim.h#1 add
.. //depot/projects/nand/usr.bin/nandsim/Makefile#1 add
.. //depot/projects/nand/usr.bin/nandsim/nandsim.c#1 add

Differences ...

==== //depot/projects/nand/sys/geom/geom_nandsim.c#2 (text+ko) ====

@@ -44,21 +44,25 @@
 #include <geom/geom.h>
 #include <geom/geom_int.h>
 
+#include "geom_nandsim.h"
+
+static d_close_t	g_nandsim_close;
+static d_ioctl_t	g_nandsim_ioctl;
 static d_open_t		g_nandsim_open;
-static d_close_t	g_nandsim_close;
+static d_read_t		g_nandsim_read;
 static d_strategy_t	g_nandsim_strategy;
-static d_ioctl_t	g_nandsim_ioctl;
+static d_write_t	g_nandsim_write;
 
 static struct cdevsw g_nandsim_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_open =	g_nandsim_open,
 	.d_close =	g_nandsim_close,
-	.d_read =	physread,
-	.d_write =	physwrite,
 	.d_ioctl =	g_nandsim_ioctl,
+	.d_open =	g_nandsim_open,
+	.d_read =	g_nandsim_read,
 	.d_strategy =	g_nandsim_strategy,
+	.d_write =	g_nandsim_write,
 	.d_name =	"g_nandsim",
-	.d_flags =	D_DISK | D_TRACKCLOSE,
+	.d_flags =	D_TRACKCLOSE,
 };
 
 static g_access_t	g_nandsim_access;
@@ -112,7 +116,7 @@
 g_nandsim_access(struct g_provider *pp, int r, int w, int e)
 {
 
-	return (ENOSYS);
+	return (0);
 }
 
 static void
@@ -158,22 +162,37 @@
 }
 
 static int
+g_nandsim_read(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+	if (dev->si_drv1 == NANDSIMCTL)
+		return (ENODEV);
+
+	return (EDOOFUS);
+}
+
+static int
+g_nandsim_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+	if (dev->si_drv1 == NANDSIMCTL)
+		return (ENODEV);
+
+	return (EDOOFUS);
+}
+
+static int
 g_nandsim_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
     struct thread *td)
 {
-	int i, error;
 
 	if (dev->si_drv1 != NANDSIMCTL)
 		return (ENOIOCTL);
 
-	i = IOCPARM_LEN(cmd);
-	switch (cmd) {
-	default:
-		error = ENOIOCTL;
-		break;
-	}
+	if (cmd != NANDSIM_CREATE)
+		return (ENOIOCTL);
 
-	return (error);
+	return (EDOOFUS);
 }
 
 static void
@@ -209,6 +228,13 @@
 	        bp->bio_cmd == BIO_DELETE,
 		("Wrong bio_cmd bio=%p cmd=%d", bp, bp->bio_cmd));
 	dev = bp->bio_dev;
+
+	if (dev->si_drv1 == NANDSIMCTL) {
+		bp->bio_resid = bp->bio_bcount;
+		biofinish(bp, NULL, ENODEV);
+		return;
+	}
+
 	cp = dev->si_drv2;
 
 	if ((bp->bio_offset % cp->provider->sectorsize) != 0 ||



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