Re: closefd: closes a file of any process

Manfred Spraul (manfred@colorfullife.com)
Tue, 27 Jun 2000 18:25:41 +0200


Tigran Aivazian wrote:
>
>
> Amazing that nobody noticed this before. Ok, next problem - how do you
> synchronize this non-current do_close() with the possibility of the
> process being between
>
> file = fget(fd);
> ...
> fput(file);

Where is the problem?

* fget atomically reads the pointer with the descriptor "fd" and
increases the reference count within "file".

* fput decreases that reference count, and if the count is 0, then it
closes the file.

* frip atomically replaces "fd" with NULL. close() then decreases the
ref count, and only if the ref count becomes 0, then file is really
closed.

--
	Manfred

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/