Date: Sun, 27 Aug 2006 09:20:45 GMT From: Alex Lyashkov <als@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 105170 for review Message-ID: <200608270920.k7R9KjoI004620@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=105170 Change 105170 by als@als_head on 2006/08/27 09:20:22 export task count limit Affected files ... .. //depot/projects/jail2/j2_tools/jctl/jctl.c#3 edit .. //depot/projects/jail2/sys/kern/kern_jail2_common.c#2 edit .. //depot/projects/jail2/sys/sys/jail2.h#4 edit Differences ... ==== //depot/projects/jail2/j2_tools/jctl/jctl.c#3 (text+ko) ==== @@ -74,7 +74,7 @@ printf("CPU limits\t%u:%u\n", jst->cpulow, jst->cpuhigh); printf("CPU usage\t%u\n", jst->cpuusage); printf("\t\tallocate limit\n"); - printf("Task count %u \n", jst->taskcount); + printf("Tasks %u %u\n", jst->taskcount, jst->tasklimit); printf("Message queue %u %u\n", jst->msq_count, jst->msq_limit); printf("Semaphore %u %u\n", jst->sem_count, jst->sem_limit); printf("Shared segments %u %u\n", jst->shm_count, jst->shm_limit); ==== //depot/projects/jail2/sys/kern/kern_jail2_common.c#2 (text+ko) ==== @@ -46,9 +46,9 @@ { struct prison *pr = NULL; int ret = 0; - + jprint("jail2_command %d ctx: %d \n", JAIL2_CMD(j->cmd), j->ctx_id); - + if (JAIL2_CMD(j->cmd) != J_CREATE) { mtx_lock(&allprison_mtx); pr = prison_find(j->ctx_id); @@ -58,7 +58,7 @@ return (ESRCH); } } - + switch(JAIL2_CMD(j->cmd)) { case J_CREATE: { @@ -102,23 +102,25 @@ case J_SETFLAGS: { uint32_t flags; - + ret = copyin(j->data, &flags, sizeof(flags)); if (ret) return (ret); - + JAIL_SET_FLAGS(pr, flags); break; } case J_STATS: { struct jail2_stats st; - + memset(&st,0,sizeof(st)); st.version = JAIL2_STATS_VER; st.id = pr->pr_id; st.v1.flags = JAIL_GET_FLAGS(pr); + /* */ st.v1.taskcount = JAIL_NPROCS(pr); + st.v1.tasklimit = JAIL_MAXPROC(pr); /* */ st.v1.msq_count = JAIL_IPC_MSG_GETCOUNT(pr); st.v1.msq_limit = JAIL_IPC_MSG_GETLIMIT(pr); @@ -128,167 +130,20 @@ st.v1.shm_limit = JAIL_IPC_SHM_GETLIMIT(pr); /* */ st.v1.fdcount = JAIL_FILE_GETCOUNT(pr); - st.v1.fdlimit = JAIL_FILE_GETLIMIT(pr); + st.v1.fdlimit = JAIL_FILE_GETLIMIT(pr); ret = copyout(&st,j->data,sizeof(st)); - + break; } default: ret = EOPNOTSUPP; break; } - + /* remove refs from find/create */ if (pr!=NULL) - prison_free(pr); - jprint("jail2_command return %d\n", ret); - return (ret); -} -/* - * Copyright (c) 2004 Alex Lyashkov <shadow@psoft.net> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/systm.h> -#include <sys/lock.h> -#include <sys/mutex.h> - -#include <sys/jail.h> -#include <sys/jail2.h> -#include <sys/jail2_flags.h> -#include <sys/jail2_file.h> - -#define jprint(a...) -/* printf(a) */ - -int jail2_common(struct thread *td, struct jail_2 *j) -{ - struct prison *pr = NULL; - int ret = 0; - - jprint("jail2_command %d ctx: %d \n", JAIL2_CMD(j->cmd), j->ctx_id); - - if (JAIL2_CMD(j->cmd) != J_CREATE) { - mtx_lock(&allprison_mtx); - pr = prison_find(j->ctx_id); - mtx_unlock(&allprison_mtx); - if (pr == NULL) { - printf("Prison not found for command %x\n", j->cmd); - return (ESRCH); - } - } - - switch(JAIL2_CMD(j->cmd)) { - case J_CREATE: - { - /* not found - create */ - pr = prison_alloc(j->ctx_id); - jprint("prison_alloc return %p\n",pr); - if (pr == NULL) { - ret = ENOMEM; - break; - } - prison_hold(pr); - break; - } - case J_DESTROY: - { - /* remove hold */ prison_free(pr); - break; - } - case J_ENTER: - { - ret = suser(td); - if (ret) { - ret = EPERM; - break; - } - - ret = jail_migrate(td, pr); - break; - } - case J_START: - { - JAIL_SET_STARTED(pr); - break; - } - case J_STOP: - { - JAIL_CLEAR_STARTED(pr); - break; - } - case J_SETFLAGS: - { - uint32_t flags; - - ret = copyin(j->data, &flags, sizeof(flags)); - if (ret) - return (ret); - - JAIL_SET_FLAGS(pr, flags); - break; - } - case J_STATS: - { - struct jail2_stats st; - - memset(&st,0,sizeof(st)); - st.version = JAIL2_STATS_VER; - st.id = pr->pr_id; - st.v1.flags = JAIL_GET_FLAGS(pr); - st.v1.taskcount = JAIL_NPROCS(pr); - /* */ - st.v1.msq_count = JAIL_IPC_MSG_GETCOUNT(pr); - st.v1.msq_limit = JAIL_IPC_MSG_GETLIMIT(pr); - st.v1.sem_count = JAIL_IPC_SEM_GETCOUNT(pr); - st.v1.sem_limit = JAIL_IPC_SEM_GETLIMIT(pr); - st.v1.shm_count = JAIL_IPC_SHM_GETCOUNT(pr); - st.v1.shm_limit = JAIL_IPC_SHM_GETLIMIT(pr); - /* */ - st.v1.fdcount = JAIL_FILE_GETCOUNT(pr); - st.v1.fdlimit = JAIL_FILE_GETLIMIT(pr); - - ret = copyout(&st,j->data,sizeof(st)); - - break; - } - default: - ret = EOPNOTSUPP; - break; - } - - /* remove refs from find/create */ - if (pr!=NULL) - prison_free(pr); jprint("jail2_command return %d\n", ret); return (ret); } ==== //depot/projects/jail2/sys/sys/jail2.h#4 (text+ko) ==== @@ -12,6 +12,7 @@ uint32_t flags; /* Task & CPU */ uint32_t taskcount; + uint32_t tasklimit; uint32_t cpulow; uint32_t cpuhigh; uint32_t cpuusage;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608270920.k7R9KjoI004620>