Skip to content

Commit 7600416

Browse files
committed
Auto merge of #2543 - asomers:fspacectl, r=Amanieu
Add fspacectl, new in FreeBSD 14
2 parents 72e4151 + be39286 commit 7600416

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

libc-test/build.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ fn test_freebsd(target: &str) {
20412041
// This was changed to 96(0x60) in FreeBSD 13:
20422042
// https://github.com/freebsd/freebsd/
20432043
// commit/06b00ceaa914a3907e4e27bad924f44612bae1d7
2044-
"MINCORE_SUPER" if Some(13) == freebsd_ver => true,
2044+
"MINCORE_SUPER" if Some(13) <= freebsd_ver => true,
20452045

20462046
// Added in FreeBSD 12.0
20472047
"EINTEGRITY" if Some(11) == freebsd_ver => true,
@@ -2089,6 +2089,9 @@ fn test_freebsd(target: &str) {
20892089
// Added in in FreeBSD 13.0 (r367776 and r367287)
20902090
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,
20912091

2092+
// Added in FreeBSD 14
2093+
"SPACECTL_DEALLOC" if Some(14) > freebsd_ver => true,
2094+
20922095
"VM_TOTAL" if Some(11) == freebsd_ver => true,
20932096

20942097
// Added in FreeBSD 13.
@@ -2196,6 +2199,9 @@ fn test_freebsd(target: &str) {
21962199
// `ptrace_sc_ret` is not available in FreeBSD 11
21972200
"ptrace_sc_ret" if Some(11) == freebsd_ver => true,
21982201

2202+
// `spacectl_range` was introduced in FreeBSD 14
2203+
"spacectl_range" if Some(14) > freebsd_ver => true,
2204+
21992205
// obsolete version
22002206
"vmtotal" if Some(11) == freebsd_ver => true,
22012207

@@ -2224,6 +2230,9 @@ fn test_freebsd(target: &str) {
22242230
// `ssize_t` in FreeBSD11:
22252231
"aio_waitcomplete" if Some(10) == freebsd_ver => true,
22262232

2233+
// `fspacectl` was introduced in FreeBSD 14
2234+
"fspacectl" if Some(14) > freebsd_ver => true,
2235+
22272236
// The `uname` function in the `utsname.h` FreeBSD header is a C
22282237
// inline function (has no symbol) that calls the `__xuname` symbol.
22292238
// Therefore the function pointer comparison does not make sense for it.

src/unix/bsd/freebsdlike/freebsd/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,11 @@ s! {
600600
pub mode: u16,
601601
}
602602

603+
pub struct spacectl_range {
604+
pub r_offset: ::off_t,
605+
pub r_len: ::off_t
606+
}
607+
603608
pub struct rusage_ext {
604609
pub rux_runtime: u64,
605610
pub rux_uticks: u64,
@@ -2978,6 +2983,9 @@ pub const F_SEAL_SEAL: ::c_int = 1;
29782983
pub const F_SEAL_SHRINK: ::c_int = 2;
29792984
pub const F_SEAL_WRITE: ::c_int = 8;
29802985

2986+
// for use with fspacectl
2987+
pub const SPACECTL_DEALLOC: ::c_int = 1;
2988+
29812989
// For getrandom()
29822990
pub const GRND_NONBLOCK: ::c_uint = 0x1;
29832991
pub const GRND_RANDOM: ::c_uint = 0x2;
@@ -3808,6 +3816,14 @@ extern "C" {
38083816
nbytes: ::size_t,
38093817
) -> ::ssize_t;
38103818

3819+
pub fn fspacectl(
3820+
fd: ::c_int,
3821+
cmd: ::c_int,
3822+
rqsr: *const spacectl_range,
3823+
flags: ::c_int,
3824+
rmsr: *mut spacectl_range,
3825+
) -> ::c_int;
3826+
38113827
pub fn jail(jail: *mut ::jail) -> ::c_int;
38123828
pub fn jail_attach(jid: ::c_int) -> ::c_int;
38133829
pub fn jail_remove(jid: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)