Android's host tools currently build with glibc from 2012, but even if
we were more up to date (or had already switched to musl for host tools,
which hopefully will be the case by this time next year), it was added
to glibc recently enough to miss the "seven year window".
---
 lib/portability.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
From a0d74d71db5293ca3a03f0ca5fc2d4f2d23f57eb Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 11 Apr 2022 15:18:15 -0700
Subject: [PATCH] lib/portability.c: don't assume we have __NR_copy_file_range.

Android's host tools currently build with glibc from 2012, but even if
we were more up to date (or had already switched to musl for host tools,
which hopefully will be the case by this time next year), it was added
to glibc recently enough to miss the "seven year window".
---
 lib/portability.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/portability.c b/lib/portability.c
index 174933c3..89744dd0 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -623,10 +623,11 @@ int get_block_device_size(int fd, unsigned long long* size)
 }
 #endif
 
-ssize_t copy_file_range_wrap(int infd, off_t *inoff, int outfd,
+static ssize_t copy_file_range_wrap(int infd, off_t *inoff, int outfd,
     off_t *outoff, size_t len, unsigned flags)
 {
-#if defined(__linux__)
+  // glibc added this constant in git at the end of 2017, shipped in 2018-02.
+#if defined(__NR_copy_file_range)
   return syscall(__NR_copy_file_range, infd, inoff, outfd, outoff, len, flags);
 #else
   errno = EINVAL;
-- 
2.35.1.1178.g4f1659d476-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to