Exemplo n.º 1
0
void sysctl_register_oid(struct sysctl_oid *oidp)
{
	struct sysctl_oid_list *parent = oidp->oid_parent;
	struct sysctl_oid *p;
	struct sysctl_oid *q;
	int n;
	funnel_t *fnl;

	fnl = spl_kernel_funnel();

	/*
	 * If this oid has a number OID_AUTO, give it a number which
	 * is greater than any current oid.  Make sure it is at least
	 * 100 to leave space for pre-assigned oid numbers.
	 */
/*	sysctl_sysctl_debug_dump_node(parent, 3); */
	if (oidp->oid_number == OID_AUTO) {
		/* First, find the highest oid in the parent list >99 */
		n = 99;
		SLIST_FOREACH(p, parent, oid_link) {
			if (p->oid_number > n)
				n = p->oid_number;
		}
		oidp->oid_number = n + 1;
	}
Exemplo n.º 2
0
void sysctl_register_oid(struct sysctl_oid *oidp)
{
	struct sysctl_oid_list *parent = oidp->oid_parent;
	struct sysctl_oid *p;
	struct sysctl_oid *q;
	int n;
	funnel_t *fnl;

	fnl = spl_kernel_funnel();

	if(sysctl_geometry_lock == NULL)
	{
		/* Initialise the geometry lock for reading/modifying the sysctl tree
		 * This is done here because IOKit registers some sysctls before bsd_init()
		 * calls sysctl_register_fixed().
		 */

		lck_grp_t* lck_grp  = lck_grp_alloc_init("sysctl", NULL);
		sysctl_geometry_lock = lck_rw_alloc_init(lck_grp, NULL);
	}
	/* Get the write lock to modify the geometry */
	lck_rw_lock_exclusive(sysctl_geometry_lock);

	/*
	 * If this oid has a number OID_AUTO, give it a number which
	 * is greater than any current oid.  Make sure it is at least
	 * OID_AUTO_START to leave space for pre-assigned oid numbers.
	 */
	if (oidp->oid_number == OID_AUTO) {
		/* First, find the highest oid in the parent list >OID_AUTO_START-1 */
		n = OID_AUTO_START;
		SLIST_FOREACH(p, parent, oid_link) {
			if (p->oid_number > n)
				n = p->oid_number;
		}
		oidp->oid_number = n + 1;
	}