use std::mem;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct proc_bsdinfo {
pub pbi_flags: u32,
pub pbi_status: u32,
pub pbi_xstatus: u32,
pub pbi_pid: u32,
pub pbi_ppid: u32,
pub pbi_uid: libc::uid_t,
pub pbi_gid: libc::gid_t,
pub pbi_ruid: libc::uid_t,
pub pbi_rgid: libc::gid_t,
pub pbi_svuid: libc::uid_t,
pub pbi_svgid: libc::gid_t,
pub rfu_1: u32,
pub pbi_comm: [libc::c_char; libc::MAXCOMLEN],
pub pbi_name: [libc::c_char; 2 * libc::MAXCOMLEN],
pub pbi_nfiles: u32,
pub pbi_pgid: u32,
pub pbi_pjobc: u32,
pub e_tdev: u32,
pub e_tpgid: u32,
pub pbi_nice: i32,
pub pbi_start_tvsec: u64,
pub pbi_start_tvusec: u64,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct proc_taskinfo {
pub pti_virtual_size: u64,
pub pti_resident_size: u64,
pub pti_total_user: u64,
pub pti_total_system: u64,
pub pti_threads_user: u64,
pub pti_threads_system: u64,
pub pti_policy: i32,
pub pti_faults: i32,
pub pti_pageins: i32,
pub pti_cow_faults: i32,
pub pti_messages_sent: i32,
pub pti_messages_received: i32,
pub pti_syscalls_mach: i32,
pub pti_syscalls_unix: i32,
pub pti_csw: i32,
pub pti_threadnum: i32,
pub pti_numrunning: i32,
pub pti_priority: i32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct proc_taskallinfo {
pub pbsd: proc_bsdinfo,
pub ptinfo: proc_taskinfo,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct proc_fdinfo {
pub proc_fd: i32,
pub proc_fdtype: u32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vinfo_stat {
pub vst_dev: u32,
pub vst_mode: u16,
pub vst_nlink: u16,
pub vst_ino: u64,
pub vst_uid: libc::uid_t,
pub vst_gid: libc::gid_t,
pub vst_atime: i64,
pub vst_atimensec: i64,
pub vst_mtime: i64,
pub vst_mtimensec: i64,
pub vst_ctime: i64,
pub vst_ctimensec: i64,
pub vst_birthtime: i64,
pub vst_birthtimensec: i64,
pub vst_size: libc::off_t,
pub vst_blocks: i64,
pub vst_blksize: i32,
pub vst_flags: u32,
pub vst_gen: u32,
pub vst_rdev: u32,
pub vst_qspare: [i64; 2],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vnode_info {
pub vi_stat: vinfo_stat,
pub vi_type: libc::c_int,
pub vi_fsid: libc::fsid_t,
pub vi_pad: libc::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct vnode_info_path {
pub vip_vi: vnode_info,
pub vip_path: [libc::c_char; crate::MAXPATHLEN],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct proc_vnodepathinfo {
pub pvi_cdir: vnode_info_path,
pub pvi_rdir: vnode_info_path,
}
pub const PROC_PIDLISTFDS: libc::c_int = 1;
pub const PROC_PIDLISTFD_SIZE: libc::c_int =
mem::size_of::<proc_fdinfo>() as libc::c_int;
pub const PROC_PIDTASKALLINFO: libc::c_int = 2;
pub const PROC_PIDTASKALLINFO_SIZE: libc::c_int =
mem::size_of::<proc_taskallinfo>() as libc::c_int;
pub const PROC_PIDTBSDINFO: libc::c_int = 3;
pub const PROC_PIDTBSDINFO_SIZE: libc::c_int =
mem::size_of::<proc_bsdinfo>() as libc::c_int;
pub const PROC_PIDTASKINFO: libc::c_int = 4;
pub const PROC_PIDTASKINFO_SIZE: libc::c_int =
mem::size_of::<proc_taskinfo>() as libc::c_int;
pub const PROC_PIDLISTTHREADS: libc::c_int = 6;
pub const PROC_PIDLISTTHREADS_SIZE: libc::c_int =
2 * mem::size_of::<u32>() as libc::c_int;
pub const PROC_PIDVNODEPATHINFO: libc::c_int = 9;
pub const PROC_PIDVNODEPATHINFO_SIZE: libc::c_int =
mem::size_of::<proc_vnodepathinfo>() as libc::c_int;
extern "C" {
pub fn proc_pidinfo(
pid: libc::c_int,
flavor: libc::c_int,
arg: u64,
buffer: *mut libc::c_void,
buffersize: libc::c_int,
) -> libc::c_int;
}
#[cfg(test)]
mod tests {
use super::*;
use std::mem;
#[test]
fn test_size() {
assert_eq!(mem::size_of::<proc_fdinfo>(), 8);
assert_eq!(PROC_PIDLISTFD_SIZE, 8);
assert_eq!(mem::size_of::<proc_taskallinfo>(), 232);
assert_eq!(PROC_PIDTASKALLINFO_SIZE, 232);
assert_eq!(mem::size_of::<proc_bsdinfo>(), 136);
assert_eq!(PROC_PIDTBSDINFO_SIZE, 136);
}
}