From owner-p4-projects@FreeBSD.ORG Sun Jul 30 13:14:52 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AB88B16A4E1; Sun, 30 Jul 2006 13:14:52 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6F01F16A4DA for ; Sun, 30 Jul 2006 13:14:52 +0000 (UTC) (envelope-from als@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 374A643D46 for ; Sun, 30 Jul 2006 13:14:52 +0000 (GMT) (envelope-from als@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6UDEqs7059335 for ; Sun, 30 Jul 2006 13:14:52 GMT (envelope-from als@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6UDEqUB059332 for perforce@freebsd.org; Sun, 30 Jul 2006 13:14:52 GMT (envelope-from als@FreeBSD.org) Date: Sun, 30 Jul 2006 13:14:52 GMT Message-Id: <200607301314.k6UDEqUB059332@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to als@FreeBSD.org using -f From: Alex Lyashkov To: Perforce Change Reviews Cc: Subject: PERFORCE change 102786 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jul 2006 13:14:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=102786 Change 102786 by als@als_head on 2006/07/30 13:14:32 Virtualize kern.maxfiles & kern.openfiles. now it show datas from context limits. kern.maxfiles - fd limit, if limit don`t set - show system maxfiles limit. kern.openfiles - show current prison fd usage. Affected files ... .. //depot/projects/jail2/sys/kern/kern_descrip.c#3 edit Differences ... ==== //depot/projects/jail2/sys/kern/kern_descrip.c#3 (text+ko) ==== @@ -2589,11 +2589,60 @@ SYSCTL_INT(_kern, KERN_MAXFILESPERPROC, maxfilesperproc, CTLFLAG_RW, &maxfilesperproc, 0, "Maximum files allowed open per process"); +#ifdef JAIL + +static int +sysctl_jail_maxfiles(SYSCTL_HANDLER_ARGS) +{ + struct prison *jail = req->td->td_ucred->cr_prison; + int error; + int32_t maxfile = JAIL_FILE_GETLIMIT(jail); + + if (maxfile == 0) { + maxfile = maxfiles; + } + error = SYSCTL_OUT(req, &maxfile, sizeof(int)); + if (error || req->newptr == NULL) + return (error); + if (jail != &jail_0) + return (EPERM); + + /* Read in and verify the new value. */ + error = SYSCTL_IN(req, &maxfile, sizeof(int)); + if (error) + return (error); + if (maxfile <= 0) + return (EINVAL); + maxfiles = maxfile; + return (0); + +} + +SYSCTL_PROC(_kern, OID_AUTO, maxfiles, CTLTYPE_INT | CTLFLAG_RW, + NULL, 0, sysctl_jail_maxfiles, "I", "Maximum number of files"); + + +static int +sysctl_jail_openfile(SYSCTL_HANDLER_ARGS) +{ + struct prison *jail = req->td->td_ucred->cr_prison; + uint32_t fdcount = JAIL_FILE_GETCOUNT(jail); + + return SYSCTL_OUT(req, &fdcount, sizeof(int)); +} + +SYSCTL_PROC(_kern, OID_AUTO, openfiles, CTLTYPE_INT | CTLFLAG_RD, + NULL, 0, sysctl_jail_openfile, "I", "System-wide number of open files"); + +#else + SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW, &maxfiles, 0, "Maximum number of files"); SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD, &openfiles, 0, "System-wide number of open files"); + +#endif /* ARGSUSED*/ static void