瀏覽代碼

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".
Elliott Hughes 2 年之前
父節點
當前提交
50361a1b07
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      lib/portability.c

+ 3 - 2
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;