summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-29 19:12:50 +0000
committerbors <bors@rust-lang.org>2021-07-29 19:12:50 +0000
commitb2c99fa36963861136edca0eadbece44e9daab54 (patch)
tree90a66fb4660b30635342d87f13f127c8f21dfac0
parent87645ed39e711e88643f866472cb7dbe3dc1a37e (diff)
parent25323c29b7431fe63c18a57c95da2b4e716c870a (diff)
downloadrust-libc-b2c99fa36963861136edca0eadbece44e9daab54.tar.gz
Auto merge of #2299 - devnexen:fbsd_kinfo_vmentry, r=JohnTitor
freebsd introduces kinfo api
-rwxr-xr-xlibc-test/build.rs3
-rw-r--r--libc-test/semver/freebsd.txt1
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs38
3 files changed, 42 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 975e0d16dd..0a48a30453 100755
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1786,6 +1786,7 @@ fn test_freebsd(target: &str) {
"sys/ucontext.h",
"sys/uio.h",
"sys/un.h",
+ "sys/user.h",
"sys/utsname.h",
"sys/wait.h",
"syslog.h",
@@ -2016,6 +2017,8 @@ fn test_freebsd(target: &str) {
("umutex", "m_owner") => true,
// c_has_waiters field is a volatile int32_t
("ucond", "c_has_waiters") => true,
+ // is PATH_MAX long but tests can't accept multi array as equivalent.
+ ("kinfo_vmentry", "kve_path") => true,
_ => false,
}
diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt
index b0844be102..41fb26f86b 100644
--- a/libc-test/semver/freebsd.txt
+++ b/libc-test/semver/freebsd.txt
@@ -1464,6 +1464,7 @@ jail_set
kevent
key_t
killpg
+kinfo_getvmmap
kqueue
kld_isloaded
kld_load
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 06fd5ed078..338d986c50 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -180,6 +180,42 @@ s! {
b_refcount: ::c_int,
b_destroying: ::c_int,
}
+
+ pub struct kinfo_vmentry {
+ pub kve_structsize: ::c_int,
+ pub kve_type: ::c_int,
+ pub kve_start: u64,
+ pub kve_end: u64,
+ pub kve_offset: u64,
+ pub kve_vn_fileid: u64,
+ #[cfg(not(freebsd11))]
+ pub kve_vn_fsid_freebsd11: u32,
+ #[cfg(freebsd11)]
+ pub kve_vn_fsid: u32,
+ pub kve_flags: ::c_int,
+ pub kve_resident: ::c_int,
+ pub kve_private_resident: ::c_int,
+ pub kve_protection: ::c_int,
+ pub kve_ref_count: ::c_int,
+ pub kve_shadow_count: ::c_int,
+ pub kve_vn_type: ::c_int,
+ pub kve_vn_size: u64,
+ #[cfg(not(freebsd11))]
+ pub kve_vn_rdev_freebsd11: u32,
+ #[cfg(freebsd11)]
+ pub kve_vn_rdev: u32,
+ pub kve_vn_mode: u16,
+ pub kve_status: u16,
+ #[cfg(not(freebsd11))]
+ pub kve_vn_fsid: u64,
+ #[cfg(not(freebsd11))]
+ pub kve_vn_rdev: u64,
+ #[cfg(not(freebsd11))]
+ _kve_is_spare: [::c_int; 8],
+ #[cfg(freebsd11)]
+ _kve_is_spare: [::c_int; 12],
+ pub kve_path: [[::c_char; 32]; 32],
+ }
}
s_no_extra_traits! {
@@ -1772,6 +1808,8 @@ extern "C" {
pub fn kld_isloaded(name: *const ::c_char) -> ::c_int;
pub fn kld_load(name: *const ::c_char) -> ::c_int;
+
+ pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::c_int) -> *mut kinfo_vmentry;
}
cfg_if! {