/* This program generates a file "bighole.file" that has a big hole. Almost no disk space is used up by this file yet it will appear to be a big file in an ls listing. This is similar to how core files appear to be huge when they actually are not. Various files generated by "database" style programs can also be of this form. In Solaris 2.6 an "ls -l" shows: 1 Megabyte | 32 -rw------- 1 user user 1000001 Nov 7 21:31 bighole.file | yet there are only 32 blocks in the file. If you copy the file in Solaris then the hole "expands" and 1 MB is actually used on disk for the copied file. Either file still counts as 1 Megabyte toward your quota, however, so watch out!! On other systems the number of blocks may vary and some utilities such as cp may not actually "fill" in the holes. */ /* sloppy programming here - no header files or error checking */ int main() { int fd; fd = creat("bighole.file", 0644); lseek(fd, 1000000, 0); /* seek 1000000 from the beginning */ write(fd, "z", 1); /* write buffer of size 1 */ close(fd); return 0; }