summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-17 23:34:35 +0000
committerbors <bors@rust-lang.org>2021-04-17 23:34:35 +0000
commit6570c66a411be9067139c4693e3a9b8e70e9ff44 (patch)
tree94f8baf779cb46b1a38202334be665be038fd849
parentdafd08dadaad089ecd6c93b31daf230fd4dc5435 (diff)
parentc8539f5bc6061c41a56d13451297fb9d5a258c59 (diff)
downloadrust-libc-6570c66a411be9067139c4693e3a9b8e70e9ff44.tar.gz
Auto merge of #2147 - nthery:clonefile, r=JohnTitor
Add macos clonefile functions
-rwxr-xr-xlibc-test/build.rs2
-rw-r--r--libc-test/semver/apple.txt3
-rw-r--r--src/unix/bsd/apple/mod.rs18
3 files changed, 23 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index a39c1ce903..446f1559a5 100755
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -217,6 +217,8 @@ fn test_apple(target: &str) {
"stdio.h",
"stdlib.h",
"string.h",
+ "sys/attr.h",
+ "sys/clonefile.h",
"sys/event.h",
"sys/file.h",
"sys/ioctl.h",
diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt
index 6fe47de1f6..d860f57d73 100644
--- a/libc-test/semver/apple.txt
+++ b/libc-test/semver/apple.txt
@@ -1514,6 +1514,8 @@ chflags
chroot
clearerr
clock_getres
+clonefile
+clonefileat
cmsghdr
connectx
cpu_subtype_t
@@ -1531,6 +1533,7 @@ exchangedata
faccessat
fchdir
fchflags
+fclonefileat
fdopendir
fgetxattr
flistxattr
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 6d77692480..a5703ef5d6 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -3835,6 +3835,24 @@ extern "C" {
outbytesleft: *mut ::size_t,
) -> ::size_t;
pub fn iconv_close(cd: iconv_t) -> ::c_int;
+
+ // Copy-on-write functions.
+ // According to the man page `flags` is an `int` but in the header
+ // this is a `uint32_t`.
+ pub fn clonefile(src: *const ::c_char, dst: *const ::c_char, flags: u32) -> ::c_int;
+ pub fn clonefileat(
+ src_dirfd: ::c_int,
+ src: *const ::c_char,
+ dst_dirfd: ::c_int,
+ dst: *const ::c_char,
+ flags: u32,
+ ) -> ::c_int;
+ pub fn fclonefileat(
+ srcfd: ::c_int,
+ dst_dirfd: ::c_int,
+ dst: *const ::c_char,
+ flags: u32,
+ ) -> ::c_int;
}
cfg_if! {