fd passing through sendmsg/recvmsg

Sitaram Iyer (ssiyer@cs.rice.edu)
Sat, 2 Jan 1999 19:01:27 -0600


When passing file descriptors, I notice sendmsg copies (kmalloc) the
necessary file structures and passes them over (in scm.c), and recvmsg
installs it into the current process' file table. Then

1. how do they share the file offset (f_pos in the file struct, I think) if
the file structures are separate?

2. if I'm wrong, and they're actually pointing to the same file structures,
then (a) where in the holy kernel is it doing that, and (b) how does it
handle the freeing on exit() - I observe __exit_files does a close_files()
and blindly trashes all the pages allocated to the file structures so I
guess it *assumes* all fd's get closed by close_files().. am I wrong?

3. if it _does_ get copied, don't the dentry and the inode get copied too?

I know all of that somehow magically works fine (I checked), and that a few
printk's would reveal the answers, but I've been trying to get at this all
afternoon and thought I'll get more insights out of replies to a posting..

one more thing - if the file structures get copied around, how in the world
does it work for processes passing fd's to themselves or forming a cycle?

thanks in advance

-- 
Sitaram Iyer <ssiyer@cs.rice.edu> http://www.cs.rice.edu/~ssiyer/
Phone: Office: (713) 527-8750 x3291 (direct dial), Res: (713) 630-9260
New graduate student in the Computer Science dept at Rice University

- 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/