Going from an inode to a file

We have discussed the fifteen entries in the block array and how they are used to specify data blocks which house a file. We have also seen that these sixty bytes may be repurposed for certain cases. If the inode stores a symbolic link and the target is less than sixty bytes long it will be stored in the block array. If the in-line data flag is set, the first sixty bytes of a file are in this space. We have also mentioned that extents use this space differently.

When parsing an inode for the list of blocks contained in a file (or directory) in the most generic situation (i.e. no extents), we read the first twelve entries in the block array and add any non-zero values to our list of blocks. If the thirteenth entry is non-zero, we read in the block with the address stored there which contains a list of up to 1024 blocks. Any non-zero entries from the data block are added to our list. This allows files as large as 4 megabytes + 48 kilobytes to be handled.

If there is an entry in the fourteenth block array item, we load the specified data block which contains a list of data blocks which in turn contain lists of data blocks. There are up to 1024 * 1024 entries in this doubly indirect level all of which point to 4 kilobyte blocks which allow files as large as 4 gigabytes + 4 megabytes + 48 kilobytes to be handled. If this is still not enough, the last entry is for a triply indirect block which permits files as large as 4 terabytes + 4 gigabytes + 4 megabytes + 48 kilobytes, at least in theory. If you have an ext4 filesystem, it is much more likely to use extents which are discussed in the next section.

results matching ""

    No results matching ""