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

Function sysctl_search_oid

freebsd/kern/kern_sysctl.c:349–378  ·  view source on GitHub ↗

* Locate the path to a given oid. Returns the length of the resulting path, * or -1 if the oid was not found. nodes must have room for CTL_MAXNAME * elements and be NULL initialized. */

Source from the content-addressed store, hash-verified

347 * elements and be NULL initialized.
348 */
349static int
350sysctl_search_oid(struct sysctl_oid **nodes, struct sysctl_oid *needle)
351{
352 int indx;
353
354 SYSCTL_ASSERT_LOCKED();
355 indx = 0;
356 while (indx < CTL_MAXNAME && indx >= 0) {
357 if (nodes[indx] == NULL && indx == 0)
358 nodes[indx] = SLIST_FIRST(&sysctl__children);
359 else if (nodes[indx] == NULL)
360 nodes[indx] = SLIST_FIRST(&nodes[indx - 1]->oid_children);
361 else
362 nodes[indx] = SLIST_NEXT(nodes[indx], oid_link);
363
364 if (nodes[indx] == needle)
365 return (indx + 1);
366
367 if (nodes[indx] == NULL) {
368 indx--;
369 continue;
370 }
371
372 if ((nodes[indx]->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
373 indx++;
374 continue;
375 }
376 }
377 return (-1);
378}
379
380static void
381sysctl_warn_reuse(const char *func, struct sysctl_oid *leaf)

Callers 1

sysctl_warn_reuseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected