Cygwin api to punch a hole into a file?

Thomas Wolff towo@towo.net
Tue Dec 5 06:36:31 GMT 2023



Am 01.12.2023 um 12:02 schrieb Corinna Vinschen via Cygwin:
> On Dec  1 11:22, Cedric Blancher via Cygwin wrote:
>> Not all filesystems have a 128k block/stripe size, and certainly most
>> filesystems have smaller minimum hole sizes than 128k (e.g. 512bytes
>> is common, ref pathconf _PC_MIN_HOLE_SIZE).
> There's no _PC_MIN_HOLE_SIZE in Linux or POSIX.  In Windows, a sparse
> file uses chunks of 64K.  You can see this even with a file of just
> a single block.  Try this:
>
>    $ touch x
>    $ chattr +S x
>
>    $ echo 1234567890123456789012345678901234567890123456789012345678901234567890123456789 >> x
>    $ ls -ls x
>    1 -rw-r--r-- 1 corinna vinschen 80 Dec  1 11:56 x
>
>    [repeat echo and ls -ls until...]
>
>    $ echo 1234567890123456789012345678901234567890123456789012345678901234567890123456789 >> x
>    $ ls -ls x
>    1 -rw-r--r-- 1 corinna vinschen 720 Dec  1 11:56 x
>    $ echo 1234567890123456789012345678901234567890123456789012345678901234567890123456789 >> x
>    $ ls -ls x
>    64 -rw-r--r-- 1 corinna vinschen 800 Dec  1 11:56 x2
>    ^^
>    This
For me, it goes up from 1 to 4, then in steps of 4KB.

> I don't know how Windows stores short files, maybe they are part of the
> metadata up to a point or some such.  However, as soon as you raise the
> size over a given point, the *allocation size* will be rounded up to 64K
> and from that point on, it will be in 64K chunks.  Also sparsifying and
> desparsifying of blocks only works in 64K chunks.
>
>
> Corinna
>


More information about the Cygwin mailing list