kern_jail.c (116182) | kern_jail.c (124882) |
---|---|
1/* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 */ 9 10#include <sys/cdefs.h> | 1/* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 */ 9 10#include <sys/cdefs.h> |
11__FBSDID("$FreeBSD: head/sys/kern/kern_jail.c 116182 2003-06-11 00:56:59Z obrien $"); | 11__FBSDID("$FreeBSD: head/sys/kern/kern_jail.c 124882 2004-01-23 20:44:26Z rwatson $"); |
12 13#include <sys/param.h> 14#include <sys/types.h> 15#include <sys/kernel.h> 16#include <sys/systm.h> 17#include <sys/errno.h> 18#include <sys/sysproto.h> 19#include <sys/malloc.h> 20#include <sys/proc.h> | 12 13#include <sys/param.h> 14#include <sys/types.h> 15#include <sys/kernel.h> 16#include <sys/systm.h> 17#include <sys/errno.h> 18#include <sys/sysproto.h> 19#include <sys/malloc.h> 20#include <sys/proc.h> |
21#include <sys/taskqueue.h> |
|
21#include <sys/jail.h> 22#include <sys/lock.h> 23#include <sys/mutex.h> 24#include <sys/namei.h> 25#include <sys/queue.h> 26#include <sys/socket.h> 27#include <sys/syscallsubr.h> 28#include <sys/sysctl.h> --- 26 unchanged lines hidden (view full) --- 55 56/* allprison, lastprid, and prisoncount are protected by allprison_mtx. */ 57struct prisonlist allprison; 58struct mtx allprison_mtx; 59int lastprid = 0; 60int prisoncount = 0; 61 62static void init_prison(void *); | 22#include <sys/jail.h> 23#include <sys/lock.h> 24#include <sys/mutex.h> 25#include <sys/namei.h> 26#include <sys/queue.h> 27#include <sys/socket.h> 28#include <sys/syscallsubr.h> 29#include <sys/sysctl.h> --- 26 unchanged lines hidden (view full) --- 56 57/* allprison, lastprid, and prisoncount are protected by allprison_mtx. */ 58struct prisonlist allprison; 59struct mtx allprison_mtx; 60int lastprid = 0; 61int prisoncount = 0; 62 63static void init_prison(void *); |
64static void prison_complete(void *context, int pending); |
|
63static struct prison *prison_find(int); 64static int sysctl_jail_list(SYSCTL_HANDLER_ARGS); 65 66static void 67init_prison(void *data __unused) 68{ 69 70 mtx_init(&allprison_mtx, "allprison", NULL, MTX_DEF); --- 179 unchanged lines hidden (view full) --- 250 } 251 return (NULL); 252} 253 254void 255prison_free(struct prison *pr) 256{ 257 | 65static struct prison *prison_find(int); 66static int sysctl_jail_list(SYSCTL_HANDLER_ARGS); 67 68static void 69init_prison(void *data __unused) 70{ 71 72 mtx_init(&allprison_mtx, "allprison", NULL, MTX_DEF); --- 179 unchanged lines hidden (view full) --- 252 } 253 return (NULL); 254} 255 256void 257prison_free(struct prison *pr) 258{ 259 |
258 mtx_assert(&Giant, MA_OWNED); | |
259 mtx_lock(&allprison_mtx); 260 mtx_lock(&pr->pr_mtx); 261 pr->pr_ref--; 262 if (pr->pr_ref == 0) { 263 LIST_REMOVE(pr, pr_list); 264 mtx_unlock(&pr->pr_mtx); 265 prisoncount--; 266 mtx_unlock(&allprison_mtx); | 260 mtx_lock(&allprison_mtx); 261 mtx_lock(&pr->pr_mtx); 262 pr->pr_ref--; 263 if (pr->pr_ref == 0) { 264 LIST_REMOVE(pr, pr_list); 265 mtx_unlock(&pr->pr_mtx); 266 prisoncount--; 267 mtx_unlock(&allprison_mtx); |
267 vrele(pr->pr_root); 268 mtx_destroy(&pr->pr_mtx); 269 if (pr->pr_linux != NULL) 270 FREE(pr->pr_linux, M_PRISON); 271 FREE(pr, M_PRISON); | 268 269 TASK_INIT(&pr->pr_task, 0, prison_complete, pr); 270 taskqueue_enqueue(taskqueue_swi, &pr->pr_task); |
272 return; 273 } 274 mtx_unlock(&pr->pr_mtx); 275 mtx_unlock(&allprison_mtx); 276} 277 | 271 return; 272 } 273 mtx_unlock(&pr->pr_mtx); 274 mtx_unlock(&allprison_mtx); 275} 276 |
277static void 278prison_complete(void *context, int pending) 279{ 280 struct prison *pr; 281 282 pr = (struct prison *)context; 283 284 mtx_lock(&Giant); 285 vrele(pr->pr_root); 286 mtx_unlock(&Giant); 287 288 mtx_destroy(&pr->pr_mtx); 289 if (pr->pr_linux != NULL) 290 FREE(pr->pr_linux, M_PRISON); 291 FREE(pr, M_PRISON); 292} 293 |
|
278void 279prison_hold(struct prison *pr) 280{ 281 282 mtx_lock(&pr->pr_mtx); 283 pr->pr_ref++; 284 mtx_unlock(&pr->pr_mtx); 285} --- 164 unchanged lines hidden --- | 294void 295prison_hold(struct prison *pr) 296{ 297 298 mtx_lock(&pr->pr_mtx); 299 pr->pr_ref++; 300 mtx_unlock(&pr->pr_mtx); 301} --- 164 unchanged lines hidden --- |