18

While looking through /proc/[PID]/fd/ folder of various processes, I found curious entry for dbus

lrwx------ 1 root root 64 Aug 20 05:46 4 -> anon_inode:[eventpoll]

Hence the question, what are anon_inodes ? Are these similar to anonymous pipes ?

Sergiy Kolodyazhnyy
  • 16,187
  • 11
  • 53
  • 104

2 Answers2

14

Everything under /proc is covered in the man proc. This section covers anon_inode.

For file descriptors for pipes and sockets, the entries will be symbolic links whose content is the file type with the inode. A readlink(2) call on this file returns a string in the format:

 type:[inode]

For example, socket:[2248868] will be a socket and its inode is 2248868. For sockets, that inode can be used to find more information in one of the files under /proc/net/.

For file descriptors that have no corresponding inode (e.g., file descriptors produced by epoll_create(2), eventfd(2), inotify_init(2), signalfd(2), and timerfd(2)), the entry will be a symbolic link with contents of the form

 anon_inode:<file-type>

In some cases, the file-type is surrounded by square brackets.

For example, an epoll file descriptor will have a symbolic link whose content is the string anon_inode:[eventpoll].

For more on epoll I discuss them here - What information can I find out about an eventpoll on a running thread?.

For additional information on anon_inode's - What is an anonymous inode in Linux?. Basically there is/was data on disk that no longer has a filesystem reference to access it. An anon_inode shows that there's a file descriptor which has no referencing inode.

slm
  • 363,520
  • 117
  • 767
  • 871
  • OK, so "...file descriptors that have no corresponding inode..." So if inode is a data structure related to filesystems, does that mean that `anon_inode` is basically a file that doesn't live on disk and is mapped in memory somewhere ? In my example it's `eventpoll` type, but I don't even know what that is and didn't even know `eventpoll` exists till today, so at the very basic level, what is `anon_inode` after all ? – Sergiy Kolodyazhnyy Aug 20 '18 at 07:10
  • @SergiyKolodyazhnyy - at basic level `anon_inode` could've been something that was a file but is no longer on the disk. `epoll` is for monitoring multiple file descriptors, similar to `poll` - https://en.wikipedia.org/wiki/Epoll – slm Aug 20 '18 at 07:15
  • OK that's what I wanted to know. – Sergiy Kolodyazhnyy Aug 20 '18 at 07:17
  • @SergiyKolodyazhnyy - the src for `anon_inodes` might be helpful too - https://github.com/torvalds/linux/blob/master/fs/anon_inodes.c. – slm Aug 20 '18 at 07:17
1

These come from the epoll syscalls for monitoring multiple other file descriptors. Nothing to do with anonymous pipes.

danblack
  • 443
  • 3
  • 9