summaryrefslogtreecommitdiff
path: root/sbin/sysctl
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-12-17 23:11:33 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-12-17 23:11:33 +0000
commit25ea8c8a69576ca14e0d418bcc7d03b82db24db2 (patch)
treed9af0722d8761b2c04ddf3def6874033dfd44219 /sbin/sysctl
parenta6dcb6be4019c0f02edd62f13fbb5737a42598aa (diff)
Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data structures via valloc() in allocsys(), allocate things dynamically using pool(9) when possible and malloc(9) when not. The various members of struct seminfo and struct shminfo are in kern.seminfo and kern.shminfo respectively (not all members of kern.seminfo are changable). The data structures used still leave something to be desired but things are not made worse in that respect by this commit.
Diffstat (limited to 'sbin/sysctl')
-rw-r--r--sbin/sysctl/sysctl.824
-rw-r--r--sbin/sysctl/sysctl.c74
2 files changed, 93 insertions, 5 deletions
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8
index 912817eb280..a10afeead75 100644
--- a/sbin/sysctl/sysctl.8
+++ b/sbin/sysctl/sysctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sysctl.8,v 1.91 2002/11/25 03:04:48 wcobb Exp $
+.\" $OpenBSD: sysctl.8,v 1.92 2002/12/17 23:11:32 millert Exp $
.\" $NetBSD: sysctl.8,v 1.4 1995/09/30 07:12:49 thorpej Exp $
.\"
.\" Copyright (c) 1993
@@ -123,6 +123,7 @@ privilege can change the value.
.It kern.nchstats struct no
.It kern.forkstat struct no
.It kern.somaxconn integer yes
+.It kern.somaxconn integer yes
.It kern.sominconn integer yes
.It kern.usermount integer yes
.It kern.random struct no
@@ -153,6 +154,20 @@ privilege can change the value.
.It kern.ttycount integer no
.It kern.numvnodes integer no
.It kern.mbstat struct no
+.It kern.seminfo.semmni integer yes
+.It kern.seminfo.semmns integer yes
+.It kern.seminfo.semmnu integer yes
+.It kern.seminfo.semmsl integer yes
+.It kern.seminfo.semopm integer yes
+.It kern.seminfo.semume integer no
+.It kern.seminfo.semusz integer no
+.It kern.seminfo.semvmx integer no
+.It kern.seminfo.semaem integer no
+.It kern.shminfo.shmmax integer yes
+.It kern.shminfo.shmmin integer yes
+.It kern.shminfo.shmmni integer yes
+.It kern.shminfo.shmseg integer yes
+.It kern.shminfo.shmall integer yes
.It vm.loadavg struct no
.It vm.psstrings struct no
.It vm.swapencrypt.enable integer yes
@@ -397,6 +412,13 @@ See
and
.Xr nfsd 8
for futher discussion.
+.Pp
+To set the amount of shared memory available in the system and
+the maximum number of shared memory segments:
+.Bd -literal noffset indent
+# sysctl -w kern.shminfo.shmmax=33554432
+# sysctl -w kern.shminfo.shmseg=32
+.Ed
.Sh FILES
.Bl -tag -width <ufs/ffs/ffs_extern.h> -compact
.It Pa <sys/sysctl.h>
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 89d1c4d2e40..114c7d1d21c 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.84 2002/07/06 19:14:20 nordin Exp $ */
+/* $OpenBSD: sysctl.c,v 1.85 2002/12/17 23:11:32 millert Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -35,16 +35,16 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
-static char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95";
+static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95";
#else
-static char *rcsid = "$OpenBSD: sysctl.c,v 1.84 2002/07/06 19:14:20 nordin Exp $";
+static char *rcsid = "$OpenBSD: sysctl.c,v 1.85 2002/12/17 23:11:32 millert Exp $";
#endif
#endif /* not lint */
@@ -52,6 +52,8 @@ static char *rcsid = "$OpenBSD: sysctl.c,v 1.84 2002/07/06 19:14:20 nordin Exp $
#include <sys/gmon.h>
#include <sys/mount.h>
#include <sys/stat.h>
+#include <sys/sem.h>
+#include <sys/shm.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <sys/malloc.h>
@@ -128,6 +130,8 @@ struct ctlname kernmallocname[] = CTL_KERN_MALLOC_NAMES;
struct ctlname forkstatname[] = CTL_KERN_FORKSTAT_NAMES;
struct ctlname nchstatsname[] = CTL_KERN_NCHSTATS_NAMES;
struct ctlname ttyname[] = CTL_KERN_TTY_NAMES;
+struct ctlname semname[] = CTL_KERN_SEMINFO_NAMES;
+struct ctlname shmname[] = CTL_KERN_SHMINFO_NAMES;
struct ctlname *vfsname;
#ifdef CTL_MACHDEP_NAMES
struct ctlname machdepname[] = CTL_MACHDEP_NAMES;
@@ -199,6 +203,8 @@ int sysctl_forkstat(char *, char **, int *, int, int *);
int sysctl_tty(char *, char **, int *, int, int *);
int sysctl_nchstats(char *, char **, int *, int, int *);
int sysctl_malloc(char *, char **, int *, int, int *);
+int sysctl_seminfo(char *, char **, int *, int, int *);
+int sysctl_shminfo(char *, char **, int *, int, int *);
#ifdef CPU_CHIPSET
int sysctl_chipset(char *, char **, int *, int, int *);
#endif
@@ -403,6 +409,16 @@ parse(char *string, int flags)
special |= LONGARRAY;
lal = CPUSTATES;
break;
+ case KERN_SEMINFO:
+ len = sysctl_seminfo(string, &bufp, mib, flags, &type);
+ if (len < 0)
+ return;
+ break;
+ case KERN_SHMINFO:
+ len = sysctl_shminfo(string, &bufp, mib, flags, &type);
+ if (len < 0)
+ return;
+ break;
}
break;
@@ -1319,6 +1335,8 @@ struct list kernmalloclist = { kernmallocname, KERN_MALLOC_MAXID };
struct list forkstatlist = { forkstatname, KERN_FORKSTAT_MAXID };
struct list nchstatslist = { nchstatsname, KERN_NCHSTATS_MAXID };
struct list ttylist = { ttyname, KERN_TTY_MAXID };
+struct list semlist = { semname, KERN_SEMINFO_MAXID };
+struct list shmlist = { shmname, KERN_SHMINFO_MAXID };
/*
* handle vfs namei cache statistics
@@ -1785,6 +1803,54 @@ sysctl_ipx(char *string, char **bufpp, int mib[], int flags, int *typep)
}
/*
+ * Handle SysV semaphore info requests
+ */
+int
+sysctl_seminfo(string, bufpp, mib, flags, typep)
+ char *string;
+ char **bufpp;
+ int mib[];
+ int flags;
+ int *typep;
+{
+ int indx;
+
+ if (*bufpp == NULL) {
+ listall(string, &semlist);
+ return(-1);
+ }
+ if ((indx = findname(string, "third", bufpp, &semlist)) == -1)
+ return(-1);
+ mib[2] = indx;
+ *typep = CTLTYPE_INT;
+ return(3);
+}
+
+/*
+ * Handle SysV shared memory info requests
+ */
+int
+sysctl_shminfo(string, bufpp, mib, flags, typep)
+ char *string;
+ char **bufpp;
+ int mib[];
+ int flags;
+ int *typep;
+{
+ int indx;
+
+ if (*bufpp == NULL) {
+ listall(string, &shmlist);
+ return(-1);
+ }
+ if ((indx = findname(string, "third", bufpp, &shmlist)) == -1)
+ return(-1);
+ mib[2] = indx;
+ *typep = CTLTYPE_INT;
+ return(3);
+}
+
+/*
* Scan a list of names searching for a particular name.
*/
int