Add copy_file_range(2) syscall stub to bionic.
Test: treehugger
Bug: https://buganizer.corp.google.com/issues/227784687
Change-Id: I543306cd2234189401bf7c9d80d405eeb6e4d41d
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 293b45a..49fec12 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -1668,3 +1668,19 @@
}
#endif // __GLIBC__
}
+
+TEST(UNISTD_TEST, copy_file_range) {
+#if defined(__GLIBC__)
+ GTEST_SKIP() << "glibc too old";
+#else // __GLIBC__
+ TemporaryFile tf;
+ ASSERT_TRUE(android::base::WriteStringToFd("hello world", tf.fd));
+ ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
+ TemporaryFile tf2;
+ ASSERT_EQ(11, copy_file_range(tf.fd, NULL, tf2.fd, NULL, 11, 0));
+ ASSERT_EQ(0, lseek(tf2.fd, SEEK_SET, 0));
+ std::string content;
+ ASSERT_TRUE(android::base::ReadFdToString(tf2.fd, &content));
+ ASSERT_EQ("hello world", content);
+#endif // __GLIBC__
+}
\ No newline at end of file