PERFORCE change 99916 for review

Alex Lyashkov als at FreeBSD.org
Sat Jun 24 07:39:21 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=99916

Change 99916 by als at als_head on 2006/06/24 07:38:50

	Update copyright.

Affected files ...

.. //depot/projects/jail2/sys/kern/kern_jail2_resource.c#2 edit

Differences ...

==== //depot/projects/jail2/sys/kern/kern_jail2_resource.c#2 (text+ko) ====

@@ -1,160 +1,5 @@
 /*
- * Copyright (c) 2004 Alex Lyashkov <shadow at 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/namei.h>
-#include <sys/vnode.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/sx.h>
-
-#include <sys/jail.h>
-#include <sys/jail2.h>
-
-#include <machine/atomic.h>
-
-#define jprint(a...)
-/* printf(a) */
-
-static int 
-jail_setproclimit(struct prison *_pr, void *_data)
-{
-    int error;
-    int limit;
-    
-    error = copyin(_data, &limit, sizeof(limit));
-    if (error)
-	return (error);
-    
-    sx_xlock(&allproc_lock);
-    _pr->pr_tasks.jt_limit = limit;
-    sx_xunlock(&allproc_lock);
-    
-    if (limit != 0)
-	JAIL_SET_PROCLIM(_pr);
-    else
-    	JAIL_CLEAR_PROCLIM(_pr);
-    
-    return (0);
-}
-
-static int 
-jail_setresource_int(uint32_t *res, void *_data)
-{
-    int error;
-    int limit;
-    
-    error = copyin(_data, &limit, sizeof(limit));
-    if (error)
-	return (error);
-    
-    atomic_store_rel_int(res, limit);
-
-    return (0);
-}
-
-
-int jail2_resource(struct thread *_td, struct jail_2 *_j)
-{
-    struct prison *pr;
-    int ret = 0;
-	
-    mtx_lock(&allprison_mtx);
-    pr = prison_find(_j->ctx_id);
-    mtx_unlock(&allprison_mtx);
-
-    jprint("jail2_resouce %d ctx: %d pr: %p\n", JAIL2_CMD(_j->cmd), _j->ctx_id, pr );
-    if (pr == NULL) {
-	printf("Prison not found for command %x\n", _j->cmd);
-	return (ESRCH);
-    }
-
-    switch(JAIL2_CMD(_j->cmd)) {
-    case J_SETVROOT:
-	if (JAIL_VROOT(pr) != NULL) {
-	    if (JAIL_NPROCS(pr) != 0) {
-		ret = EPERM;
-		break;
-	    }
-	    jail_destroyvroot(pr);
-	}
-	ret = jail_setvroot(pr, _td, _j->data);
-	break;
-    case J_SETPROCLIMIT:
-	ret = jail_setproclimit(pr, _j->data);
-	break;
-    case J_SETUSEDSPACE:
-	ret = jail_setresource_int(&pr->pr_disk.pr_du, _j->data);
-	break;
-    case J_SETDISKQUOTE:
-	ret = jail_setresource_int(&pr->pr_disk.pr_l_du, _j->data);
-	break;
-    case J_INODEUSAGE:
-	ret = jail_setresource_int(&pr->pr_disk.pr_inodes, _j->data);
-	break;
-    case J_INODELIMIT:
-	ret = jail_setresource_int(&pr->pr_disk.pr_l_inodes, _j->data);
-	break;
-    case J_MSQLIMIT:
-    	ret = jail_setresource_int(&pr->pr_ipc.msq_limit, _j->data);
-	break;
-    case J_SEMLIMIT:
-    	ret = jail_setresource_int(&pr->pr_ipc.sem_limit, _j->data);
-	break;
-    case J_SHMLIMIT:
-    	ret = jail_setresource_int(&pr->pr_ipc.shm_limit, _j->data);
-	break;
-    case J_SETFILELIMIT:
-    	ret = jail_setresource_int(&pr->pr_limits.fdlimit, _j->data);
-	break;
-    case J_SETMEMLIMIT:
-    case J_SETRSSLIMIT:
-    case J_SETTCPSOCKETSLIMIT:
-    case J_SETUDPSOCKETSLIMIT:
-    case J_CPUHARDLIMIT:
-    case J_CPUSOFTLIMIT:
-    default:
-	ret = EOPNOTSUPP;
-	break;
-    }
-
-    /* remove refs from find/create */
-    prison_free (pr); 
-    jprint("jail2_resouce return %d\n", ret);
-    return (ret);
-
-}
-/*
- * Copyright (c) 2004 Alex Lyashkov <shadow at psoft.net>
+ * Copyright (c) 2004-2006 Alex Lyashkov <shadow at itt.net.ru>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without


More information about the p4-projects mailing list