Subject: Re: Understanding foo_open, foo_read, etc.
To: Peter Seebach <seebs@plethora.net>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 08/29/2006 23:01:14
--VYFbYIvcJQJZrcbx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 29, 2006 at 03:47:19PM -0500, Peter Seebach wrote:
[...]
> With all that in mind... It'd be awfully convenient if I could easily
> clone the device, rather than cloning file descriptors, because it would
> dramatically reduce the amount of code I have to modify, since all the
> existing code is written as foo_read(device, ...) rather than foo_read(st=
ruct
> file *, ...).  However, I'm not sure whether this is possible; I don't see
> anything corresponding to FreeBSD's make_dev(devsw, minor, ...).
>=20
> So, do I just have to convert to fileops instead of cdevsw ops, or is the=
re
> some easy way to clone the device?  It looks like it's the same logic eit=
her
> way, one's just fewer code changes.

AFAIK, but I know or remember very little about that, but FreeBSD allows
having close() called for each call of the system call, instead of only
the last one.  I prefer the NetBSD approach which is I think clearer in
its intent.

What's so complicated about calling fdalloc and returning the ressult
of fdclone()?

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.

--VYFbYIvcJQJZrcbx
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iQEVAwUBRPSrGtgoQloHrPnoAQK3Ogf/efrmsecp3AgehZkHiuFh370bUn5vCfH8
qy/HB15Z1MjdcBjFiDT86honCutmXf70mlnxQzDJbOqZkBcR9Szru74735C9BZ8B
EJPtCFcTALsmdp727oVLMMlzSWFtotIaTxJhf47twu0Kpanc7534PYOHPJK1xOOT
6zAGLTkfC8srIV4l/NwhhaRUkztIRLkVZXdiaLztAtk4gWqENwOdndmINopCi1XM
ylGraN7S57yWuKchWMtt6gInXLM68e6VqVZIHqtTalq6wnbSrn7719cCpX5tgIsx
mUAxyCaHNjRJk1hyzC0XKxeMGWWJ81fBp+Pbf/DLkutBJInEDXtVcw==
=tNjO
-----END PGP SIGNATURE-----

--VYFbYIvcJQJZrcbx--