fstat.c (230934) | fstat.c (232233) |
---|---|
1/*- 2 * Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org> 3 * Copyright (c) 1988, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 15 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org> 3 * Copyright (c) 1988, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 15 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/usr.bin/fstat/fstat.c 230934 2012-02-03 09:07:53Z pluknet $"); | 32__FBSDID("$FreeBSD: head/usr.bin/fstat/fstat.c 232233 2012-02-27 17:39:34Z pluknet $"); |
33 34#include <sys/param.h> 35#include <sys/user.h> 36#include <sys/stat.h> 37#include <sys/socket.h> 38#include <sys/socketvar.h> 39#include <sys/sysctl.h> 40#include <sys/queue.h> | 33 34#include <sys/param.h> 35#include <sys/user.h> 36#include <sys/stat.h> 37#include <sys/socket.h> 38#include <sys/socketvar.h> 39#include <sys/sysctl.h> 40#include <sys/queue.h> |
41#include <sys/un.h> | |
42 43#include <netinet/in.h> 44 45#include <assert.h> 46#include <ctype.h> 47#include <err.h> 48#include <libprocstat.h> 49#include <limits.h> --- 170 unchanged lines hidden (view full) --- 220 procstat_freefiles(procstat, head); 221} 222 223 224static void 225print_file_info(struct procstat *procstat, struct filestat *fst, 226 const char *uname, const char *cmd, int pid) 227{ | 41 42#include <netinet/in.h> 43 44#include <assert.h> 45#include <ctype.h> 46#include <err.h> 47#include <libprocstat.h> 48#include <limits.h> --- 170 unchanged lines hidden (view full) --- 219 procstat_freefiles(procstat, head); 220} 221 222 223static void 224print_file_info(struct procstat *procstat, struct filestat *fst, 225 const char *uname, const char *cmd, int pid) 226{ |
228 struct sockstat sock; | |
229 struct vnstat vn; 230 DEVS *d; 231 const char *filename; 232 int error, fsmatch = 0; 233 char errbuf[_POSIX2_LINE_MAX]; 234 | 227 struct vnstat vn; 228 DEVS *d; 229 const char *filename; 230 int error, fsmatch = 0; 231 char errbuf[_POSIX2_LINE_MAX]; 232 |
235 error = 0; | |
236 filename = NULL; 237 if (checkfile != 0) { | 233 filename = NULL; 234 if (checkfile != 0) { |
238 switch (fst->fs_type) { 239 case PS_FST_TYPE_VNODE: 240 case PS_FST_TYPE_FIFO: 241 error = procstat_get_vnode_info(procstat, fst, &vn, errbuf); 242 break; 243 case PS_FST_TYPE_SOCKET: 244 error = procstat_get_socket_info(procstat, fst, &sock, errbuf); 245 break; 246 default: | 235 if (fst->fs_type != PS_FST_TYPE_VNODE && 236 fst->fs_type != PS_FST_TYPE_FIFO) |
247 return; | 237 return; |
248 } | 238 error = procstat_get_vnode_info(procstat, fst, &vn, errbuf); |
249 if (error != 0) 250 return; 251 252 for (d = devs; d != NULL; d = d->next) | 239 if (error != 0) 240 return; 241 242 for (d = devs; d != NULL; d = d->next) |
253 switch (fst->fs_type) { 254 case PS_FST_TYPE_VNODE: 255 case PS_FST_TYPE_FIFO: 256 if (d->fsid == vn.vn_fsid) { 257 fsmatch = 1; 258 if ((unsigned)d->ino == vn.vn_fileid) { 259 filename = d->name; 260 break; 261 } | 243 if (d->fsid == vn.vn_fsid) { 244 fsmatch = 1; 245 if ((unsigned)d->ino == vn.vn_fileid) { 246 filename = d->name; 247 break; |
262 } | 248 } |
263 break; 264 case PS_FST_TYPE_SOCKET: 265 if (sock.dom_family == AF_UNIX) { 266 fsmatch = 1; 267 if (strcmp(((struct sockaddr_un *) 268 (&sock.sa_local))->sun_path, 269 d->name) == 0) { 270 filename = d->name; 271 break; 272 } 273 } 274 break; | |
275 } 276 if (fsmatch == 0 || (filename == NULL && fsflg == 0)) 277 return; 278 } 279 280 /* 281 * Print entry prefix. 282 */ --- 253 unchanged lines hidden --- | 249 } 250 if (fsmatch == 0 || (filename == NULL && fsflg == 0)) 251 return; 252 } 253 254 /* 255 * Print entry prefix. 256 */ --- 253 unchanged lines hidden --- |