From e82670759e7eea3fb9faec99fcd94ad9f2fe03b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 15 Nov 2021 23:15:07 +0000 Subject: [PATCH] copy: avoid SEEK_DATA on macOS * src/copy.c (infer_scantype): Don't probe for SEEK_DATA support on __APPLE__ systems, as SEEK_DATA was seen to return ENXIO inappropriately there. * init.cfg (seek_data_capable_): Return failure on Darwin systems. Addresses https://bugs.gnu.org/51857 --- init.cfg | 6 ++++++ src/copy.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/init.cfg b/init.cfg index b92f717f5..2ab607cf3 100644 --- a/init.cfg +++ b/init.cfg @@ -533,6 +533,12 @@ require_kill_group_() # which SEEK_DATA support exists. seek_data_capable_() { + # The SEEK_DATA implementation on macOS is not supported + if test "$(uname)" = Darwin; then + warn_ 'seek_data_capable_: Darwin detected: assuming not SEEK_DATA capable' + return 1 + fi + { python3 < /dev/null && PYTHON_=python3; } || { python < /dev/null && PYTHON_=python; } diff --git a/src/copy.c b/src/copy.c index f88bf3ed3..ecb37a02c 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1100,7 +1100,7 @@ infer_scantype (int fd, struct stat const *sb, && ST_NBLOCKS (*sb) < sb->st_size / ST_NBLOCKSIZE)) return PLAIN_SCANTYPE; -#ifdef SEEK_HOLE +#if defined SEEK_HOLE && !defined __APPLE__ scan_inference->ext_start = lseek (fd, 0, SEEK_DATA); if (0 <= scan_inference->ext_start || errno == ENXIO) return LSEEK_SCANTYPE; -- 2.26.2