HELP with *BLOCK* device driver

Michael Gersten michael at stb.uucp
Mon Feb 5 18:45:41 AEST 1990


HELP! I'm getting bind errors with this.

Repeat-by:
masterupd -a block open close strategy release nfs
cc -c nfs.c
lddrv -av nfs

lddrv complains: BIND error: Invalid parameter.

Note that if I say it is a char driver, with read instead of strategy,
it works fine. Can block device drivers be loaded at all?

(this is an attempt to write a driver whose data is supplied by another
user program; in this case getting data from another machine by serial
port).
	
/* block device driver. */
#define NUMDEV 8	/* Number of remote files */
/* Here's how it works. read/write (character device) is the user
mode relay code. strategy is the block code. We get the address,
length, and pass it to whoever is waiting on the read channel.

Specifically: Relayer does a read (char dev). We send him a READ
(long) start address (long) length (long)
Or a WRITE (long) start address (long) length (long) data

	This is the driver code. */

#define DEBUG

#include <sys/param.h>
#include <sys/buf.h>
#include <sys/iobuf.h>
#include <sys/dir.h>
#include <sys/conf.h>
#include <sys/user.h>
#include <errno.h>

extern struct user u;

struct iobuf nfstab[NUMDEV];	/* Start of request queue */
int ControlOpen = 0;
struct buf *CurrentBuf = NULL;

struct io {
	long devicenum;
	long readflag;
	long startblock;
	long length;
	char data[4];
};

/* An idea for the future: one raw control channel per real disk? Nahw, then
we can't do real raw i/o to the drives */

nfsopen (dev, flag, id)
/* id = 0 for char, 1 for block */
/* dev = 0 for control channel, other for real channel */
{
eprintf ("Open: dev=%d, flag=%d, id=%d\n", dev, flag, id);
	if (dev == 0 && id == 0 && ControlOpen == 0)	/* raw control */
		ControlOpen = 1;
	else if (dev == 0 || id == 0)	/* raw real or block control */
		u.u_error = ENXIO;
}

nfsclose (dev, flag)
{
eprintf ("Close: dev=%d, flag=%d\n", dev, flag);
	if (dev == 0)
		ControlOpen = 0;
}

nfsstrategy(bp)
struct buf *bp;
{
	int x;
#ifdef DEBUG
eprintf ("Strategy: Incoming data:\n");
eprintf ("for dev=%d\n", bp->b_dev);
eprintf ("count cyl sec trk\n");
eprintf ("  %d  %d   %d  %d\n", bp->x.count, bp->x.cyl, bp->x.sec, bp->x.trk);
eprintf ("blkno bcount paddr\n");
eprintf ("%5d %5d %x", bp->b_blkno, bp->b_bcount, paddr(bp));
#endif
	iodone (bp);
	return;
	/*NOTREACHED*/
	/* NOTREACHED */
	bp->x.cyl = 0;
	/** No disksort() routine???
	x = spl6();
	disksort (&nfstab[bp->b_dev], bp);
	splx (x);
	*/
	wakeup (&nfstab[bp->b_dev]); /* Wakeup someone waiting for a command */
}

nfsrelease()
{};

nfsread()
{}
;
-- 
		Michael
denwa!stb!michael anes.ucla.edu!stb!michael 
"The 80's: Ten years that came in a row."



More information about the Unix-pc.general mailing list