Support for transferring sparse files via scp/sftp correctly?

Darren Tucker dtucker at dtucker.net
Sat Apr 5 21:08:04 AEDT 2025


On Sat, 5 Apr 2025 at 09:07, Lionel Cons <lionelcons1972 at gmail.com> wrote:

> On Fri, 4 Apr 2025 at 07:07, Ron Frederick <ronf at timeheart.net> wrote:
> >
> > On Apr 3, 2025, at 6:02 PM, Darren Tucker <dtucker at dtucker.net> wrote:
> [...]
> > > Damien pointed out that it's possible to do a reasonable but not
> perfect sparse file support by memcmp'ing your existing file buffer with a
> block of zeros and skipping the write if it matches.  OpenBSD's cp(1) does
> this (look for "skipholes"):
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/bin/cp/utils.c?annotate=HEAD
> .
>
> This should not be done. Either a system has SEEK_DATA/SEEK_HOLE,
> Win32 (Windows&ReactOS) FSCTL_QUERY_ALLOCATED_RANGES, or just copy all
> bytes.


If there's a protocol extension I'd like for it to be able to support other
use cases, not just the one you care about.

-- 
Darren Tucker (dtucker at dtucker.net)
GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860  37F4 9357 ECEF 11EA A6FA
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.


More information about the openssh-unix-dev mailing list