On Jan 21, 2009, at 1:21 AM, Narayan Subramanian wrote:
My question here is: Do we not call close() on the executable files descriptor after we mmap() them into the process address space (inside dyld)? I am assuming that the vnode corresponding to the file descriptor should get freed after the file descriptor gets closed (right?).
No.
(I mean isn't that the only way we can move around an (on disk) executable file that being run by another process?).
What do you mean by "move around"?
If that is true, how is it that we are still able to trace the vnode that represents the file that was mmap()ed, after its descriptor was close()d?
The same way as before.
Who caches this vnode, how and where?
Who do you think? 8)
If this vnode is still 'alive' how is one able to physically move the executable file (mapped by the process) on disk?
Again, what do you mean by "move"?
If you would like to point me to some code in the kernel for some explanation, that is welcome. I have the sources for 10.4.11 with me.
Start with everything in xnu/bsd/vfs, xnu/bsd/kern and osfmk/vm.
A couple of concepts worth considering:
- What do you mean by "move"?
- Why do you think that an open file handle is fundamentally different from an address space map entry when it comes to referring to an open file?
- Why do you (seem to) think that a file can only exist if it has a reference in the filesystem namespace?
= Mike