Subject: Re: Time to fix a 25 year old misdesign
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Lennart Augustsson <lennart@augustsson.net>
List: tech-kern
Date: 10/15/2000 17:03:53
Manuel Bouyer wrote:

> > How should it be fixed?  Well, the only% way I can see is to change
> > when the close() routine is called for character device drivers.
> > Doing that would be a huge amount of work, so instead I suggest that
> > we add a routine to the struct cdevsw.  This routine will have the
> > same type as the close() routine, but will be called on every close().
> > If left out, it will not be called.  This way all old drivers can
> > remain intact, and only those that require the new functionality need
> > to know about it.
>
> Ok, so two close routines in cdevsw, but only one is used for each driver
> (a driver can use the old or new behavior, but not both). This way we
> could eventually convert all drivers to the new behavior and garbage-collect
> the old close entry when done.
>
> However for most drivers we only care about the last close, so converting all
> driver would add complexity to most of them. Maybe we need some generic
> ref-counting for this ?

We could pass the reference count to the close routine.  That way it's easy
for the close routine to just return early if the reference count is above 0.


--

        -- Lennart