Inode (source code)

= Inode
{wiki}

An <inode> is a <data structure> describing an object in an <inode>-based <file system>. For an ordinary <file>, it records <file metadata> such as type, owner, access permissions, size and <hard link> count, together with information locating the contents. In the direct-reference toy layout, <inode> 42 points to <file data blocks> 7 and 9; its two names `a` and `b` live in <directory entries>. Other <file systems> can locate contents differently, so the diagram is a model of the separation rather than a universal storage layout. https://pages.cs.wisc.edu/~remzi/OSTEP/file-implementation.pdf[Arpaci-Dusseau and Arpaci-Dusseau, OSTEP chapter 40, sections 40.3–40.4: inodes and directory organization]{ref}

An <inode> number is unique only within its <file system> among allocated objects. Two different <file systems> can each have <inode> 42, referring to unrelated <files>. <POSIX> exposes the <file system>'s device identity as `st_dev` and the <file>'s serial number as `st_ino`; the pair identifies a <file> within a running system. Neither the bare <inode> number nor that pair is a permanent historical identifier: after reclamation, a later <file> can reuse the number. In particular, comparing an old saved number with a new one does not establish continuity of the <file>. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html[The Open Group, POSIX.1-2017, sys/stat.h: joint identity from st_dev and st_ino]{ref}

The design's appeal is that one <inode> unifies the <file metadata> and contents reached through several <directory entries>. Ritchie and Thompson's original 1974 account explicitly describes a <directory entry> as a name and an i-number, with the corresponding <inode> holding ownership, protection, size, content addresses and the <hard link> count. It gives a concrete early explanation of how names and <file> identity can evolve separately. https://www.cs.cmu.edu/~15712/papers/ritchie74.pdf[Ritchie and Thompson, The UNIX Time-Sharing System, 1974, section 4: implementation of the file system]{ref}

// Target: computer-science.bigb