diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 12:02:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 12:02:44 +0000 |
commit | 21e131dd4839d744742b615f61b0d3ace455fe11 (patch) | |
tree | 83657f14cdfe7819ab1adecaea3813bef54d2865 /sys/compat/common | |
parent | d3c0e996ee9caa0a77ccb7378d4acc77326d58ae (diff) |
sync
Diffstat (limited to 'sys/compat/common')
-rw-r--r-- | sys/compat/common/Makefile | 6 | ||||
-rw-r--r-- | sys/compat/common/Makefile.inc | 8 | ||||
-rw-r--r-- | sys/compat/common/compat_exec.c | 189 | ||||
-rw-r--r-- | sys/compat/common/kern_info_43.c | 95 | ||||
-rw-r--r-- | sys/compat/common/tty_43.c | 11 |
5 files changed, 301 insertions, 8 deletions
diff --git a/sys/compat/common/Makefile b/sys/compat/common/Makefile index 100a36d00d2..d8871fcb934 100644 --- a/sys/compat/common/Makefile +++ b/sys/compat/common/Makefile @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile,v 1.4 1996/03/03 05:26:21 mickey Exp $ -# $NetBSD: Makefile,v 1.7 1996/02/05 01:58:28 christos Exp $ +# $OpenBSD: Makefile,v 1.5 1996/05/22 12:01:44 deraadt Exp $ +# $NetBSD: Makefile,v 1.8 1996/05/18 15:52:19 christos Exp $ LIB= compat NOPIC= @@ -8,7 +8,7 @@ CPPFLAGS= ${COMPATCPPFLAGS:S/-I./-I${COMPATREL}./g} .PATH: ${COMPATREL}${COMPATDIR} -SRCS= compat_util.c kern_exit_43.c kern_info_09.c \ +SRCS= compat_exec.c compat_util.c kern_exit_43.c kern_info_09.c \ kern_info_43.c kern_prot_43.c kern_resource_43.c kern_sig_43.c \ tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c diff --git a/sys/compat/common/Makefile.inc b/sys/compat/common/Makefile.inc index 032e72e56b5..e6f6a879b72 100644 --- a/sys/compat/common/Makefile.inc +++ b/sys/compat/common/Makefile.inc @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile.inc,v 1.3 1996/03/03 05:26:22 mickey Exp $ -# $NetBSD: Makefile.inc,v 1.3 1996/02/02 20:34:44 mycroft Exp $ +# $OpenBSD: Makefile.inc,v 1.4 1996/05/22 12:01:44 deraadt Exp $ +# $NetBSD: Makefile.inc,v 1.4 1996/05/11 16:13:31 mycroft Exp $ # # NOTE: $S must correspond to the top of the 'sys' tree @@ -30,5 +30,9 @@ clean:: .NOTMAIN __always_make_compatlib @echo cleaning the compat library objects @${COMPATMAKE} clean +depend:: .NOTMAIN __always_make_compatlib + @echo depending the compat library objects + @${COMPATMAKE} depend + __always_make_compatlib: .NOTMAIN @mkdir -p ${COMPATDST} diff --git a/sys/compat/common/compat_exec.c b/sys/compat/common/compat_exec.c new file mode 100644 index 00000000000..f745710a92f --- /dev/null +++ b/sys/compat/common/compat_exec.c @@ -0,0 +1,189 @@ +/* $NetBSD: compat_exec.c,v 1.1 1996/05/18 15:52:21 christos Exp $ */ + +/* + * Copyright (c) 1993, 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> +#include <sys/malloc.h> +#include <sys/vnode.h> +#include <sys/exec.h> +#include <sys/resourcevar.h> +#include <vm/vm.h> + +/* + * exec_aout_prep_oldzmagic(): + * Prepare the vmcmds to build a vmspace for an old ZMAGIC + * binary. [386BSD/BSDI/4.4BSD/NetBSD0.8] + * + * Cloned from exec_aout_prep_zmagic() in kern/exec_aout.c; a more verbose + * description of operation is there. + * There were copies of this in the mac68k, hp300, and i386 ports. + */ +int +exec_aout_prep_oldzmagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct exec *execp = epp->ep_hdr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->a_text; + epp->ep_daddr = epp->ep_taddr + execp->a_text; + epp->ep_dsize = execp->a_data + execp->a_bss; + epp->ep_entry = execp->a_entry; + + /* + * check if vnode is in open for writing, because we want to + * demand-page out of it. if it is, don't do it, for various + * reasons + */ + if ((execp->a_text != 0 || execp->a_data != 0) && + epp->ep_vp->v_writecount != 0) { +#ifdef DIAGNOSTIC + if (epp->ep_vp->v_flag & VTEXT) + panic("exec: a VTEXT vnode has writecount != 0\n"); +#endif + return ETXTBSY; + } + epp->ep_vp->v_flag |= VTEXT; + + /* set up command for text segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text, + epp->ep_taddr, epp->ep_vp, NBPG, /* XXX should NBPG be CLBYTES? */ + VM_PROT_READ|VM_PROT_EXECUTE); + + /* set up command for data segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_data, + epp->ep_daddr, epp->ep_vp, + execp->a_text + NBPG, /* XXX should NBPG be CLBYTES? */ + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, + epp->ep_daddr + execp->a_data, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return exec_aout_setup_stack(p, epp); +} + + +/* + * exec_aout_prep_oldnmagic(): + * Prepare the vmcmds to build a vmspace for an old NMAGIC + * binary. [BSDI] + * + * Cloned from exec_aout_prep_nmagic() in kern/exec_aout.c; with text starting + * at 0. + * XXX: There must be a better way to share this code. + */ +int +exec_aout_prep_oldnmagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct exec *execp = epp->ep_hdr; + long bsize, baddr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->a_text; + epp->ep_daddr = roundup(epp->ep_taddr + execp->a_text, __LDPGSZ); + epp->ep_dsize = execp->a_data + execp->a_bss; + epp->ep_entry = execp->a_entry; + + /* set up command for text segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_text, + epp->ep_taddr, epp->ep_vp, sizeof(struct exec), + VM_PROT_READ|VM_PROT_EXECUTE); + + /* set up command for data segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_data, + epp->ep_daddr, epp->ep_vp, execp->a_text + sizeof(struct exec), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = roundup(epp->ep_daddr + execp->a_data, NBPG); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return exec_aout_setup_stack(p, epp); +} + + +/* + * exec_aout_prep_oldomagic(): + * Prepare the vmcmds to build a vmspace for an old OMAGIC + * binary. [BSDI] + * + * Cloned from exec_aout_prep_omagic() in kern/exec_aout.c; with text starting + * at 0. + * XXX: There must be a better way to share this code. + */ +int +exec_aout_prep_oldomagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct exec *execp = epp->ep_hdr; + long dsize, bsize, baddr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->a_text; + epp->ep_daddr = epp->ep_taddr + execp->a_text; + epp->ep_dsize = execp->a_data + execp->a_bss; + epp->ep_entry = execp->a_entry; + + /* set up command for text and data segments */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, + execp->a_text + execp->a_data, epp->ep_taddr, epp->ep_vp, + sizeof(struct exec), VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = roundup(epp->ep_daddr + execp->a_data, NBPG); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* + * Make sure (# of pages) mapped above equals (vm_tsize + vm_dsize); + * obreak(2) relies on this fact. Both `vm_tsize' and `vm_dsize' are + * computed (in execve(2)) by rounding *up* `ep_tsize' and `ep_dsize' + * respectively to page boundaries. + * Compensate `ep_dsize' for the amount of data covered by the last + * text page. + */ + dsize = epp->ep_dsize + execp->a_text - roundup(execp->a_text, NBPG); + epp->ep_dsize = (dsize > 0) ? dsize : 0; + return exec_aout_setup_stack(p, epp); +} diff --git a/sys/compat/common/kern_info_43.c b/sys/compat/common/kern_info_43.c index d5e1da49527..6cb8c297fcc 100644 --- a/sys/compat/common/kern_info_43.c +++ b/sys/compat/common/kern_info_43.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_info_43.c,v 1.5 1996/03/03 05:26:23 mickey Exp $ */ +/* $OpenBSD: kern_info_43.c,v 1.6 1996/05/22 12:01:45 deraadt Exp $ */ /* $NetBSD: kern_info_43.c,v 1.5 1996/02/04 02:02:22 christos Exp $ */ /* @@ -109,6 +109,40 @@ compat_43_sys_gethostname(p, v, retval) #define KINFO_METER (4<<8) #define KINFO_LOADAVG (5<<8) #define KINFO_CLOCKRATE (6<<8) +#define KINFO_BSDI_SYSINFO (101<<8) + + +/* + * The string data is appended to the end of the bsdi_si structure during + * copyout. The "char *" offsets in the bsdi_si struct are relative to the + * base of the bsdi_si struct. + */ +struct bsdi_si { + char *machine; + char *cpu_model; + long ncpu; + long cpuspeed; + long hwflags; + u_long physmem; + u_long usermem; + u_long pagesize; + + char *ostype; + char *osrelease; + long os_revision; + long posix1_version; + char *version; + + long hz; + long profhz; + int ngroups_max; + long arg_max; + long open_max; + long child_max; + + struct timeval boottime; + char *hostname; +}; /* Non-standard BSDI extension - only present on their 4.3 net-2 releases */ #define KINFO_BSDI_SYSINFO (101<<8) @@ -195,6 +229,65 @@ compat_43_sys_getkerninfo(p, v, retval) kern_sysctl(name, 1, SCARG(uap, where), &size, NULL, 0, p); break; + + case KINFO_BSDI_SYSINFO: + { + size_t len; + struct bsdi_si *usi = + (struct bsdi_si *) SCARG(uap, where); + struct bsdi_si ksi; + char *us = (char *) &usi[1]; + extern struct timeval boottime; + extern char ostype[], osrelease[], machine[], + hostname[], cpu_model[], version[]; + + if (usi == NULL) { + size = sizeof(ksi) + + strlen(ostype) + strlen(cpu_model) + + strlen(osrelease) + strlen(machine) + + strlen(version) + strlen(hostname) + 6; + error = 0; + break; + } + +#define COPY(fld) \ + ksi.fld = us - (u_long) usi; \ + if ((error = copyoutstr(fld, us, 1024, &len)) != 0)\ + return error; \ + us += len + + COPY(machine); + COPY(cpu_model); + ksi.ncpu = 1; /* XXX */ + ksi.cpuspeed = 40; /* XXX */ + ksi.hwflags = 0; /* XXX */ + ksi.physmem = ctob(physmem); + ksi.usermem = ctob(physmem); /* XXX */ + ksi.pagesize = PAGE_SIZE; + + COPY(ostype); + COPY(osrelease); + ksi.os_revision = NetBSD; /* XXX */ + ksi.posix1_version = _POSIX_VERSION; + COPY(version); /* XXX */ + + ksi.hz = hz; + ksi.profhz = profhz; + ksi.ngroups_max = NGROUPS_MAX; + ksi.arg_max = ARG_MAX; + ksi.open_max = OPEN_MAX; + ksi.child_max = CHILD_MAX; + + ksi.boottime = boottime; + COPY(hostname); + + size = (us - (char *) &usi[1]) + sizeof(ksi); + + if ((error = copyout(&ksi, usi, sizeof(ksi))) != 0) + return error; + } + break; + case KINFO_PROC: name[0] = KERN_PROC; name[1] = SCARG(uap, op) & 0xff; diff --git a/sys/compat/common/tty_43.c b/sys/compat/common/tty_43.c index 6da912cc228..96e32d7af2d 100644 --- a/sys/compat/common/tty_43.c +++ b/sys/compat/common/tty_43.c @@ -1,5 +1,5 @@ -/* $OpenBSD: tty_43.c,v 1.2 1996/04/18 21:21:34 niklas Exp $ */ -/* $NetBSD: tty_43.c,v 1.3 1996/03/14 19:31:49 christos Exp $ */ +/* $OpenBSD: tty_43.c,v 1.3 1996/05/22 12:01:46 deraadt Exp $ */ +/* $NetBSD: tty_43.c,v 1.4 1996/05/18 22:17:49 veego Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -51,6 +51,11 @@ #include <sys/syslog.h> #include <sys/ioctl_compat.h> +/* + * XXX libcompat files should be included with config attributes + */ +#ifdef COMPAT_OLDTTY + int ttydebug = 0; static struct speedtab compatspeeds[] = { @@ -475,3 +480,5 @@ ttcompatsetlflags(tp, t) t->c_lflag = lflag; t->c_cflag = cflag; } + +#endif /* COMPAT_OLDTTY */ |