I have a process tree which talks using (unix) socket pairs. Now I wrote a
perl script which read /proc/*/fd/* and displays the communications channels.
I have one problem left: the association of socket pairs.
Sometimes it happens that the pair has an even and an odd inode (say, 50
and 51), but sometimes they are more than 1 from each other.
Looking in the sources I think I found out why. The sys_socketpair call calls
->create() two times; the create-call uses kalloc, which can block.
So if there are some processes trying to get pairs it can happen that the
->create calls are interleaving.
The unix sockets are paired by unix_peer(), which is a #define to ->pair.
But as this is a pointer to another skb it doesn't make much sense to
export that as-is to userspace.
In /proc/net/unix there is a "num"-field exported, which is just a pointer
to the "struct sock"-structure (?).
Maybe this num-field could be substituted (if adding another field then
this should be done before path, as for socketpairs the path is empty and
adding behind that would make parsing more difficult) by some ->pair->
I'd suggest the ->i_ino value, as this is already visible in user space,
but I'm lost how to get the dentry from the ->pair pointer.
Finished patches :-) ???
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Tue May 07 2002 - 22:00:28 EST