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

Function prison_find_name

freebsd/kern/kern_jail.c:2592–2622  ·  view source on GitHub ↗

* Look for the name relative to mypr. Returns a locked prison or NULL. */

Source from the content-addressed store, hash-verified

2590 * Look for the name relative to mypr. Returns a locked prison or NULL.
2591 */
2592struct prison *
2593prison_find_name(struct prison *mypr, const char *name)
2594{
2595 struct prison *pr, *deadpr;
2596 size_t mylen;
2597 int descend;
2598
2599 sx_assert(&allprison_lock, SX_LOCKED);
2600 mylen = (mypr == &prison0) ? 0 : strlen(mypr->pr_name) + 1;
2601 again:
2602 deadpr = NULL;
2603 FOREACH_PRISON_DESCENDANT(mypr, pr, descend) {
2604 if (!strcmp(pr->pr_name + mylen, name)) {
2605 mtx_lock(&pr->pr_mtx);
2606 if (prison_isalive(pr))
2607 return (pr);
2608 if (prison_isvalid(pr))
2609 deadpr = pr;
2610 mtx_unlock(&pr->pr_mtx);
2611 }
2612 }
2613 /* There was no valid prison - perhaps there was a dying one. */
2614 if (deadpr != NULL) {
2615 mtx_lock(&deadpr->pr_mtx);
2616 if (!prison_isvalid(deadpr)) {
2617 mtx_unlock(&deadpr->pr_mtx);
2618 goto again;
2619 }
2620 }
2621 return (deadpr);
2622}
2623
2624/*
2625 * See if a prison has the specific flag set. The prison should be locked,

Callers 2

kern_jail_setFunction · 0.85
kern_jail_getFunction · 0.85

Calls 5

strcmpFunction · 0.85
prison_isaliveFunction · 0.85
prison_isvalidFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected