From owner-freebsd-hackers Tue Feb 13 11:40:26 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from iguana.aciri.org (iguana.aciri.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id 123E137B491 for ; Tue, 13 Feb 2001 11:40:25 -0800 (PST) Received: (from rizzo@localhost) by iguana.aciri.org (8.11.1/8.11.1) id f1DJeMH34966; Tue, 13 Feb 2001 11:40:22 -0800 (PST) (envelope-from rizzo) From: Luigi Rizzo Message-Id: <200102131940.f1DJeMH34966@iguana.aciri.org> Subject: Re: character device driver In-Reply-To: <20010213193150.A882@btinternet.com> from David Rufino at "Feb 13, 2001 7:31:50 pm" To: daverufino@btinternet.com (David Rufino) Date: Tue, 13 Feb 2001 11:40:22 -0800 (PST) Cc: hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Hi, > > I'm writing a character device driver in which each minor device can be > opened more than once. When a device is opened is there a way to associate > some private data for each opened instance ? Thanks. allocation is easy -- what is complex is looking up the private data on each system calls because you usually have no reference to which instance of the open() the syscall refers to. A hack that can work in some cases (ioctl and some other calls do include the necessary info) is to use the process id of the caller to differentiate. But you must be careful about processes forking and passing fd's to their children... cheers luigi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message