| delorie.com/archives/browse.cgi | search |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 delorie.com 51ECoMsf1556457 |
| Authentication-Results: | delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com |
| Authentication-Results: | delorie.com; spf=pass smtp.mailfrom=cygwin.com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 delorie.com 51ECoMsf1556457 |
| Authentication-Results: | delorie.com; |
| dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=d2gkZuBK | |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 1D79E3858420 |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
| s=default; t=1739537420; | |
| bh=BPoTQgcQLYO6mysQl46mCzzl3+PBIWurjQxBOhtNwV0=; | |
| h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: | |
| List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: | |
| From; | |
| b=d2gkZuBKqyhLDaKumax0c7bldup34RPktnIQZ9nrESofQMeJ8FdvsJxkD4rpLJSXy | |
| uESekJuAv+nj/utxWwvHORrBFkJQiu24opoJR9oQX6l2WmCA3jpIASX18cFm8Baa3Q | |
| NQ+Q5xLRxliSjbjjKVIzXGn9Get8lmWaQ3+Qij3E= | |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org F314C3858C53 |
| Date: | Fri, 14 Feb 2025 13:49:52 +0100 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: SEEK_DATA should fail at EOF (was: coreutils-9.6-1 (TEST): cp: |
| infinite SEEK_SET/DATA/HOLE loop if file is compressed) | |
| Message-ID: | <Z6878Laugk31H2oO@calimero.vinschen.de> |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <614771e9-592c-6154-d56d-13842b6fc6ac AT t-online DOT de> |
| <5ccdf4be-4e4b-1846-9fd6-cba29c9dbb11 AT t-online DOT de> | |
| MIME-Version: | 1.0 |
| In-Reply-To: | <5ccdf4be-4e4b-1846-9fd6-cba29c9dbb11@t-online.de> |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.30 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe> | |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| From: | Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com> |
| Reply-To: | cygwin AT cygwin DOT com |
| Cc: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| Errors-To: | cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com |
| Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
| X-MIME-Autoconverted: | from base64 to 8bit by delorie.com id 51ECoMsf1556457 |
On Feb 14 12:24, Christian Franke via Cygwin wrote:
> Christian Franke via Cygwin wrote:
> > Testcase:
> > [...]
> > Upstream bug?
>
> Possibly not. A closer look shows that the main loop in copy.c:lseek_copy()
> expects that SEEK_DATA fails with ENXIO at EOF.
>
> https://github.com/coreutils/coreutils/blob/v9.6/src/copy.c#L543
>
> Â lseek_copy(..., off_t ext_start, ...)
> Â {
> Â Â ...
> Â Â while (0 <= ext_start) {
> Â Â Â Â {
> Â Â Â Â Â ...
> Â Â Â Â Â ext_start = lseek (src_fd, dest_pos, SEEK_DATA);
> Â Â Â Â Â if (ext_start < 0 && errno != ENXIO)
> Â Â Â Â Â Â Â goto cannot_lseek;
> Â Â Â }
> Â Â ...
> }
>
> This works on Linux (checked on Debian 12) but Cygwin returns the offset if
> it is equal to the file size.
>
> Recent POSIX says:
> "[ENXIO] The whence argument is SEEK_HOLE or SEEK_DATA, and offset is
> greater than or equal to the file size"
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/lseek.html
>
> But (at least older) Linux man pages suggest that Cygwin behavior may be
> correct also:
> "In the simplest implementation, a filesystem can support the operations by
> making ... SEEK_DATA always return offset."
> "ENXIO - whence is SEEK_DATA or SEEK_HOLE, and offset is beyond the end of
> the file"
> https://man7.org/linux/man-pages/man2/lseek.2.html
In terms of "older", this text is still part of
https://man7.org/linux/man-pages/man2/lseek.2.html.
But we do return ENXIO. However...
> Hmm... does "beyond" mean '>=' or '>' ?
...do you think this fixes it?
diff --git a/winsup/cygwin/fhandler/base.cc b/winsup/cygwin/fhandler/base.cc
index 8f3dbd4ed51a..79dfaaa5987a 100644
--- a/winsup/cygwin/fhandler/base.cc
+++ b/winsup/cygwin/fhandler/base.cc
@@ -1144,7 +1144,7 @@ fhandler_base::lseek (off_t offset, int whence)
return -1;
}
/* Per Linux man page, ENXIO if offset is beyond EOF */
- if (offset > fsi.EndOfFile.QuadPart)
+ if (offset >= fsi.EndOfFile.QuadPart)
{
set_errno (ENXIO);
return -1;
Corinna
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |