1/* 2 * dstore.c - Darwin global storage for /dev/kmem-based lsof 3 */ 4 5 6/* 7 * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana 8 * 47907. All rights reserved. 9 * 10 * Written by Victor A. Abell 11 * 12 * This software is not subject to any license of the American Telephone 13 * and Telegraph Company or the Regents of the University of California. 14 * 15 * Permission is granted to anyone to use this software for any purpose on 16 * any computer system, and to alter it and redistribute it freely, subject 17 * to the following restrictions: 18 * 19 * 1. Neither the authors nor Purdue University are responsible for any 20 * consequences of the use of this software. 21 * 22 * 2. The origin of this software must not be misrepresented, either by 23 * explicit claim or by omission. Credit to the authors and Purdue 24 * University must appear in documentation and sources. 25 * 26 * 3. Altered versions must be plainly marked as such, and must not be 27 * misrepresented as being the original software. 28 * 29 * 4. This notice may not be removed or altered. 30 */ 31 32#ifndef lint 33static char copyright[] = 34"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n"; 35static char *rcsid = "$Id: dstore.c,v 1.5 2005/11/01 20:24:51 abe Exp $"; 36#endif 37 38 39#include "lsof.h" 40 41struct file *Cfp; /* curent file's file struct pointer */ 42 43 44/* 45 * Drive_Nl -- table to drive the building of Nl[] via build_Nl() 46 * (See lsof.h and misc.c.) 47 */ 48 49struct drive_Nl Drive_Nl[] = { 50 51 { "aproc", "_allproc" }, 52 { "nproc", "_nprocs" }, 53 { X_NCACHE, "_nchashtbl" }, 54 { X_NCSIZE, "_nchash" }, 55 { "", "" }, 56 { NULL, NULL } 57}; 58 59int Kd = -1; /* KMEM descriptor */ 60KA_T Kpa; /* kernel proc struct address */ 61struct l_vfs *Lvfs = NULL; /* local vfs structure table */ 62 63int Np = 0; /* number of kernel processes */ 64 65struct kinfo_proc *P = NULL; /* local process table copy */ 66 67#if defined(HASFSTRUCT) 68/* 69 * Pff_tab[] - table for printing file flags 70 */ 71 72struct pff_tab Pff_tab[] = { 73 { (long)FREAD, FF_READ }, 74 { (long)FWRITE, FF_WRITE }, 75 { (long)FNONBLOCK, FF_NBLOCK }, 76 { (long)FNDELAY, FF_NDELAY }, 77 { (long)FAPPEND, FF_APPEND }, 78 { (long)FASYNC, FF_ASYNC }, 79 { (long)FFSYNC, FF_FSYNC }, 80 { (long)FMARK, FF_MARK }, 81 { (long)FDEFER, FF_DEFER }, 82 { (long)FHASLOCK, FF_HASLOCK }, 83 { (long)O_NOCTTY, FF_NOCTTY }, 84 { (long)O_EVTONLY, FF_EVTONLY }, 85 { (long)0, NULL } 86}; 87 88 89/* 90 * Pof_tab[] - table for print process open file flags 91 */ 92 93struct pff_tab Pof_tab[] = { 94 95# if defined(UF_EXCLOSE) 96 { (long)UF_EXCLOSE, POF_CLOEXEC }, 97# endif /* defined(UF_EXCLOSE) */ 98 99# if defined(UF_MAPPED) 100 { (long)UF_MAPPED, POF_MAPPED }, 101# endif /* defined(UF_MAPPED) */ 102 103 { (long)0, NULL } 104}; 105#endif /* defined(HASFSTRUCT) */ 106