From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 21 14:12:27 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 D05021065760 for ; Wed, 21 Jan 2009 14:12:27 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id B5E188FC37 for ; Wed, 21 Jan 2009 14:12:26 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA07212; Wed, 21 Jan 2009 16:12:25 +0200 (EET) (envelope-from avg@icyb.net.ua) Message-ID: <49772D47.2090602@icyb.net.ua> Date: Wed, 21 Jan 2009 16:12:23 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.18 (X11/20081124) MIME-Version: 1.0 To: Robert Watson References: <49770513.8090203@icyb.net.ua> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Kostik Belousov , freebsd-hackers@FreeBSD.org 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:12:30 -0000 on 21/01/2009 16:05 Robert Watson said the following: > > On Wed, 21 Jan 2009, Andriy Gapon wrote: > >> 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? > > 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. Robert, Kostik, 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. 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? -- Andriy Gapon