19

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 ?

3
  • Some info here. Commented Aug 19, 2018 at 23:45
  • Some related anonymous inode concepts that might be of interest can be found at: stackoverflow.com/questions/4508998/… e.g. O_TMPFILE and epoll. Commented Oct 18, 2019 at 17:35
  • Thanks, will check Commented Oct 18, 2019 at 17:37

2 Answers 2

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.

4
  • 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 ? Commented Aug 20, 2018 at 7: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 - en.wikipedia.org/wiki/Epoll Commented Aug 20, 2018 at 7:15
  • OK that's what I wanted to know. Commented Aug 20, 2018 at 7:17
  • @SergiyKolodyazhnyy - the src for anon_inodes might be helpful too - github.com/torvalds/linux/blob/master/fs/anon_inodes.c. Commented Aug 20, 2018 at 7:17
1

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.