How to create a file with file holes?

后端 未结 4 1814
故里飘歌
故里飘歌 2020-12-02 14:58

File holes are the empty spaces in file, which, however, doesn\'t take up any disk space and contains null bytes. Therefore, the file size is larger than its actual size on

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 15:15

    1. Create a file.
    2. Seek to position N.
    3. Write some data.

    There will be a hole at the start of the file (up to, and excluding, position N). You can similarly create files with holes in the middle.

    The following document has some sample C code (search for "Sparse files"): http://www.win.tue.nl/~aeb/linux/lk/lk-6.html

提交回复
热议问题