Subject: fyi: freebsd's cdevsw and select code is changing a tiny bit...
To: None <cgd@NetBSD.ORG, mycroft@ai.mit.edu, karels@bsdi.com>
From: Paul Traina <pst@shockwave.com>
List: current-users
Date: 02/23/1995 22:09:16
In order to remove some cruft that has been built on top of the FreeBSD
kernel,  I'm making a change to the cdevsw and the gunk stored therein, and
I wanted to chat it over outside the confines of the FreeBSD camp.

Recently someone added a tty snooping device to FreeBSD.  Regardless of
whether there is consensus on if this is a good thing or not,  it's there
now.  This addition brought up the point that storing an array of pointers
to tty structures in cdevsw means that anyone using ttselect-like
functionality usually ends up having to put wrappers and protection code
around the old ttselect function (or equivelent) so that one doesn't waltz
off the end of this stupid array that is only public for the benefit of
ttselect.

The snoop device had hard coded knowledge of the various tty drivers,  and
this made me promptly toss cookies.  I thought to myself,  how can one grab
a "struct tty *" without playing guessing games with minor numbers et al
and came up with the obvious solution...one should be asking the driver for
this stuff,  not doing pointer arithmetic accessing some bloody public array.

The long and the short of it is that I proposed and received no objections
from the FreeBSD folks to removing the pointer to the tty array and replacing
that with a function vector to a routine that is passed a major/minor pair
and returns a pointer to a valid and initialized tty entry if available
(or NULL).  In addition, ttselect has gotten the axe and was changed to
follow BSDI's ttyselect() calling convention (it's passed a pointer to the
tty structure entity instead of a device number).

In addition, this removes one of the blocks to making the tty structure
fully dynamicly allocatable (this may just be a limitation in freebsd that
you folks have already solved some other way,  but the hard coded limit on
ttys always struck me as a pretty vile wart.)

Why am I bugging you about this?

(a) I'd like a final sanity check from the folks outside the FreeBSD camp.
    If you think this is stupid,  I'd like to know why.  If you think this
    is a good idea, let me know.  If you have a better idea,  I want to hear
    it...this just struck me as less crufty than the current way ttselect is
    implemented and gives a semi-portable interface to things that may access
    the tty structures (such as snooping devices).

(b) I'd like to suggest that if the consensus is a good idea,  we all consider
    a common solution...I'm not wedded to any particular way of cleaning this
    cruft up,  rather I'd prefer to have an informal agreement that we all do
    it the same way.  Let's make the lives of device driver porters easier. :-)

Thanks for your time,

Paul