Skip to content

Commit 5087445

Browse files
devnexendarfink
authored andcommitted
freebsd implementation simplification, relying more on the libc crate instead.
1 parent cd29436 commit 5087445

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

Diff for: src/os/freebsd.rs

+4-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::{Error, Protection, Region, Result};
2-
use libc::{c_int, c_void, free, getpid, pid_t};
2+
use libc::{
3+
c_int, c_void, free, getpid, kinfo_getvmmap, kinfo_vmentry, KVME_PROT_EXEC, KVME_PROT_READ,
4+
KVME_PROT_WRITE, KVME_TYPE_DEFAULT,
5+
};
36
use std::io;
47

58
pub struct QueryIter {
@@ -76,33 +79,6 @@ impl Protection {
7679
}
7780
}
7881

79-
// These defintions come from <sys/user.h>, describing data returned by the
80-
// `kinfo_getvmmap` system call.
81-
#[repr(C)]
82-
struct kinfo_vmentry {
83-
kve_structsize: c_int,
84-
kve_type: c_int,
85-
kve_start: u64,
86-
kve_end: u64,
87-
kve_offset: u64,
88-
kve_vn_fileid: u64,
89-
kve_vn_fsid_freebsd11: u32,
90-
kve_flags: c_int,
91-
kve_resident: c_int,
92-
kve_private_resident: c_int,
93-
kve_protection: c_int,
94-
}
95-
96-
const KVME_TYPE_DEFAULT: c_int = 1;
97-
const KVME_PROT_READ: c_int = 1;
98-
const KVME_PROT_WRITE: c_int = 2;
99-
const KVME_PROT_EXEC: c_int = 4;
100-
101-
#[link(name = "util")]
102-
extern "C" {
103-
fn kinfo_getvmmap(pid: pid_t, cntp: *mut c_int) -> *mut kinfo_vmentry;
104-
}
105-
10682
#[cfg(test)]
10783
mod tests {
10884
use super::*;

0 commit comments

Comments
 (0)