version 1.37, 2002/05/18 17:54:15 |
version 1.38, 2002/05/19 22:01:15 |
|
|
#include <sys/sysctl.h> |
#include <sys/sysctl.h> |
#include <sys/filedesc.h> |
#include <sys/filedesc.h> |
#include <sys/mount.h> |
#include <sys/mount.h> |
#include <crypto/cryptodev.h> |
|
#define _KERNEL |
#define _KERNEL |
|
#include <crypto/cryptodev.h> |
|
#include <dev/systrace.h> |
#include <sys/file.h> |
#include <sys/file.h> |
#include <ufs/ufs/quota.h> |
#include <ufs/ufs/quota.h> |
#include <ufs/ufs/inode.h> |
#include <ufs/ufs/inode.h> |
|
|
} DEVS; |
} DEVS; |
DEVS *devs; |
DEVS *devs; |
|
|
int fsflg, /* show files on same filesystem as file(s) argument */ |
int fsflg, /* show files on same filesystem as file(s) argument */ |
pflg, /* show files open by a particular pid */ |
pflg, /* show files open by a particular pid */ |
uflg; /* show files open by a particular (effective) user */ |
uflg; /* show files open by a particular (effective) user */ |
int checkfile; /* true if restricting to particular files or filesystems */ |
int checkfile; /* true if restricting to particular files or filesystems */ |
int nflg; /* (numerical) display f.s. and rdev as dev_t */ |
int nflg; /* (numerical) display f.s. and rdev as dev_t */ |
int oflg; /* display file offset */ |
int oflg; /* display file offset */ |
int vflg; /* display errors in locating kernel data objects etc... */ |
int vflg; /* display errors in locating kernel data objects etc... */ |
|
|
void pipetrans(struct pipe *, int); |
void pipetrans(struct pipe *, int); |
void kqueuetrans(struct kqueue *, int); |
void kqueuetrans(struct kqueue *, int); |
void cryptotrans(void *, int i); |
void cryptotrans(void *, int i); |
void systracetrans(void *, int i); |
void systracetrans(struct fsystrace *, int i); |
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
|
|
case 'v': |
case 'v': |
vflg = 1; |
vflg = 1; |
break; |
break; |
case '?': |
|
default: |
default: |
usage(); |
usage(); |
} |
} |
|
|
#define filed filed0.fd_fd |
#define filed filed0.fd_fd |
struct proc *p = &kp->kp_proc; |
struct proc *p = &kp->kp_proc; |
struct eproc *ep = &kp->kp_eproc; |
struct eproc *ep = &kp->kp_eproc; |
|
|
extern char *user_from_uid(); |
extern char *user_from_uid(); |
|
|
Uname = user_from_uid(ep->e_ucred.cr_uid, 0); |
Uname = user_from_uid(ep->e_ucred.cr_uid, 0); |
|
|
continue; |
continue; |
} |
} |
if (file.f_type == DTYPE_VNODE) |
if (file.f_type == DTYPE_VNODE) |
vtrans((struct vnode *)file.f_data, i, file.f_flag, file.f_offset); |
vtrans((struct vnode *)file.f_data, i, file.f_flag, |
|
file.f_offset); |
else if (file.f_type == DTYPE_SOCKET) { |
else if (file.f_type == DTYPE_SOCKET) { |
if (checkfile == 0) |
if (checkfile == 0) |
socktrans((struct socket *)file.f_data, i); |
socktrans((struct socket *)file.f_data, i); |
|
|
cryptotrans(file.f_data, i); |
cryptotrans(file.f_data, i); |
} else if (file.f_type == DTYPE_SYSTRACE) { |
} else if (file.f_type == DTYPE_SYSTRACE) { |
if (checkfile == 0) |
if (checkfile == 0) |
systracetrans((void *)file.f_data, i); |
systracetrans((struct fsystrace *)file.f_data, i); |
} else { |
} else { |
dprintf("unknown file type %d for file %d of pid %d", |
dprintf("unknown file type %d for file %d of pid %d", |
file.f_type, i, Pid); |
file.f_type, i, Pid); |
|
|
*/ |
*/ |
maxaddr = MAX(pipe, pi.pipe_peer); |
maxaddr = MAX(pipe, pi.pipe_peer); |
|
|
printf("pipe %p state: %s%s%s", maxaddr, |
printf("pipe %p state: %s%s%s\n", maxaddr, |
(pi.pipe_state & PIPE_WANTR) ? "R" : "", |
(pi.pipe_state & PIPE_WANTR) ? "R" : "", |
(pi.pipe_state & PIPE_WANTW) ? "W" : "", |
(pi.pipe_state & PIPE_WANTW) ? "W" : "", |
(pi.pipe_state & PIPE_EOF) ? "E" : ""); |
(pi.pipe_state & PIPE_EOF) ? "E" : ""); |
|
|
printf("\n"); |
|
return; |
return; |
bad: |
bad: |
printf("* error\n"); |
printf("* error\n"); |
|
|
goto bad; |
goto bad; |
} |
} |
|
|
printf("kqueue %p %d state: %s%s", kq, kqi.kq_count, |
printf("kqueue %p %d state: %s%s\n", kq, kqi.kq_count, |
(kqi.kq_state & KQ_SEL) ? "S" : "", |
(kqi.kq_state & KQ_SEL) ? "S" : "", |
(kqi.kq_state & KQ_SLEEP) ? "W" : ""); |
(kqi.kq_state & KQ_SLEEP) ? "W" : ""); |
|
|
printf("\n"); |
|
return; |
return; |
bad: |
bad: |
printf("* error\n"); |
printf("* error\n"); |
|
|
|
|
printf(" "); |
printf(" "); |
|
|
printf("crypto %p", f); |
printf("crypto %p\n", f); |
|
|
printf("\n"); |
|
return; |
return; |
bad: |
bad: |
printf("* error\n"); |
printf("* error\n"); |
|
|
|
|
void |
void |
systracetrans(f, i) |
systracetrans(f, i) |
void *f; |
struct fsystrace *f; |
int i; |
int i; |
{ |
{ |
|
struct fsystrace fi; |
|
|
PREFIX(i); |
PREFIX(i); |
|
|
printf(" "); |
printf(" "); |
|
|
printf("systrace %p", f); |
/* fill it in */ |
|
if (!KVM_READ(f, &fi, sizeof(fi))) { |
|
dprintf("can't read fsystrace at %p", f); |
|
goto bad; |
|
} |
|
|
printf("\n"); |
printf("systrace %p npol %d\n", f, fi.npolicies); |
return; |
return; |
bad: |
bad: |
printf("* error\n"); |
printf("* error\n"); |
|
|
if (IN6_IS_ADDR_LINKLOCAL(p) && |
if (IN6_IS_ADDR_LINKLOCAL(p) && |
*(u_int16_t *)&sin6.sin6_addr.s6_addr[2] != 0) { |
*(u_int16_t *)&sin6.sin6_addr.s6_addr[2] != 0) { |
sin6.sin6_scope_id = |
sin6.sin6_scope_id = |
ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]); |
ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]); |
sin6.sin6_addr.s6_addr[2] = sin6.sin6_addr.s6_addr[3] = 0; |
sin6.sin6_addr.s6_addr[2] = sin6.sin6_addr.s6_addr[3] = 0; |
} |
} |
|
|
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len, |
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len, |
hbuf, sizeof(hbuf), NULL, 0, niflags)) |
hbuf, sizeof(hbuf), NULL, 0, niflags)) |
return "invalid"; |
return "invalid"; |
|
|
return hbuf; |
return hbuf; |
|
|
{ |
{ |
static char *stypename[] = { |
static char *stypename[] = { |
"unused", /* 0 */ |
"unused", /* 0 */ |
"stream", /* 1 */ |
"stream", /* 1 */ |
"dgram", /* 2 */ |
"dgram", /* 2 */ |
"raw", /* 3 */ |
"raw", /* 3 */ |
"rdm", /* 4 */ |
"rdm", /* 4 */ |
|
|
sizeof(dname) - 1)) != sizeof(dname) -1) { |
sizeof(dname) - 1)) != sizeof(dname) -1) { |
dprintf("can't read domain name at %p", dom.dom_name); |
dprintf("can't read domain name at %p", dom.dom_name); |
dname[0] = '\0'; |
dname[0] = '\0'; |
} |
} else |
else |
|
dname[len] = '\0'; |
dname[len] = '\0'; |
|
|
if ((u_short)so.so_type > STYPEMAX) |
if ((u_short)so.so_type > STYPEMAX) |
|
|
void |
void |
usage() |
usage() |
{ |
{ |
(void)fprintf(stderr, |
fprintf(stderr, "usage: fstat [-fnv] [-p pid] [-u user] " |
"usage: fstat [-fnv] [-p pid] [-u user] [-N system] [-M core] [file ...]\n"); |
"[-N system] [-M core] [file ...]\n"); |
exit(1); |
exit(1); |
} |
} |