Re: 2.4 Q: list of open files per inode?

From: Al Viro
Date: Sun Jul 22 2007 - 10:35:45 EST


On Sun, Jul 22, 2007 at 05:23:22PM +0300, Jacob Avraham wrote:
> > {
> > struct mystuff *pd = filp->private_data;
> > list_del(&pd->list);
> > free(pd);
> > }
> >
> > Simple as that. *Of course* this requires that the file descriptor remains
> > open. But that should not be a problem, would it?

First of all, that's obviously racy (list manipulations without any
exclusion *or* preventing aforementioned timer running while you do
it).

More important part is that stuff put into your private_data would
better remain valid through the lifetime of opened file. In particular,
you _can't_ expect that process that had opened the file in question
is still alive.

> I ended up implementing my own list (similar to the above), so now the question is more theoretical.
> BTW, does 2.6 has an easy way to get from an inode to all the open fds?

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