Re: thread_t, uthread_t, at al.?
Re: thread_t, uthread_t, at al.?
- Subject: Re: thread_t, uthread_t, at al.?
- From: Rick Mann <email@hidden>
- Date: Fri, 27 Oct 2006 11:05:55 -0700
On Oct 27, 2006, at 10:52 , Michael Smith wrote:
That's doing it the hard way, as there is a one-to-many
relationship between vnodes and file descriptors and as I recall no
straightforward way to go from the former to the latter.
Hmm. I guess you're telling me that a process would own a file
descriptor, but but not a vnode. Crap, this throws a wrench in my works.
Really, you want to take this on from the consumer side, not the
provider side. Walk the descriptor table for each process to
enumerate files that are held open with a descriptor. Then walk
the memory map for each process, tracking down the mapped VM
objects and following them back to their respective pagers to work
out whether they are backed by a file that is not otherwise open.
I believe this is what lsof does, and it's very slow.
This gets you all the files currently "open" by a process. There
are other things that will hold vnodes referenced (pagers, disk
images, etc.) that you may want to detect as well.
Yes, I've learned this. In these cases, there can still be a vnode,
but no file descriptor.
So far though, I can't think of anything that involves tracking the
process to which a thread belongs in what I've outlined above. You
aren't making an assumption about v_owner, are you?
Looking at the sources, v_owner is either null or it's current_thread
(), but I guess that can change as a file is accessed, so that won't
be reliable at all.
Coming from over a decade of Mac OS development, I'm less and less
impressed with the overall design of Unix/Darwin APIs and code. This
is very frustrating.
Thanks for the info!
--
Rick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >thread_t, uthread_t, at al.? (From: Rick Mann <email@hidden>) |
| >Re: thread_t, uthread_t, at al.? (From: Michael Smith <email@hidden>) |
| >Re: thread_t, uthread_t, at al.? (From: plumber Idraulico <email@hidden>) |
| >Re: Re: thread_t, uthread_t, at al.? (From: "Shawn Erickson" <email@hidden>) |
| >Re: thread_t, uthread_t, at al.? (From: Rick Mann <email@hidden>) |
| >Re: thread_t, uthread_t, at al.? (From: Michael Smith <email@hidden>) |