FreeBSD/usr.sbin/mountd/mountd.c
/*
 * Traverse the binary tree either updating a node that is already there
 * for the new directory or adding the new node.
 */
Traverse the binary tree either updating a node that is already there
for the new directory or adding the new node.
Traverse the binary tree either updating a node that is already there for the new directory or adding the new node .
static void
add_dlist(struct dirlist **dpp, struct dirlist *newdp, struct grouplist *grp,
	int flags, struct exportlist *ep)
{
	struct dirlist *dp;
	struct hostlist *hp;
	int cmp;
	dp = *dpp;
	if (dp) {
		cmp = strcmp(dp->dp_dirp, newdp->dp_dirp);
		if (cmp > 0) {
			add_dlist(&dp->dp_left, newdp, grp, flags, ep);
			return;
		} else if (cmp < 0) {
			add_dlist(&dp->dp_right, newdp, grp, flags, ep);
			return;
		} else
			free((caddr_t)newdp);
	} else {
		dp = newdp;
		dp->dp_left = (struct dirlist *)NULL;
		*dpp = dp;
	}
	if (grp) {
		do {
			hp = get_ht();
			hp->ht_grp = grp;
			hp->ht_next = dp->dp_hosts;
			dp->dp_hosts = hp;
			grp->gr_numsecflavors = ep->ex_numsecflavors;
			if (ep->ex_numsecflavors > 0)
				memcpy(grp->gr_secflavors, ep->ex_secflavors,
				    sizeof(ep->ex_secflavors));
			grp = grp->gr_next;
		} while (grp);
	} else {
		dp->dp_flag |= DP_DEFSET;
		ep->ex_defnumsecflavors = ep->ex_numsecflavors;
		if (ep->ex_numsecflavors > 0)
			memcpy(ep->ex_defsecflavors, ep->ex_secflavors,
			    sizeof(ep->ex_secflavors));
	}
}
static void add_dlist ( struct dirlist * * dpp , struct dirlist * newdp , struct grouplist * grp , int flags , struct exportlist * ep ) { struct dirlist * dp ; struct hostlist * hp ; int cmp ; dp = * dpp ; if ( dp ) { cmp = strcmp ( dp -> dp_dirp , newdp -> dp_dirp ) ; if ( cmp > 0 ) { add_dlist ( & dp -> dp_left , newdp , grp , flags , ep ) ; return ; } else if ( cmp < 0 ) { add_dlist ( & dp -> dp_right , newdp , grp , flags , ep ) ; return ; } else free ( ( caddr_t ) newdp ) ; } else { dp = newdp ; dp -> dp_left = ( struct dirlist * ) NULL ; * dpp = dp ; } if ( grp ) { do { hp = get_ht ( ) ; hp -> ht_grp = grp ; hp -> ht_next = dp -> dp_hosts ; dp -> dp_hosts = hp ; grp -> gr_numsecflavors = ep -> ex_numsecflavors ; if ( ep -> ex_numsecflavors > 0 ) memcpy ( grp -> gr_secflavors , ep -> ex_secflavors , sizeof ( ep -> ex_secflavors ) ) ; grp = grp -> gr_next ; } while ( grp ) ; } else { dp -> dp_flag |= DP_DEFSET ; ep -> ex_defnumsecflavors = ep -> ex_numsecflavors ; if ( ep -> ex_numsecflavors > 0 ) memcpy ( ep -> ex_defsecflavors , ep -> ex_secflavors , sizeof ( ep -> ex_secflavors ) ) ; } }
Traverse the binary tree either updating a node that is already there
 for the new directory or adding the new node.
Traverse the binary tree either updating a node that is already there for the new directory or adding the new node .
/*
		 * Hang all of the host(s) off of the directory point.
		 */ /* Save the security flavors list for this host set. */ /* Save the default security flavors list. */