From owner-svn-src-projects@FreeBSD.ORG Thu Jul 16 16:55:08 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E91C1065670; Thu, 16 Jul 2009 16:55:08 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63A0C8FC13; Thu, 16 Jul 2009 16:55:08 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6GGt8xi034757; Thu, 16 Jul 2009 16:55:08 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6GGt8NN034754; Thu, 16 Jul 2009 16:55:08 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200907161655.n6GGt8NN034754@svn.freebsd.org> From: Stanislav Sedov Date: Thu, 16 Jul 2009 16:55:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195722 - projects/libprocstat/usr.bin/fstat X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2009 16:55:08 -0000 Author: stas Date: Thu Jul 16 16:55:08 2009 New Revision: 195722 URL: http://svn.freebsd.org/changeset/base/195722 Log: - Cleanup. Modified: projects/libprocstat/usr.bin/fstat/fstat.c projects/libprocstat/usr.bin/fstat/libprocstat.c Modified: projects/libprocstat/usr.bin/fstat/fstat.c ============================================================================== --- projects/libprocstat/usr.bin/fstat/fstat.c Thu Jul 16 16:38:41 2009 (r195721) +++ projects/libprocstat/usr.bin/fstat/fstat.c Thu Jul 16 16:55:08 2009 (r195722) @@ -36,55 +36,24 @@ __FBSDID("$FreeBSD$"); #include -#include -#include #include #include -#include #include #include -#include -#include -#include -#include #include -#include -#include #include -#define _WANT_FILE -#include -#include -#define _KERNEL -#include -#include -#include -#include -#include -#include -#undef _KERNEL -#include -#include -#include - #include #include #include -#include #include -#include -#include -#include #include #include #include -#include #include -#include #include -#include #include #include #include @@ -114,37 +83,30 @@ typedef struct devs { DEVS *devs; char *memf, *nlistf; -static void fstat1(int what, int arg); -static void dofiles(struct procstat *procstat, struct kinfo_proc *p); -void dofiles_kinfo(struct kinfo_proc *kp); -void dommap(struct kinfo_proc *kp); -void vtrans(struct vnode *vp, int i, int flag, const char *uname, const char *cmd, int pid); -char *getmnton(struct mount *m); -void pipetrans(struct pipe *pi, int i, int flag, const char *uname, const char *cmd, int pid); -void socktrans(struct socket *sock, int i, const char *uname, const char *cmd, int pid); -void ptstrans(struct tty *tp, int i, int flag, const char *uname, const char *cmd, int pid); -void getinetproto(int number); -int getfname(const char *filename); -void usage(void); -void vtrans_kinfo(struct kinfo_file *, int i, int flag, const char *uname, const char *cmd, int pid); -static void print_file_info(struct procstat *procstat, struct filestat *fst, const char *uname, const char *cmd, int pid); - -static void -print_socket_info(struct procstat *procstat, struct filestat *fst); -static void -print_pipe_info(struct procstat *procstat, struct filestat *fst); -static void -print_pts_info(struct procstat *procstat, struct filestat *fst); -static void -print_vnode_info(struct procstat *procstat, struct filestat *fst); -static void -print_access_flags(int flags); +static int getfname(const char *filename); +static void dofiles(struct procstat *procstat, struct kinfo_proc *p); +static void dommap(struct procstat *procstat, struct kinfo_proc *p); +static void print_access_flags(int flags); +static void print_file_info(struct procstat *procstat, + struct filestat *fst, const char *uname, const char *cmd, int pid); +static void print_pipe_info(struct procstat *procstat, + struct filestat *fst); +static void print_pts_info(struct procstat *procstat, + struct filestat *fst); +static void print_socket_info(struct procstat *procstat, + struct filestat *fst); +static void print_vnode_info(struct procstat *procstat, + struct filestat *fst); +static void usage(void) __dead2; int do_fstat(int argc, char **argv) { + struct kinfo_proc *p; struct passwd *passwd; + struct procstat *procstat; int arg, ch, what; + int cnt, i; arg = 0; what = KERN_PROC_PROC; @@ -208,18 +170,6 @@ do_fstat(int argc, char **argv) checkfile = 1; } - fstat1(what, arg); - exit(0); -} - -static void -fstat1(int what, int arg) -{ - struct kinfo_proc *p; - struct procstat *procstat; - int cnt; - int i; - procstat = procstat_open(nlistf, memf); if (procstat == NULL) errx(1, "procstat_open()"); @@ -248,13 +198,19 @@ fstat1(int what, int arg) if (p[i].ki_stat == SZOMB) continue; dofiles(procstat, &p[i]); -/* if (mflg) dommap(procstat, &p[i]); -*/ } free(p); procstat_close(procstat); + return (0); +} + +static void +dommap(struct procstat *procstat __unused, struct kinfo_proc *kp __unused) +{ + + fprintf(stderr, "Not implemented\n"); } static void @@ -449,17 +405,17 @@ print_socket_info(struct procstat *procs static void print_pipe_info(struct procstat *procstat, struct filestat *fst) { - struct pipestat pipe; + struct pipestat ps; char errbuf[_POSIX2_LINE_MAX]; int error; - error = procstat_get_pipe_info(procstat, fst, &pipe, errbuf); + error = procstat_get_pipe_info(procstat, fst, &ps, errbuf); if (error != 0) { printf("* error"); return; } - printf("* pipe %8lx <-> %8lx", (u_long)pipe.addr, (u_long)pipe.peer); - printf(" %6zd", pipe.buffer_cnt); + printf("* pipe %8lx <-> %8lx", (u_long)ps.addr, (u_long)ps.peer); + printf(" %6zd", ps.buffer_cnt); print_access_flags(fst->fs_fflags); } @@ -566,7 +522,7 @@ getfname(const char *filename) return (1); } -void +static void usage(void) { (void)fprintf(stderr, Modified: projects/libprocstat/usr.bin/fstat/libprocstat.c ============================================================================== --- projects/libprocstat/usr.bin/fstat/libprocstat.c Thu Jul 16 16:38:41 2009 (r195721) +++ projects/libprocstat/usr.bin/fstat/libprocstat.c Thu Jul 16 16:55:08 2009 (r195722) @@ -455,15 +455,15 @@ procstat_getfiles_sysctl(struct kinfo_pr int procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst, - struct pipestat *pipe, char *errbuf) + struct pipestat *ps, char *errbuf) { - assert(pipe); + assert(ps); if (procstat->type == PROCSTAT_KVM) { - return (procstat_get_pipe_info_kvm(procstat->kd, fst, pipe, + return (procstat_get_pipe_info_kvm(procstat->kd, fst, ps, errbuf)); } else if (procstat->type == PROCSTAT_SYSCTL) { - return (procstat_get_pipe_info_sysctl(fst, pipe, errbuf)); + return (procstat_get_pipe_info_sysctl(fst, ps, errbuf)); } else { warnx("unknow access method: %d", procstat->type); snprintf(errbuf, _POSIX2_LINE_MAX, "error"); @@ -473,15 +473,15 @@ procstat_get_pipe_info(struct procstat * static int procstat_get_pipe_info_kvm(kvm_t *kd, struct filestat *fst, - struct pipestat *pipe, char *errbuf) + struct pipestat *ps, char *errbuf) { struct pipe pi; void *pipep; assert(kd); - assert(pipe); + assert(ps); assert(fst); - bzero(pipe, sizeof(*pipe)); + bzero(ps, sizeof(*ps)); pipep = fst->fs_typedep; if (pipep == NULL) goto fail; @@ -489,9 +489,9 @@ procstat_get_pipe_info_kvm(kvm_t *kd, st warnx("can't read pipe at %p", (void *)pipep); goto fail; } - pipe->addr = (caddr_t)pipep; - pipe->peer = (caddr_t)pi.pipe_peer; - pipe->buffer_cnt = pi.pipe_buffer.cnt; + ps->addr = (caddr_t)pipep; + ps->peer = (caddr_t)pi.pipe_peer; + ps->buffer_cnt = pi.pipe_buffer.cnt; return (0); fail: @@ -500,7 +500,7 @@ fail: } static int -procstat_get_pipe_info_sysctl(struct filestat *fst, struct pipestat *pipe, +procstat_get_pipe_info_sysctl(struct filestat *fst, struct pipestat *ps, char *errbuf) {