summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-01-21 20:47:54 +0000
committerbors <bors@rust-lang.org>2022-01-21 20:47:54 +0000
commit7600416f1ca896b501d58b0f44f1869d566359d6 (patch)
tree8b2d6d16be1e00d987bfa3e1d32a46e6706503d9
parent72e41512de52649e70d470b159bbecb47d12c93d (diff)
parentbe392861b6c23321baf54ffd8f7c931ae6b9e157 (diff)
downloadrust-libc-7600416f1ca896b501d58b0f44f1869d566359d6.tar.gz
Auto merge of #2543 - asomers:fspacectl, r=Amanieu
Add fspacectl, new in FreeBSD 14
-rw-r--r--libc-test/build.rs11
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs16
2 files changed, 26 insertions, 1 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 77087ba72f..69231fc060 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2041,7 +2041,7 @@ fn test_freebsd(target: &str) {
// This was changed to 96(0x60) in FreeBSD 13:
// https://github.com/freebsd/freebsd/
// commit/06b00ceaa914a3907e4e27bad924f44612bae1d7
- "MINCORE_SUPER" if Some(13) == freebsd_ver => true,
+ "MINCORE_SUPER" if Some(13) <= freebsd_ver => true,
// Added in FreeBSD 12.0
"EINTEGRITY" if Some(11) == freebsd_ver => true,
@@ -2089,6 +2089,9 @@ fn test_freebsd(target: &str) {
// Added in in FreeBSD 13.0 (r367776 and r367287)
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,
+ // Added in FreeBSD 14
+ "SPACECTL_DEALLOC" if Some(14) > freebsd_ver => true,
+
"VM_TOTAL" if Some(11) == freebsd_ver => true,
// Added in FreeBSD 13.
@@ -2196,6 +2199,9 @@ fn test_freebsd(target: &str) {
// `ptrace_sc_ret` is not available in FreeBSD 11
"ptrace_sc_ret" if Some(11) == freebsd_ver => true,
+ // `spacectl_range` was introduced in FreeBSD 14
+ "spacectl_range" if Some(14) > freebsd_ver => true,
+
// obsolete version
"vmtotal" if Some(11) == freebsd_ver => true,
@@ -2224,6 +2230,9 @@ fn test_freebsd(target: &str) {
// `ssize_t` in FreeBSD11:
"aio_waitcomplete" if Some(10) == freebsd_ver => true,
+ // `fspacectl` was introduced in FreeBSD 14
+ "fspacectl" if Some(14) > freebsd_ver => true,
+
// The `uname` function in the `utsname.h` FreeBSD header is a C
// inline function (has no symbol) that calls the `__xuname` symbol.
// Therefore the function pointer comparison does not make sense for it.
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index f52cb322de..50ed5f6896 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -600,6 +600,11 @@ s! {
pub mode: u16,
}
+ pub struct spacectl_range {
+ pub r_offset: ::off_t,
+ pub r_len: ::off_t
+ }
+
pub struct rusage_ext {
pub rux_runtime: u64,
pub rux_uticks: u64,
@@ -2978,6 +2983,9 @@ pub const F_SEAL_SEAL: ::c_int = 1;
pub const F_SEAL_SHRINK: ::c_int = 2;
pub const F_SEAL_WRITE: ::c_int = 8;
+// for use with fspacectl
+pub const SPACECTL_DEALLOC: ::c_int = 1;
+
// For getrandom()
pub const GRND_NONBLOCK: ::c_uint = 0x1;
pub const GRND_RANDOM: ::c_uint = 0x2;
@@ -3808,6 +3816,14 @@ extern "C" {
nbytes: ::size_t,
) -> ::ssize_t;
+ pub fn fspacectl(
+ fd: ::c_int,
+ cmd: ::c_int,
+ rqsr: *const spacectl_range,
+ flags: ::c_int,
+ rmsr: *mut spacectl_range,
+ ) -> ::c_int;
+
pub fn jail(jail: *mut ::jail) -> ::c_int;
pub fn jail_attach(jid: ::c_int) -> ::c_int;
pub fn jail_remove(jid: ::c_int) -> ::c_int;