/* $Id: machine.h,v 2.9 2012/09/24 17:45:09 ksb Exp $ */ #if !defined(USE_KVM_FROM_GETPROCS) #define USE_KVM_FROM_GETPROCS (defined(NETBSD)) #endif #if !defined(USE_KVM_FROM_PROC) #define USE_KVM_FROM_PROC (defined(LINUX)) #endif #if !defined(USE_KVM_FROM_PSINFO) #define USE_KVM_FROM_PSINFO (defined(IBMR2)||defined(AIX)) #endif #if !defined(USE_KVM_FROM_PSTAT_GETPROC) #define USE_KVM_FROM_PSTAT_GETPROC (defined(HPUX11)||defined(HPUX10)) #endif #if USE_KVM_FROM_GETPROCS #include #include #endif #if !USE_KVM_FROM_PSINFO && !USE_KVM_FROM_PSTAT_GETPROC #include #endif #if USE_KVM_FROM_PROC || USE_KVM_FROM_PSINFO || USE_KVM_FROM_PSTAT_GETPROC #if !defined(KERN_PROC_ALL) #define KERN_PROC_ALL 0 #endif #if !defined(MAXCOMLEN) #define MAXCOMLEN 16 #endif /* How much of the command line to stop in the ptree */ #if !defined(XM_2BIG) #define XM_2BIG (8192-sizeof(long)) #endif typedef struct kinfo_proc { pid_t xm_ppid; pid_t xm_pid; uid_t xm_ruid; gid_t xm_rgid; char xm_comm[(XM_2BIG|(sizeof(long)-1))+1]; } XMkinfo_proc; #define PTREE_FIND_PPID xm_ppid #define PTREE_FIND_PID xm_pid #define PTREE_FIND_COMM xm_comm #define PTREE_FIND_RUID xm_ruid typedef struct XMkvm { struct kinfo_proc *pKImem; } kvm_t; extern kvm_t *kvm_openfiles(const char *pcExec, const char *pcCore, const char *pcSwap, int iFlags, char *pcError); extern struct kinfo_proc *kvm_getprocs(kvm_t *pkvm, int iFlag, int Junk, int *piEntries); extern int kvm_close(kvm_t *pkvm); extern char **kvm_getargv(kvm_t *, struct kinfo_proc *, int); extern char *kvm_geterr(kvm_t *); #else #include #include /* FreeBSD < 6.0 uses a more nested structure to get to the * fields we need to see, 6.0 and up use more more like NetBSD. (ksb) */ #if defined(NETBSD) #define PTREE_FIND_PPID kp_eproc.e_ppid #define PTREE_FIND_PID kp_proc.p_pid #define PTREE_FIND_COMM kp_proc.p_comm #define PTREE_FIND_RUID kp_eproc.e_pcred.p_ruid #else #if defined(FREEBSD) && (HOSTOS < 50000) #define PTREE_FIND_PPID kp_eproc.e_ppid #define PTREE_FIND_PID kp_proc.p_pid #define PTREE_FIND_COMM kp_proc.p_comm #define PTREE_FIND_RUID kp_eproc.e_pcred.p_ruid #else #define PTREE_FIND_PPID ki_ppid #define PTREE_FIND_PID ki_pid #define PTREE_FIND_COMM ki_ocomm #define PTREE_FIND_RUID ki_ruid #endif #endif /* NETBSD */ #endif /* USE_KVM_FROM_PROC || USE_KVM_FROM_PSINFO || USE_KVM_FROM_PSTAT_GETPROC || USE_KVM_FROM_GETPROCS */ #if !defined(_PATH_DEVNULL) #define _PATH_DEVNULL "/dev/null" #endif