Go to the first, previous, next, last section, table of contents.
For a given file, data is stored in blocks. The inode holds (directly and possibly indirectly) a list of every block in the file. When you want to retrieve a byte, the filesystem code determines in which block it is stored, gets the block, and reads the byte from it. For instance, if we assume that the block size is 1KB, a file whose length is 3897 bytes holds 4 blocks, the first three holding 1024 bytes, and the last one holding 199 bytes (plus 825 trailing null bytes that aren't usually shown to the user). The file looks like this:
block# bytes ------ ----- [0] 0 to 1023 [1] 1024 to 2047 [2] 2048 to 3071 [3] 3072 to 3896
A file can contain holes, i.e., some missing blocks. In this case the apparent size of the file is much bigger than the product of the number of blocks it really holds and the block size. A file with holes may look like this:
block# ------ [0] data [1] missing block [2] data [3] missing block [4] missing block [5] data [6] data [7] data
A missing block is considered as a block filled with zeros, but does not waste space on the disk. In the above example, the size of the file is 8096 bytes, while the real space used on the disk is only 5120 bytes.
Go to the first, previous, next, last section, table of contents.