Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Feb 2001 16:17:29 -0700
From:      Drew Eckhardt <drew@PoohSticks.ORG>
To:        David Rufino <daverufino@btinternet.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: character device driver 
Message-ID:  <200102182317.f1INHTn24123@chopper.Poohsticks.ORG>
In-Reply-To: Your message of "Tue, 13 Feb 2001 19:31:50 GMT." <20010213193150.A882@btinternet.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20010213193150.A882@btinternet.com>, daverufino@btinternet.com writ
es:
>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 ?

As other people have noted, not in the general case.

The solution I've used is to split the device minor number into a physical
unit and open instance part.  You keep the existing per-unit structure, and
add per-instance data including a busy flag which causes opens to return
EBUSY.  In your user land application, you iterate over the devices in 
round-robin fashion as long as you get back EBUSY as you would for pty 
masters.

-- 
<a href="http://www.poohsticks.org/drew/">Home Page</a>
For those who do, no explanation is necessary.  
For those who don't, no explanation is possible.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102182317.f1INHTn24123>