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

Function sysctl_register_oid

freebsd/kern/kern_sysctl.c:423–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

421#endif
422
423void
424sysctl_register_oid(struct sysctl_oid *oidp)
425{
426 struct sysctl_oid_list *parent = oidp->oid_parent;
427 struct sysctl_oid *p;
428 struct sysctl_oid *q;
429 int oid_number;
430 int timeout = 2;
431
432 /*
433 * First check if another oid with the same name already
434 * exists in the parent's list.
435 */
436 SYSCTL_ASSERT_WLOCKED();
437 p = sysctl_find_oidname(oidp->oid_name, parent);
438 if (p != NULL) {
439 if ((p->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
440 p->oid_refcnt++;
441 return;
442 } else {
443 sysctl_warn_reuse(__func__, p);
444 return;
445 }
446 }
447 /* get current OID number */
448 oid_number = oidp->oid_number;
449
450#if (OID_AUTO >= 0)
451#error "OID_AUTO is expected to be a negative value"
452#endif
453 /*
454 * Any negative OID number qualifies as OID_AUTO. Valid OID
455 * numbers should always be positive.
456 *
457 * NOTE: DO NOT change the starting value here, change it in
458 * <sys/sysctl.h>, and make sure it is at least 256 to
459 * accommodate e.g. net.inet.raw as a static sysctl node.
460 */
461 if (oid_number < 0) {
462 static int newoid;
463
464 /*
465 * By decrementing the next OID number we spend less
466 * time inserting the OIDs into a sorted list.
467 */
468 if (--newoid < CTL_AUTO_START)
469 newoid = 0x7fffffff;
470
471 oid_number = newoid;
472 }
473
474 /*
475 * Insert the OID into the parent's list sorted by OID number.
476 */
477retry:
478 q = NULL;
479 SLIST_FOREACH(p, parent, oid_link) {
480 /* check if the current OID number is in use */

Callers 7

vfs_registerFunction · 0.85
sysctl_ctx_freeFunction · 0.85
sysctl_add_oidFunction · 0.85
sysctl_move_oidFunction · 0.85
sysctl_register_allFunction · 0.85

Calls 5

sysctl_find_oidnameFunction · 0.85
sysctl_warn_reuseFunction · 0.85
panicFunction · 0.70
printfFunction · 0.70

Tested by

no test coverage detected