From owner-freebsd-hackers Fri Jun 29 5:35:41 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from tele-post-20.mail.demon.net (tele-post-20.mail.demon.net [194.217.242.20]) by hub.freebsd.org (Postfix) with ESMTP id 73CF437B40B for ; Fri, 29 Jun 2001 05:35:37 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from [62.49.251.130] (helo=herring.nlsystems.com) by tele-post-20.mail.demon.net with esmtp (Exim 2.12 #2) id 15FxUm-000Mt2-0K; Fri, 29 Jun 2001 12:35:36 +0000 Received: from herring (herring [10.0.0.2]) by herring.nlsystems.com (8.11.2/8.11.2) with ESMTP id f5TCYK703458; Fri, 29 Jun 2001 13:34:20 +0100 (BST) (envelope-from dfr@nlsystems.com) Date: Fri, 29 Jun 2001 13:34:19 +0100 (BST) From: Doug Rabson To: Nicolas Souchu Cc: Subject: Re: processes private data In-Reply-To: <20010629110607.B19935@avon.alcove-fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 29 Jun 2001, Nicolas Souchu wrote: > On Thu, Jun 28, 2001 at 07:48:21PM +0100, Doug Rabson wrote: > > On Thu, 28 Jun 2001, Nicolas Souchu wrote: > > > > > Hi folks, > > > > > > I have a char driver that must be opened by more than one process. The minor > > > index is not sufficient for this. Is there any process private data (void *) > > > in the devfs structure (or the opposite) I could point to with the minor index > > > of my device? > > > > The only way I know of to do this is to get a new struct file with > > falloc() and install your own fileops. You can then set p->p_dupfd to the > > new file descriptor and return ENXIO. The caller will magically use the > > new struct file. For an example, see streamsopen() in > > sys/dev/streams/streams.c. > > Ok, it seems to do part of the job. But this won't change the content of the > file struct. Does anything ensure that the f_data of the freshly allocated > struct file won't be used by vfs? Is the new struct file only local to my > device driver? > > Otherwise, I could write my own falloc() which would allocate a struct file > compatible with the original one like this: When you get a new struct file from falloc(), VFS has nothing to do with it. As you can see from the streamsopen() code, you can change f_ops (which by default points at &badfileops) and f_data (defaults to zero) to point at your own functions and data. The point is that you are creating a new file. The VFS-owned file which ended up calling the open driver entrypoint will be discarded in favour of your new one. -- Doug Rabson Mail: dfr@nlsystems.com Phone: +44 20 8348 6160 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message