FreeBSD/sys/compat/linux/linux_mib.c
/*
 * Ensure a prison has its own Linux info.  If lprp is non-null, point it to
 * the Linux info and lock the prison.
 */
Ensure a prison has its own Linux info.  If lprp is non-null, point it to
the Linux info and lock the prison.
Ensure a prison has its own Linux info . If lprp is non - null point it to the Linux info and lock the prison .
static void
linux_alloc_prison(struct prison *pr, struct linux_prison **lprp)
{
	struct prison *ppr;
	struct linux_prison *lpr, *nlpr;
	void **rsv;
	lpr = linux_find_prison(pr, &ppr);
	if (ppr == pr)
		goto done;
	mtx_unlock(&ppr->pr_mtx);
	nlpr = malloc(sizeof(struct linux_prison), M_PRISON, M_WAITOK);
	rsv = osd_reserve(linux_osd_jail_slot);
	lpr = linux_find_prison(pr, &ppr);
	if (ppr == pr) {
		free(nlpr, M_PRISON);
		osd_free_reserved(rsv);
		goto done;
	}
	mtx_lock(&pr->pr_mtx);
	(void)osd_jail_set_reserved(pr, linux_osd_jail_slot, rsv, nlpr);
	bcopy(lpr, nlpr, sizeof(*lpr));
	lpr = nlpr;
	mtx_unlock(&ppr->pr_mtx);
 done:
	if (lprp != NULL)
		*lprp = lpr;
	else
		mtx_unlock(&pr->pr_mtx);
}
static void linux_alloc_prison ( struct prison * pr , struct linux_prison * * lprp ) { struct prison * ppr ; struct linux_prison * lpr , * nlpr ; void * * rsv ; lpr = linux_find_prison ( pr , & ppr ) ; if ( ppr == pr ) goto done ; mtx_unlock ( & ppr -> pr_mtx ) ; nlpr = malloc ( sizeof ( struct linux_prison ) , M_PRISON , M_WAITOK ) ; rsv = osd_reserve ( linux_osd_jail_slot ) ; lpr = linux_find_prison ( pr , & ppr ) ; if ( ppr == pr ) { free ( nlpr , M_PRISON ) ; osd_free_reserved ( rsv ) ; goto done ; } mtx_lock ( & pr -> pr_mtx ) ; ( void ) osd_jail_set_reserved ( pr , linux_osd_jail_slot , rsv , nlpr ) ; bcopy ( lpr , nlpr , sizeof ( * lpr ) ) ; lpr = nlpr ; mtx_unlock ( & ppr -> pr_mtx ) ; done : if ( lprp != NULL ) * lprp = lpr ; else mtx_unlock ( & pr -> pr_mtx ) ; }
Ensure a prison has its own Linux info.
Ensure a prison has its own Linux info .
/* If this prison already has Linux info, return that. */ /*
	 * Allocate a new info record.  Then check again, in case something
	 * changed during the allocation.
	 */ /* Inherit the initial values from the ancestor. */