diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-17 23:11:33 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-17 23:11:33 +0000 |
commit | 25ea8c8a69576ca14e0d418bcc7d03b82db24db2 (patch) | |
tree | d9af0722d8761b2c04ddf3def6874033dfd44219 /sys/kern/kern_sysctl.c | |
parent | a6dcb6be4019c0f02edd62f13fbb5737a42598aa (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 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7cfc0910383..cd07eeb4ae7 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.75 2002/09/01 11:35:52 art Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.76 2002/12/17 23:11:31 millert Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -256,11 +256,22 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) #endif /* all sysctl names at this level are terminal except a ton of them */ - if (namelen != 1 && !(name[0] == KERN_PROC || name[0] == KERN_PROF || - name[0] == KERN_MALLOCSTATS || name[0] == KERN_TTY || - name[0] == KERN_POOL || name[0] == KERN_SYSVIPC_INFO || - name[0] == KERN_PROC_ARGS)) - return (ENOTDIR); /* overloaded */ + if (namelen != 1) { + switch (name[0]) { + case KERN_PROC: + case KERN_PROF: + case KERN_MALLOCSTATS: + case KERN_TTY: + case KERN_POOL: + case KERN_PROC_ARGS: + case KERN_SYSVIPC_INFO: + case KERN_SEMINFO: + case KERN_SHMINFO: + break; + default: + return (ENOTDIR); /* overloaded */ + } + } switch (name[0]) { case KERN_OSTYPE: @@ -455,6 +466,16 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case KERN_SPLASSERT: return (sysctl_int(oldp, oldlenp, newp, newlen, &splassert_ctl)); +#ifdef SYSVSEM + case KERN_SEMINFO: + return (sysctl_sysvsem(name + 1, namelen - 1, oldp, oldlenp, + newp, newlen)); +#endif +#ifdef SYSVSHM + case KERN_SHMINFO: + return (sysctl_sysvshm(name + 1, namelen - 1, oldp, oldlenp, + newp, newlen)); +#endif default: return (EOPNOTSUPP); } @@ -1395,12 +1416,20 @@ sysctl_sysvipc(name, namelen, where, sizep) #endif #ifdef SYSVSEM case KERN_SYSVIPC_SEM_INFO: - bcopy(&sema[i], &semsi->semids[i], dssize); + if (sema[i] != NULL) + bcopy(sema[i], &semsi->semids[i], + dssize); + else + bzero(&semsi->semids[i], dssize); break; #endif #ifdef SYSVSHM case KERN_SYSVIPC_SHM_INFO: - bcopy(&shmsegs[i], &shmsi->shmids[i], dssize); + if (shmsegs[i] != NULL) + bcopy(shmsegs[i], &shmsi->shmids[i], + dssize); + else + bzero(&shmsi->shmids[i], dssize); break; #endif } |