Subject: Re: multiple cdev open/close
To: Jiri Slaby <jirislaby@gmail.com>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 09/04/2006 11:56:05
--4WCFFtl4AQpQKunj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Sep 04, 2006 at 11:26:57AM +0200, Quentin Garnier wrote:
> On Mon, Sep 04, 2006 at 11:20:45AM +0159, Jiri Slaby wrote:
> > Hello,
> >=20
> > I have netbsd cdev driver. I do multiple opens (more instances) on it, =
is=20
> > there any way to get know about each close of these instances?
> >=20
> > 'A' process does:
> > open
> > ioctl(START_IT) + others
> > for (;;) {
> > poll
> > ioctl(LOCK_IT)
> > read it by mmap
> > ioctl(UNLOCK_IT)
> > }
> >=20
> > ^C, so kernel calls close for it and releases A process' resources.
> >=20
> > If there is also process B, which does the very same thing, for first=
=20
> > process killed there is no close call and kernel turns into ddb. I do n=
eed=20
> > to know about all closes -- is there such a way?
>=20
> Yes, make the device clonable, like e.g. tap(4) and bpf(4).

So, actually, that won't give you mmap.  Support for it should be added.
The cdev has to keep track of the resources and free them all at close
time...  This is probably not ideal, but support for mmap on fdclone'd
descriptors really should be added.

--=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.

--4WCFFtl4AQpQKunj
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iQEVAwUBRPv4NdgoQloHrPnoAQKPTwf+IuL6JrYvtNF8dadzdaKE7YHw8St2d0av
9z0gta1znDpujyQIfMe9Y/htanM1Za75IZ3IPaFGy44Lz2nAXcQbphTFH7uY76/6
7VgMvQNLIcIxgaoIMt+XtLlTYNApmtP0p0q4NsFX6mQbmHa2zeM6RR65CAuWmRxR
OPtYtMYAOoUUXQ9ZcNZ5E4+n6QIB6nAbUwla35IFnUjpaliB0JK+4R+q4oeQN7i9
d+2f2S5d0VAeD8NkzAuJkic9vb37/PZTek3b1/hrxrl+0vTMibeNoTO2nDTYnxho
Cd/2fu+lTrbllR8y4ttJ8llzS8LemcBGKvhDsZZbd6euQd720NP/cg==
=E1IE
-----END PGP SIGNATURE-----

--4WCFFtl4AQpQKunj--