Unix kernel calling the kernel

Andrew Klossner andrew at frip.gwd.tek.com
Thu Nov 3 08:07:35 AEST 1988


[]

	"Specifically, I am planning to write a device driver for a
	block device that would read the data from a tty device
	(Actually a pseudo tty who's other end is another device driver
	...)"

I've done something like this, as part of a mechanism by which kernel
messages and /dev/console traffic are routed to an X window
if-and-only-if X is up.  You open the routine by calling ptsopen; you
write by calling ptswrite; and you close by calling ptsclose.  There
are several pitfalls:

1) Under some varieties of Unix, the device driver expects the entire
device number, not just the minor number.  You have no easy way of
finding out what the major number is.  I hacked our pty driver not to
care about the major number.

2) If you call ptsclose for a pseudo-terminal that's still open, the
close routine will shut down the pty and the "legitimate" processes
that have it open will have trouble.  On the other hand, if you don't
call ptsclose and nobody had it open, it won't get shut down.  You
either have to interact with the inode locking mechanism, or you need
alternate "open" and "close" entry points into the pty driver.

3) After call call to ptswrite, you need to unschedule yourself so that
the other end of the pseudo-terminal can digest what you've fed it.

  -=- Andrew Klossner   (uunet!tektronix!tekecs!frip!andrew)    [UUCP]
                        (andrew%frip.gwd.tek.com at relay.cs.net)  [ARPA]



More information about the Comp.unix.wizards mailing list