From owner-freebsd-hackers Fri Aug 1 12:25:13 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id MAA07072 for hackers-outgoing; Fri, 1 Aug 1997 12:25:13 -0700 (PDT) Received: from rah.star-gate.com (rah.star-gate.com [204.188.121.18]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA07057 for ; Fri, 1 Aug 1997 12:25:07 -0700 (PDT) Received: from rah.star-gate.com (localhost.star-gate.com [127.0.0.1]) by rah.star-gate.com (8.8.5/8.8.5) with ESMTP id MAA05657; Fri, 1 Aug 1997 12:23:48 -0700 (PDT) Message-Id: <199708011923.MAA05657@rah.star-gate.com> To: Terry Lambert cc: msmith@atrad.adelaide.edu.au (Michael Smith), luigi@labinfo.iet.unipi.it, hackers@FreeBSD.ORG Subject: Re: device close behaviour - a question In-reply-to: Your message of "Fri, 01 Aug 1997 10:40:34 PDT." <199708011740.KAA09486@phaeton.artisoft.com> Date: Fri, 01 Aug 1997 12:23:48 -0700 From: Amancio Hasty Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Hi, Curious, shouldn't the responsibility of managing the behavior of open/close fall on the device driver . After all the driver should dictate whether it can manage multiple open instances. As for determining whether there are multiple opens on a device we can create an ioctl which returns the number of opens . Ideally, it should return instances of the states for each open. Amancio >From The Desk Of Terry Lambert : > > > I am having a problem related to the having multiple (actually, > > > 2) open descriptors on the same character device. More specifically, > > > I notice that only the last close does actually invoke the device > > > close routine. > > > > Heh. This one is tricky. > > Poul-Henning was talking about this before on the -current list. > > In general, I believe everyone agreed that it was desirable to > differentiate between "close" and "last close" to provide for > "per open instance" private data on devices. > > There is an issue on open, as well, since a device may be > instanced once, but have multiple references created for it > (Mike's inheritance of fd's on fork() or on exec() without > the close-on-exec flag set via fcntl() is one example of this). > > The issue is that there is not a semantic seperation between > reference instance vs. device instance at open time, so a close > differentiation is less than useful. Both corrections would > need to occur simultaneously for either one to be useful alone. > > > > You cannot ever guarantee any fixed number of openers on a device. > > O_EXCL or function equivalent. > > > Terry Lambert > terry@lambert.org > --- > Any opinions in this posting are my own and not those of my present > or previous employers. >