Inode,block the directory tree Relationship directory
When we create a new directory in the file system under Linux, EXT4 allocates an inode with at least one block to the directory. Where the Inode records the permissions and attributes of the directory and logs the block number assigned to it, and block is the inode number data that is used to record the file or directory name in this directory with the file or directory. Ls-i can view inode numbers for each file or directory under the directory. If there are too many files or directories under the directory, a block record will take up more than one block.
File
When we create a new generic file under Linux, the system assigns an inode to the file with the number of blocks relative to the file size. However, because the inode size is limited, when the file is particularly large, the system will create an indirect block, the so-called indirect block is the inode to record a block number, but the block does not record the actual contents of the file, but the number of other blocks recorded, and then by the block records the contents of the file, This indirect block can continue multiple layers, forming a tree structure that allows the inode to correlate the file content exponentially, which is key to the Inode's ability to act as the sole entry point for the file.
Directory tree Reads
Therefore, the file inode itself does not record the file name, the file name is recorded in the directory block, so we add, delete, rename the file requires the directory's W permission. Because the directory tree is read from the root directory, so the system through the information can be mounted to find the inode number of the mount point, you can get the inode content of the root directory, and according to the inode to read the root directory of the file name data within the block, and then read down to the correct file layer.
Linux Learning note 10-file, directory, and disk format three