From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 21 14:15:14 2009 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FE3510657D2; Wed, 21 Jan 2009 14:15:14 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id E60D78FC32; Wed, 21 Jan 2009 14:15:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1LPdrM-000Bf3-R1; Wed, 21 Jan 2009 16:15:12 +0200 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n0LEFAEw012017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Jan 2009 16:15:10 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n0LEFA4x024876; Wed, 21 Jan 2009 16:15:10 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n0LEF9MA024875; Wed, 21 Jan 2009 16:15:09 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 21 Jan 2009 16:15:09 +0200 From: Kostik Belousov To: Andriy Gapon Message-ID: <20090121141509.GN58517@deviant.kiev.zoral.com.ua> References: <49770513.8090203@icyb.net.ua> <49772D47.2090602@icyb.net.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+cfQkLQGU7KOA/8T" Content-Disposition: inline In-Reply-To: <49772D47.2090602@icyb.net.ua> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1LPdrM-000Bf3-R1 27a6638792289c7e398fe02084c62e8e X-Terabit: YES Cc: freebsd-hackers@FreeBSD.org, Robert Watson Subject: Re: device driver: cdesw questions? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2009 14:15:16 -0000 --+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--