From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 0AAEA3858D20; Thu, 10 Aug 2023 08:28:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AAEA3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1691656099; bh=wb/MQTZor1oRCIpx75FHzq8i9wCzBV3DC7FN6nz6F4U=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=fWY8lZUhfIAtAwczkh3HI15vRcUqGf9UjdGJkc/yJ5cztH3WNroB92APVGie6roXj hyg1h/Y+mspxL9PLG8Owci8ERwO1FVDoAEKNryRhr5waw9FZzOmEEM15/GemdeX0v0 R7lLdE0qUU+fM2O8ubw7AE2oYkAHbNDP+tTO83uU= Received: by calimero.vinschen.de (Postfix, from userid 500) id 5A150A80D33; Thu, 10 Aug 2023 10:28:15 +0200 (CEST) Date: Thu, 10 Aug 2023 10:28:15 +0200 From: Corinna Vinschen To: Cedric Blancher Cc: cygwin-developers@cygwin.com Subject: Re: SEEK_HOLE Support in Cygwin? Message-ID: Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: Cedric Blancher , cygwin-developers@cygwin.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: List-Id: On Aug 10 04:43, Cedric Blancher wrote: > On Wed, 9 Aug 2023 at 17:30, Corinna Vinschen wrote: > > > > On Aug 7 10:33, Corinna Vinschen wrote: > > > Wrong mailing list, use cygwin AT cygwin DOT com for user questions. > > > > > > On Aug 6 19:14, Cedric Blancher wrote: > > > > Good evening! > > > > > > > > Are there plans for a SEEK_HOLE support to Cygwin, e.g. on top of the > > > > FSCTL_QUERY_ALLOCATED_RANGES api (if appropriate)? > > > > > > No plans, but patches are welcome. This looks like a fun task for a > > > rainy weekend. > > > > Today was a really rainy day and I had to wait for a test system to > > come up, so I hacked on SEEK_DATA/SEEK_HOLE support. > > > > Check out the next Cygwin test release 3.5.0-0.384.g9939aa7d0945. > > Thank you! > Or should I thank the weather gods? ;) > > How can I download this version? Cygwin setup, as usual. Just install the above version of the packages cygwin and cygwin-devel. > > Note that this defaults to the default behaviour described in the > > Linux man page, see https://man7.org/linux/man-pages/man2/lseek.2.html > > > > I.e., "In the simplest implementation, a filesystem can support the > > operations by making SEEK_HOLE always return the offset of the end of > > the file, and making SEEK_DATA always return offset" > > So this supports multiple holes in one file, right? Curious question. Cygwin supports sparse files for ages. Only the lseek options SEEK_HOLE and SEEK_DATA are new. But, yes, it supports what Windows supports. But note that Cygwin *only* switches files to sparse, if you seek by more than 128K beyond current EOF and then wrote something, or if you call truncate/ftruncate, raising the filesize by more than 128K. In contrast to Linux, one has to sparsify a file explicitely on WIndows, and that's Cygwin's strategy. > > The real deal obviously requires a filesystem supporting sparse files, > > *and* it requires that you access the file via a mount point with the > > "sparse" option set! The mount option "sparse" is not set by default. > > Why is "sparse" not the default mount option? It was, at one point long ago. People complained that sparse file access is slower than standard file access, so the "sparse" mount option was added. Corinna