St_size member in file stat struct
For all file types, st_size members have a real meaning to ordinary files, directories, and symbolic links. For ordinary files, St_size records the actual size of the file, and for a directory, the value of St_size is 16 or a multiple of 512, and for symbolic links, the value of st_size is the length of the path that the symbolic link refers to. For example, Lib->usr/lib, the value of St_size is 7.
In some UNIX systems, the value of st_size is also meaningful for files such as pipes, indicating the number of bytes that can be read in the current pipe.
Causes of holes production
When we use the Lseek function to start writing bytes at a location beyond the end of the file's original file, the space that is not written between them is not fully allocated to the file system in order to conserve disk space. This time, it will cause the size of the file, and the amount of disk space occupied by the file is inconsistent. We can see the size of the file using the Ls-l command. When using Du-s to view the disk footprint of a file, there is an inconsistency between them, and interested readers can experiment on their own under Linux.
If we use the Read function for reading in a location in hole, the function returns 0.
One thing to note is that when we use cat instructions to copy files with hole, the hole are populated with 0, which matches the disk footprint of the file to its actual size.
Description of St_size in file structure stat in Linux operating system and understanding of holes (Holes) in Files