Re: How to tell whether a struct file is held by a process?

From: Al Viro
Date: Thu May 21 2009 - 05:52:28 EST


On Tue, May 19, 2009 at 12:57:21PM -0400, Alan Stern wrote:
> What's the best way to tell whether the current process has a
> particular struct file among its open files? Is there any better way
> to find out than blindly calling fget() for each possible fd?
>
> Is this a totally insane thing to do?

It is insane. You might lock fdtable and scan it, but as soon as you
drop the spinlock your return value is worthless.

What are you trying to do? If the process is cooperating, you don't really
need that in the kernel, if it's not, the check is not usable...
--
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/