Cygwin copy_file_range() support with sparse file+FSCTL_DUPLICATE_EXTENTS_TO_FILE?

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Sun Jan 5 16:31:24 GMT 2025


On 2025-01-05 06:52, Takeshi Nishimura via Cygwin wrote:
> On Sun, Jan 5, 2025 at 1:06 PM Václav Haisman via Cygwin wrote:
>> On 05. 01. 25 7:31, Cedric Blancher via Cygwin wrote:
>>> Could Cygwin implement copy_file_range() support, including sparse
>>> file support so holes are preserved, and
>>> FSCTL_DUPLICATE_EXTENTS_TO_FILE support?
>>
>> In theory, this could be used to implement that function. In practice,
>> the block cloning is only supported by ReFS. See
>> <https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_duplicate_extents_to_file>
> 
> All Windows Server (2019, 2022) installations we have. and those which
> I know about, use ReFS (except in cases where Alternate Streams are
> required).
> AFAIK SMB3 also support FSCTL_DUPLICATE_EXTENTS_TO_FILE, so this would
> be a HUGE win for Cygwin

Cygwin has supported sparse files since 2000, mount option to enable it for over 
a decade, inode sparse ioctl flag for half that, and automatic support on SSDs 
just over a year ago:

https://cygwin.com/git/?p=newlib-cygwin.git&a=search&st=commit&s=sparse&h=363357

https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=05297c

https://cygwin.com/git/?p=newlib-cygwin.git;a=blob_plain;f=winsup/cygwin/include/cygwin/fs.h

It works on NTFS, include remote mounts, but I don't know about other filesystems?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin mailing list