Search code examples
linuxepollinode

What is an anonymous inode in Linux?


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


Solution

  • 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.