diff options
author | des <des@FreeBSD.org> | 2002-07-31 12:43:17 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2002-07-31 12:43:17 +0000 |
commit | 81f45956da84eb139efa30306f8e1692f8df89f1 (patch) | |
tree | dd411535d86fd6189bdba959356dd2f5a5bb8980 | |
parent | 06dac202026d0eaa1803bcc5fb7d3f295b40ab07 (diff) | |
download | FreeBSD-src-81f45956da84eb139efa30306f8e1692f8df89f1.zip FreeBSD-src-81f45956da84eb139efa30306f8e1692f8df89f1.tar.gz |
Use struct xfile, not struct file.
-rw-r--r-- | usr.sbin/pstat/pstat.8 | 7 | ||||
-rw-r--r-- | usr.sbin/pstat/pstat.c | 41 |
2 files changed, 22 insertions, 26 deletions
diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8 index d73c88d..93d3c11 100644 --- a/usr.sbin/pstat/pstat.8 +++ b/usr.sbin/pstat/pstat.8 @@ -1,5 +1,12 @@ .\" Copyright (c) 1980, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 2002 Networks Associates Technology, Inc. +.\" All rights reserved. +.\" +.\" Portions of this software was developed for the FreeBSD Project by +.\" ThinkSec AS and NAI Labs, the Security Research Division of Network +.\" Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 +.\" ("CBOSS"), as part of the DARPA CHATS research program. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index 04afd27..f85de47 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -54,10 +54,7 @@ static const char rcsid[] = #include <sys/param.h> #include <sys/time.h> -#define _KERNEL #include <sys/file.h> -#include <sys/uio.h> -#undef _KERNEL #include <sys/stat.h> #include <sys/stdint.h> #include <sys/ioctl.h> @@ -375,12 +372,12 @@ ttyprt(struct xtty *xt) static void filemode(void) { - struct file *fp; - struct file *addr; + struct xfile *fp; char *buf, flagbuf[16], *fbp; int maxf, openf; size_t len; static char *dtypes[] = { "???", "inode", "socket" }; + int i; if (kd != NULL) { if (kvm_read(kd, nl[NL_MAXFILES].n_value, @@ -401,36 +398,28 @@ filemode(void) } if (getfiles(&buf, &len) == -1) return; - /* - * Getfiles returns in malloc'd memory a pointer to the first file - * structure, and then an array of file structs (whose addresses are - * derivable from the previous entry). - */ - addr = LIST_FIRST((struct filelist *)buf); - fp = (struct file *)(buf + sizeof(struct filelist)); - openf = (len - sizeof(struct filelist)) / sizeof(struct file); - + openf = len / sizeof *fp; (void)printf("%d/%d open files\n", openf, maxf); (void)printf(" LOC TYPE FLG CNT MSG DATA OFFSET\n"); - for (; (char *)fp < buf + len; addr = LIST_NEXT(fp, f_list), fp++) { - if ((unsigned)fp->f_type > DTYPE_SOCKET) + for (fp = (struct xfile *)buf, i = 0; i < openf; ++fp, ++i) { + if ((unsigned)fp->xf_type > DTYPE_SOCKET) continue; - (void)printf("%8lx ", (u_long)(void *)addr); - (void)printf("%-8.8s", dtypes[fp->f_type]); + (void)printf("%8jx ", (uintmax_t)(uintptr_t)fp->xf_file); + (void)printf("%-8.8s", dtypes[fp->xf_type]); fbp = flagbuf; - if (fp->f_flag & FREAD) + if (fp->xf_flag & FREAD) *fbp++ = 'R'; - if (fp->f_flag & FWRITE) + if (fp->xf_flag & FWRITE) *fbp++ = 'W'; - if (fp->f_flag & FAPPEND) + if (fp->xf_flag & FAPPEND) *fbp++ = 'A'; - if (fp->f_flag & FASYNC) + if (fp->xf_flag & FASYNC) *fbp++ = 'I'; *fbp = '\0'; - (void)printf("%6s %3d", flagbuf, fp->f_count); - (void)printf(" %3d", fp->f_msgcount); - (void)printf(" %8lx", (u_long)(void *)fp->f_data); - (void)printf(" %jx\n", (uintmax_t)fp->f_offset); + (void)printf("%6s %3d", flagbuf, fp->xf_count); + (void)printf(" %3d", fp->xf_msgcount); + (void)printf(" %8lx", (u_long)(void *)fp->xf_data); + (void)printf(" %jx\n", (uintmax_t)fp->xf_offset); } free(buf); } |