How do I find the inode of a TCP socket?

寵の児 提交于 2019-12-01 06:32:57

The inode shown by ls and stat is for the symlink that points to the inode associated with the socket. Running ls -iLalh shows the right inode. Ditto for stat -L.

Herpa derp derp. I only figured this out when I was composing my question. ;_;

Inode id represent a file id per fs mount (proc, sys, ntfs, ext...), so as you probably understand you deal with two different fs here: procfs and some pseudo socket fs.

The files under the /proc/pid/fd/ directories are soft links which have inode representation in the procfs fs. These links are "pointing" to different "fs" - socket fs.

What stat -L and ls -iLalh do, is to give you the inode of the file the links points to. You can do this also explicitly with readlink /proc/#pid/fd/#fdnum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!