1/*- 2 * Copyright (c) 2007 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.bin/procstat/procstat_files.c 185548 2008-12-02 06:50:26Z peter $ |
27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31#include <sys/sysctl.h> 32#include <sys/un.h> 33#include <sys/user.h> 34 35#include <netinet/in.h> 36 37#include <arpa/inet.h> 38 39#include <err.h> 40#include <inttypes.h> 41#include <stdio.h> 42#include <stdlib.h> 43#include <string.h> |
44#include <libutil.h> |
45 46#include "procstat.h" 47 48static const char * 49protocol_to_string(int domain, int type, int protocol) 50{ 51 52 switch (domain) { --- 77 unchanged lines hidden (view full) --- 130 addr_to_string(ss, addr, sizeof(addr)); 131 printf("%s", addr); 132} 133 134void 135procstat_files(pid_t pid, struct kinfo_proc *kipp) 136{ 137 struct kinfo_file *freep, *kif; |
138 int i, cnt; |
139 const char *str; |
140 141 if (!hflag) 142 printf("%5s %-16s %4s %1s %1s %-8s %3s %7s %-3s %-12s\n", 143 "PID", "COMM", "FD", "T", "V", "FLAGS", "REF", "OFFSET", 144 "PRO", "NAME"); 145 |
146 freep = kinfo_getfile(pid, &cnt); 147 for (i = 0; i < cnt; i++) { 148 kif = &freep[i]; 149 |
150 printf("%5d ", pid); 151 printf("%-16s ", kipp->ki_comm); 152 switch (kif->kf_fd) { 153 case KF_FD_TYPE_CWD: 154 printf(" cwd "); 155 break; 156 157 case KF_FD_TYPE_ROOT: --- 162 unchanged lines hidden --- |