Re: [PATCH][2.1.71] BSD revoke() syscall

Theodore Y. Ts'o (tytso@MIT.EDU)
Tue, 9 Dec 1997 14:18:45 -0500


From: alan@lxorguk.ukuu.org.uk (Alan Cox)
Date: Tue, 9 Dec 1997 17:22:15 +0000 (GMT)

> Good point but how, then, do I deal correctly with close()? I'm not
> allowed to modify *(filp->f_op) (would break the whole filesystem,
> wouldn't it?), but I _am_ allowed to change filp->f_op, if I'm not
> mistaken. Except that then it's not possible cleanly to handle the
> file close.

How about kmallocing a new f_op set with an attached private pointer to the
original one, so your close flips it back and frees the temporary one?

You really want to do the close as part of the revoke, and then make the
revoke'd close be pretty much a no-op. (See the tty code, which does
something a bit more complex, but it's the same basic idea.)

The reason for this is because you need to get the ref-counting right so
that the semantics with close() lowering DTR, etc. still apply even
though there are revoke'd file descriptors hanging around. (Similar
issues exist with any device which has semantics about what happens when
the last file descriptor is closed --- tape drives, for example.)

- Ted