From owner-freebsd-current@FreeBSD.ORG Tue Aug 28 15:31:10 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1FB71065676; Tue, 28 Aug 2012 15:31:10 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 906FC8FC14; Tue, 28 Aug 2012 15:31:09 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id A4EA27300A; Tue, 28 Aug 2012 17:50:25 +0200 (CEST) Date: Tue, 28 Aug 2012 17:50:25 +0200 From: Luigi Rizzo To: John Baldwin Message-ID: <20120828155025.GA66068@onelab2.iet.unipi.it> References: <20120827073403.GA49223@onelab2.iet.unipi.it> <503B2803.1010104@FreeBSD.org> <201208271227.54785.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201208271227.54785.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: freebsd-current@freebsd.org, current@freebsd.org, Andriy Gapon Subject: Re: per file descriptor device callbacks ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Aug 2012 15:31:10 -0000 On Mon, Aug 27, 2012 at 12:27:54PM -0400, John Baldwin wrote: > On Monday, August 27, 2012 3:55:47 am Andriy Gapon wrote: > > on 27/08/2012 10:34 Luigi Rizzo said the following: > > > This requires to track calls to open/ioctl/poll/mmap/close. > > > The difficulty i have is with mmap() and close(), because FreeBSD > > > seems to handle these calls per-cdev rather than per-file-descriptor > > > (for instance, no 'struct file' argument is available in mmap(), and > > > the d_close method is only called on the last close() on the device). > > > > devfs_set_cdevpriv(9), etc > > mmap() is still problematic, but if you have the freedom to create your > own VM objects, then d_mmap_single() can let you handle that fairly > easily. Would dev_clone(9) be a better way to do what i need ? This way the struct cdev would be unique per file descriptor, could be used as a key on the page fault callbacks (i still do not have callbacks on dev_pager_ctor/dtor though). cheers luigi