Subject: Re: Time to fix a 25 year old misdesign
To: None <email@example.com>
From: Lennart Augustsson <firstname.lastname@example.org>
Date: 10/15/2000 19:36:09
Lennart Augustsson wrote:
> The old UNIX device driver interface is fundamentally broken. The
> problem is the following
> The driver routine open() is called every time the device
> is opened, but close() is only called on the last close.
> 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().
Thinking some more about my proposal I realize that it is flawed.
The problem is that it is not only the open() system call that generates
an extra reference to a device vnode, but also for().
This means that with my scheme there would (potentially) be more
calls to dev_close() than dev_open(), which is also broken.
This could be fixed by introducing a device method that is called when
the reference count is increased (e.g. by fork). But now its starts to