version 1.75, 2013/03/31 01:42:28 |
version 1.76, 2013/10/22 16:40:27 |
|
|
kvm_t *kd; |
kvm_t *kd; |
uid_t uid; |
uid_t uid; |
|
|
void fstat_dofile(struct kinfo_file2 *); |
void fstat_dofile(struct kinfo_file *); |
void fstat_header(void); |
void fstat_header(void); |
void getinetproto(int); |
void getinetproto(int); |
void usage(void); |
void usage(void); |
int getfname(char *); |
int getfname(char *); |
void cryptotrans(struct kinfo_file2 *); |
void cryptotrans(struct kinfo_file *); |
void kqueuetrans(struct kinfo_file2 *); |
void kqueuetrans(struct kinfo_file *); |
void pipetrans(struct kinfo_file2 *); |
void pipetrans(struct kinfo_file *); |
struct kinfo_file2 *splice_find(char, u_int64_t); |
struct kinfo_file *splice_find(char, u_int64_t); |
void splice_insert(char, u_int64_t, struct kinfo_file2 *); |
void splice_insert(char, u_int64_t, struct kinfo_file *); |
void find_splices(struct kinfo_file2 *, int); |
void find_splices(struct kinfo_file *, int); |
void print_inet_details(struct kinfo_file2 *); |
void print_inet_details(struct kinfo_file *); |
#ifdef INET6 |
#ifdef INET6 |
void print_inet6_details(struct kinfo_file2 *); |
void print_inet6_details(struct kinfo_file *); |
#endif |
#endif |
void print_sock_details(struct kinfo_file2 *); |
void print_sock_details(struct kinfo_file *); |
void socktrans(struct kinfo_file2 *); |
void socktrans(struct kinfo_file *); |
void systracetrans(struct kinfo_file2 *); |
void systracetrans(struct kinfo_file *); |
void vtrans(struct kinfo_file2 *); |
void vtrans(struct kinfo_file *); |
const char *inet6_addrstr(struct in6_addr *); |
const char *inet6_addrstr(struct in6_addr *); |
int signame_to_signum(char *); |
int signame_to_signum(char *); |
void hide(void *p); |
void hide(void *p); |
|
|
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
struct passwd *passwd; |
struct passwd *passwd; |
struct kinfo_file2 *kf, *kflast; |
struct kinfo_file *kf, *kflast; |
int arg, ch, what; |
int arg, ch, what; |
char *memf, *nlistf, *optstr; |
char *memf, *nlistf, *optstr; |
char buf[_POSIX2_LINE_MAX]; |
char buf[_POSIX2_LINE_MAX]; |
|
|
checkfile = 1; |
checkfile = 1; |
} |
} |
|
|
if ((kf = kvm_getfile2(kd, what, arg, sizeof(*kf), &cnt)) == NULL) |
if ((kf = kvm_getfiles(kd, what, arg, sizeof(*kf), &cnt)) == NULL) |
errx(1, "%s", kvm_geterr(kd)); |
errx(1, "%s", kvm_geterr(kd)); |
|
|
find_splices(kf, cnt); |
find_splices(kf, cnt); |
|
|
* print open files attributed to this process |
* print open files attributed to this process |
*/ |
*/ |
void |
void |
fstat_dofile(struct kinfo_file2 *kf) |
fstat_dofile(struct kinfo_file *kf) |
{ |
{ |
|
|
Uname = user_from_uid(kf->p_uid, 0); |
Uname = user_from_uid(kf->p_uid, 0); |
|
|
} |
} |
|
|
void |
void |
vtrans(struct kinfo_file2 *kf) |
vtrans(struct kinfo_file *kf) |
{ |
{ |
const char *badtype = NULL; |
const char *badtype = NULL; |
char rw[3], mode[12]; |
char rw[3], mode[12]; |
|
|
} |
} |
|
|
void |
void |
pipetrans(struct kinfo_file2 *kf) |
pipetrans(struct kinfo_file *kf) |
{ |
{ |
void *maxaddr; |
void *maxaddr; |
|
|
|
|
} |
} |
|
|
void |
void |
kqueuetrans(struct kinfo_file2 *kf) |
kqueuetrans(struct kinfo_file *kf) |
{ |
{ |
PREFIX(kf->fd_fd); |
PREFIX(kf->fd_fd); |
|
|
|
|
} |
} |
|
|
void |
void |
cryptotrans(struct kinfo_file2 *kf) |
cryptotrans(struct kinfo_file *kf) |
{ |
{ |
PREFIX(kf->fd_fd); |
PREFIX(kf->fd_fd); |
|
|
|
|
} |
} |
|
|
void |
void |
systracetrans(struct kinfo_file2 *kf) |
systracetrans(struct kinfo_file *kf) |
{ |
{ |
PREFIX(kf->fd_fd); |
PREFIX(kf->fd_fd); |
|
|
|
|
#endif |
#endif |
|
|
void |
void |
splice_insert(char type, u_int64_t ptr, struct kinfo_file2 *data) |
splice_insert(char type, u_int64_t ptr, struct kinfo_file *data) |
{ |
{ |
ENTRY entry, *found; |
ENTRY entry, *found; |
|
|
|
|
found->data = NULL; |
found->data = NULL; |
} |
} |
|
|
struct kinfo_file2 * |
struct kinfo_file * |
splice_find(char type, u_int64_t ptr) |
splice_find(char type, u_int64_t ptr) |
{ |
{ |
ENTRY entry, *found; |
ENTRY entry, *found; |
|
|
} |
} |
|
|
void |
void |
find_splices(struct kinfo_file2 *kf, int cnt) |
find_splices(struct kinfo_file *kf, int cnt) |
{ |
{ |
int i, created; |
int i, created; |
|
|
|
|
} |
} |
|
|
void |
void |
print_inet_details(struct kinfo_file2 *kf) |
print_inet_details(struct kinfo_file *kf) |
{ |
{ |
struct in_addr laddr, faddr; |
struct in_addr laddr, faddr; |
|
|
|
|
|
|
#ifdef INET6 |
#ifdef INET6 |
void |
void |
print_inet6_details(struct kinfo_file2 *kf) |
print_inet6_details(struct kinfo_file *kf) |
{ |
{ |
char xaddrbuf[NI_MAXHOST + 2]; |
char xaddrbuf[NI_MAXHOST + 2]; |
struct in6_addr laddr6, faddr6; |
struct in6_addr laddr6, faddr6; |
|
|
#endif |
#endif |
|
|
void |
void |
print_sock_details(struct kinfo_file2 *kf) |
print_sock_details(struct kinfo_file *kf) |
{ |
{ |
if (kf->so_family == AF_INET) |
if (kf->so_family == AF_INET) |
print_inet_details(kf); |
print_inet_details(kf); |
|
|
} |
} |
|
|
void |
void |
socktrans(struct kinfo_file2 *kf) |
socktrans(struct kinfo_file *kf) |
{ |
{ |
static char *stypename[] = { |
static char *stypename[] = { |
"unused", /* 0 */ |
"unused", /* 0 */ |
|
|
hide((void *)(uintptr_t)kf->f_data); |
hide((void *)(uintptr_t)kf->f_data); |
} |
} |
if (kf->so_splice != 0 || kf->so_splicelen == -1) { |
if (kf->so_splice != 0 || kf->so_splicelen == -1) { |
struct kinfo_file2 *from, *to; |
struct kinfo_file *from, *to; |
|
|
from = splice_find('<', kf->f_data); |
from = splice_find('<', kf->f_data); |
to = NULL; |
to = NULL; |