version 1.48, 2003/09/09 04:46:44 |
version 1.49, 2004/01/08 19:28:56 |
|
|
int nfs_filestat(struct vnode *, struct filestat *); |
int nfs_filestat(struct vnode *, struct filestat *); |
int xfs_filestat(struct vnode *, struct filestat *); |
int xfs_filestat(struct vnode *, struct filestat *); |
int null_filestat(struct vnode *, struct filestat *); |
int null_filestat(struct vnode *, struct filestat *); |
void dofiles(struct kinfo_proc *); |
void dofiles(struct kinfo_proc2 *); |
void getinetproto(int); |
void getinetproto(int); |
void socktrans(struct socket *, int); |
void socktrans(struct socket *, int); |
void usage(void); |
void usage(void); |
|
|
extern char *optarg; |
extern char *optarg; |
extern int optind; |
extern int optind; |
struct passwd *passwd; |
struct passwd *passwd; |
struct kinfo_proc *p, *plast; |
struct kinfo_proc2 *p, *plast; |
int arg, ch, what; |
int arg, ch, what; |
char *memf, *nlistf; |
char *memf, *nlistf; |
char buf[_POSIX2_LINE_MAX]; |
char buf[_POSIX2_LINE_MAX]; |
|
|
checkfile = 1; |
checkfile = 1; |
} |
} |
|
|
if ((p = kvm_getprocs(kd, what, arg, &cnt)) == NULL) |
if ((p = kvm_getproc2(kd, what, arg, sizeof(*p), &cnt)) == NULL) |
errx(1, "%s", kvm_geterr(kd)); |
errx(1, "%s", kvm_geterr(kd)); |
if (nflg) |
if (nflg) |
printf("%s", |
printf("%s", |
|
|
putchar('\n'); |
putchar('\n'); |
|
|
for (plast = &p[cnt]; p < plast; ++p) { |
for (plast = &p[cnt]; p < plast; ++p) { |
if (p->kp_proc.p_stat == SZOMB) |
if (p->p_stat == SZOMB) |
continue; |
continue; |
dofiles(p); |
dofiles(p); |
} |
} |
|
|
* print open files attributed to this process |
* print open files attributed to this process |
*/ |
*/ |
void |
void |
dofiles(struct kinfo_proc *kp) |
dofiles(struct kinfo_proc2 *kp) |
{ |
{ |
int i; |
int i; |
struct file file; |
struct file file; |
struct filedesc0 filed0; |
struct filedesc0 filed0; |
#define filed filed0.fd_fd |
#define filed filed0.fd_fd |
struct proc *p = &kp->kp_proc; |
|
struct eproc *ep = &kp->kp_eproc; |
|
|
|
Uname = user_from_uid(ep->e_ucred.cr_uid, 0); |
Uname = user_from_uid(kp->p_uid, 0); |
Pid = p->p_pid; |
Pid = kp->p_pid; |
Comm = p->p_comm; |
Comm = kp->p_comm; |
|
|
if (p->p_fd == NULL) |
if (kp->p_fd == 0) |
return; |
return; |
if (!KVM_READ(p->p_fd, &filed0, sizeof (filed0))) { |
if (!KVM_READ(kp->p_fd, &filed0, sizeof (filed0))) { |
dprintf("can't read filedesc at %p for pid %ld", |
dprintf("can't read filedesc at %p for pid %ld", |
p->p_fd, (long)Pid); |
(void *)(u_long)kp->p_fd, (long)Pid); |
return; |
return; |
} |
} |
if (filed.fd_nfiles < 0 || filed.fd_lastfile >= filed.fd_nfiles || |
if (filed.fd_nfiles < 0 || filed.fd_lastfile >= filed.fd_nfiles || |
filed.fd_freefile > filed.fd_lastfile + 1) { |
filed.fd_freefile > filed.fd_lastfile + 1) { |
dprintf("filedesc corrupted at %p for pid %ld", |
dprintf("filedesc corrupted at %p for pid %ld", |
p->p_fd, (long)Pid); |
(void *)(u_long)kp->p_fd, (long)Pid); |
return; |
return; |
} |
} |
/* |
/* |
|
|
/* |
/* |
* ktrace vnode, if one |
* ktrace vnode, if one |
*/ |
*/ |
if (p->p_tracep) |
if (kp->p_tracep) |
vtrans(p->p_tracep, TRACE, FREAD|FWRITE, 0); |
vtrans((struct vnode *)(u_long)kp->p_tracep, TRACE, FREAD|FWRITE, 0); |
/* |
/* |
* open files |
* open files |
*/ |
*/ |