What is an anonymous inode in Linux?

mrkschan picture mrkschan · Dec 22, 2010 · Viewed 15.8k times · Source

I made a google search about "anonymous inode" and it seems it's related to epoll ... but what actually is it?

Answer

user335938 picture user335938 · Dec 22, 2010

At least in some contexts, an anonymous inode is an inode without an attached directory entry. The easiest way to create such an inode is as such:

int fd = open( "/tmp/file", O_CREAT | O_RDWR, 0666 );
unlink( "/tmp/file" );
// Note that the descriptor fd now points to an inode that has no filesystem entry; you
// can still write to it, fstat() it, etc. but you can't find it in the filesystem.