diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-08-21 18:56:08 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-08-21 18:56:08 +0000 |
commit | 0d5b09054c67f03f088bb749fe3b1e53819a82d8 (patch) | |
tree | 5bcf3c6fc7e2695399f960b2ccabc5ae6cdc7bca /sys/kern/kern_sysctl.c | |
parent | 07999a2beca07715a2095b080aa2444ef6cf1b67 (diff) |
emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index a15d511470b..b75ad814560 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.85 2003/08/15 20:32:18 tedu Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.86 2003/08/21 18:56:07 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -92,6 +92,7 @@ int sysctl_diskinit(int, struct proc *); int sysctl_proc_args(int *, u_int, void *, size_t *, struct proc *); int sysctl_intrcnt(int *, u_int, void *, size_t *); int sysctl_sensors(int *, u_int, void *, size_t *, void *, size_t); +int sysctl_emul(int *, u_int, void *, size_t *, void *, size_t); /* * Lock to avoid too many processes vslocking a large amount of memory @@ -268,6 +269,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case KERN_SHMINFO: case KERN_INTRCNT: case KERN_WATCHDOG: + case KERN_EMUL: break; default: return (ENOTDIR); /* overloaded */ @@ -482,6 +484,9 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case KERN_WATCHDOG: return (sysctl_wdog(name + 1, namelen - 1, oldp, oldlenp, newp, newlen)); + case KERN_EMUL: + return (sysctl_emul(name + 1, namelen - 1, oldp, oldlenp, + newp, newlen)); default: return (EOPNOTSUPP); } @@ -1516,3 +1521,40 @@ sysctl_sensors(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (sysctl_rdstruct(oldp, oldlenp, newp, s, sizeof(struct sensor))); } + +int +sysctl_emul(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + int enabled, error; + struct emul *e; + + if (name[0] == KERN_EMUL_NUM) { + if (namelen != 1) + return (ENOTDIR); + return (sysctl_rdint(oldp, oldlenp, newp, nemuls)); + } + + if (namelen != 2) + return (ENOTDIR); + if (name[0] > nemuls || name[0] < 0) + return (EINVAL); + e = emulsw[name[0] - 1]; + + switch (name[1]) { + case KERN_EMUL_NAME: + return (sysctl_rdstring(oldp, oldlenp, newp, e->e_name)); + case KERN_EMUL_ENABLED: + if (e->e_flags & EMUL_NATIVE) + return (sysctl_rdint(oldp, oldlenp, newp, 1)); + else { + enabled = (e->e_flags & EMUL_ENABLED); + error = sysctl_int(oldp, oldlenp, newp, newlen, + &enabled); + e->e_flags |= (enabled & EMUL_ENABLED); + return (error); + } + default: + return (EINVAL); + } +} |