I'm writing a program, which write some contents in a sparse file. Say, I create the file by
fd = open(filepath, O_RDWR | O_CREAT | O_EXCL, 0644);
assert(fd != -1);
int s = ftruncate(fd, len);
len
is very large, but the actual content may only takes several kbs.
Then I do memory mapped IO on this file. How do I ensure contents are deleted from this file, so that temporary stuff is not stored, and the actual storage is still "sparse"?
Thanks for any suggestions.