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

Function prison_find

freebsd/kern/kern_jail.c:2544–2566  ·  view source on GitHub ↗

* Returns a locked prison instance, or NULL on failure. */

Source from the content-addressed store, hash-verified

2542 * Returns a locked prison instance, or NULL on failure.
2543 */
2544struct prison *
2545prison_find(int prid)
2546{
2547 struct prison *pr;
2548
2549 sx_assert(&allprison_lock, SX_LOCKED);
2550 TAILQ_FOREACH(pr, &allprison, pr_list) {
2551 if (pr->pr_id == prid) {
2552 mtx_lock(&pr->pr_mtx);
2553 if (prison_isvalid(pr))
2554 return (pr);
2555 /*
2556 * Any active prison with the same ID would have
2557 * been inserted before a dead one.
2558 */
2559 mtx_unlock(&pr->pr_mtx);
2560 break;
2561 }
2562 if (pr->pr_id > prid)
2563 break;
2564 }
2565 return (NULL);
2566}
2567
2568/*
2569 * Find a prison that is a descendant of mypr. Returns a locked prison or NULL.

Callers 2

zone_dataset_attachFunction · 0.85
zone_dataset_detachFunction · 0.85

Calls 3

prison_isvalidFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected