Skip to content

Commit b2c99fa

Browse files
committed
Auto merge of #2299 - devnexen:fbsd_kinfo_vmentry, r=JohnTitor
freebsd introduces kinfo api
2 parents 87645ed + 25323c2 commit b2c99fa

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,7 @@ fn test_freebsd(target: &str) {
17861786
"sys/ucontext.h",
17871787
"sys/uio.h",
17881788
"sys/un.h",
1789+
"sys/user.h",
17891790
"sys/utsname.h",
17901791
"sys/wait.h",
17911792
"syslog.h",
@@ -2016,6 +2017,8 @@ fn test_freebsd(target: &str) {
20162017
("umutex", "m_owner") => true,
20172018
// c_has_waiters field is a volatile int32_t
20182019
("ucond", "c_has_waiters") => true,
2020+
// is PATH_MAX long but tests can't accept multi array as equivalent.
2021+
("kinfo_vmentry", "kve_path") => true,
20192022

20202023
_ => false,
20212024
}

libc-test/semver/freebsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,7 @@ jail_set
14641464
kevent
14651465
key_t
14661466
killpg
1467+
kinfo_getvmmap
14671468
kqueue
14681469
kld_isloaded
14691470
kld_load

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,42 @@ s! {
180180
b_refcount: ::c_int,
181181
b_destroying: ::c_int,
182182
}
183+
184+
pub struct kinfo_vmentry {
185+
pub kve_structsize: ::c_int,
186+
pub kve_type: ::c_int,
187+
pub kve_start: u64,
188+
pub kve_end: u64,
189+
pub kve_offset: u64,
190+
pub kve_vn_fileid: u64,
191+
#[cfg(not(freebsd11))]
192+
pub kve_vn_fsid_freebsd11: u32,
193+
#[cfg(freebsd11)]
194+
pub kve_vn_fsid: u32,
195+
pub kve_flags: ::c_int,
196+
pub kve_resident: ::c_int,
197+
pub kve_private_resident: ::c_int,
198+
pub kve_protection: ::c_int,
199+
pub kve_ref_count: ::c_int,
200+
pub kve_shadow_count: ::c_int,
201+
pub kve_vn_type: ::c_int,
202+
pub kve_vn_size: u64,
203+
#[cfg(not(freebsd11))]
204+
pub kve_vn_rdev_freebsd11: u32,
205+
#[cfg(freebsd11)]
206+
pub kve_vn_rdev: u32,
207+
pub kve_vn_mode: u16,
208+
pub kve_status: u16,
209+
#[cfg(not(freebsd11))]
210+
pub kve_vn_fsid: u64,
211+
#[cfg(not(freebsd11))]
212+
pub kve_vn_rdev: u64,
213+
#[cfg(not(freebsd11))]
214+
_kve_is_spare: [::c_int; 8],
215+
#[cfg(freebsd11)]
216+
_kve_is_spare: [::c_int; 12],
217+
pub kve_path: [[::c_char; 32]; 32],
218+
}
183219
}
184220

185221
s_no_extra_traits! {
@@ -1772,6 +1808,8 @@ extern "C" {
17721808

17731809
pub fn kld_isloaded(name: *const ::c_char) -> ::c_int;
17741810
pub fn kld_load(name: *const ::c_char) -> ::c_int;
1811+
1812+
pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::c_int) -> *mut kinfo_vmentry;
17751813
}
17761814

17771815
cfg_if! {

0 commit comments

Comments
 (0)