Subject: Re: Kernel device driver
To: Paul Mather <paul@gromit.dlib.vt.edu>
From: R. C. Dowdeswell <elric@mabelode.imrryr.org>
List: port-alpha
Date: 09/12/2000 16:11:49
On 968790861 seconds since the Beginning of the UNIX epoch
Paul Mather wrote:
>
>I apologise in advance that this is probably not the best place to post
>this, but I know there are a number of kernel hackers on port-alpha,
>and, at the very least, they can tell me a better place to seek a
>solution.
>
>I need to develop a kernel device driver---something akin to the vnd
>pseudo device, but that works over a TCP/IP socket, instead of with a
>local file.  The remote end of the socket is some custom API (over which
>I have no control) acting as a front-end for some custom storage bricks 
>(again, over which I have no control).  The object of the driver is to
>provide a block-device abstraction on which filesystems may be created
>(a la vnd, raid).

So, if you are looking to develop something like the vnd driver
that uses network sockets rather than a file, I'd recommend that
you just copy the vnd and hack it to taste.

You need to get your new driver to be recognised as a pseudo-device,
by adding a few lines to sys/conf/files.  You'll probably want to
add lines like:

defpseudo netd:	disk

and

file dev/netd.c		netd		needs-flag

Then use vnd and/or ccd as a reference on how to set up a disk
pseudo device, but the short form is that you need to have routines
for attach, open, close, strategy, ioctl, read, and write.

As for building TCP connections or dealing with UDP in the kernel,
the nfs code would be a good guide (sys/nfs).

Both sys/dev/ccd.c sys/dev/vnd.c are about 1k lines long.

Hopefully someone will correct me a bit, or mention what I missed.  :-)

 == Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/  ==
 == The Unofficial NetBSD Web Pages        http://www.Imrryr.ORG/NetBSD/  ==
 == The NetBSD Project                            http://www.NetBSD.ORG/  ==