PERFORCE change 102786 for review
Alex Lyashkov
als at FreeBSD.org
Sun Jul 30 13:14:52 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=102786
Change 102786 by als at 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
More information about the p4-projects
mailing list