Date: Sat, 1 Feb 1997 17:33:19 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: phk@freebsd.org Cc: current@freebsd.org Subject: Re: device driver open semantics... Message-ID: <199702020033.RAA07056@phaeton.artisoft.com> In-Reply-To: <3050.854800300@critter.dk.tfs.com> from "Poul-Henning Kamp" at Feb 1, 97 01:31:40 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> Proc A Proc B Device foo > ------------------------------------------ > open(foo,RD) > \__________________ > \ > ->open(foo, RD,A) > open(foo,WR) > \__ > \ > ->open(foo, WR,B) > close(foo) > >>nothing<< > close(foo) > \____________________ > \ > ->close(foo,A) > > > I'm dissatisfied with the >>nothing<< step. At this time > there is nobody who has the device open for writing but > we fail to communicate this to the driver. Good point. > open(foo,WR) > \__ > \ > ->isopen(foo, RD|WR) > close(foo) > \____ > \ > ->isopen(foo, RD) [ ... ] > Comments ? > > I realize that changing this behaviour in general would > probably surprise most if not all of our device-drivers, > So we're probably talking about a per-driver flag or possibly > a different open/close entry point in the [cb]devsw structure. > > Preferences ? > > Objections ? I assume you must be reference-counting the flags on a per flag basis? I suspect you could do equally well by passing the open flags back in to the close. If I'm not mistaken, the flags are preserved for system call mode testing purposes already to do things like fail writes on a file open only for reading, etc., since the permissions for the open are tested at open time, and it would not do to have 'A' open a file for read that he only had read access to, and take advantage of 'B' opening the file read/write so he can write it (think passwd file and passwd or vipw program; the db is rebuilt and may create an valid entry for an entry written in the race window that would open if modes had not been saved, or if the test was on the open flags). In any case, a driver could choose to implement reference counting, or not, depending on whether it personally cared how something was open (ie: sound cards probably would, but disks probably wouldn't, etc.). You might want to make some generic #defined macros in a header for it, though... Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702020033.RAA07056>