Files with Holes
- This does not apply to all file systems.
- If you seek past the end (more than just at the end)
- And then write
- You will create a file with a "hole"
- The resulting file will potentially not be as large as the file with the hole filled in.
- Reading in a hole produces 0.
- An example of a program that creates a file hole.
- Linux has two additional whence options
- SEEK_DATA : adjust the file pointer to the next location greater or equal to offset where there is data. It can be offset
- SEEK_HOLE: Adjust the file pointer to the next location greater than or equal to offset where there is a file hole. It can be offset if offset points to a hole. It will be the end of the file if there are no holes at offset or beyond.
- Big warnings in the man page that this is not supported on all file systems.
- Just for fun, I program append to a log. mylogger.C