Subject: How to support clone devices (i.e. /dev/tcp)
To: None <christos@deshaw.com>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: tech-kern
Date: 11/15/1994 11:10:47
> Date: Mon, 14 Nov 1994 20:55:30 GMT
> From: christos@deshaw.com (Christos Zoulas)

> In article <9411141522.AA00614@bach> "Gordon Ross" <gwr@mc.com> writes:
[ added extra argument to vn_open ]
> >Was this discussed anywhere?  (like tech-kern?)

> I sent mail to core a couple of weeks ago. I received two replies which
> said it was ok to proceed.

OK, I'm just surprised there was no discussion on tech-kern first.

> >Why was this change done?
> 
> To implement cloning devices [needed for svr4 /dev/{tcp,udp,...}

> If you think that this is not the right way to do it and you provide an
> alternative implementation that does not change half the files in sys
> I am all for it.

Well, it's probably too late to consider, but another way to allow
svr4 programs using -lsocket and -lnsl to work would be to write a
special libsocket.so that interfaces to the BSD socket calls.
If one really needs libnsl.so (and I doubt it) then that too could
be implemented as a layer on top of the BSD socket calls.
This would avoid the need for a kernel-level interface for the
cloning devices (/dev/tcp, /dev/udp).  Did you consider this?
(I could write the libsocket.so if someone wants me to.)

If we just want clone open capabilities for the fun of it,
I like the SunOS method for allowing a driver to do cloning:

  int xxx_open(dev_t *devp, int flag, int otyp, cred_t *credp);

The key to it is that the first arg is a pointer to a dev_t
that the driver may modify during open.  The dev_t provided
is the one from the device node (i.e. minor zero) but if the
driver sets it to (i.e.) minor 4 (because that was the first
available minor unit) then the specfs layer makes a new vnode
for this open file and things continue from there.

I think the above interface can be implemented without any
changes outside the specfs module (though I'm not sure).

(Just my two cents 8-)
Gordon