diff options
author | 1996-05-22 11:58:41 +0000 | |
---|---|---|
committer | 1996-05-22 11:58:41 +0000 | |
commit | 403e97cc9b0949a4c2322a793ceadcff7c9b191f (patch) | |
tree | 58a8c2bc07f5ec8d6327b21216bd1f2aa2bd67fe | |
parent | unload after last close (diff) | |
download | wireguard-openbsd-403e97cc9b0949a4c2322a793ceadcff7c9b191f.tar.xz wireguard-openbsd-403e97cc9b0949a4c2322a793ceadcff7c9b191f.zip |
sync
-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 | ||||
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.c | 4 | ||||
-rw-r--r-- | sys/compat/linux/linux_file.c | 19 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 56 | ||||
-rw-r--r-- | sys/compat/linux/linux_syscall.h | 7 | ||||
-rw-r--r-- | sys/compat/linux/linux_syscallargs.h | 17 | ||||
-rw-r--r-- | sys/compat/linux/linux_syscalls.c | 17 | ||||
-rw-r--r-- | sys/compat/linux/linux_sysent.c | 34 | ||||
-rw-r--r-- | sys/compat/linux/linux_types.h | 14 | ||||
-rw-r--r-- | sys/compat/linux/syscalls.master | 19 | ||||
-rw-r--r-- | sys/netccitt/if_x25subr.c | 6 | ||||
-rw-r--r-- | sys/netiso/if_eon.c | 6 | ||||
-rw-r--r-- | sys/netns/ns_ip.c | 6 | ||||
-rw-r--r-- | sys/scsi/ss_scanjet.c | 183 |
18 files changed, 634 insertions, 63 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 */ diff --git a/sys/compat/freebsd/freebsd_exec.c b/sys/compat/freebsd/freebsd_exec.c index 1d7f27d26b5..a960efe614a 100644 --- a/sys/compat/freebsd/freebsd_exec.c +++ b/sys/compat/freebsd/freebsd_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: freebsd_exec.c,v 1.1 1995/10/10 01:19:27 mycroft Exp $ */ +/* $NetBSD: freebsd_exec.c,v 1.2 1996/05/18 16:02:08 christos Exp $ */ /* * Copyright (c) 1993, 1994 Christopher G. Demetriou @@ -91,7 +91,7 @@ exec_freebsd_aout_makecmds(p, epp) /* assume FreeBSD's MID_MACHINE and [ZQNO]MAGIC is same as NetBSD's */ switch (midmag) { case (MID_MACHINE << 16) | ZMAGIC: - error = cpu_exec_aout_prep_oldzmagic(p, epp); + error = exec_aout_prep_oldzmagic(p, epp); break; case (MID_MACHINE << 16) | QMAGIC: error = exec_aout_prep_zmagic(p, epp); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 92f2858088f..3a940f6e702 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1,5 +1,5 @@ -/* $OpenBSD: linux_file.c,v 1.2 1996/04/17 05:23:49 mickey Exp $ */ -/* $NetBSD: linux_file.c,v 1.14 1996/04/05 00:01:21 christos Exp $ */ +/* $OpenBSD: linux_file.c,v 1.3 1996/05/22 12:01:48 deraadt Exp $ */ +/* $NetBSD: linux_file.c,v 1.15 1996/05/20 01:59:09 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -806,3 +806,18 @@ linux_sys_truncate(p, v, retval) return compat_43_sys_truncate(p, uap, retval); } + +/* + * This is just fsync() for now (just as it is in the Linux kernel) + */ +int +linux_sys_fdatasync(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct linux_sys_fdatasync_args /* { + syscallarg(int) fd; + } */ *uap = v; + return sys_fsync(p, v, retval); +} diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 57bef416c1c..fc5e17a87a0 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: linux_misc.c,v 1.4 1996/04/17 05:23:54 mickey Exp $ */ -/* $NetBSD: linux_misc.c,v 1.26 1996/04/04 23:56:01 christos Exp $ */ +/* $OpenBSD: linux_misc.c,v 1.5 1996/05/22 12:01:48 deraadt Exp $ */ +/* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -1111,3 +1111,55 @@ linux_sys_setregid(p, v, retval) return compat_43_sys_setregid(p, &bsa, retval); } + +int +linux_sys_getsid(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct linux_sys_getsid_args /* { + syscallarg(int) pid; + } */ *uap = v; + struct proc *p1; + pid_t pid; + + pid = (pid_t)SCARG(uap, pid); + + if (pid == 0) { + retval[0] = (int)p->p_session; /* XXX Oh well */ + return 0; + } + + p1 = pfind((int)pid); + if (p1 == NULL) + return ESRCH; + + retval[0] = (int)p1->p_session; + return 0; +} + +int +linux_sys___sysctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct linux_sys___sysctl_args /* { + syscallarg(struct linux___sysctl *) lsp; + } */ *uap = v; + struct linux___sysctl ls; + struct sys___sysctl_args bsa; + int error; + + if ((error = copyin(SCARG(uap, lsp), &ls, sizeof ls))) + return error; + SCARG(&bsa, name) = ls.name; + SCARG(&bsa, namelen) = ls.namelen; + SCARG(&bsa, old) = ls.old; + SCARG(&bsa, oldlenp) = ls.oldlenp; + SCARG(&bsa, new) = ls.new; + SCARG(&bsa, newlen) = ls.newlen; + + return sys___sysctl(p, &bsa, retval); +} diff --git a/sys/compat/linux/linux_syscall.h b/sys/compat/linux/linux_syscall.h index 7fc5cd62292..89a9da969e0 100644 --- a/sys/compat/linux/linux_syscall.h +++ b/sys/compat/linux/linux_syscall.h @@ -122,4 +122,9 @@ #define LINUX_SYS_msync 144 #define LINUX_SYS_readv 145 #define LINUX_SYS_writev 146 -#define LINUX_SYS_MAXSYSCALL 147 +#define LINUX_SYS_getsid 147 +#define LINUX_SYS_fdatasync 148 +#define LINUX_SYS___sysctl 149 +#define LINUX_SYS_mlock 150 +#define LINUX_SYS_munlock 151 +#define LINUX_SYS_MAXSYSCALL 164 diff --git a/sys/compat/linux/linux_syscallargs.h b/sys/compat/linux/linux_syscallargs.h index ce7ad96116a..12efb98f917 100644 --- a/sys/compat/linux/linux_syscallargs.h +++ b/sys/compat/linux/linux_syscallargs.h @@ -326,6 +326,18 @@ struct linux_sys_msync_args { syscallarg(int) fl; }; +struct linux_sys_getsid_args { + syscallarg(int) pid; +}; + +struct linux_sys_fdatasync_args { + syscallarg(int) fd; +}; + +struct linux_sys___sysctl_args { + syscallarg(struct linux___sysctl *) lsp; +}; + /* * System call prototypes. */ @@ -454,3 +466,8 @@ int sys_flock __P((struct proc *, void *, register_t *)); int linux_sys_msync __P((struct proc *, void *, register_t *)); int sys_readv __P((struct proc *, void *, register_t *)); int sys_writev __P((struct proc *, void *, register_t *)); +int linux_sys_getsid __P((struct proc *, void *, register_t *)); +int linux_sys_fdatasync __P((struct proc *, void *, register_t *)); +int linux_sys___sysctl __P((struct proc *, void *, register_t *)); +int sys_mlock __P((struct proc *, void *, register_t *)); +int sys_munlock __P((struct proc *, void *, register_t *)); diff --git a/sys/compat/linux/linux_syscalls.c b/sys/compat/linux/linux_syscalls.c index be17ca299a3..8ed6859d25e 100644 --- a/sys/compat/linux/linux_syscalls.c +++ b/sys/compat/linux/linux_syscalls.c @@ -165,4 +165,21 @@ char *linux_syscallnames[] = { "msync", /* 144 = msync */ "readv", /* 145 = readv */ "writev", /* 146 = writev */ + "getsid", /* 147 = getsid */ + "fdatasync", /* 148 = fdatasync */ + "__sysctl", /* 149 = __sysctl */ + "mlock", /* 150 = mlock */ + "munlock", /* 151 = munlock */ + "#152 (unimplemented mlockall)", /* 152 = unimplemented mlockall */ + "#153 (unimplemented munlockall)", /* 153 = unimplemented munlockall */ + "#154 (unimplemented sched_setparam)", /* 154 = unimplemented sched_setparam */ + "#155 (unimplemented sched_getparam)", /* 155 = unimplemented sched_getparam */ + "#156 (unimplemented sched_setscheduler)", /* 156 = unimplemented sched_setscheduler */ + "#157 (unimplemented sched_getscheduler)", /* 157 = unimplemented sched_getscheduler */ + "#158 (unimplemented sched_yield)", /* 158 = unimplemented sched_yield */ + "#159 (unimplemented sched_get_priority_max)", /* 159 = unimplemented sched_get_priority_max */ + "#160 (unimplemented sched_get_priority_min)", /* 160 = unimplemented sched_get_priority_min */ + "#161 (unimplemented sched_rr_get_interval)", /* 161 = unimplemented sched_rr_get_interval */ + "#162 (unimplemented nanosleep)", /* 162 = unimplemented nanosleep */ + "#163 (unimplemented mremap)", /* 163 = unimplemented mremap */ }; diff --git a/sys/compat/linux/linux_sysent.c b/sys/compat/linux/linux_sysent.c index 6ae863fccba..ebda0c5f720 100644 --- a/sys/compat/linux/linux_sysent.c +++ b/sys/compat/linux/linux_sysent.c @@ -327,5 +327,39 @@ struct sysent linux_sysent[] = { sys_readv }, /* 145 = readv */ { 3, s(struct sys_writev_args), sys_writev }, /* 146 = writev */ + { 1, s(struct linux_sys_getsid_args), + linux_sys_getsid }, /* 147 = getsid */ + { 1, s(struct linux_sys_fdatasync_args), + linux_sys_fdatasync }, /* 148 = fdatasync */ + { 1, s(struct linux_sys___sysctl_args), + linux_sys___sysctl }, /* 149 = __sysctl */ + { 2, s(struct sys_mlock_args), + sys_mlock }, /* 150 = mlock */ + { 2, s(struct sys_munlock_args), + sys_munlock }, /* 151 = munlock */ + { 0, 0, + sys_nosys }, /* 152 = unimplemented mlockall */ + { 0, 0, + sys_nosys }, /* 153 = unimplemented munlockall */ + { 0, 0, + sys_nosys }, /* 154 = unimplemented sched_setparam */ + { 0, 0, + sys_nosys }, /* 155 = unimplemented sched_getparam */ + { 0, 0, + sys_nosys }, /* 156 = unimplemented sched_setscheduler */ + { 0, 0, + sys_nosys }, /* 157 = unimplemented sched_getscheduler */ + { 0, 0, + sys_nosys }, /* 158 = unimplemented sched_yield */ + { 0, 0, + sys_nosys }, /* 159 = unimplemented sched_get_priority_max */ + { 0, 0, + sys_nosys }, /* 160 = unimplemented sched_get_priority_min */ + { 0, 0, + sys_nosys }, /* 161 = unimplemented sched_rr_get_interval */ + { 0, 0, + sys_nosys }, /* 162 = unimplemented nanosleep */ + { 0, 0, + sys_nosys }, /* 163 = unimplemented mremap */ }; diff --git a/sys/compat/linux/linux_types.h b/sys/compat/linux/linux_types.h index a9da8aad44f..64561e4cd64 100644 --- a/sys/compat/linux/linux_types.h +++ b/sys/compat/linux/linux_types.h @@ -1,5 +1,5 @@ -/* $OpenBSD: linux_types.h,v 1.2 1996/04/17 05:24:10 mickey Exp $ */ -/* $NetBSD: linux_types.h,v 1.4 1995/08/21 03:42:11 mycroft Exp $ */ +/* $OpenBSD: linux_types.h,v 1.3 1996/05/22 12:01:51 deraadt Exp $ */ +/* $NetBSD: linux_types.h,v 1.5 1996/05/20 01:59:28 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -149,4 +149,14 @@ struct linux_utimbuf { linux_time_t l_modtime; }; +struct linux___sysctl { + int *name; + int namelen; + void *old; + size_t *oldlenp; + void *new; + size_t newlen; + unsigned long __unused[4]; +}; + #endif /* !_LINUX_TYPES_H */ diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master index 792855b3125..3bcb21655c6 100644 --- a/sys/compat/linux/syscalls.master +++ b/sys/compat/linux/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.6 1996/04/28 07:53:18 etheisen Exp $ + $OpenBSD: syscalls.master,v 1.7 1996/05/22 12:01:51 deraadt Exp $ ; $NetBSD: syscalls.master,v 1.15 1995/12/18 14:35:10 fvdl Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -240,3 +240,20 @@ u_int iovcnt); } 146 NOARGS { int sys_writev(int fd, struct iovec *iovp, \ u_int iovcnt); } +147 STD { int linux_sys_getsid(int pid); } +148 STD { int linux_sys_fdatasync(int fd); } +149 STD { int linux_sys___sysctl(struct linux___sysctl *lsp); } +150 NOARGS { int sys_mlock(caddr_t addr, size_t len); } +151 NOARGS { int sys_munlock(caddr_t addr, size_t len); } +152 UNIMPL mlockall +153 UNIMPL munlockall +154 UNIMPL sched_setparam +155 UNIMPL sched_getparam +156 UNIMPL sched_setscheduler +157 UNIMPL sched_getscheduler +158 UNIMPL sched_yield +159 UNIMPL sched_get_priority_max +160 UNIMPL sched_get_priority_min +161 UNIMPL sched_rr_get_interval +162 UNIMPL nanosleep +163 UNIMPL mremap diff --git a/sys/netccitt/if_x25subr.c b/sys/netccitt/if_x25subr.c index ade9f558b48..b635df4ab74 100644 --- a/sys/netccitt/if_x25subr.c +++ b/sys/netccitt/if_x25subr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_x25subr.c,v 1.2 1996/03/04 07:36:29 niklas Exp $ */ -/* $NetBSD: if_x25subr.c,v 1.12 1996/02/13 22:04:39 christos Exp $ */ +/* $OpenBSD: if_x25subr.c,v 1.3 1996/05/22 12:02:40 deraadt Exp $ */ +/* $NetBSD: if_x25subr.c,v 1.13 1996/05/09 22:29:25 scottr Exp $ */ /* * Copyright (c) 1990, 1993 @@ -47,6 +47,8 @@ #include <sys/errno.h> #include <sys/syslog.h> +#include <machine/cpu.h> /* XXX for setsoftnet(). This must die. */ + #include <net/if.h> #include <net/if_types.h> #include <net/netisr.h> diff --git a/sys/netiso/if_eon.c b/sys/netiso/if_eon.c index 223c79c8acc..8d6f6778da9 100644 --- a/sys/netiso/if_eon.c +++ b/sys/netiso/if_eon.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_eon.c,v 1.4 1996/05/10 12:31:22 deraadt Exp $ */ -/* $NetBSD: if_eon.c,v 1.14 1996/05/07 02:45:10 thorpej Exp $ */ +/* $OpenBSD: if_eon.c,v 1.5 1996/05/22 12:02:42 deraadt Exp $ */ +/* $NetBSD: if_eon.c,v 1.15 1996/05/09 22:29:37 scottr Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -85,6 +85,8 @@ SOFTWARE. #include <sys/errno.h> #include <sys/types.h> +#include <machine/cpu.h> /* XXX for setsoftnet(). This must die. */ + #include <net/if.h> #include <net/if_types.h> #include <net/if_dl.h> diff --git a/sys/netns/ns_ip.c b/sys/netns/ns_ip.c index c72f6a58d1d..fc699c84f66 100644 --- a/sys/netns/ns_ip.c +++ b/sys/netns/ns_ip.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ns_ip.c,v 1.5 1996/05/12 03:18:34 mickey Exp $ */ -/* $NetBSD: ns_ip.c,v 1.15 1996/05/07 02:48:08 thorpej Exp $ */ +/* $OpenBSD: ns_ip.c,v 1.6 1996/05/22 12:02:43 deraadt Exp $ */ +/* $NetBSD: ns_ip.c,v 1.16 1996/05/09 22:29:40 scottr Exp $ */ /* * Copyright (c) 1984, 1985, 1986, 1987, 1993 @@ -51,6 +51,8 @@ #include <sys/ioctl.h> #include <sys/protosw.h> +#include <machine/cpu.h> /* XXX for setsoftnet(). This must die. */ + #include <net/if.h> #include <net/netisr.h> #include <net/route.h> diff --git a/sys/scsi/ss_scanjet.c b/sys/scsi/ss_scanjet.c index a629cd70687..9045da36ceb 100644 --- a/sys/scsi/ss_scanjet.c +++ b/sys/scsi/ss_scanjet.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ss_scanjet.c,v 1.5 1996/05/10 12:31:41 deraadt Exp $ */ -/* $NetBSD: ss_scanjet.c,v 1.4 1996/05/05 19:52:58 christos Exp $ */ +/* $OpenBSD: ss_scanjet.c,v 1.6 1996/05/22 11:58:41 deraadt Exp $ */ +/* $NetBSD: ss_scanjet.c,v 1.6 1996/05/18 22:58:01 christos Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -61,9 +61,14 @@ int scanjet_trigger_scanner __P((struct ss_softc *)); int scanjet_read __P((struct ss_softc *, struct buf *)); /* only used internally */ -int scanjet_write __P((struct ss_softc *ss, char *buf, u_int size, int flags)); -int scanjet_set_window __P((struct ss_softc *ss)); -void scanjet_compute_sizes __P((struct ss_softc *)); +int scanjet_ctl_write __P((struct ss_softc *, char *, u_int, int)); +int scanjet_ctl_read __P((struct ss_softc *, char *, u_int, int)); +int scanjet_set_window __P((struct ss_softc *)); +int scanjet_compute_sizes __P((struct ss_softc *)); +/* Maybe move to libkern? */ +__inline static int atoi __P((const char *)); +__inline static char *strchr __P((const char *, char)); + /* * structure for the special handlers @@ -90,6 +95,7 @@ scanjet_attach(ss, sa) #ifdef SCSIDEBUG struct scsi_link *sc_link = sa->sa_sc_link; #endif + int error; SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: start\n")); ss->sio.scan_scanner_type = 0; @@ -100,11 +106,11 @@ scanjet_attach(ss, sa) if (!bcmp(sa->sa_inqbuf->product, "C1750A", 6)) { ss->sio.scan_scanner_type = HP_SCANJET_IIC; - printf("HP ScanJet IIc\n"); + printf("HP ScanJet IIc"); } if (!bcmp(sa->sa_inqbuf->product, "C2500A", 6)) { ss->sio.scan_scanner_type = HP_SCANJET_IIC; - printf("HP ScanJet IIcx\n"); + printf("HP ScanJet IIcx"); } SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: scanner_type = %d\n", @@ -127,7 +133,18 @@ scanjet_attach(ss, sa) ss->sio.scan_quality = 100; ss->sio.scan_image_mode = SIM_GRAYSCALE; - scanjet_compute_sizes(ss); + error = scanjet_set_window(ss); + if (error) { + printf(" set_window failed\n"); + return; + } + error = scanjet_compute_sizes(ss); + if (error) { + printf(" compute_sizes failed\n"); + return; + } + + printf("\n"); } int @@ -148,9 +165,9 @@ scanjet_set_params(ss, sio) struct ss_softc *ss; struct scan_io *sio; { -#if 0 int error; +#if 0 /* * if the scanner is triggered, then rewind it */ @@ -189,7 +206,16 @@ scanjet_set_params(ss, sio) sio->scan_scanner_type = ss->sio.scan_scanner_type; bcopy(sio, &ss->sio, sizeof(struct scan_io)); - scanjet_compute_sizes(ss); + error = scanjet_set_window(ss); + if (error) { + uprintf("%s: set_window failed\n", ss->sc_dev.dv_xname); + return (error); + } + error = scanjet_compute_sizes(ss); + if (error) { + uprintf("%s: compute_sizes failed\n", ss->sc_dev.dv_xname); + return (error); + } return (0); } @@ -206,20 +232,22 @@ scanjet_trigger_scanner(ss) char escape_codes[20]; int error; - scanjet_compute_sizes(ss); - - /* send parameters */ error = scanjet_set_window(ss); if (error) { - uprintf("set window failed\n"); + uprintf("%s: set_window failed\n", ss->sc_dev.dv_xname); + return (error); + } + error = scanjet_compute_sizes(ss); + if (error) { + uprintf("%s: compute_sizes failed\n", ss->sc_dev.dv_xname); return (error); } /* send "trigger" operation */ strcpy(escape_codes, "\033*f0S"); - error = scanjet_write(ss, escape_codes, strlen(escape_codes), 0); + error = scanjet_ctl_write(ss, escape_codes, strlen(escape_codes), 0); if (error) { - uprintf("trigger failed\n"); + uprintf("%s: trigger_scanner failed\n", ss->sc_dev.dv_xname); return (error); } @@ -267,7 +295,7 @@ scanjet_read(ss, bp) * Do a synchronous write. Used to send control messages. */ int -scanjet_write(ss, buf, size, flags) +scanjet_ctl_write(ss, buf, size, flags) struct ss_softc *ss; char *buf; u_int size; @@ -275,11 +303,6 @@ scanjet_write(ss, buf, size, flags) { struct scsi_rw_scanner cmd; - /* - * If it's a null transfer, return immediatly - */ - if (size == 0) - return (0); bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE; _lto3b(size, cmd.len); @@ -288,6 +311,28 @@ scanjet_write(ss, buf, size, flags) flags | SCSI_DATA_OUT)); } + +/* + * Do a synchronous read. Used to read responses to control messages. + */ +int +scanjet_ctl_read(ss, buf, size, flags) + struct ss_softc *ss; + char *buf; + u_int size; + int flags; +{ + struct scsi_rw_scanner cmd; + + bzero(&cmd, sizeof(cmd)); + cmd.opcode = READ; + _lto3b(size, cmd.len); + return (scsi_scsi_cmd(ss->sc_link, (struct scsi_generic *) &cmd, + sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL, + flags | SCSI_DATA_IN)); +} + + #ifdef SCANJETDEBUG static void show_es(char *es) { @@ -329,6 +374,7 @@ scanjet_set_window(ss) switch (ss->sio.scan_image_mode) { case SIM_BINARY_MONOCHROME: + ss->sio.scan_bits_per_pixel = 1; /* use "line art" mode */ strcpy(p, "\033*a0T"); p += strlen(p); @@ -337,6 +383,7 @@ scanjet_set_window(ss) p += strlen(p); break; case SIM_DITHERED_MONOCHROME: + ss->sio.scan_bits_per_pixel = 1; /* use dithered mode */ strcpy(p, "\033*a3T"); p += strlen(p); @@ -345,6 +392,7 @@ scanjet_set_window(ss) p += strlen(p); break; case SIM_GRAYSCALE: + ss->sio.scan_bits_per_pixel = 8; /* use grayscale mode */ strcpy(p, "\033*a4T"); p += strlen(p); @@ -353,6 +401,7 @@ scanjet_set_window(ss) p += strlen(p); break; case SIM_COLOR: + ss->sio.scan_bits_per_pixel = 24; /* use RGB color mode */ strcpy(p, "\033*a5T"); p += strlen(p); @@ -362,6 +411,7 @@ scanjet_set_window(ss) /* use pass-through matrix (disable NTSC) */ strcpy(p, "\033*u2T"); p += strlen(p); + break; } sprintf(p, "\033*a%dG", ss->sio.scan_bits_per_pixel); @@ -371,14 +421,44 @@ scanjet_set_window(ss) sprintf(p, "\033*a%dK", (int)(ss->sio.scan_contrast) - 128); p += strlen(p); - return (scanjet_write(ss, escape_codes, p - escape_codes, 0)); + return (scanjet_ctl_write(ss, escape_codes, p - escape_codes, 0)); } -void +/* atoi() and strchr() are from /sys/arch/amiga/dev/ite.c + and are only used in scanjet_compute_sizes */ + +__inline static int +atoi(cp) + const char *cp; +{ + int n; + + for (n = 0; *cp && *cp >= '0' && *cp <= '9'; cp++) + n = n * 10 + *cp - '0'; + + return (n); +} + +__inline static char * +strchr(cp, ch) + const char *cp; + char ch; +{ + while (*cp && *cp != ch) cp++; + return (*cp ? (char *)cp : 0); +} + +int scanjet_compute_sizes(ss) struct ss_softc *ss; { - int r = 0; /* round up by r 1/1200" */ + int error; + static char *wfail = "%s: interrogate write failed\n"; + static char *rfail = "%s: interrogate read failed\n"; + static char *dfail = "%s: bad data returned\n"; + char escape_codes[20]; + char response[20]; + char *p; /* * Deal with the fact that the HP ScanJet IIc uses 1/300" not 1/1200" @@ -391,27 +471,52 @@ scanjet_compute_sizes(ss) switch (ss->sio.scan_image_mode) { case SIM_BINARY_MONOCHROME: case SIM_DITHERED_MONOCHROME: - ss->sio.scan_bits_per_pixel = 1; + strcpy(escape_codes, "\033*s1025E"); /* bytes wide */ break; case SIM_GRAYSCALE: - r = 600; - ss->sio.scan_bits_per_pixel = 8; - break; case SIM_COLOR: - r = 600; - ss->sio.scan_bits_per_pixel = 24; + strcpy(escape_codes, "\033*s1024E"); /* pixels wide */ break; } + error = scanjet_ctl_write(ss, escape_codes, strlen(escape_codes), 0); + if (error) { + uprintf(wfail, ss->sc_dev.dv_xname); + return (error); + } + error = scanjet_ctl_read(ss, response, 20, 0); + if (error) { + uprintf(rfail, ss->sc_dev.dv_xname); + return (error); + } + p = strchr(response, 'd'); + if (p == 0) { + uprintf(dfail, ss->sc_dev.dv_xname); + return (EIO); + } + ss->sio.scan_pixels_per_line = atoi(p + 1); + if (ss->sio.scan_image_mode < SIM_GRAYSCALE) + ss->sio.scan_pixels_per_line *= 8; - ss->sio.scan_pixels_per_line = - (ss->sio.scan_width * ss->sio.scan_x_resolution + r) / 1200; - if (ss->sio.scan_bits_per_pixel == 1) - /* pad to byte boundary: */ - ss->sio.scan_pixels_per_line = - (ss->sio.scan_pixels_per_line + 7) & 0xfffffff8; + strcpy(escape_codes, "\033*s1026E"); /* pixels high */ + error = scanjet_ctl_write(ss, escape_codes, strlen(escape_codes), 0); + if (error) { + uprintf(wfail, ss->sc_dev.dv_xname); + return (error); + } + error = scanjet_ctl_read(ss, response, 20, 0); + if (error) { + uprintf(rfail, ss->sc_dev.dv_xname); + return (error); + } + p = strchr(response, 'd'); + if (p == 0) { + uprintf(dfail, ss->sc_dev.dv_xname); + return (EIO); + } + ss->sio.scan_lines = atoi(p + 1); - ss->sio.scan_lines = - (ss->sio.scan_height * ss->sio.scan_y_resolution + r) / 1200; ss->sio.scan_window_size = ss->sio.scan_lines * ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8); + + return (0); } |