Skip to content

Commit be39286

Browse files
committed
Add fspacectl, new in FreeBSD 14
1 parent 599fa5c commit be39286

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.
@@ -2193,6 +2196,9 @@ fn test_freebsd(target: &str) {
21932196
// `ptrace_sc_ret` is not available in FreeBSD 11
21942197
"ptrace_sc_ret" if Some(11) == freebsd_ver => true,
21952198

2199+
// `spacectl_range` was introduced in FreeBSD 14
2200+
"spacectl_range" if Some(14) > freebsd_ver => true,
2201+
21962202
// obsolete version
21972203
"vmtotal" if Some(11) == freebsd_ver => true,
21982204

@@ -2221,6 +2227,9 @@ fn test_freebsd(target: &str) {
22212227
// `ssize_t` in FreeBSD11:
22222228
"aio_waitcomplete" if Some(10) == freebsd_ver => true,
22232229

2230+
// `fspacectl` was introduced in FreeBSD 14
2231+
"fspacectl" if Some(14) > freebsd_ver => true,
2232+
22242233
// The `uname` function in the `utsname.h` FreeBSD header is a C
22252234
// inline function (has no symbol) that calls the `__xuname` symbol.
22262235
// 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;
@@ -3805,6 +3813,14 @@ extern "C" {
38053813
nbytes: ::size_t,
38063814
) -> ::ssize_t;
38073815

3816+
pub fn fspacectl(
3817+
fd: ::c_int,
3818+
cmd: ::c_int,
3819+
rqsr: *const spacectl_range,
3820+
flags: ::c_int,
3821+
rmsr: *mut spacectl_range,
3822+
) -> ::c_int;
3823+
38083824
pub fn jail(jail: *mut ::jail) -> ::c_int;
38093825
pub fn jail_attach(jid: ::c_int) -> ::c_int;
38103826
pub fn jail_remove(jid: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)