Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jan 2009 16:15:09 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-hackers@FreeBSD.org, Robert Watson <rwatson@FreeBSD.org>
Subject:   Re: device driver: cdesw questions?
Message-ID:  <20090121141509.GN58517@deviant.kiev.zoral.com.ua>
In-Reply-To: <49772D47.2090602@icyb.net.ua>
References:  <49770513.8090203@icyb.net.ua> <alpine.BSF.2.00.0901211353440.13974@fledge.watson.org> <49772D47.2090602@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--+cfQkLQGU7KOA/8T
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Jan 21, 2009 at 04:12:23PM +0200, Andriy Gapon wrote:
> on 21/01/2009 16:05 Robert Watson said the following:
> >=20
> > On Wed, 21 Jan 2009, Andriy Gapon wrote:
> >=20
> >> Question 1: I am writing a driver that would use per-open private data
> >> (among other features). Do I have to use D_TRACKCLOSE flag in this
> >> case? In general I am a little bit confused about when d_close is
> >> invoked. Supposing D_TRACKCLOSE is not set and multiple programs
> >> concurrently open, use and close a device - when d_close is called -
> >> when one program closes its last descriptor tied to the device or when
> >> the system-wide last such descriptor is closed?
> >=20
> > Kostik has already pointed at the cdevpriv API, but just to reiterate
> > his point: most people will find the semantics of D_TRACKCLOSE confusing
> > and consider them incorrect, so I would advise against using them.
>=20
> Robert, Kostik,
>=20
> in simplistic layman's terms I need the following - when a particular
> program "closes my cdev" (explicitly or via exit) I need to catch that
> and de-allocate certain resources. There can be multiple concurrent
> programs opening, using and closing my cdev.
>=20
> I guess what you both say is that I shouldn't use D_TRACKCLOSE, instead
> I should perform the resource management in cdevpriv destructor.
> Am I guessing correctly this time?

Yes. This is the purpose of the cdevpriv KPI.

--+cfQkLQGU7KOA/8T
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkl3Le0ACgkQC3+MBN1Mb4gr1gCgwnF62FbmZOVjZ/zlQazR70FO
WwcAoLzScUMCpgDy7/LQfJkDz9KI7txK
=5R02
-----END PGP SIGNATURE-----

--+cfQkLQGU7KOA/8T--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090121141509.GN58517>