aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2023-07-08 23:24:38 +0000
committerMartin Matuska <mm@FreeBSD.org>2023-07-08 23:25:23 +0000
commite64780fbc394b10581e50a850cc06c1c12a8e4f9 (patch)
tree6153ca5f55dfff7b0843ef6014b7a5b795cf5123 /usr.bin
parent055f920ebe21b8e05235363bc11a83cc649cdc6a (diff)
downloadsrc-e64780fbc394b10581e50a850cc06c1c12a8e4f9.tar.gz
src-e64780fbc394b10581e50a850cc06c1c12a8e4f9.zip
xinstall: do not use copy_file_range(2) when BOOTSTRAPPING
Reported by: arichardson
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xinstall/Makefile5
-rw-r--r--usr.bin/xinstall/xinstall.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile
index 9969ef104e98..3b49cb39d27a 100644
--- a/usr.bin/xinstall/Makefile
+++ b/usr.bin/xinstall/Makefile
@@ -17,6 +17,11 @@ CFLAGS+= -I${SRCTOP}/lib/libnetbsd
LIBADD= md
CFLAGS+= -DWITH_MD5 -DWITH_RIPEMD160
+.ifdef BOOTSTRAPPING
+# For the bootstrap we disable copy_file_range()
+CFLAGS+= -DBOOTSTRAP_XINSTALL
+.endif
+
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 8dace862ef1e..6c269bbb5d91 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1300,7 +1300,9 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
static size_t bufsize;
int nr, nw;
int serrno;
+#ifndef BOOTSTRAP_XINSTALL
ssize_t ret;
+#endif
char *p;
int done_copy;
DIGEST_CTX ctx;
@@ -1311,6 +1313,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
if (lseek(to_fd, (off_t)0, SEEK_SET) == (off_t)-1)
err(EX_OSERR, "lseek: %s", to_name);
+#ifndef BOOTSTRAP_XINSTALL
/* Try copy_file_range() if no digest is requested */
if (digesttype == DIGEST_NONE) {
ret = 1;
@@ -1331,6 +1334,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
/* Fall back */
}
+#endif
digest_init(&ctx);
done_copy = 0;