File size
A regular file's logical size is its length in bytes, including holes, rather than the space allocated to store it.
On Linux, st_size reports regular-file length in bytes. st_blocks counts allocated 512-byte units, while st_blksize is a preferred I/O size, not the multiplier for that count. Neither field directly measures a lower thin pool's consumption. These regular-file meanings must not be applied to pipe buffers or device capacity. [1] [5]
The file offset is a position, not a length. lseek can move it beyond EOF without growing the file; writing there can extend the file and leave a zero-reading gap. FALLOC_FL_KEEP_SIZE can instead allocate beyond EOF without increasing st_size. Allocation, length and cursor position can therefore change independently. [2] [3]
A status call does not freeze file contents. Linux permits different returned fields to reflect different moments during concurrent changes. An observed length is not a promise that a later read will see the same file state. [4]
Relations
- related
- End of file, File offset, Regular file, Sparse file, File truncation
Limitations
- Logical length does not establish physical allocation, content identity or durability.
Citations
- Linux man-pages: inode(7), size and allocation fields
- Linux man-pages: lseek(2), cursor movement and file growth
- Linux man-pages: fallocate(2), KEEP_SIZE allocation
- Linux man-pages: stat(2), concurrent metadata observations
- Hesela: File length, EOF and zero bytes
Sources & caveats
- Primary-documentation synthesis for regular-file accounting, not a new allocation or crash experiment.