MCPcopy Create free account
hub / github.com/F-Stack/f-stack / unixpr

Function unixpr

tools/netstat/unix.c:201–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199#endif
200
201void
202unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
203 u_long sphead_off, bool *first)
204{
205 char *buf;
206 int ret, type;
207 struct xsocket *so;
208 struct xunpgen *xug, *oxug;
209 struct xunpcb *xunp;
210#ifndef FSTACK
211 u_long head_off;
212#endif
213
214 buf = NULL;
215 for (type = SOCK_STREAM; type <= SOCK_SEQPACKET; type++) {
216 if (live)
217 ret = pcblist_sysctl(type, &buf);
218 else {
219#ifndef FSTACK
220 head_off = 0;
221 switch (type) {
222 case SOCK_STREAM:
223 head_off = shead_off;
224 break;
225
226 case SOCK_DGRAM:
227 head_off = dhead_off;
228 break;
229
230 case SOCK_SEQPACKET:
231 head_off = sphead_off;
232 break;
233 }
234 ret = pcblist_kvm(count_off, gencnt_off, head_off,
235 &buf);
236#endif
237 }
238 if (ret == -1)
239 continue;
240 if (ret < 0)
241 return;
242
243 oxug = xug = (struct xunpgen *)buf;
244 for (xug = (struct xunpgen *)((char *)xug + xug->xug_len);
245 xug->xug_len > sizeof(struct xunpgen);
246 xug = (struct xunpgen *)((char *)xug + xug->xug_len)) {
247 xunp = (struct xunpcb *)xug;
248 so = &xunp->xu_socket;
249
250 /* Ignore PCBs which were freed during copyout. */
251 if (xunp->unp_gencnt > oxug->xug_gen)
252 continue;
253 if (*first) {
254 xo_open_list("socket");
255 *first = false;
256 }
257 xo_open_instance("socket");
258 unixdomainpr(xunp, so);

Callers 1

main.cFile · 0.85

Calls 8

pcblist_kvmFunction · 0.85
xo_open_listFunction · 0.85
xo_open_instanceFunction · 0.85
unixdomainprFunction · 0.85
xo_close_instanceFunction · 0.85
xo_emitFunction · 0.85
pcblist_sysctlFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected