1 .\" Copyright (c) 2011 Sergey Kandaurov <pluknet@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm procstat_open_kvm ,
32 .Nm procstat_open_sysctl ,
34 .Nm procstat_getfiles ,
35 .Nm procstat_getprocs ,
36 .Nm procstat_freefiles ,
37 .Nm procstat_freeprocs ,
38 .Nm procstat_get_pipe_info ,
39 .Nm procstat_get_pts_info ,
40 .Nm procstat_get_socket_info ,
41 .Nm procstat_get_vnode_info
42 .Nd library interface for file and process information retrieval
50 .Fn procstat_close "struct procstat *procstat"
52 .Fo procstat_freefiles
53 .Fa "struct procstat *procstat"
54 .Fa "struct filestat_list *head"
57 .Fn procstat_freeprocs "struct procstat *procstat" "struct kinfo_proc *p"
59 .Fo procstat_get_pipe_info
60 .Fa "struct procstat *procstat"
61 .Fa "struct filestat *fst"
62 .Fa "struct pipestat *pipe"
66 .Fo procstat_get_pts_info
67 .Fa "struct procstat *procstat"
68 .Fa "struct filestat *fst"
69 .Fa "struct ptsstat *pts"
73 .Fo procstat_get_socket_info
74 .Fa "struct procstat *procstat"
75 .Fa "struct filestat *fst"
76 .Fa "struct sockstat *sock"
80 .Fo procstat_get_vnode_info
81 .Fa "struct procstat *procstat"
82 .Fa "struct filestat *fst"
83 .Fa "struct vnstat *vn"
86 .Ft "struct filestat_list *"
88 .Fa "struct procstat *procstat"
89 .Fa "struct kinfo_proc *kp"
92 .Ft "struct kinfo_proc *"
94 .Fa "struct procstat *procstat"
97 .Fa "unsigned int *count"
99 .Ft "struct procstat *"
100 .Fn procstat_open_kvm "const char *nlistf" "const char *memf"
101 .Ft "struct procstat *"
102 .Fn procstat_open_sysctl void
106 library contains the API for runtime file and process information
107 retrieval from the running kernel via the
109 library backend, and for post-mortem analysis via the
114 .Fn procstat_open_kvm
116 .Fn procstat_open_sysctl
121 library routines, respectively, to access kernel state information
122 used to retrieve processes and files states.
125 argument is the executable image of the kernel being examined.
128 the currently running kernel is assumed.
131 argument is the kernel memory device file.
140 Both functions dynamically allocate and return a
142 structure pointer used in the rest of the
144 library routines until the corresponding
146 call that cleans up the resources allocated by the
151 .Fn procstat_getprocs
152 function gets a pointer to the
154 structure from one of the
156 functions and returns a dynamically allocated (sub-)set of active processes
157 in the kernel filled in to array of
164 arguments constitute a filtering predicate as described in the
167 The number of processes found is returned in the reference parameter
169 The caller is responsible to free the allocated memory with a subsequent
170 .Fn procstat_freeprocs
174 .Fn procstat_getfiles
175 function gets a pointer to the
177 structure initialized with one of the
179 functions, a pointer to
181 structure from the array obtained from the
183 function, and returns a dynamically allocated linked list of filled in
185 structures using the STAILQ macros defined in
187 The caller is responsible to free the allocated memory with a subsequent
188 .Fn procstat_freefiles
192 .Fn procstat_get_pipe_info ,
193 .Fn procstat_get_pts_info ,
194 .Fn procstat_get_socket_info
196 .Fn procstat_get_vnode_info
197 functions are used to retrive information about pipes, pseudo-terminals,
198 sockets, and vnodes, respectively.
199 Each of them have a similar interface API.
202 argument is a pointer obtained from one of
207 argument is an element of STAILQ linked list as obtained from the
208 .Fn procstat_getfiles
214 field that specifies a file type and a corresponding function to be
216 .Nm procstat_get_*_info
218 The actual object is returned in the 3rd reference parameter.
221 argument indicates an actual error message in case of failure.
223 .Bl -tag -width 20n -compact -offset indent
224 .It Li PS_FST_TYPE_FIFO
225 .Nm procstat_get_vnode_info
226 .It Li PS_FST_TYPE_VNODE
227 .Nm procstat_get_vnode_info
228 .It Li PS_FST_TYPE_SOCKET
229 .Nm procstat_get_socket_info
230 .It Li PS_FST_TYPE_PIPE
231 .Nm procstat_get_pipe_info
232 .It Li PS_FST_TYPE_PTS
233 .Nm procstat_get_pts_info
254 library was written by
255 .An Stanislav Sedov Aq stas@FreeBSD.org .
257 This manual page was written by
258 .An Sergey Kandaurov Aq pluknet@FreeBSD.org .