-/* $NetBSD: exec_aout.c,v 1.13 1994/08/01 18:49:49 pk Exp $ */
+/* $OpenBSD: exec_aout.c,v 1.2 1996/03/03 17:19:36 niklas Exp $ */
+/* $NetBSD: exec_aout.c,v 1.14 1996/02/04 02:15:01 christos Exp $ */
/*
* Copyright (c) 1993, 1994 Christopher G. Demetriou
if (error)
kill_vmcmds(&epp->ep_vmcmds);
-bad:
return error;
}
-/* $NetBSD: exec_elf.c,v 1.4 1996/01/16 23:07:18 fvdl Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.3 1996/03/03 17:19:37 niklas Exp $ */
+/* $NetBSD: exec_elf.c,v 1.6 1996/02/09 18:59:18 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#include <compat/svr4/svr4_exec.h>
#endif
-int (*elf_probe_funcs[])() = {
+int (*elf_probe_funcs[]) __P((struct proc *, struct exec_package *,
+ char *, u_long *)) = {
#ifdef COMPAT_SVR4
svr4_elf_probe,
#endif
#endif
};
+int elf_check_header __P((Elf32_Ehdr *, int));
+int elf_load_file __P((struct proc *, char *, struct exec_vmcmd_set *,
+ u_long *, struct elf_args *, u_long *));
+
static int elf_read_from __P((struct proc *, struct vnode *, u_long,
caddr_t, int));
static void elf_load_psection __P((struct exec_vmcmd_set *,
}
}
+ /*
+ * If no position to load the interpreter was set by a probe
+ * function, pick the same address that a non-fixed mmap(0, ..)
+ * would (i.e. something safely out of the way).
+ */
+ if (pos == ELF32_NO_ADDR)
+ pos = round_page(epp->ep_daddr + MAXDSIZ);
+
/*
* Check if we found a dynamically linked binary and arrange to load
* it's interpreter
-/* $NetBSD: exec_script.c,v 1.12 1995/04/10 18:27:59 mycroft Exp $ */
+/* $OpenBSD: exec_script.c,v 1.2 1996/03/03 17:19:38 niklas Exp $ */
+/* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */
/*
* Copyright (c) 1993, 1994 Christopher G. Demetriou
shellname = NULL;
shellarg = NULL;
+ shellarglen = 0;
/* strip spaces before the shell name */
for (cp = hdrstr + EXEC_SCRIPT_MAGICLEN; *cp == ' ' || *cp == '\t';
* behaviour.
*/
shellarg = cp;
- shellarglen = 0;
for ( /* cp = cp */ ; *cp != '\0'; cp++)
shellarglen++;
*cp++ = '\0';
/* XXX oldpnbuf not set for "goto fail" path */
epp->ep_ndp->ni_cnd.cn_pnbuf = oldpnbuf;
+#ifdef FDSCRIPTS
fail:
+#endif
/* note that we've clobbered the header */
epp->ep_flags |= EXEC_DESTR;
-/* $NetBSD: init_main.c,v 1.80 1996/01/07 22:03:47 thorpej Exp $ */
+/* $OpenBSD: init_main.c,v 1.4 1996/03/03 17:19:39 niklas Exp $ */
+/* $NetBSD: init_main.c,v 1.82 1996/02/09 18:59:21 christos Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
#include <sys/protosw.h>
#include <sys/reboot.h>
#include <sys/user.h>
+#include <sys/cpu.h>
+#ifdef SYSVSHM
+#include <sys/shm.h>
+#endif
+#ifdef SYSVSEM
+#include <sys/sem.h>
+#endif
+#ifdef SYSVMSG
+#include <sys/msg.h>
+#endif
+#include <sys/domain.h>
+#include <sys/mbuf.h>
#include <sys/syscall.h>
#include <sys/syscallargs.h>
#include <machine/cpu.h>
#include <vm/vm.h>
+#include <vm/vm_pageout.h>
+
+#include <net/if.h>
+#include <net/raw_cb.h>
char copyright[] =
"Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of California. All rights reserved.\n\n";
static void start_init __P((struct proc *));
static void start_pagedaemon __P((struct proc *));
+void main __P((void *));
#ifdef cpu_set_init_frame
void *initframep; /* XXX should go away */
* hard work is done in the lower-level initialization routines including
* startup(), which does memory initialization and autoconfiguration.
*/
-int
+void
main(framep)
void *framep; /* XXX should go away */
{
int options, i, error;
register_t retval[2];
char flags[4], *flagsp;
- char **pathp, *path, *ucp, **uap, *arg0, *arg1;
+ char **pathp, *path, *ucp, **uap, *arg0, *arg1 = NULL;
/*
* Now in process 1.
-/* $NetBSD: kern_acct.c,v 1.41 1995/10/07 06:28:07 mycroft Exp $ */
+/* $OpenBSD: kern_acct.c,v 1.2 1996/03/03 17:19:40 niklas Exp $ */
+/* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
int error;
/* Make sure that the caller is root. */
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
/*
if (SCARG(uap, path) != NULL) {
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path),
p);
- if (error = vn_open(&nd, FWRITE, 0))
+ if ((error = vn_open(&nd, FWRITE, 0)) != 0)
return (error);
VOP_UNLOCK(nd.ni_vp);
if (nd.ni_vp->v_type != VREG) {
+/* $OpenBSD: kern_clock.c,v 1.7 1996/03/03 17:19:41 niklas Exp $ */
/* $NetBSD: kern_clock.c,v 1.23 1995/12/28 19:16:41 thorpej Exp $ */
/*-
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
+#include <sys/cpu.h>
+#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <sys/timex.h>
#include <machine/cpu.h>
/*
* Return information about system clocks.
*/
+int
sysctl_clockrate(where, sizep)
register char *where;
size_t *sizep;
#ifdef DDB
#include <machine/db_machdep.h>
+#include <ddb/db_interface.h>
#include <ddb/db_access.h>
#include <ddb/db_sym.h>
+#include <ddb/db_output.h>
-void db_show_callout(long addr, int haddr, int count, char *modif)
+void db_show_callout(addr, haddr, count, modif)
+ db_expr_t addr;
+ int haddr;
+ db_expr_t count;
+ char *modif;
{
register struct callout *p1;
register int cum;
-/* $NetBSD: kern_descrip.c,v 1.37 1995/10/07 06:28:09 mycroft Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.3 1996/03/03 17:19:42 niklas Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.39 1996/02/09 18:59:26 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
#include <sys/mount.h>
#include <sys/syscallargs.h>
+#include <vm/vm.h>
+
+#include <kern/kern_conf.h>
+
/*
* Descriptor management.
*/
struct filelist filehead; /* head of list of open files */
int nfiles; /* actual number of open files */
-static __inline
+static __inline void fd_used __P((struct filedesc *, int));
+static __inline void fd_unused __P((struct filedesc *, int));
+int finishdup __P((struct filedesc *, int, int, register_t *));
+
+static __inline void
fd_used(fdp, fd)
register struct filedesc *fdp;
register int fd;
fdp->fd_lastfile = fd;
}
-static __inline
+static __inline void
fd_unused(fdp, fd)
register struct filedesc *fdp;
register int fd;
* Duplicate a file descriptor.
*/
/* ARGSUSED */
+int
sys_dup(p, v, retval)
struct proc *p;
void *v;
if ((u_int)old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL)
return (EBADF);
- if (error = fdalloc(p, 0, &new))
+ if ((error = fdalloc(p, 0, &new)) != 0)
return (error);
return (finishdup(fdp, old, new, retval));
}
* Duplicate a file descriptor to a particular value.
*/
/* ARGSUSED */
+int
sys_dup2(p, v, retval)
struct proc *p;
void *v;
return (0);
}
if (new >= fdp->fd_nfiles) {
- if (error = fdalloc(p, new, &i))
+ if ((error = fdalloc(p, new, &i)) != 0)
return (error);
if (new != i)
panic("dup2: fdalloc");
* The file control system call.
*/
/* ARGSUSED */
+int
sys_fcntl(p, v, retval)
struct proc *p;
void *v;
if ((u_int)newmin >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
(u_int)newmin >= maxfiles)
return (EINVAL);
- if (error = fdalloc(p, newmin, &i))
+ if ((error = fdalloc(p, newmin, &i)) != 0)
return (error);
return (finishdup(fdp, fd, i, retval));
return (error);
if (fl.l_whence == SEEK_CUR)
fl.l_start += fp->f_offset;
- if (error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX))
+ error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX);
+ if (error)
return (error);
return (copyout((caddr_t)&fl, (caddr_t)SCARG(uap, arg),
sizeof (fl)));
* Close a file descriptor.
*/
/* ARGSUSED */
+int
sys_close(p, v, retval)
struct proc *p;
void *v;
* Return status information about a file descriptor.
*/
/* ARGSUSED */
+int
sys_fstat(p, v, retval)
struct proc *p;
void *v;
* Return pathconf information about a file descriptor.
*/
/* ARGSUSED */
+int
sys_fpathconf(p, v, retval)
struct proc *p;
void *v;
*/
int fdexpand;
+int
fdalloc(p, want, result)
struct proc *p;
int want;
* Check to see whether n user file descriptors
* are available to the process p.
*/
+int
fdavail(p, n)
struct proc *p;
register int n;
* Create a new open file structure and allocate
* a file decriptor for the process that refers to it.
*/
+int
falloc(p, resultfp, resultfd)
register struct proc *p;
struct file **resultfp;
register struct file *fp, *fq;
int error, i;
- if (error = fdalloc(p, 0, &i))
+ if ((error = fdalloc(p, 0, &i)) != 0)
return (error);
if (nfiles >= maxfiles) {
tablefull("file");
nfiles++;
MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK);
bzero(fp, sizeof(struct file));
- if (fq = p->p_fd->fd_ofiles[0]) {
+ if ((fq = p->p_fd->fd_ofiles[0]) != NULL) {
LIST_INSERT_AFTER(fq, fp, f_list);
} else {
LIST_INSERT_HEAD(&filehead, fp, f_list);
/*
* Free a file descriptor.
*/
+void
ffree(fp)
register struct file *fp;
{
- register struct file *fq;
-
LIST_REMOVE(fp, f_list);
crfree(fp->f_cred);
#ifdef DIAGNOSTIC
* Note: p may be NULL when closing a file
* that was being passed in a message.
*/
+int
closef(fp, p)
register struct file *fp;
register struct proc *p;
* the entire file (l_whence = SEEK_SET, l_start = 0, l_len = 0).
*/
/* ARGSUSED */
+int
sys_flock(p, v, retval)
struct proc *p;
void *v;
-/* $NetBSD: kern_exec.c,v 1.73 1995/12/09 04:11:00 mycroft Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.3 1996/03/03 17:19:43 niklas Exp $ */
+/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
* Copyright (C) 1993, 1994 Christopher G. Demetriou
#include <sys/mman.h>
#include <sys/signalvar.h>
#include <sys/stat.h>
+#ifdef SYSVSHM
+#include <sys/shm.h>
+#endif
#include <sys/syscallargs.h>
{
int error, i;
struct vnode *vp;
- char *cp, *ep, *name;
struct nameidata *ndp;
int resid;
ndp->ni_cnd.cn_nameiop = LOOKUP;
ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF | SAVENAME;
/* first get the vnode */
- if (error = namei(ndp))
+ if ((error = namei(ndp)) != 0)
return error;
epp->ep_vp = vp = ndp->ni_vp;
}
/* get attributes */
- if (error = VOP_GETATTR(vp, epp->ep_vap, p->p_ucred, p))
+ if ((error = VOP_GETATTR(vp, epp->ep_vap, p->p_ucred, p)) != 0)
goto bad1;
/* Check mount point */
epp->ep_vap->va_mode &= ~(VSUID | VSGID);
/* check access. for root we have to see if any exec bit on */
- if (error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p))
+ if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p)) != 0)
goto bad1;
if ((epp->ep_vap->va_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) {
error = EACCES;
}
/* try to open it */
- if (error = VOP_OPEN(vp, FREAD, p->p_ucred, p))
+ if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0)
goto bad1;
/* now we have the file, get the exec header */
- if (error = vn_rdwr(UIO_READ, vp, epp->ep_hdr, epp->ep_hdrlen, 0,
- UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p))
+ error = vn_rdwr(UIO_READ, vp, epp->ep_hdr, epp->ep_hdrlen, 0,
+ UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
+ if (error)
goto bad2;
epp->ep_hdrvalid = epp->ep_hdrlen - resid;
* exec system call
*/
/* ARGSUSED */
+int
sys_execve(p, v, retval)
register struct proc *p;
void *v;
pack.ep_flags = 0;
/* see if we can run it. */
- if (error = check_exec(p, &pack))
+ if ((error = check_exec(p, &pack)) != 0)
goto freehdr;
/* XXX -- THE FOLLOWING SECTION NEEDS MAJOR CLEANUP */
cp = *tmpfap;
while (*cp)
*dp++ = *cp++;
- *dp++;
+ dp++;
FREE(*tmpfap, M_EXEC);
tmpfap++; argc++;
while (1) {
len = argp + ARG_MAX - dp;
- if (error = copyin(cpp, &sp, sizeof(sp)))
+ if ((error = copyin(cpp, &sp, sizeof(sp))) != 0)
goto bad;
if (!sp)
break;
- if (error = copyinstr(sp, dp, len, &len)) {
+ if ((error = copyinstr(sp, dp, len, &len)) != 0) {
if (error == ENAMETOOLONG)
error = E2BIG;
goto bad;
}
envc = 0;
- if (cpp = SCARG(uap, envp)) { /* environment need not be there */
+ /* environment need not be there */
+ if ((cpp = SCARG(uap, envp)) != NULL ) {
while (1) {
len = argp + ARG_MAX - dp;
- if (error = copyin(cpp, &sp, sizeof(sp)))
+ if ((error = copyin(cpp, &sp, sizeof(sp))) != 0)
goto bad;
if (!sp)
break;
- if (error = copyinstr(sp, dp, len, &len)) {
+ if ((error = copyinstr(sp, dp, len, &len)) != 0) {
if (error == ENAMETOOLONG)
error = E2BIG;
goto bad;
* MNT_NOEXEC and P_TRACED have already been used to disable s[ug]id.
*/
p->p_flag &= ~P_SUGID;
- if (((attr.va_mode & VSUID) != 0 &&
- p->p_ucred->cr_uid != attr.va_uid)
- || (attr.va_mode & VSGID) != 0 &&
- p->p_ucred->cr_gid != attr.va_gid) {
+ if (((attr.va_mode & VSUID) != 0 && p->p_ucred->cr_uid != attr.va_uid)
+ || ((attr.va_mode & VSGID) != 0 && p->p_ucred->cr_gid != attr.va_gid)){
p->p_ucred = crcopy(cred);
#ifdef KTRACE
/*
-/* $NetBSD: kern_exit.c,v 1.35 1995/12/24 11:23:33 mycroft Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.5 1996/03/03 17:19:44 niklas Exp $ */
+/* $NetBSD: kern_exit.c,v 1.38 1996/02/09 18:59:29 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
#include <sys/resourcevar.h>
#include <sys/ptrace.h>
#include <sys/acct.h>
+#include <sys/filedesc.h>
+#include <sys/signalvar.h>
+#ifdef SYSVSHM
+#include <sys/shm.h>
+#endif
+#ifdef SYSVSEM
+#include <sys/sem.h>
+#endif
+#include <sys/cpu.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
-void cpu_exit __P((struct proc *)); /* XXX MOVE ME */
-void exit1 __P((struct proc *, int));
-
/*
* exit --
* Death of process.
MALLOC(p->p_ru, struct rusage *, sizeof(struct rusage),
M_ZOMBIE, M_WAITOK);
/*
- * If parent is waiting for us to exit or exec,
- * P_PPWAIT is set; we will wakeup the parent below.
+ * If parent is waiting for us to exit or exec, P_PPWAIT is set; we
+ * wake up the parent early to avoid deadlock.
*/
- p->p_flag &= ~(P_TRACED | P_PPWAIT);
p->p_flag |= P_WEXIT;
+ p->p_flag &= ~P_TRACED;
+ if (p->p_flag & P_PPWAIT) {
+ p->p_flag &= ~P_PPWAIT;
+ wakeup((caddr_t)p->p_pptr);
+ }
p->p_sigignore = ~0;
p->p_siglist = 0;
untimeout(realitexpire, (caddr_t)p);
q = p->p_children.lh_first;
if (q) /* only need this if any child is S_ZOMB */
- wakeup((caddr_t) initproc);
+ wakeup((caddr_t)initproc);
for (; q != 0; q = nq) {
nq = q->p_sibling.le_next;
proc_reparent(q, initproc);
* Other substructures are freed from wait().
*/
curproc = NULL;
- limfree(p->p_limit);
+ if (--p->p_limit->p_refcnt == 0)
+ FREE(p->p_limit, M_SUBPROC);
/*
* Finally, call machine-dependent code to release the remaining
if (SCARG(uap, status)) {
status = p->p_xstat; /* convert to int */
- if (error = copyout((caddr_t)&status,
- (caddr_t)SCARG(uap, status),
- sizeof(status)))
+ error = copyout((caddr_t)&status,
+ (caddr_t)SCARG(uap, status),
+ sizeof(status));
+ if (error)
return (error);
}
if (SCARG(uap, rusage) &&
retval[0] = 0;
return (0);
}
- if (error = tsleep((caddr_t)q, PWAIT | PCATCH, "wait", 0))
+ if ((error = tsleep((caddr_t)q, PWAIT | PCATCH, "wait", 0)) != 0)
return (error);
goto loop;
}
-/* $NetBSD: kern_fork.c,v 1.27 1995/12/10 08:26:02 mycroft Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.5 1996/03/03 17:19:45 niklas Exp $ */
+/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/vnode.h>
#include <sys/acct.h>
#include <sys/ktrace.h>
-#include <vm/vm.h>
-
-#include <sys/mount.h>
#include <sys/syscallargs.h>
+#include <vm/vm.h>
+
int nprocs = 1; /* process 0 */
#define ISFORK 0
#define ISVFORK 1
#define ISRFORK 2
+int fork1 __P((struct proc *, int, int, register_t *));
+
+/*ARGSUSED*/
int
sys_fork(p, v, retval)
struct proc *p;
return (fork1(p, ISFORK, 0, retval));
}
+/*ARGSUSED*/
int
sys_vfork(p, v, retval)
struct proc *p;
register struct proc *p2;
register uid_t uid;
struct proc *newproc;
- struct proc **hash;
int count;
static int nextpid, pidchecked = 0;
int dupfd = 1, cleanfd = 0;
-/* $NetBSD: kern_ktrace.c,v 1.21 1995/10/22 00:35:06 christos Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.3 1996/03/03 17:19:46 niklas Exp $ */
+/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#include <sys/mount.h>
#include <sys/syscallargs.h>
+struct ktr_header *ktrgetheader __P((int));
+int ktrops __P((struct proc *, struct proc *, int, int, struct vnode *));
+int ktrsetchildren __P((struct proc *, struct proc *, int, int,
+ struct vnode *));
+void ktrwrite __P((struct vnode *, struct ktr_header *));
+int ktrcanset __P((struct proc *, struct proc *));
+
struct ktr_header *
ktrgetheader(type)
int type;
register struct vnode *vp = NULL;
register struct proc *p;
struct pgrp *pg;
- int facs = SCARG(uap, facs) & ~KTRFAC_ROOT;
+ int facs = SCARG(uap, facs) & ~((unsigned) KTRFAC_ROOT);
int ops = KTROP(SCARG(uap, ops));
int descend = SCARG(uap, ops) & KTRFLAG_DESCEND;
int ret = 0;
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, fname),
curp);
- if (error = vn_open(&nd, FREAD|FWRITE, 0)) {
+ if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) {
curp->p_traceflag &= ~KTRFAC_ACTIVE;
return (error);
}
return (1);
}
+int
ktrsetchildren(curp, top, ops, facs, vp)
struct proc *curp, *top;
int ops, facs;
/*NOTREACHED*/
}
+void
ktrwrite(vp, kth)
struct vnode *vp;
register struct ktr_header *kth;
*
* TODO: check groups. use caller effective gid.
*/
+int
ktrcanset(callp, targetp)
struct proc *callp, *targetp;
{
-/* $NetBSD: kern_lkm.c,v 1.26 1995/10/10 00:23:20 thorpej Exp $ */
+/* $OpenBSD: kern_lkm.c,v 1.2 1996/03/03 17:19:47 niklas Exp $ */
+/* $NetBSD: kern_lkm.c,v 1.28 1996/02/09 18:59:38 christos Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
-#include <sys/conf.h>
#include <sys/file.h>
#include <sys/proc.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/exec.h>
+#include <sys/syscallargs.h>
+
+#include <kern/kern_conf.h>
+
#include <sys/lkm.h>
#include <sys/syscall.h>
#include <vm/vm_param.h>
#include <vm/vm_kern.h>
+
#define PAGESIZE 1024 /* kmem_alloc() allocation quantum */
#define LKM_ALLOC 0x01
static struct lkm_table lkmods[MAXLKMS]; /* table of loaded modules */
static struct lkm_table *curp; /* global for in-progress ops */
+static void lkmunreserve __P((void));
+static int _lkm_syscall __P((struct lkm_table *, int));
+static int _lkm_vfs __P((struct lkm_table *, int));
+static int _lkm_dev __P((struct lkm_table *, int));
+#ifdef STREAMS
+static int _lkm_strmod __P((struct lkm_table *, int));
+#endif
+static int _lkm_exec __P((struct lkm_table *, int));
+
+int lkmexists __P((struct lkm_table *));
+int lkmdispatch __P((struct lkm_table *, int));
+
/*ARGSUSED*/
int
lkmopen(dev, flag, devtype, p)
* Sleep pending unlock; we use tsleep() to allow
* an alarm out of the open.
*/
- if (error = tsleep((caddr_t)&lkm_v, TTIPRI|PCATCH, "lkmopn", 0))
+ error = tsleep((caddr_t)&lkm_v, TTIPRI|PCATCH, "lkmopn", 0);
+ if (error)
return (error); /* leave LKM_WANT set -- no problem */
}
lkm_v |= LKM_ALLOC;
* a coerced close of the lkm device (close on premature exit of modload)
* or explicitly by modload as a result of a link failure.
*/
-static int
+static void
lkmunreserve()
{
/*ARGSUSED*/
int
-lkmioctl(dev, cmd, data, flag)
+lkmioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
caddr_t data;
int flag;
+ struct proc *p;
{
- int err = 0;
+ int error = 0;
int i;
struct lmc_resrv *resrvp;
struct lmc_loadbuf *loadbufp;
struct lmc_unload *unloadp;
struct lmc_stat *statp;
- int (*funcp)();
char istr[MAXLKMNAME];
switch(cmd) {
if (!lkmods[i].used)
break;
if (i == MAXLKMS) {
- err = ENOMEM; /* no slots available */
+ error = ENOMEM; /* no slots available */
break;
}
curp = &lkmods[i];
|| i < 0
|| i > MODIOBUF
|| i > curp->size - curp->offset) {
- err = ENOMEM;
+ error = ENOMEM;
break;
}
/* copy in buffer full of data */
- if (err = copyin((caddr_t)loadbufp->data, (caddr_t)curp->area + curp->offset, i))
+ error = copyin(loadbufp->data,
+ (caddr_t)curp->area + curp->offset, i);
+ if (error)
break;
if ((curp->offset + i) < curp->size) {
return ENXIO;
}
- curp->entry = (int (*)()) (*((long *) (data)));
+ curp->entry = (int (*) __P((struct lkm_table *, int, int)))
+ (*((long *) (data)));
/* call entry(load)... (assigns "private" portion) */
- if (err = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION)) {
+ error = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION);
+ if (error) {
/*
* Module may refuse loading or may have a
* version mismatch...
* Copy name and lookup id from all loaded
* modules. May fail.
*/
- if (err = copyinstr(unloadp->name, istr, MAXLKMNAME-1,
- (size_t *)0))
+ error = copyinstr(unloadp->name, istr, MAXLKMNAME-1,
+ NULL);
+ if (error)
break;
/*
* Range check the value; on failure, return EINVAL
*/
if (i < 0 || i >= MAXLKMS) {
- err = EINVAL;
+ error = EINVAL;
break;
}
curp = &lkmods[i];
if (!curp->used) {
- err = ENOENT;
+ error = ENOENT;
break;
}
/* call entry(unload) */
if ((*(curp->entry))(curp, LKM_E_UNLOAD, LKM_VERSION)) {
- err = EBUSY;
+ error = EBUSY;
break;
}
}
if (i == MAXLKMS) { /* Not found */
- err = ENOENT;
+ error = ENOENT;
break;
}
}
* Range check the value; on failure, return EINVAL
*/
if (i < 0 || i >= MAXLKMS) {
- err = EINVAL;
+ error = EINVAL;
break;
}
curp = &lkmods[i];
if (!curp->used) { /* Not found */
- err = ENOENT;
+ error = ENOENT;
break;
}
break;
default: /* bad ioctl()... */
- err = ENOTTY;
+ error = ENOTTY;
break;
}
- return (err);
+ return (error);
}
/*
{
struct lkm_syscall *args = lkmtp->private.lkm_syscall;
int i;
- int err = 0;
+ int error = 0;
switch(cmd) {
case LKM_E_LOAD:
break; /* found it! */
/* out of allocable slots? */
if (i == SYS_MAXSYSCALL) {
- err = ENFILE;
+ error = ENFILE;
break;
}
} else { /* assign */
if (i < 0 || i >= SYS_MAXSYSCALL) {
- err = EINVAL;
+ error = EINVAL;
break;
}
}
break;
}
- return (err);
+ return (error);
}
/*
{
struct lkm_vfs *args = lkmtp->private.lkm_vfs;
int i;
- int err = 0;
+ int error = 0;
switch(cmd) {
case LKM_E_LOAD:
for (i = 0; i < nvfssw; i++)
if (vfssw[i] != (struct vfsops *)0 &&
strncmp(vfssw[i]->vfs_name,
- args->lkm_vfsops->vfs_name, MFSNAMELEN) == 0)
+ args->lkm_vfsops->vfs_name,
+ MFSNAMELEN) == 0)
return (EEXIST);
/* pick the last available empty slot */
if (vfssw[i] == (struct vfsops *)0)
break;
if (i == -1) { /* or if none, punt */
- err = EINVAL;
+ error = EINVAL;
break;
}
break;
}
- return (err);
+ return (error);
}
/*
{
struct lkm_dev *args = lkmtp->private.lkm_dev;
int i;
- int err = 0;
+ int error = 0;
extern int nblkdev, nchrdev; /* from conf.c */
switch(cmd) {
break; /* found it! */
/* out of allocable slots? */
if (i == nblkdev) {
- err = ENFILE;
+ error = ENFILE;
break;
}
} else { /* assign */
if (i < 0 || i >= nblkdev) {
- err = EINVAL;
+ error = EINVAL;
break;
}
}
break; /* found it! */
/* out of allocable slots? */
if (i == nchrdev) {
- err = ENFILE;
+ error = ENFILE;
break;
}
} else { /* assign */
if (i < 0 || i >= nchrdev) {
- err = EINVAL;
+ error = EINVAL;
break;
}
}
break;
default:
- err = ENODEV;
+ error = ENODEV;
break;
}
break;
break;
default:
- err = ENODEV;
+ error = ENODEV;
break;
}
break;
break;
}
- return (err);
+ return (error);
}
#ifdef STREAMS
{
struct lkm_strmod *args = lkmtp->private.lkm_strmod;
int i;
- int err = 0;
+ int error = 0;
switch(cmd) {
case LKM_E_LOAD:
break;
}
- return (err);
+ return (error);
}
#endif /* STREAMS */
{
struct lkm_exec *args = lkmtp->private.lkm_exec;
int i;
- int err = 0;
+ int error = 0;
switch(cmd) {
case LKM_E_LOAD:
break; /* found it! */
/* out of allocable slots? */
if (i == nexecs) {
- err = ENFILE;
+ error = ENFILE;
break;
}
} else { /* assign */
if (i < 0 || i >= nexecs) {
- err = EINVAL;
+ error = EINVAL;
break;
}
}
break;
}
- return (err);
+ return (error);
}
/*
struct lkm_table *lkmtp;
int cmd;
{
- int err = 0; /* default = success */
+ int error = 0; /* default = success */
switch(lkmtp->private.lkm_any->lkm_type) {
case LM_SYSCALL:
- err = _lkm_syscall(lkmtp, cmd);
+ error = _lkm_syscall(lkmtp, cmd);
break;
case LM_VFS:
- err = _lkm_vfs(lkmtp, cmd);
+ error = _lkm_vfs(lkmtp, cmd);
break;
case LM_DEV:
- err = _lkm_dev(lkmtp, cmd);
+ error = _lkm_dev(lkmtp, cmd);
break;
#ifdef STREAMS
#endif /* STREAMS */
case LM_EXEC:
- err = _lkm_exec(lkmtp, cmd);
+ error = _lkm_exec(lkmtp, cmd);
break;
case LM_MISC: /* ignore content -- no "misc-specific" procedure */
break;
default:
- err = ENXIO; /* unknown type */
+ error = ENXIO; /* unknown type */
break;
}
- return (err);
+ return (error);
}
-/* $NetBSD: kern_malloc.c,v 1.11 1995/05/01 22:39:11 cgd Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.2 1996/03/03 17:19:49 niklas Exp $ */
+/* $NetBSD: kern_malloc.c,v 1.13 1996/02/09 18:59:39 christos Exp $ */
/*
* Copyright (c) 1987, 1991, 1993
#include <sys/map.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/systm.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
* The WEIRD_ADDR is used as known text to copy into free objects so
* that modifications after frees can be detected.
*/
-#define WEIRD_ADDR 0xdeadbeef
+#define WEIRD_ADDR ((unsigned) 0xdeadbeef)
#define MAX_COPY 32
/*
continue;
printf("%s %d of object %p size %d %s %s (%p != %p)\n",
"Data modified on freelist: word", lp - (int32_t *)va,
- va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
+ va, size, "previous type", savedtype, (void *)*lp,
+ (void *) WEIRD_ADDR);
break;
}
/*
* Initialize the kernel memory allocator
*/
+void
kmeminit()
{
register long indx;
-/* $NetBSD: kern_physio.c,v 1.25 1995/10/10 02:51:45 mycroft Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.2 1996/03/03 17:19:50 niklas Exp $ */
+/* $NetBSD: kern_physio.c,v 1.26 1996/02/04 02:15:51 christos Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
#include <sys/conf.h>
#include <sys/proc.h>
+#include <vm/vm.h>
+
/*
* The routines implemented in this file are described in:
* Leffler, et al.: The Design and Implementation of the 4.3BSD
return (EFAULT);
/* Make sure we have a buffer, creating one if necessary. */
- if (nobuf = (bp == NULL))
+ if ((nobuf = (bp == NULL)) != 0)
bp = getphysbuf();
/* [raise the processor priority level to splbio;] */
-/* $NetBSD: kern_proc.c,v 1.12 1995/03/19 23:44:49 mycroft Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.2 1996/03/03 17:19:51 niklas Exp $ */
+/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
struct proclist allproc;
struct proclist zombproc;
+static void orphanpg __P((struct pgrp *));
+#ifdef DEBUG
+void pgrpdump __P((void));
+#endif
+
/*
* Initialize global process hashing structures.
*/
FREE(pgrp, M_PGRP);
}
-static void orphanpg();
-
/*
* Adjust pgrp jobc counters when specified process changes process group.
* We count the number of processes in each process group that "qualify"
}
#ifdef DEBUG
+void
pgrpdump()
{
register struct pgrp *pgrp;
register i;
for (i = 0; i <= pgrphash; i++) {
- if (pgrp = pgrphashtbl[i].lh_first) {
+ if ((pgrp = pgrphashtbl[i].lh_first) != NULL) {
printf("\tindx %d\n", i);
for (; pgrp != 0; pgrp = pgrp->pg_hash.le_next) {
printf("\tpgrp %p, pgid %d, sess %p, sesscnt %d, mem %p\n",
-/* $NetBSD: kern_prot.c,v 1.31 1995/10/10 01:26:53 mycroft Exp $ */
+/* $OpenBSD: kern_prot.c,v 1.2 1996/03/03 17:19:52 niklas Exp $ */
+/* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
#include <sys/syscallargs.h>
/* ARGSUSED */
+int
sys_getpid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_getppid(p, v, retval)
struct proc *p;
void *v;
}
/* Get process group ID; note that POSIX getpgrp takes no parameter */
+int
sys_getpgrp(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_getuid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_geteuid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_getgid(p, v, retval)
struct proc *p;
void *v;
* correctly in a library function.
*/
/* ARGSUSED */
+int
sys_getegid(p, v, retval)
struct proc *p;
void *v;
return (0);
}
+int
sys_getgroups(p, v, retval)
struct proc *p;
void *v;
if (ngrp < pc->pc_ucred->cr_ngroups)
return (EINVAL);
ngrp = pc->pc_ucred->cr_ngroups;
- if (error = copyout((caddr_t)pc->pc_ucred->cr_groups,
- (caddr_t)SCARG(uap, gidset), ngrp * sizeof(gid_t)))
+ error = copyout((caddr_t)pc->pc_ucred->cr_groups,
+ (caddr_t)SCARG(uap, gidset), ngrp * sizeof(gid_t));
+ if (error)
return (error);
*retval = ngrp;
return (0);
}
/* ARGSUSED */
+int
sys_setsid(p, v, retval)
register struct proc *p;
void *v;
* pid must not be session leader (EPERM)
*/
/* ARGSUSED */
+int
sys_setpgid(curp, v, retval)
struct proc *curp;
void *v;
}
/* ARGSUSED */
+int
sys_setuid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_seteuid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_setgid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_setegid(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_setgroups(p, v, retval)
struct proc *p;
void *v;
register u_int ngrp;
int error;
- if (error = suser(pc->pc_ucred, &p->p_acflag))
+ if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0)
return (error);
ngrp = SCARG(uap, gidsetsize);
if (ngrp > NGROUPS)
return (EINVAL);
pc->pc_ucred = crcopy(pc->pc_ucred);
- if (error = copyin((caddr_t)SCARG(uap, gidset),
- (caddr_t)pc->pc_ucred->cr_groups, ngrp * sizeof(gid_t)))
+ error = copyin((caddr_t)SCARG(uap, gidset),
+ (caddr_t)pc->pc_ucred->cr_groups, ngrp * sizeof(gid_t));
+ if (error)
return (error);
pc->pc_ucred->cr_ngroups = ngrp;
p->p_flag |= P_SUGID;
/*
* Check if gid is a member of the group set.
*/
+int
groupmember(gid, cred)
gid_t gid;
register struct ucred *cred;
* indicating use of super-powers.
* Returns 0 or error.
*/
+int
suser(cred, acflag)
struct ucred *cred;
u_short *acflag;
* Get login name, if available.
*/
/* ARGSUSED */
+int
sys_getlogin(p, v, retval)
struct proc *p;
void *v;
* Set login name.
*/
/* ARGSUSED */
+int
sys_setlogin(p, v, retval)
struct proc *p;
void *v;
} */ *uap = v;
int error;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
error = copyinstr((caddr_t) SCARG(uap, namebuf),
(caddr_t) p->p_pgrp->pg_session->s_login,
-/* $NetBSD: kern_resource.c,v 1.32 1995/12/09 04:09:34 mycroft Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.3 1996/03/03 17:19:53 niklas Exp $ */
+/* $NetBSD: kern_resource.c,v 1.34 1996/02/09 18:59:44 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
#include <vm/vm.h>
-int donice __P((struct proc *curp, struct proc *chgp, int n));
-int dosetrlimit __P((struct proc *p, u_int which, struct rlimit *limp));
-
+void limfree __P((struct plimit *));
/*
* Resource controls and accounting.
*/
struct rlimit alim;
int error;
- if (error = copyin((caddr_t)SCARG(uap, rlp), (caddr_t)&alim,
- sizeof (struct rlimit)))
+ error = copyin((caddr_t)SCARG(uap, rlp), (caddr_t)&alim,
+ sizeof (struct rlimit));
+ if (error)
return (error);
return (dosetrlimit(p, SCARG(uap, which), &alim));
}
alimp = &p->p_rlimit[which];
if (limp->rlim_cur > alimp->rlim_max ||
limp->rlim_max > alimp->rlim_max)
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if (limp->rlim_cur > limp->rlim_max)
limp->rlim_cur = limp->rlim_max;
-/* $NetBSD: kern_sig.c,v 1.51 1996/01/04 22:23:14 jtc Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.3 1996/03/03 17:19:54 niklas Exp $ */
+/* $NetBSD: kern_sig.c,v 1.53 1996/02/09 18:59:47 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
#include <sys/syslog.h>
#include <sys/stat.h>
#include <sys/core.h>
+#include <sys/ptrace.h>
+#include <sys/cpu.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <sys/user.h> /* for coredump */
void stop __P((struct proc *p));
+void killproc __P((struct proc *, char *));
/*
* Can process p, with pcred pc, send the signal signum to process q?
((signum) == SIGCONT && (q)->p_session == (p)->p_session))
/* ARGSUSED */
+int
sys_sigaction(p, v, retval)
struct proc *p;
void *v;
if ((sa->sa_mask & bit) == 0)
sa->sa_flags |= SA_NODEFER;
sa->sa_mask &= ~bit;
- if (error = copyout((caddr_t)sa, (caddr_t)SCARG(uap, osa),
- sizeof (vec)))
+ error = copyout((caddr_t)sa, (caddr_t)SCARG(uap, osa),
+ sizeof (vec));
+ if (error)
return (error);
}
if (SCARG(uap, nsa)) {
- if (error = copyin((caddr_t)SCARG(uap, nsa), (caddr_t)sa,
- sizeof (vec)))
+ error = copyin((caddr_t)SCARG(uap, nsa), (caddr_t)sa,
+ sizeof (vec));
+ if (error)
return (error);
setsigvec(p, signum, sa);
}
return (0);
}
+void
setsigvec(p, signum, sa)
register struct proc *p;
int signum;
* and return old mask as return value;
* the library stub does the rest.
*/
+int
sys_sigprocmask(p, v, retval)
register struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_sigpending(p, v, retval)
struct proc *p;
void *v;
}
/* ARGSUSED */
+int
sys_sigaltstack(p, v, retval)
struct proc *p;
void *v;
return (error);
if (SCARG(uap, nss) == 0)
return (0);
- if (error = copyin((caddr_t)SCARG(uap, nss), (caddr_t)&ss,
- sizeof (ss)))
+ error = copyin((caddr_t)SCARG(uap, nss), (caddr_t)&ss, sizeof (ss));
+ if (error)
return (error);
if (ss.ss_flags & SS_DISABLE) {
if (psp->ps_sigstk.ss_flags & SS_ONSTACK)
* Common code for kill process group/broadcast kill.
* cp is calling process.
*/
+int
killpg1(cp, signum, pgid, all)
register struct proc *cp;
int signum, pgid, all;
/*
* Kill the current process for stated reason.
*/
+void
killproc(p, why)
struct proc *p;
char *why;
* If dumping core, save the signal number for the debugger. Calls exit and
* does not return.
*/
-int
+void
sigexit(p, signum)
register struct proc *p;
int signum;
return (EFAULT);
sprintf(name, "%s.core", p->p_comm);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
- if (error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR))
+ error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR);
+ if (error)
return (error);
vp = nd.ni_vp;
-/* $NetBSD: kern_synch.c,v 1.33 1995/06/08 23:51:03 mycroft Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.2 1996/03/03 17:19:55 niklas Exp $ */
+/* $NetBSD: kern_synch.c,v 1.35 1996/02/09 18:59:50 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
#include <sys/buf.h>
#include <sys/signalvar.h>
#include <sys/resourcevar.h>
-#include <sys/vmmeter.h>
+#include <vm/vm.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
+#include <sys/cpu.h>
#include <machine/cpu.h>
u_char curpriority; /* usrpri of curproc */
int lbolt; /* once a second sleep address */
+void roundrobin __P((void *));
+void schedcpu __P((void *));
+void updatepri __P((struct proc *));
+void endtsleep __P((void *));
+
/*
* Force switch among equal priority processes every 100ms.
*/
*/
if (catch) {
p->p_flag |= P_SINTR;
- if (sig = CURSIG(p)) {
+ if ((sig = CURSIG(p)) != 0) {
if (p->p_wchan)
unsleep(p);
p->p_stat = SRUN;
}
} else if (timo)
untimeout(endtsleep, (void *)p);
- if (catch && (sig != 0 || (sig = CURSIG(p)))) {
+ if (catch && (sig != 0 || (sig = CURSIG(p)) != 0)) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
s = splhigh();
qp = &slpque[LOOKUP(ident)];
restart:
- for (q = &qp->sq_head; p = *q; ) {
+ for (q = &qp->sq_head; (p = *q) != NULL; ) {
#ifdef DIAGNOSTIC
- if (p->p_back || p->p_stat != SSLEEP && p->p_stat != SSTOP)
+ if (p->p_back || (p->p_stat != SSLEEP && p->p_stat != SSTOP))
panic("wakeup");
#endif
if (p->p_wchan == ident) {
}
#ifdef DDB
+#include <machine/db_machdep.h>
+
+#include <ddb/db_interface.h>
+#include <ddb/db_output.h>
+
void
db_show_all_procs(addr, haddr, count, modif)
- long addr;
+ db_expr_t addr;
int haddr;
- int count;
+ db_expr_t count;
char *modif;
{
int map = modif[0] == 'm';
-/* $NetBSD: kern_sysctl.c,v 1.12 1995/10/07 06:28:27 mycroft Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.2 1996/03/03 17:19:56 niklas Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.14 1996/02/09 18:59:52 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
#include <sys/mount.h>
#include <sys/syscallargs.h>
-sysctlfn kern_sysctl;
-sysctlfn hw_sysctl;
-#ifdef DEBUG
-sysctlfn debug_sysctl;
-#endif
-extern sysctlfn vm_sysctl;
-extern sysctlfn fs_sysctl;
-extern sysctlfn net_sysctl;
-extern sysctlfn cpu_sysctl;
-
/*
* Locking and stats
*/
syscallarg(size_t) newlen;
} */ *uap = v;
int error, dolock = 1;
- size_t savelen, oldlen = 0;
+ size_t savelen = 0, oldlen = 0;
sysctlfn *fn;
int name[CTL_MAXNAME];
*/
if (SCARG(uap, namelen) > CTL_MAXNAME || SCARG(uap, namelen) < 2)
return (EINVAL);
- if (error =
- copyin(SCARG(uap, name), &name, SCARG(uap, namelen) * sizeof(int)))
+ error = copyin(SCARG(uap, name), &name,
+ SCARG(uap, namelen) * sizeof(int));
+ if (error)
return (error);
switch (name[0]) {
&oldlen, SCARG(uap, new), SCARG(uap, newlen), p);
if (SCARG(uap, old) != NULL) {
if (dolock)
- vsunlock(SCARG(uap, old), savelen, B_WRITE);
+ vsunlock(SCARG(uap, old), savelen);
memlock.sl_lock = 0;
if (memlock.sl_want) {
memlock.sl_want = 0;
/*
* kernel related system variables.
*/
+int
kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
/*
* hardware related system variables.
*/
+int
hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
* Validate parameters and get old / set new parameters
* for an integer-valued sysctl function.
*/
+int
sysctl_int(oldp, oldlenp, newp, newlen, valp)
void *oldp;
size_t *oldlenp;
/*
* As above, but read-only.
*/
+int
sysctl_rdint(oldp, oldlenp, newp, val)
void *oldp;
size_t *oldlenp;
* Validate parameters and get old / set new parameters
* for a string-valued sysctl function.
*/
+int
sysctl_string(oldp, oldlenp, newp, newlen, str, maxlen)
void *oldp;
size_t *oldlenp;
/*
* As above, but read-only.
*/
+int
sysctl_rdstring(oldp, oldlenp, newp, str)
void *oldp;
size_t *oldlenp;
* Validate parameters and get old / set new parameters
* for a structure oriented sysctl function.
*/
+int
sysctl_struct(oldp, oldlenp, newp, newlen, sp, len)
void *oldp;
size_t *oldlenp;
* Validate parameters and get old parameters
* for a structure oriented sysctl function.
*/
+int
sysctl_rdstruct(oldp, oldlenp, newp, sp, len)
void *oldp;
size_t *oldlenp;
/*
* Get file structures.
*/
+int
sysctl_file(where, sizep)
char *where;
size_t *sizep;
*sizep = 0;
return (0);
}
- if (error = copyout((caddr_t)&filehead, where, sizeof(filehead)))
+ error = copyout((caddr_t)&filehead, where, sizeof(filehead));
+ if (error)
return (error);
buflen -= sizeof(filehead);
where += sizeof(filehead);
*sizep = where - start;
return (ENOMEM);
}
- if (error = copyout((caddr_t)fp, where, sizeof (struct file)))
+ error = copyout((caddr_t)fp, where, sizeof (struct file));
+ if (error)
return (error);
buflen -= sizeof(struct file);
where += sizeof(struct file);
*/
#define KERN_PROCSLOP (5 * sizeof (struct kinfo_proc))
+int
sysctl_doproc(name, namelen, where, sizep)
int *name;
u_int namelen;
}
if (buflen >= sizeof(struct kinfo_proc)) {
fill_eproc(p, &eproc);
- if (error = copyout((caddr_t)p, &dp->kp_proc,
- sizeof(struct proc)))
+ error = copyout((caddr_t)p, &dp->kp_proc,
+ sizeof(struct proc));
+ if (error)
return (error);
- if (error = copyout((caddr_t)&eproc, &dp->kp_eproc,
- sizeof(eproc)))
+ error = copyout((caddr_t)&eproc, &dp->kp_eproc,
+ sizeof(eproc));
+ if (error)
return (error);
dp++;
buflen -= sizeof(struct kinfo_proc);
-/* $NetBSD: kern_time.c,v 1.16 1995/10/07 06:28:28 mycroft Exp $ */
+/* $OpenBSD: kern_time.c,v 1.2 1996/03/03 17:19:57 niklas Exp $ */
+/* $NetBSD: kern_time.c,v 1.19 1996/02/13 21:10:43 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/vnode.h>
+#include <sys/signalvar.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
+#if defined(NFSCLIENT) || defined(NFSSERVER)
+#include <nfs/nfs_var.h>
+#endif
+
#include <machine/cpu.h>
/*
if (SCARG(uap, tp)) {
microtime(&atv);
- if (error = copyout((caddr_t)&atv, (caddr_t)SCARG(uap, tp),
- sizeof (atv)))
+ error = copyout((caddr_t)&atv, (caddr_t)SCARG(uap, tp),
+ sizeof (atv));
+ if (error)
return (error);
}
if (SCARG(uap, tzp))
struct timezone atz;
int error, s;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
/* Verify all parameters before changing time. */
if (SCARG(uap, tv) && (error = copyin((caddr_t)SCARG(uap, tv),
register long ndelta, ntickdelta, odelta;
int s, error;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
- if (error = copyin((caddr_t)SCARG(uap, delta), (caddr_t)&atv,
- sizeof(struct timeval)))
+
+ error = copyin((caddr_t)SCARG(uap, delta), (caddr_t)&atv,
+ sizeof(struct timeval));
+ if (error)
return (error);
/*
int
sys_setitimer(p, v, retval)
struct proc *p;
- void *v;
+ register void *v;
register_t *retval;
{
register struct sys_setitimer_args /* {
-/* $NetBSD: kern_xxx.c,v 1.29 1995/10/07 06:28:30 mycroft Exp $ */
+/* $OpenBSD: kern_xxx.c,v 1.2 1996/03/03 17:19:58 niklas Exp $ */
+/* $NetBSD: kern_xxx.c,v 1.31 1996/02/09 18:59:54 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
#include <sys/reboot.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
-
+#include <sys/cpu.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
} */ *uap = v;
int error;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
boot(SCARG(uap, opt));
return (0);
-/* $NetBSD: subr_autoconf.c,v 1.16 1994/11/04 06:40:11 mycroft Exp $ */
+/* $OpenBSD: subr_autoconf.c,v 1.2 1996/03/03 17:19:59 niklas Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.17 1996/02/04 02:16:35 christos Exp $ */
/*
* Copyright (c) 1992, 1993
#include <sys/param.h>
#include <sys/device.h>
#include <sys/malloc.h>
-#include <lib/libkern/libkern.h>
+#include <sys/systm.h>
#include <machine/limits.h>
/*
int indirect, pri;
};
+static char *number __P((char *, int));
+static void mapply __P((struct matchinfo *, struct cfdata *));
+
/*
* Apply the matching function and choose the best. This is used
* a few times and we want to keep the code small.
-/* $NetBSD: subr_log.c,v 1.8 1994/10/30 21:47:47 cgd Exp $ */
+/* $OpenBSD: subr_log.c,v 1.2 1996/03/03 17:20:00 niklas Exp $ */
+/* $NetBSD: subr_log.c,v 1.10 1996/02/09 18:59:58 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
#include <sys/ioctl.h>
#include <sys/msgbuf.h>
#include <sys/file.h>
+#include <sys/signalvar.h>
+#include <sys/syslog.h>
+
+#include <kern/kern_conf.h>
#define LOG_RDPRI (PZERO + 1)
int
logclose(dev, flag, mode, p)
dev_t dev;
- int flag;
+ int flag, mode;
+ struct proc *p;
{
log_open = 0;
return (EWOULDBLOCK);
}
logsoftc.sc_state |= LOG_RDWAIT;
- if (error = tsleep((caddr_t)mbp, LOG_RDPRI | PCATCH,
- "klog", 0)) {
+ error = tsleep((caddr_t)mbp, LOG_RDPRI | PCATCH,
+ "klog", 0);
+ if (error) {
splx(s);
return (error);
}
if (logsoftc.sc_state & LOG_ASYNC) {
if (logsoftc.sc_pgid < 0)
gsignal(-logsoftc.sc_pgid, SIGIO);
- else if (p = pfind(logsoftc.sc_pgid))
+ else if ((p = pfind(logsoftc.sc_pgid)) != NULL)
psignal(p, SIGIO);
}
if (logsoftc.sc_state & LOG_RDWAIT) {
/*ARGSUSED*/
int
-logioctl(dev, com, data, flag)
+logioctl(dev, com, data, flag, p)
dev_t dev;
u_long com;
caddr_t data;
int flag;
+ struct proc *p;
{
long l;
int s;
-/* $NetBSD: subr_prof.c,v 1.8 1995/11/22 23:07:26 cgd Exp $ */
+/* $OpenBSD: subr_prof.c,v 1.3 1996/03/03 17:20:01 niklas Exp $ */
+/* $NetBSD: subr_prof.c,v 1.10 1996/02/09 19:00:06 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/user.h>
-
+#include <sys/cpu.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
extern char etext[];
+
+void
kmstartup()
{
char *cp;
* 1.0 is represented as 0x10000. A scale factor of 0 turns off profiling.
*/
/* ARGSUSED */
+int
sys_profil(p, v, retval)
struct proc *p;
void *v;
{
register struct sys_profil_args /* {
syscallarg(caddr_t) samples;
- syscallarg(size_t) size;
- syscallarg(u_long) offset;
+ syscallarg(u_int) size;
+ syscallarg(u_int) offset;
syscallarg(u_int) scale;
} */ *uap = v;
register struct uprof *upp;
-/* $NetBSD: subr_rmap.c,v 1.9 1994/06/29 06:33:02 cgd Exp $ */
+/* $OpenBSD: subr_rmap.c,v 1.2 1996/03/03 17:20:02 niklas Exp $ */
+/* $NetBSD: subr_rmap.c,v 1.10 1996/02/04 02:16:49 christos Exp $ */
/*
* Copyright (C) 1992, 1994 Wolfgang Solfrank.
#include <sys/param.h>
#include <sys/map.h>
+#include <sys/systm.h>
/*
* Resource allocation map handling.
*/
if (fp->m_size > size) {
/* range to free is smaller, so drop that */
- printf("rmfree: map '%s' loses space (%d)\n", mp->m_name,
- size);
+ printf("rmfree: map '%s' loses space (%d)\n",
+ mp->m_name, size);
return;
} else {
/* drop the smallest slot in the list */
- printf("rmfree: map '%s' loses space (%d)\n", mp->m_name,
- fp->m_size);
- ovbcopy(fp + 1,fp,(char *)(mp->m_limit - 1) - (char *)fp);
+ printf("rmfree: map '%s' loses space (%d)\n",
+ mp->m_name, fp->m_size);
+ ovbcopy(fp + 1, fp,
+ (char *)(mp->m_limit - 1) - (char *)fp);
mp->m_limit[-1].m_addr = 0;
/* now retry */
}
-/* $NetBSD: sys_generic.c,v 1.21 1995/10/07 06:28:34 mycroft Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.2 1996/03/03 17:20:03 niklas Exp $ */
+/* $NetBSD: sys_generic.c,v 1.23 1996/02/09 19:00:09 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
#include <sys/file.h>
#include <sys/proc.h>
#include <sys/socketvar.h>
+#include <sys/signalvar.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
+int selscan __P((struct proc *, fd_set *, fd_set *, int, register_t *));
+int seltrue __P((dev_t, int, struct proc *));
+
/*
* Read system call.
*/
/* ARGSUSED */
+int
sys_read(p, v, retval)
struct proc *p;
void *v;
ktriov = aiov;
#endif
cnt = SCARG(uap, nbyte);
- if (error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred))
+ error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred);
+ if (error)
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
/*
* Scatter read system call.
*/
+int
sys_readv(p, v, retval)
struct proc *p;
void *v;
auio.uio_rw = UIO_READ;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
- if (error = copyin((caddr_t)SCARG(uap, iovp), (caddr_t)iov, iovlen))
+ error = copyin((caddr_t)SCARG(uap, iovp), (caddr_t)iov, iovlen);
+ if (error)
goto done;
auio.uio_resid = 0;
for (i = 0; i < SCARG(uap, iovcnt); i++) {
+#if 0
+ /* Cannot happen iov_len is unsigned */
if (iov->iov_len < 0) {
error = EINVAL;
goto done;
}
+#endif
auio.uio_resid += iov->iov_len;
if (auio.uio_resid < 0) {
error = EINVAL;
}
#endif
cnt = auio.uio_resid;
- if (error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred))
+ error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred);
+ if (error)
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
/*
* Write system call
*/
+int
sys_write(p, v, retval)
struct proc *p;
void *v;
ktriov = aiov;
#endif
cnt = SCARG(uap, nbyte);
- if (error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred)) {
+ error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred);
+ if (error) {
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
/*
* Gather write system call
*/
+int
sys_writev(p, v, retval)
struct proc *p;
void *v;
auio.uio_rw = UIO_WRITE;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
- if (error = copyin((caddr_t)SCARG(uap, iovp), (caddr_t)iov, iovlen))
+ error = copyin((caddr_t)SCARG(uap, iovp), (caddr_t)iov, iovlen);
+ if (error)
goto done;
auio.uio_resid = 0;
for (i = 0; i < SCARG(uap, iovcnt); i++) {
+#if 0
+ /* Cannot happen iov_len is unsigned */
if (iov->iov_len < 0) {
error = EINVAL;
goto done;
}
+#endif
auio.uio_resid += iov->iov_len;
if (auio.uio_resid < 0) {
error = EINVAL;
}
#endif
cnt = auio.uio_resid;
- if (error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred)) {
+ error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred);
+ if (error) {
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
* Ioctl system call
*/
/* ARGSUSED */
+int
sys_ioctl(p, v, retval)
struct proc *p;
void *v;
switch (com) {
case FIONBIO:
- if (tmp = *(int *)data)
+ if ((tmp = *(int *)data) != 0)
fp->f_flag |= FNONBLOCK;
else
fp->f_flag &= ~FNONBLOCK;
break;
case FIOASYNC:
- if (tmp = *(int *)data)
+ if ((tmp = *(int *)data) != 0)
fp->f_flag |= FASYNC;
else
fp->f_flag &= ~FASYNC;
/*
* Select system call.
*/
+int
sys_select(p, v, retval)
register struct proc *p;
void *v;
s = splhigh();
/* this should be timercmp(&time, &atv, >=) */
if (SCARG(uap, tv) && (time.tv_sec > atv.tv_sec ||
- time.tv_sec == atv.tv_sec && time.tv_usec >= atv.tv_usec)) {
+ (time.tv_sec == atv.tv_sec && time.tv_usec >= atv.tv_usec))) {
splx(s);
goto done;
}
return (error);
}
+int
selscan(p, ibits, obits, nfd, retval)
struct proc *p;
fd_set *ibits, *obits;
}
/*ARGSUSED*/
+int
seltrue(dev, flag, p)
dev_t dev;
int flag;
-/* $NetBSD: sys_process.c,v 1.52 1995/10/07 06:28:36 mycroft Exp $ */
+/* $OpenBSD: sys_process.c,v 1.2 1996/03/03 17:20:04 niklas Exp $ */
+/* $NetBSD: sys_process.c,v 1.54 1996/02/09 19:00:14 christos Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
#include <machine/reg.h>
+#include <miscfs/procfs/procfs.h>
+
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
/*
* Arrange for a single-step, if that's requested and possible.
*/
- if (error = process_sstep(t, SCARG(uap, req) == PT_STEP))
+ error = process_sstep(t, SCARG(uap, req) == PT_STEP);
+ if (error)
goto relebad;
#endif
/* If the address paramter is not (int *)1, set the pc. */
if ((int *)SCARG(uap, addr) != (int *)1)
- if (error = process_set_pc(t, SCARG(uap, addr)))
+ if ((error = process_set_pc(t, SCARG(uap, addr))) != 0)
goto relebad;
PRELE(t);
#ifdef DIAGNOSTIC
panic("ptrace: impossible");
#endif
+ return 0;
}
+int
trace_req(a1)
struct proc *a1;
{
-/* $NetBSD: sysv_msg.c,v 1.17 1995/10/07 06:28:40 mycroft Exp $ */
+/* $OpenBSD: sysv_msg.c,v 1.2 1996/03/03 17:20:05 niklas Exp $ */
+/* $NetBSD: sysv_msg.c,v 1.19 1996/02/09 19:00:18 christos Exp $ */
/*
* Implementation of SVID messages
short free_msgmaps; /* head of linked list of free map entries */
struct msg *free_msghdrs; /* list of free msg headers */
-int
+static void msg_freehdr __P((struct msg *));
+
+void
msginit()
{
register int i;
- vm_offset_t whocares1, whocares2;
/*
* msginfo.msgssz should be a power of two for efficiency reasons.
int cmd = SCARG(uap, cmd);
struct msqid_ds *user_msqptr = SCARG(uap, buf);
struct ucred *cred = p->p_ucred;
- int i, rval, eval;
+ int rval, eval;
struct msqid_ds msqbuf;
register struct msqid_ds *msqptr;
case IPC_RMID:
{
struct msg *msghdr;
- if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M)))
+ if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M)) != 0)
return(eval);
/* Free the message headers */
msghdr = msqptr->msg_first;
int key = SCARG(uap, key);
int msgflg = SCARG(uap, msgflg);
struct ucred *cred = p->p_ucred;
- register struct msqid_ds *msqptr;
+ register struct msqid_ds *msqptr = NULL;
#ifdef MSG_DEBUG_OK
printf("msgget(0x%x, 0%o)\n", key, msgflg);
int need_more_resources = 0;
/*
- * check msgsz
+ * check msgsz [cannot be negative since it is unsigned]
* (inside this loop in case msg_qbytes changes while we sleep)
*/
- if (msgsz < 0 || msgsz > msqptr->msg_qbytes) {
+ if (msgsz > msqptr->msg_qbytes) {
#ifdef MSG_DEBUG_OK
printf("msgsz > msqptr->msg_qbytes\n");
#endif
return(eval);
}
+#if 0
+ /* cannot happen, msgsz is unsigned */
if (msgsz < 0) {
#ifdef MSG_DEBUG_OK
printf("msgsz < 0\n");
#endif
return(EINVAL);
}
+#endif
msghdr = NULL;
while (msghdr == NULL) {
-/* $NetBSD: sysv_sem.c,v 1.24 1995/10/07 06:28:42 mycroft Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.2 1996/03/03 17:20:06 niklas Exp $ */
+/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
* Implementation of SVID semaphores
int semtot = 0;
struct proc *semlock_holder = NULL;
-int
+void semlock __P((struct proc *));
+struct sem_undo *semu_alloc __P((struct proc *));
+int semundo_adjust __P((struct proc *, struct sem_undo **, int, int, int));
+void semundo_clear __P((int, int));
+
+void
seminit()
{
register int i;
- vm_offset_t whocares1, whocares2;
if (sema == NULL)
panic("sema is NULL");
panic("semu_alloc - second attempt failed");
}
}
+ return NULL;
}
/*
int
sys___semctl(p, v, retval)
struct proc *p;
- void *v;
+ register void *v;
register_t *retval;
{
register struct sys___semctl_args /* {
switch (cmd) {
case IPC_RMID:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_M)))
+ if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_M)) != 0)
return(eval);
semaptr->sem_perm.cuid = cred->cr_uid;
semaptr->sem_perm.uid = cred->cr_uid;
int nsops = SCARG(uap, nsops);
struct sembuf sops[MAX_SOPS];
register struct semid_ds *semaptr;
- register struct sembuf *sopptr;
- register struct sem *semptr;
+ register struct sembuf *sopptr = NULL;
+ register struct sem *semptr = NULL;
struct sem_undo *suptr = NULL;
struct ucred *cred = p->p_ucred;
int i, j, eval;
- int all_ok, do_wakeup, do_undos;
+ int do_wakeup, do_undos;
#ifdef SEM_DEBUG
printf("call to semop(%d, %p, %d)\n", semid, sops, nsops);
#endif
if (sopptr->sem_op < 0) {
- if (semptr->semval + sopptr->sem_op < 0) {
+ if ((int)(semptr->semval +
+ sopptr->sem_op) < 0) {
#ifdef SEM_DEBUG
printf("semop: can't do it now\n");
#endif
* Go through the undo structures for this process and apply the adjustments to
* semaphores.
*/
+void
semexit(p)
struct proc *p;
{
-/* $NetBSD: sysv_shm.c,v 1.34 1995/12/09 04:12:56 mycroft Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.3 1996/03/03 17:20:08 niklas Exp $ */
+/* $NetBSD: sysv_shm.c,v 1.36 1996/02/09 19:00:29 christos Exp $ */
/*
* Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
+struct shmid_ds *shm_find_segment_by_shmid __P((int));
+void shmexit __P((struct proc *));
+
/*
* Provides the following externally accessible functions:
*
int shmid;
};
-static void shm_deallocate_segment __P((struct shmid_ds *));
static int shm_find_segment_by_key __P((key_t));
-struct shmid_ds *shm_find_segment_by_shmid __P((int));
+static void shm_deallocate_segment __P((struct shmid_ds *));
static int shm_delete_mapping __P((struct proc *, struct shmmap_state *));
+static int shmget_existing __P((struct proc *, struct sys_shmget_args *,
+ int, int, register_t *));
+static int shmget_allocate_segment __P((struct proc *, struct sys_shmget_args *,
+ int, register_t *));
static int
shm_find_segment_by_key(key)
struct sys_shmat_args /* {
syscallarg(int) shmid;
syscallarg(void *) shmaddr;
- syscallarg(int) shmflag;
+ syscallarg(int) shmflg;
} */ *uap = v;
int error, i, flags;
struct ucred *cred = p->p_ucred;
shmseg = shm_find_segment_by_shmid(SCARG(uap, shmid));
if (shmseg == NULL)
return EINVAL;
- if (error = ipcperm(cred, &shmseg->shm_perm,
- (SCARG(uap, shmflg) & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W))
+ error = ipcperm(cred, &shmseg->shm_perm,
+ (SCARG(uap, shmflg) & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);
+ if (error)
return error;
for (i = 0; i < shminfo.shmseg; i++) {
if (shmmap_s->shmid == -1)
syscallarg(int) cmd;
syscallarg(struct shmid_ds *) buf;
} */ *uap = v;
- int error, segnum;
+ int error;
struct ucred *cred = p->p_ucred;
struct shmid_ds inbuf;
struct shmid_ds *shmseg;
return EINVAL;
switch (SCARG(uap, cmd)) {
case IPC_STAT:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
+ if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_R)) != 0)
return error;
- if (error = copyout((caddr_t)shmseg, SCARG(uap, buf),
- sizeof(inbuf)))
+ error = copyout((caddr_t)shmseg, SCARG(uap, buf),
+ sizeof(inbuf));
+ if (error)
return error;
break;
case IPC_SET:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
+ if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_M)) != 0)
return error;
- if (error = copyin(SCARG(uap, buf), (caddr_t)&inbuf,
- sizeof(inbuf)))
+ error = copyin(SCARG(uap, buf), (caddr_t)&inbuf,
+ sizeof(inbuf));
+ if (error)
return error;
shmseg->shm_perm.uid = inbuf.shm_perm.uid;
shmseg->shm_perm.gid = inbuf.shm_perm.gid;
shmseg->shm_ctime = time.tv_sec;
break;
case IPC_RMID:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
+ if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_M)) != 0)
return error;
shmseg->shm_perm.key = IPC_PRIVATE;
shmseg->shm_perm.mode |= SHMSEG_REMOVED;
struct sys_shmget_args /* {
syscallarg(key_t) key;
syscallarg(int) size;
- syscallarg(int) shmflag;
+ syscallarg(int) shmflg;
} */ *uap;
int mode;
int segnum;
* allocation failed or it was freed).
*/
shmseg->shm_perm.mode |= SHMSEG_WANTED;
- if (error =
- tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0))
+ error = tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0);
+ if (error)
return error;
return EAGAIN;
}
- if (error = ipcperm(cred, &shmseg->shm_perm, mode))
+ if ((error = ipcperm(cred, &shmseg->shm_perm, mode)) != 0)
return error;
if (SCARG(uap, size) && SCARG(uap, size) > shmseg->shm_segsz)
return EINVAL;
struct sys_shmget_args /* {
syscallarg(key_t) key;
syscallarg(int) size;
- syscallarg(int) shmflag;
+ syscallarg(int) shmflg;
} */ *uap;
int mode;
register_t *retval;
struct sys_shmget_args /* {
syscallarg(key_t) key;
syscallarg(int) size;
- syscallarg(int) shmflag;
+ syscallarg(int) shmflg;
} */ *uap = v;
int segnum, mode, error;
- struct shmid_ds *shmseg;
mode = SCARG(uap, shmflg) & ACCESSPERMS;
if (SCARG(uap, key) != IPC_PRIVATE) {
struct proc *p;
{
struct shmmap_state *shmmap_s;
- struct shmid_ds *shmseg;
int i;
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
-/* $NetBSD: tty.c,v 1.64 1996/01/10 20:52:27 pk Exp $ */
+/* $OpenBSD: tty.c,v 1.3 1996/03/03 17:20:09 niklas Exp $ */
+/* $NetBSD: tty.c,v 1.66 1996/02/09 19:00:38 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
#include <sys/vnode.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
+#include <sys/signalvar.h>
+#include <sys/resourcevar.h>
#include <vm/vm.h>
-static int proc_compare __P((struct proc *p1, struct proc *p2));
-static int ttnread __P((struct tty *));
-static void ttyblock __P((struct tty *tp));
-static void ttyecho __P((int, struct tty *tp));
-static void ttyrubo __P((struct tty *, int));
+static int ttnread __P((struct tty *));
+static void ttyblock __P((struct tty *));
+static void ttyecho __P((int, struct tty *));
+static void ttyrubo __P((struct tty *, int));
+static int proc_compare __P((struct proc *, struct proc *));
/* Symbolic sleep message strings. */
char ttclos[] = "ttycls";
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
-#define CLR(t, f) (t) &= ~(f)
+#define CLR(t, f) (t) &= ~((unsigned)(f))
#define ISSET(t, f) ((t) & (f))
/*
if (!ISSET(tp->t_state, TS_ISOPEN)) {
SET(tp->t_state, TS_ISOPEN);
bzero(&tp->t_winsize, sizeof(tp->t_winsize));
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_SVR4) || \
- defined(COMPAT_FREEBSD)
+#ifdef COMPAT_OLDTTY
tp->t_flags = 0;
#endif
}
/* Is 'c' a line delimiter ("break" character)? */
#define TTBREAKC(c) \
((c) == '\n' || ((c) == cc[VEOF] || \
- (c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE)
+ (c) == cc[VEOL] || (((c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE)))
/*
{
register int iflag, lflag;
register u_char *cc;
- int i, err;
+ int i, error;
/*
* If input is pending take it first.
/* Handle exceptional conditions (break, parity, framing). */
cc = tp->t_cc;
iflag = tp->t_iflag;
- if (err = (ISSET(c, TTY_ERRORMASK))) {
+ if ((error = (ISSET(c, TTY_ERRORMASK))) != 0) {
CLR(c, TTY_ERRORMASK);
- if (ISSET(err, TTY_FE) && !c) { /* Break. */
+ if (ISSET(error, TTY_FE) && !c) { /* Break. */
if (ISSET(iflag, IGNBRK))
goto endcase;
else if (ISSET(iflag, BRKINT) &&
c = cc[VINTR];
else if (ISSET(iflag, PARMRK))
goto parmrk;
- } else if (ISSET(err, TTY_PE) &&
- ISSET(iflag, INPCK) || ISSET(err, TTY_FE)) {
+ } else if ((ISSET(error, TTY_PE) &&
+ ISSET(iflag, INPCK)) || ISSET(error, TTY_FE)) {
if (ISSET(iflag, IGNPAR))
goto endcase;
else if (ISSET(iflag, PARMRK)) {
case TIOCSTAT:
case TIOCSTI:
case TIOCSWINSZ:
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_SVR4) || \
- defined(COMPAT_FREEBSD)
+#ifdef COMPAT_OLDTTY
case TIOCLBIC:
case TIOCLBIS:
case TIOCLSET:
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
pgsignal(p->p_pgrp, SIGTTOU, 1);
- if (error = ttysleep(tp,
- &lbolt, TTOPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp,
+ &lbolt, TTOPRI | PCATCH, ttybg, 0);
+ if (error)
return (error);
}
break;
(TS_CARR_ON | TS_ISOPEN))
return (EBUSY);
#ifndef UCONSOLE
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
#endif
constty = tp;
constty = NULL;
break;
case TIOCDRAIN: /* wait till output drained */
- if (error = ttywait(tp))
+ if ((error = ttywait(tp)) != 0)
return (error);
break;
case TIOCGETA: { /* get termios struct */
s = spltty();
if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
- if (error = ttywait(tp)) {
+ if ((error = ttywait(tp)) != 0) {
splx(s);
return (error);
}
case TIOCSCTTY: /* become controlling tty */
/* Session ctty vnode pointer set in vnode layer. */
if (!SESS_LEADER(p) ||
- (p->p_session->s_ttyvp || tp->t_session) &&
- (tp->t_session != p->p_session))
+ ((p->p_session->s_ttyvp || tp->t_session) &&
+ (tp->t_session != p->p_session)))
return (EPERM);
tp->t_session = p->p_session;
tp->t_pgrp = p->p_pgrp;
}
break;
default:
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_SVR4) || \
- defined(COMPAT_FREEBSD)
+#ifdef COMPAT_OLDTTY
return (ttcompat(tp, cmd, data, flag, p));
#else
return (-1);
switch (rw) {
case FREAD:
nread = ttnread(tp);
- if (nread > 0 || !ISSET(tp->t_cflag, CLOCAL) &&
- !ISSET(tp->t_state, TS_CARR_ON))
+ if (nread > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
+ !ISSET(tp->t_state, TS_CARR_ON)))
goto win;
selrecord(p, &tp->t_rsel);
break;
&& tp->t_oproc) {
(*tp->t_oproc)(tp);
SET(tp->t_state, TS_ASLEEP);
- if (error = ttysleep(tp,
- &tp->t_outq, TTOPRI | PCATCH, ttyout, 0))
+ error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
+ if (error)
break;
}
splx(s);
* Block further input iff: current input > threshold
* AND input is available to user program.
*/
- if (total >= TTYHOG / 2 &&
- !ISSET(tp->t_state, TS_TBLOCK) &&
- !ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0) {
+ if ((total >= TTYHOG / 2 &&
+ !ISSET(tp->t_state, TS_TBLOCK) &&
+ !ISSET(tp->t_lflag, ICANON)) || tp->t_canq.c_cc > 0) {
if (ISSET(tp->t_iflag, IXOFF) &&
tp->t_cc[VSTOP] != _POSIX_VDISABLE &&
putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
register struct proc *p = curproc;
int s, first, error = 0;
struct timeval stime;
- int has_stime = 0, last_cc;
+ int has_stime = 0, last_cc = 0;
long slp = 0;
loop: lflag = tp->t_lflag;
p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
- if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
+ if (error)
return (error);
goto loop;
}
if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
pgsignal(tp->t_pgrp, SIGTSTP, 1);
if (first) {
- if (error = ttysleep(tp,
- &lbolt, TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, &lbolt,
+ TTIPRI | PCATCH, ttybg, 0);
+ if (error)
break;
goto loop;
}
register struct uio *uio;
int flag;
{
- register u_char *cp;
+ register u_char *cp = NULL;
register int cc, ce;
register struct proc *p;
int i, hiwat, cnt, error, s;
(p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
p->p_pgrp->pg_jobc) {
pgsignal(p->p_pgrp, SIGTTOU, 1);
- if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
+ if (error)
goto out;
goto loop;
}
(!ISSET(tp->t_lflag, ECHONL) || c != '\n')) ||
ISSET(tp->t_lflag, EXTPROC))
return;
- if (ISSET(tp->t_lflag, ECHOCTL) &&
- (ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n' ||
+ if (((ISSET(tp->t_lflag, ECHOCTL) &&
+ (ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n')) ||
ISSET(c, TTY_CHARMASK) == 0177)) {
(void)ttyoutput('^', tp);
CLR(c, ~TTY_CHARMASK);
#define pgtok(a) (((a) * NBPG) / 1024)
/* Print percentage cpu, resident set size. */
- tmp = pick->p_pctcpu * 10000 + FSCALE / 2 >> FSHIFT;
+ tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
ttyprintf(tp, "%d%% %dk\n",
tmp / 100,
pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
short gen;
gen = tp->t_gen;
- if (error = tsleep(chan, pri, wmesg, timo))
+ if ((error = tsleep(chan, pri, wmesg, timo)) != 0)
return (error);
return (tp->t_gen == gen ? 0 : ERESTART);
}
+++ /dev/null
-/* $NetBSD: tty_compat.c,v 1.27 1995/12/07 00:53:29 mycroft Exp $ */
-
-/*-
- * Copyright (c) 1982, 1986, 1991, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- *
- * @(#)tty_compat.c 8.1 (Berkeley) 6/10/93
- */
-
-/*
- * mapping routines for old line discipline (yuck)
- */
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_SVR4) || \
- defined(COMPAT_FREEBSD)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/ioctl.h>
-#include <sys/proc.h>
-#include <sys/tty.h>
-#include <sys/termios.h>
-#include <sys/file.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-
-int ttydebug = 0;
-
-static struct speedtab compatspeeds[] = {
-#define MAX_SPEED 17
- { 115200, 17 },
- { 57600, 16 },
- { 38400, 15 },
- { 19200, 14 },
- { 9600, 13 },
- { 4800, 12 },
- { 2400, 11 },
- { 1800, 10 },
- { 1200, 9 },
- { 600, 8 },
- { 300, 7 },
- { 200, 6 },
- { 150, 5 },
- { 134, 4 },
- { 110, 3 },
- { 75, 2 },
- { 50, 1 },
- { 0, 0 },
- { -1, -1 },
-};
-static int compatspcodes[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
- 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200
-};
-
-/* Macros to clear/set/test flags. */
-#define SET(t, f) (t) |= (f)
-#define CLR(t, f) (t) &= ~(f)
-#define ISSET(t, f) ((t) & (f))
-
-/*ARGSUSED*/
-ttcompat(tp, com, data, flag, p)
- register struct tty *tp;
- u_long com;
- caddr_t data;
- int flag;
- struct proc *p;
-{
-
- switch (com) {
- case TIOCGETP: {
- register struct sgttyb *sg = (struct sgttyb *)data;
- register u_char *cc = tp->t_cc;
- register int speed;
-
- speed = ttspeedtab(tp->t_ospeed, compatspeeds);
- sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
- if (tp->t_ispeed == 0)
- sg->sg_ispeed = sg->sg_ospeed;
- else {
- speed = ttspeedtab(tp->t_ispeed, compatspeeds);
- sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
- }
- sg->sg_erase = cc[VERASE];
- sg->sg_kill = cc[VKILL];
- sg->sg_flags = ttcompatgetflags(tp);
- break;
- }
-
- case TIOCSETP:
- case TIOCSETN: {
- register struct sgttyb *sg = (struct sgttyb *)data;
- struct termios term;
- int speed;
-
- term = tp->t_termios;
- if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0)
- term.c_ispeed = speed;
- else
- term.c_ispeed = compatspcodes[speed];
- if ((speed = sg->sg_ospeed) > MAX_SPEED || speed < 0)
- term.c_ospeed = speed;
- else
- term.c_ospeed = compatspcodes[speed];
- term.c_cc[VERASE] = sg->sg_erase;
- term.c_cc[VKILL] = sg->sg_kill;
- tp->t_flags = (ttcompatgetflags(tp)&0xffff0000) | (sg->sg_flags&0xffff);
- ttcompatsetflags(tp, &term);
- return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA,
- (caddr_t)&term, flag, p));
- }
-
- case TIOCGETC: {
- struct tchars *tc = (struct tchars *)data;
- register u_char *cc = tp->t_cc;
-
- tc->t_intrc = cc[VINTR];
- tc->t_quitc = cc[VQUIT];
- tc->t_startc = cc[VSTART];
- tc->t_stopc = cc[VSTOP];
- tc->t_eofc = cc[VEOF];
- tc->t_brkc = cc[VEOL];
- break;
- }
- case TIOCSETC: {
- struct tchars *tc = (struct tchars *)data;
- register u_char *cc = tp->t_cc;
-
- cc[VINTR] = tc->t_intrc;
- cc[VQUIT] = tc->t_quitc;
- cc[VSTART] = tc->t_startc;
- cc[VSTOP] = tc->t_stopc;
- cc[VEOF] = tc->t_eofc;
- cc[VEOL] = tc->t_brkc;
- if (tc->t_brkc == -1)
- cc[VEOL2] = _POSIX_VDISABLE;
- break;
- }
- case TIOCSLTC: {
- struct ltchars *ltc = (struct ltchars *)data;
- register u_char *cc = tp->t_cc;
-
- cc[VSUSP] = ltc->t_suspc;
- cc[VDSUSP] = ltc->t_dsuspc;
- cc[VREPRINT] = ltc->t_rprntc;
- cc[VDISCARD] = ltc->t_flushc;
- cc[VWERASE] = ltc->t_werasc;
- cc[VLNEXT] = ltc->t_lnextc;
- break;
- }
- case TIOCGLTC: {
- struct ltchars *ltc = (struct ltchars *)data;
- register u_char *cc = tp->t_cc;
-
- ltc->t_suspc = cc[VSUSP];
- ltc->t_dsuspc = cc[VDSUSP];
- ltc->t_rprntc = cc[VREPRINT];
- ltc->t_flushc = cc[VDISCARD];
- ltc->t_werasc = cc[VWERASE];
- ltc->t_lnextc = cc[VLNEXT];
- break;
- }
- case TIOCLBIS:
- case TIOCLBIC:
- case TIOCLSET: {
- struct termios term;
- int flags;
-
- term = tp->t_termios;
- flags = ttcompatgetflags(tp);
- switch (com) {
- case TIOCLSET:
- tp->t_flags = (flags&0xffff) | (*(int *)data<<16);
- break;
- case TIOCLBIS:
- tp->t_flags = flags | (*(int *)data<<16);
- break;
- case TIOCLBIC:
- tp->t_flags = flags & ~(*(int *)data<<16);
- break;
- }
- ttcompatsetlflags(tp, &term);
- return (ttioctl(tp, TIOCSETA, (caddr_t)&term, flag, p));
- }
- case TIOCLGET:
- *(int *)data = ttcompatgetflags(tp)>>16;
- if (ttydebug)
- printf("CLGET: returning %x\n", *(int *)data);
- break;
-
- case OTIOCGETD:
- *(int *)data = tp->t_line ? tp->t_line : 2;
- break;
-
- case OTIOCSETD: {
- int ldisczero = 0;
-
- return (ttioctl(tp, TIOCSETD,
- *(int *)data == 2 ? (caddr_t)&ldisczero : data, flag,
- p));
- }
-
- case OTIOCCONS:
- *(int *)data = 1;
- return (ttioctl(tp, TIOCCONS, data, flag, p));
-
- case TIOCHPCL:
- SET(tp->t_cflag, HUPCL);
- break;
-
- case TIOCGSID:
- if (tp->t_session == NULL)
- return ENOTTY;
-
- if (tp->t_session->s_leader == NULL)
- return ENOTTY;
-
- *(int *) data = tp->t_session->s_leader->p_pid;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-int
-ttcompatgetflags(tp)
- register struct tty *tp;
-{
- register tcflag_t iflag = tp->t_iflag;
- register tcflag_t lflag = tp->t_lflag;
- register tcflag_t oflag = tp->t_oflag;
- register tcflag_t cflag = tp->t_cflag;
- register int flags = 0;
-
- if (ISSET(iflag, IXOFF))
- SET(flags, TANDEM);
- if (ISSET(iflag, ICRNL) || ISSET(oflag, ONLCR))
- SET(flags, CRMOD);
- if (ISSET(cflag, PARENB)) {
- if (ISSET(iflag, INPCK)) {
- if (ISSET(cflag, PARODD))
- SET(flags, ODDP);
- else
- SET(flags, EVENP);
- } else
- SET(flags, ANYP);
- }
-
- if (!ISSET(lflag, ICANON)) {
- /* fudge */
- if (ISSET(iflag, IXON) || ISSET(lflag, ISIG|IEXTEN) ||
- ISSET(cflag, PARENB))
- SET(flags, CBREAK);
- else
- SET(flags, RAW);
- }
-
- if (ISSET(flags, RAW))
- SET(flags, ISSET(tp->t_flags, LITOUT|PASS8));
- else if (ISSET(cflag, CSIZE) == CS8) {
- if (!ISSET(oflag, OPOST))
- SET(flags, LITOUT);
- if (!ISSET(iflag, ISTRIP))
- SET(flags, PASS8);
- }
-
- if (ISSET(cflag, MDMBUF))
- SET(flags, MDMBUF);
- if (!ISSET(cflag, HUPCL))
- SET(flags, NOHANG);
- if (ISSET(oflag, OXTABS))
- SET(flags, XTABS);
- if (ISSET(lflag, ECHOE))
- SET(flags, CRTERA|CRTBS);
- if (ISSET(lflag, ECHOKE))
- SET(flags, CRTKIL|CRTBS);
- if (ISSET(lflag, ECHOPRT))
- SET(flags, PRTERA);
- if (ISSET(lflag, ECHOCTL))
- SET(flags, CTLECH);
- if (!ISSET(iflag, IXANY))
- SET(flags, DECCTQ);
- SET(flags, ISSET(lflag, ECHO|TOSTOP|FLUSHO|PENDIN|NOFLSH));
- if (ttydebug)
- printf("getflags: %x\n", flags);
- return (flags);
-}
-
-ttcompatsetflags(tp, t)
- register struct tty *tp;
- register struct termios *t;
-{
- register int flags = tp->t_flags;
- register tcflag_t iflag = t->c_iflag;
- register tcflag_t oflag = t->c_oflag;
- register tcflag_t lflag = t->c_lflag;
- register tcflag_t cflag = t->c_cflag;
-
- if (ISSET(flags, TANDEM))
- SET(iflag, IXOFF);
- else
- CLR(iflag, IXOFF);
- if (ISSET(flags, ECHO))
- SET(lflag, ECHO);
- else
- CLR(lflag, ECHO);
- if (ISSET(flags, CRMOD)) {
- SET(iflag, ICRNL);
- SET(oflag, ONLCR);
- } else {
- CLR(iflag, ICRNL);
- CLR(oflag, ONLCR);
- }
- if (ISSET(flags, XTABS))
- SET(oflag, OXTABS);
- else
- CLR(oflag, OXTABS);
-
-
- if (ISSET(flags, RAW)) {
- iflag &= IXOFF;
- CLR(lflag, ISIG|ICANON|IEXTEN);
- CLR(cflag, PARENB);
- } else {
- SET(iflag, BRKINT|IXON|IMAXBEL);
- SET(lflag, ISIG|IEXTEN);
- if (ISSET(flags, CBREAK))
- CLR(lflag, ICANON);
- else
- SET(lflag, ICANON);
- switch (ISSET(flags, ANYP)) {
- case 0:
- CLR(cflag, PARENB);
- break;
- case ANYP:
- SET(cflag, PARENB);
- CLR(iflag, INPCK);
- break;
- case EVENP:
- SET(cflag, PARENB);
- SET(iflag, INPCK);
- CLR(cflag, PARODD);
- break;
- case ODDP:
- SET(cflag, PARENB);
- SET(iflag, INPCK);
- SET(cflag, PARODD);
- break;
- }
- }
-
- if (ISSET(flags, RAW|LITOUT|PASS8)) {
- CLR(cflag, CSIZE);
- SET(cflag, CS8);
- if (!ISSET(flags, RAW|PASS8))
- SET(iflag, ISTRIP);
- else
- CLR(iflag, ISTRIP);
- if (!ISSET(flags, RAW|LITOUT))
- SET(oflag, OPOST);
- else
- CLR(oflag, OPOST);
- } else {
- CLR(cflag, CSIZE);
- SET(cflag, CS7);
- SET(iflag, ISTRIP);
- SET(oflag, OPOST);
- }
-
- t->c_iflag = iflag;
- t->c_oflag = oflag;
- t->c_lflag = lflag;
- t->c_cflag = cflag;
-}
-
-ttcompatsetlflags(tp, t)
- register struct tty *tp;
- register struct termios *t;
-{
- register int flags = tp->t_flags;
- register tcflag_t iflag = t->c_iflag;
- register tcflag_t oflag = t->c_oflag;
- register tcflag_t lflag = t->c_lflag;
- register tcflag_t cflag = t->c_cflag;
-
- /* Nothing we can do with CRTBS. */
- if (ISSET(flags, PRTERA))
- SET(lflag, ECHOPRT);
- else
- CLR(lflag, ECHOPRT);
- if (ISSET(flags, CRTERA))
- SET(lflag, ECHOE);
- else
- CLR(lflag, ECHOE);
- /* Nothing we can do with TILDE. */
- if (ISSET(flags, MDMBUF))
- SET(cflag, MDMBUF);
- else
- CLR(cflag, MDMBUF);
- if (ISSET(flags, NOHANG))
- CLR(cflag, HUPCL);
- else
- SET(cflag, HUPCL);
- if (ISSET(flags, CRTKIL))
- SET(lflag, ECHOKE);
- else
- CLR(lflag, ECHOKE);
- if (ISSET(flags, CTLECH))
- SET(lflag, ECHOCTL);
- else
- CLR(lflag, ECHOCTL);
- if (!ISSET(flags, DECCTQ))
- SET(iflag, IXANY);
- else
- CLR(iflag, IXANY);
- CLR(lflag, TOSTOP|FLUSHO|PENDIN|NOFLSH);
- SET(lflag, ISSET(flags, TOSTOP|FLUSHO|PENDIN|NOFLSH));
-
- if (ISSET(flags, RAW|LITOUT|PASS8)) {
- CLR(cflag, CSIZE);
- SET(cflag, CS8);
- if (!ISSET(flags, RAW|PASS8))
- SET(iflag, ISTRIP);
- else
- CLR(iflag, ISTRIP);
- if (!ISSET(flags, RAW|LITOUT))
- SET(oflag, OPOST);
- else
- CLR(oflag, OPOST);
- } else {
- CLR(cflag, CSIZE);
- SET(cflag, CS7);
- SET(iflag, ISTRIP);
- SET(oflag, OPOST);
- }
-
- t->c_iflag = iflag;
- t->c_oflag = oflag;
- t->c_lflag = lflag;
- t->c_cflag = cflag;
-}
-#endif /* COMPAT_43 || COMPAT_SUNOS || COMPAT_SVR4 || COMPAT_FREEBSD */
-/* $NetBSD: tty_conf.c,v 1.16 1995/10/10 01:27:01 mycroft Exp $ */
+/* $OpenBSD: tty_conf.c,v 1.2 1996/03/03 17:20:11 niklas Exp $ */
+/* $NetBSD: tty_conf.c,v 1.17 1996/02/04 02:17:22 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
#define ttyerrinput ((int (*) __P((int c, struct tty *)))enodev)
#define ttyerrstart ((int (*) __P((struct tty *)))enodev)
-int nullioctl __P((struct tty *tp, u_long cmd, caddr_t data,
- int flag, struct proc *p));
+int nullioctl __P((struct tty *, u_long, caddr_t, int, struct proc *));
#include "tb.h"
#if NTB > 0
* discipline specific ioctl command.
*/
/*ARGSUSED*/
+int
nullioctl(tp, cmd, data, flags, p)
struct tty *tp;
u_long cmd;
-/* $NetBSD: tty_subr.c,v 1.11 1994/10/30 21:48:03 cgd Exp $ */
+/* $OpenBSD: tty_subr.c,v 1.2 1996/03/03 17:20:12 niklas Exp $ */
+/* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */
/*
* Copyright (c) 1993, 1994 Theo de Raadt
#define QMEM(n) (n)
#endif
+void cinit __P((void));
+int ndqb __P((struct clist *, int));
+int putc __P((int, struct clist *));
+#ifdef QBITS
+void clrbits __P((u_char *, int, int));
+#endif
+int b_to_q __P((u_char *, int, struct clist *));
+u_char *firstc __P((struct clist *, int *));
/*
* Initialize clists.
* Return count of contiguous characters in clist.
* Stop counting if flag&character is non-null.
*/
+int
ndqb(clp, flag)
struct clist *clp;
int flag;
int c;
struct clist *clp;
{
- register u_char *q;
register int i;
- int r = -1;
int s;
s = spltty();
int count;
struct clist *clp;
{
- register int i, cc;
+ register int cc;
register u_char *p = cp;
- int off, s;
+ int s;
if (count <= 0)
return 0;
struct clist *clp;
int *c;
{
- int empty = 0;
register u_char *cp;
- register int i;
cc = clp->c_cc;
if (cc == 0)
-/* $NetBSD: tty_tb.c,v 1.17 1995/05/10 16:53:02 christos Exp $ */
+/* $OpenBSD: tty_tb.c,v 1.2 1996/03/03 17:20:13 niklas Exp $ */
+/* $NetBSD: tty_tb.c,v 1.18 1996/02/04 02:17:36 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
*/
#include <sys/param.h>
#include <sys/tablet.h>
+#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/ioctl_compat.h>
#include <sys/tty.h>
#include <sys/proc.h>
+union tbpos {
+ struct hitpos hitpos;
+ struct gtcopos gtcopos;
+ struct polpos polpos;
+};
+
/*
* Tablet configuration table.
*/
short tbc_recsize; /* input record size in bytes */
short tbc_uiosize; /* size of data record returned user */
int tbc_sync; /* mask for finding sync byte/bit */
- int (*tbc_decode)();/* decoding routine */
+ /* decoding routine */
+ void (*tbc_decode) __P((struct tbconf *, char *, union tbpos *));
u_char *tbc_run; /* enter run mode sequence */
u_char *tbc_point; /* enter point mode sequence */
u_char *tbc_stop; /* stop sequence */
#define TBF_INPROX 0x2 /* tablet has proximity info */
};
-static int tbdecode(), gtcodecode(), poldecode();
-static int tblresdecode(), tbhresdecode();
+static void gtcodecode __P((struct tbconf *, char *, union tbpos *));
+static void tbolddecode __P((struct tbconf *, char *, union tbpos *));
+static void tblresdecode __P((struct tbconf *, char *, union tbpos *));
+static void tbhresdecode __P((struct tbconf *, char *, union tbpos *));
+static void poldecode __P((struct tbconf *, char *, union tbpos *));
+
struct tbconf tbconf[TBTYPE] = {
{ 0 },
-{ 5, sizeof (struct tbpos), 0200, tbdecode, "6", "4" },
-{ 5, sizeof (struct tbpos), 0200, tbdecode, "\1CN", "\1RT", "\2", "\4" },
+{ 5, sizeof (struct hitpos), 0200, tbolddecode, "6", "4" },
+{ 5, sizeof (struct hitpos), 0200, tbolddecode, "\1CN", "\1RT", "\2", "\4" },
{ 8, sizeof (struct gtcopos), 0200, gtcodecode },
{17, sizeof (struct polpos), 0200, poldecode, 0, 0, "\21", "\5\22\2\23",
TBF_POL },
-{ 5, sizeof (struct tbpos), 0100, tblresdecode, "\1CN", "\1PT", "\2", "\4",
+{ 5, sizeof (struct hitpos), 0100, tblresdecode, "\1CN", "\1PT", "\2", "\4",
TBF_INPROX },
-{ 6, sizeof (struct tbpos), 0200, tbhresdecode, "\1CN", "\1PT", "\2", "\4",
+{ 6, sizeof (struct hitpos), 0200, tbhresdecode, "\1CN", "\1PT", "\2", "\4",
TBF_INPROX },
-{ 5, sizeof (struct tbpos), 0100, tblresdecode, "\1CL\33", "\1PT\33", 0, 0},
-{ 6, sizeof (struct tbpos), 0200, tbhresdecode, "\1CL\33", "\1PT\33", 0, 0},
+{ 5, sizeof (struct hitpos), 0100, tblresdecode, "\1CL\33", "\1PT\33", 0, 0},
+{ 6, sizeof (struct hitpos), 0200, tbhresdecode, "\1CL\33", "\1PT\33", 0, 0},
};
/*
char cbuf[TBMAXREC]; /* input buffer */
int tbinbuf;
char *tbcp;
- union {
- struct tbpos tbpos;
- struct gtcopos gtcopos;
- struct polpos polpos;
- } rets; /* processed state */
+ union tbpos tbpos;
} tb[NTB];
+
+int tbopen __P((dev_t, struct tty *));
+void tbclose __P((struct tty *));
+int tbread __P((struct tty *, struct uio *));
+void tbinput __P((int, struct tty *));
+int tbtioctl __P((struct tty *, u_long, caddr_t, int, struct proc *));
+void tbattach __P((int));
+
/*
* Open as tablet discipline; called on discipline change.
*/
/*ARGSUSED*/
+int
tbopen(dev, tp)
dev_t dev;
register struct tty *tp;
tbp->tbflags = TBTIGER|TBPOINT; /* default */
tbp->tbcp = tbp->cbuf;
tbp->tbinbuf = 0;
- bzero((caddr_t)&tbp->rets, sizeof (tbp->rets));
+ bzero((caddr_t)&tbp->tbpos, sizeof (tbp->tbpos));
tp->t_sc = (caddr_t)tbp;
tp->t_flags |= LITOUT;
return (0);
/*
* Line discipline change or last device close.
*/
+void
tbclose(tp)
register struct tty *tp;
{
int modebits = TBPOINT|TBSTOP;
- tbtioctl(tp, BIOSMODE, &modebits, 0, curproc);
+ tbtioctl(tp, BIOSMODE, (caddr_t) &modebits, 0, curproc);
}
/*
* Read from a tablet line.
* Characters have been buffered in a buffer and decoded.
*/
+int
tbread(tp, uio)
register struct tty *tp;
struct uio *uio;
if ((tp->t_state&TS_CARR_ON) == 0)
return (EIO);
- ret = uiomove(&tbp->rets, tc->tbc_uiosize, uio);
+ ret = uiomove((caddr_t) &tbp->tbpos, tc->tbc_uiosize, uio);
if (tc->tbc_flags&TBF_POL)
- tbp->rets.polpos.p_key = ' ';
+ tbp->tbpos.polpos.p_key = ' ';
return (ret);
}
* This routine could be expanded in-line in the receiver
* interrupt routine to make it run as fast as possible.
*/
+void
tbinput(c, tp)
register int c;
register struct tty *tp;
* Call decode routine only if a full record has been collected.
*/
if (++tbp->tbinbuf == tc->tbc_recsize)
- (*tc->tbc_decode)(tc, tbp->cbuf, &tbp->rets);
+ (*tc->tbc_decode)(tc, tbp->cbuf, &tbp->tbpos);
}
/*
* Decode GTCO 8 byte format (high res, tilt, and pressure).
*/
-static
-gtcodecode(tc, cp, tbpos)
+static void
+gtcodecode(tc, cp, u)
struct tbconf *tc;
register char *cp;
- register struct gtcopos *tbpos;
+ register union tbpos *u;
{
-
- tbpos->pressure = *cp >> 2;
- tbpos->status = (tbpos->pressure > 16) | TBINPROX; /* half way down */
- tbpos->xpos = (*cp++ & 03) << 14;
- tbpos->xpos |= *cp++ << 7;
- tbpos->xpos |= *cp++;
- tbpos->ypos = (*cp++ & 03) << 14;
- tbpos->ypos |= *cp++ << 7;
- tbpos->ypos |= *cp++;
- tbpos->xtilt = *cp++;
- tbpos->ytilt = *cp++;
- tbpos->scount++;
+ struct gtcopos *pos = &u->gtcopos;
+ pos->pressure = *cp >> 2;
+ pos->status = (pos->pressure > 16) | TBINPROX; /* half way down */
+ pos->xpos = (*cp++ & 03) << 14;
+ pos->xpos |= *cp++ << 7;
+ pos->xpos |= *cp++;
+ pos->ypos = (*cp++ & 03) << 14;
+ pos->ypos |= *cp++ << 7;
+ pos->ypos |= *cp++;
+ pos->xtilt = *cp++;
+ pos->ytilt = *cp++;
+ pos->scount++;
}
/*
* Decode old Hitachi 5 byte format (low res).
*/
-static
-tbdecode(tc, cp, tbpos)
+static void
+tbolddecode(tc, cp, u)
struct tbconf *tc;
register char *cp;
- register struct tbpos *tbpos;
+ register union tbpos *u;
{
+ struct hitpos *pos = &u->hitpos;
register char byte;
byte = *cp++;
- tbpos->status = (byte&0100) ? TBINPROX : 0;
+ pos->status = (byte&0100) ? TBINPROX : 0;
byte &= ~0100;
if (byte > 036)
- tbpos->status |= 1 << ((byte-040)/2);
- tbpos->xpos = *cp++ << 7;
- tbpos->xpos |= *cp++;
- if (tbpos->xpos < 256) /* tablet wraps around at 256 */
- tbpos->status &= ~TBINPROX; /* make it out of proximity */
- tbpos->ypos = *cp++ << 7;
- tbpos->ypos |= *cp++;
- tbpos->scount++;
+ pos->status |= 1 << ((byte-040)/2);
+ pos->xpos = *cp++ << 7;
+ pos->xpos |= *cp++;
+ if (pos->xpos < 256) /* tablet wraps around at 256 */
+ pos->status &= ~TBINPROX; /* make it out of proximity */
+ pos->ypos = *cp++ << 7;
+ pos->ypos |= *cp++;
+ pos->scount++;
}
/*
* Decode new Hitach 5-byte format (low res).
*/
-static
-tblresdecode(tc, cp, tbpos)
+static void
+tblresdecode(tc, cp, u)
struct tbconf *tc;
register char *cp;
- register struct tbpos *tbpos;
+ register union tbpos *u;
{
+ struct hitpos *pos = &u->hitpos;
*cp &= ~0100; /* mask sync bit */
- tbpos->status = (*cp++ >> 2) | TBINPROX;
- if (tc->tbc_flags&TBF_INPROX && tbpos->status&020)
- tbpos->status &= ~(020|TBINPROX);
- tbpos->xpos = *cp++;
- tbpos->xpos |= *cp++ << 6;
- tbpos->ypos = *cp++;
- tbpos->ypos |= *cp++ << 6;
- tbpos->scount++;
+ pos->status = (*cp++ >> 2) | TBINPROX;
+ if (tc->tbc_flags&TBF_INPROX && pos->status&020)
+ pos->status &= ~(020|TBINPROX);
+ pos->xpos = *cp++;
+ pos->xpos |= *cp++ << 6;
+ pos->ypos = *cp++;
+ pos->ypos |= *cp++ << 6;
+ pos->scount++;
}
/*
* Decode new Hitach 6-byte format (high res).
*/
-static
-tbhresdecode(tc, cp, tbpos)
+static void
+tbhresdecode(tc, cp, u)
struct tbconf *tc;
register char *cp;
- register struct tbpos *tbpos;
+ register union tbpos *u;
{
+ struct hitpos *pos = &u->hitpos;
char byte;
byte = *cp++;
- tbpos->xpos = (byte & 03) << 14;
- tbpos->xpos |= *cp++ << 7;
- tbpos->xpos |= *cp++;
- tbpos->ypos = *cp++ << 14;
- tbpos->ypos |= *cp++ << 7;
- tbpos->ypos |= *cp++;
- tbpos->status = (byte >> 2) | TBINPROX;
- if (tc->tbc_flags&TBF_INPROX && tbpos->status&020)
- tbpos->status &= ~(020|TBINPROX);
- tbpos->scount++;
+ pos->xpos = (byte & 03) << 14;
+ pos->xpos |= *cp++ << 7;
+ pos->xpos |= *cp++;
+ pos->ypos = *cp++ << 14;
+ pos->ypos |= *cp++ << 7;
+ pos->ypos |= *cp++;
+ pos->status = (byte >> 2) | TBINPROX;
+ if (tc->tbc_flags&TBF_INPROX && pos->status&020)
+ pos->status &= ~(020|TBINPROX);
+ pos->scount++;
}
/*
* Polhemus decode.
*/
-static
-poldecode(tc, cp, polpos)
+static void
+poldecode(tc, cp, u)
struct tbconf *tc;
register char *cp;
- register struct polpos *polpos;
+ register union tbpos *u;
{
-
- polpos->p_x = cp[4] | cp[3]<<7 | (cp[9] & 0x03) << 14;
- polpos->p_y = cp[6] | cp[5]<<7 | (cp[9] & 0x0c) << 12;
- polpos->p_z = cp[8] | cp[7]<<7 | (cp[9] & 0x30) << 10;
- polpos->p_azi = cp[11] | cp[10]<<7 | (cp[16] & 0x03) << 14;
- polpos->p_pit = cp[13] | cp[12]<<7 | (cp[16] & 0x0c) << 12;
- polpos->p_rol = cp[15] | cp[14]<<7 | (cp[16] & 0x30) << 10;
- polpos->p_stat = cp[1] | cp[0]<<7;
+ struct polpos *pos = &u->polpos;
+
+ pos->p_x = cp[4] | cp[3]<<7 | (cp[9] & 0x03) << 14;
+ pos->p_y = cp[6] | cp[5]<<7 | (cp[9] & 0x0c) << 12;
+ pos->p_z = cp[8] | cp[7]<<7 | (cp[9] & 0x30) << 10;
+ pos->p_azi = cp[11] | cp[10]<<7 | (cp[16] & 0x03) << 14;
+ pos->p_pit = cp[13] | cp[12]<<7 | (cp[16] & 0x0c) << 12;
+ pos->p_rol = cp[15] | cp[14]<<7 | (cp[16] & 0x30) << 10;
+ pos->p_stat = cp[1] | cp[0]<<7;
if (cp[2] != ' ')
- polpos->p_key = cp[2];
+ pos->p_key = cp[2];
}
/*ARGSUSED*/
+int
tbtioctl(tp, cmd, data, flag, p)
struct tty *tp;
u_long cmd;
return (0);
}
-void tbattach(dummy)
+void
+tbattach(dummy)
int dummy;
{
/* stub to handle side effect of new config */
-/* $NetBSD: tty_tty.c,v 1.11 1994/10/30 21:48:05 cgd Exp $ */
+/* $OpenBSD: tty_tty.c,v 1.2 1996/03/03 17:20:15 niklas Exp $ */
+/* $NetBSD: tty_tty.c,v 1.12 1996/02/04 02:17:39 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
*/
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/conf.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/tty.h>
#include <sys/vnode.h>
#include <sys/file.h>
+#include <kern/kern_conf.h>
+
#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
/*ARGSUSED*/
+int
cttyopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
}
/*ARGSUSED*/
+int
cttyread(dev, uio, flag)
dev_t dev;
struct uio *uio;
}
/*ARGSUSED*/
+int
cttywrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
}
/*ARGSUSED*/
+int
cttyioctl(dev, cmd, addr, flag, p)
dev_t dev;
u_long cmd;
}
/*ARGSUSED*/
+int
cttyselect(dev, flag, p)
dev_t dev;
int flag;
-/* $NetBSD: uipc_domain.c,v 1.12 1994/06/29 06:33:33 cgd Exp $ */
+/* $OpenBSD: uipc_domain.c,v 1.2 1996/03/03 17:20:16 niklas Exp $ */
+/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
for (dp = domains; dp; dp = dp->dom_next)
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_ctlinput)
- (*pr->pr_ctlinput)(cmd, sa, (caddr_t)0);
+ (*pr->pr_ctlinput)(cmd, sa, NULL);
}
void
-/* $NetBSD: uipc_mbuf.c,v 1.13 1994/10/30 21:48:06 cgd Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.2 1996/03/03 17:20:17 niklas Exp $ */
+/* $NetBSD: uipc_mbuf.c,v 1.15 1996/02/09 19:00:45 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1991, 1993
* Must be called at splimp.
*/
/* ARGSUSED */
+int
m_clalloc(ncl, nowait)
register int ncl;
int nowait;
return (m);
}
+void
m_reclaim()
{
register struct domain *dp;
return;
do {
MFREE(m, n);
- } while (m = n);
+ } while ((m = n) != NULL);
}
/*
* Copy data from an mbuf chain starting "off" bytes from the beginning,
* continuing for "len" bytes, into the indicated buffer.
*/
+void
m_copydata(m, off, len, cp)
register struct mbuf *m;
register int off;
* Both chains must be of the same type (e.g. MT_DATA).
* Any m_pkthdr is not updated.
*/
+void
m_cat(m, n)
register struct mbuf *m, *n;
{
}
count -= m->m_len;
}
- while (m = m->m_next)
+ while ((m = m->m_next) != NULL)
m->m_len = 0;
}
}
char *buf;
int totlen, off0;
struct ifnet *ifp;
- void (*copy)();
+ void (*copy) __P((const void *, void *, size_t));
{
register struct mbuf *m;
struct mbuf *top = 0, **mp = ⊤
len = m->m_len;
}
if (copy)
- copy(cp, mtod(m, caddr_t), (unsigned)len);
+ copy(cp, mtod(m, caddr_t), (size_t)len);
else
- bcopy(cp, mtod(m, caddr_t), (unsigned)len);
+ bcopy(cp, mtod(m, caddr_t), (size_t)len);
cp += len;
*mp = m;
mp = &m->m_next;
-/* $NetBSD: uipc_proto.c,v 1.5 1994/06/29 06:33:36 cgd Exp $ */
+/* $OpenBSD: uipc_proto.c,v 1.2 1996/03/03 17:20:18 niklas Exp $ */
+/* $NetBSD: uipc_proto.c,v 1.8 1996/02/13 21:10:47 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
#include <sys/protosw.h>
#include <sys/domain.h>
#include <sys/mbuf.h>
+#include <sys/un.h>
+#include <sys/socketvar.h>
+
+#include <net/if.h>
+#include <net/raw_cb.h>
/*
* Definitions of protocols supported in the UNIX domain.
*/
-int uipc_usrreq(), raw_usrreq();
-void raw_init(), raw_input(), raw_ctlinput();
extern struct domain unixdomain; /* or at least forward */
struct protosw unixsw[] = {
}
};
-int unp_externalize(), unp_dispose();
-
struct domain unixdomain =
{ AF_UNIX, "unix", 0, unp_externalize, unp_dispose,
unixsw, &unixsw[sizeof(unixsw)/sizeof(unixsw[0])] };
-/* $NetBSD: uipc_socket.c,v 1.20 1995/08/12 23:59:11 mycroft Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.3 1996/03/03 17:20:19 niklas Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/signalvar.h>
#include <sys/resourcevar.h>
/*
so->so_state = SS_PRIV;
so->so_proto = prp;
error =
- (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0,
- (struct mbuf *)(long)proto, (struct mbuf *)0);
+ (*prp->pr_usrreq)(so, PRU_ATTACH, NULL, (struct mbuf *)(long)proto,
+ NULL);
if (error) {
so->so_state |= SS_NOFDREF;
sofree(so);
int s = splsoftnet();
int error;
- error =
- (*so->so_proto->pr_usrreq)(so, PRU_BIND,
- (struct mbuf *)0, nam, (struct mbuf *)0);
+ error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, NULL, nam, NULL);
splx(s);
return (error);
}
{
int s = splsoftnet(), error;
- error =
- (*so->so_proto->pr_usrreq)(so, PRU_LISTEN,
- (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0);
+ error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, NULL, NULL, NULL);
if (error) {
splx(s);
return (error);
if ((so->so_state & SS_ISDISCONNECTING) &&
(so->so_state & SS_NBIO))
goto drop;
- while (so->so_state & SS_ISCONNECTED)
- if (error = tsleep((caddr_t)&so->so_timeo,
- PSOCK | PCATCH, netcls, so->so_linger))
+ while (so->so_state & SS_ISCONNECTED) {
+ error = tsleep((caddr_t)&so->so_timeo,
+ PSOCK | PCATCH, netcls,
+ so->so_linger);
+ if (error)
break;
+ }
}
}
drop:
if (so->so_pcb) {
- int error2 =
- (*so->so_proto->pr_usrreq)(so, PRU_DETACH,
- (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0);
+ int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, NULL,
+ NULL, NULL);
if (error == 0)
error = error2;
}
struct socket *so;
{
- return (
- (*so->so_proto->pr_usrreq)(so, PRU_ABORT,
- (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0));
+ return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, NULL, NULL, NULL);
}
int
if ((so->so_state & SS_NOFDREF) == 0)
panic("soaccept: !NOFDREF");
so->so_state &= ~SS_NOFDREF;
- error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,
- (struct mbuf *)0, nam, (struct mbuf *)0);
+ error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, NULL, nam, NULL);
splx(s);
return (error);
}
error = EISCONN;
else
error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT,
- (struct mbuf *)0, nam, (struct mbuf *)0);
+ NULL, nam, NULL);
splx(s);
return (error);
}
int s = splsoftnet();
int error;
- error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2,
- (struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0);
+ error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2, NULL,
+ (struct mbuf *)so2, NULL);
splx(s);
return (error);
}
error = EALREADY;
goto bad;
}
- error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT,
- (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0);
+ error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT, NULL, NULL,
+ NULL);
bad:
splx(s);
return (error);
#define snderr(errno) { error = errno; splx(s); goto release; }
restart:
- if (error = sblock(&so->so_snd, SBLOCKWAIT(flags)))
+ if ((error = sblock(&so->so_snd, SBLOCKWAIT(flags))) != 0)
goto out;
do {
s = splsoftnet();
space = sbspace(&so->so_snd);
if (flags & MSG_OOB)
space += 1024;
- if (atomic && resid > so->so_snd.sb_hiwat ||
+ if ((atomic && resid > so->so_snd.sb_hiwat) ||
clen > so->so_snd.sb_hiwat)
snderr(EMSGSIZE);
if (space < resid + clen && uio &&
if (dontroute)
so->so_options |= SO_DONTROUTE;
s = splsoftnet(); /* XXX */
- error = (*so->so_proto->pr_usrreq)(so,
- (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND,
- top, addr, control);
+ error = (*so->so_proto->pr_usrreq)(so, (flags & MSG_OOB) ?
+ PRU_SENDOOB : PRU_SEND,
+ top, addr, control);
splx(s);
if (dontroute)
so->so_options &= ~SO_DONTROUTE;
register int flags, len, error, s, offset;
struct protosw *pr = so->so_proto;
struct mbuf *nextrecord;
- int moff, type;
+ int moff, type = 0;
int orig_resid = uio->uio_resid;
mp = mp0;
if (flags & MSG_OOB) {
m = m_get(M_WAIT, MT_DATA);
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,
- (struct mbuf *)(long)(flags & MSG_PEEK), (struct mbuf *)0);
+ (struct mbuf *)(long)(flags & MSG_PEEK),
+ NULL);
if (error)
goto bad;
do {
if (mp)
*mp = (struct mbuf *)0;
if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)
- (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
- (struct mbuf *)0, (struct mbuf *)0);
+ (*pr->pr_usrreq)(so, PRU_RCVD, NULL, NULL, NULL);
restart:
- if (error = sblock(&so->so_rcv, SBLOCKWAIT(flags)))
+ if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)
return (error);
s = splsoftnet();
* we have to do the receive in sections, and thus risk returning
* a short count if a timeout or signal occurs after we start.
*/
- if (m == 0 || ((flags & MSG_DONTWAIT) == 0 &&
+ if (m == 0 || (((flags & MSG_DONTWAIT) == 0 &&
so->so_rcv.sb_cc < uio->uio_resid) &&
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
((flags & MSG_WAITALL) && uio->uio_resid <= so->so_rcv.sb_hiwat)) &&
- m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0) {
+ m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0)) {
#ifdef DIAGNOSTIC
if (m == 0 && so->so_rcv.sb_cc)
panic("receive 1");
splx(s);
return (0);
}
- if (m = so->so_rcv.sb_mb)
+ if ((m = so->so_rcv.sb_mb) != NULL)
nextrecord = m->m_nextpkt;
}
}
if (m == 0)
so->so_rcv.sb_mb = nextrecord;
if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)
- (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
- (struct mbuf *)(long)flags, (struct mbuf *)0,
- (struct mbuf *)0);
+ (*pr->pr_usrreq)(so, PRU_RCVD, NULL,
+ (struct mbuf *)(long)flags, NULL);
}
if (orig_resid == uio->uio_resid && orig_resid &&
(flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
if (how & FREAD)
sorflush(so);
if (how & FWRITE)
- return ((*pr->pr_usrreq)(so, PRU_SHUTDOWN,
- (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0));
+ return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, NULL, NULL, NULL);
return (0);
}
-/* $NetBSD: uipc_socket2.c,v 1.10 1995/08/16 01:03:19 mycroft Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.2 1996/03/03 17:20:20 niklas Exp $ */
+/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/signalvar.h>
/*
* Primitive routines for operating on sockets and socket buffers
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
- if (error = tsleep((caddr_t)&sb->sb_flags,
- (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
- netio, 0))
+ error = tsleep((caddr_t)&sb->sb_flags,
+ (sb->sb_flags & SB_NOINTR) ?
+ PSOCK : PSOCK|PCATCH, netio, 0);
+ if (error)
return (error);
}
sb->sb_flags |= SB_LOCK;
if (m == 0)
return;
- if (n = sb->sb_mb) {
+ if ((n = sb->sb_mb) != NULL) {
while (n->m_nextpkt)
n = n->m_nextpkt;
do {
if (m0 == 0)
return;
- if (m = sb->sb_mb)
+ if ((m = sb->sb_mb) != NULL)
while (m->m_nextpkt)
m = m->m_nextpkt;
/*
if (m0 == 0)
return;
- for (mp = &sb->sb_mb; m = *mp; mp = &((*mp)->m_nextpkt)) {
+ for (mp = &sb->sb_mb; (m = *mp) != NULL; mp = &((*mp)->m_nextpkt)) {
again:
switch (m->m_type) {
continue; /* WANT next train */
case MT_CONTROL:
- if (m = m->m_next)
+ if ((m = m->m_next) != NULL)
goto again; /* inspect THIS train further */
}
break;
m->m_next = control;
for (n = m; n; n = n->m_next)
sballoc(sb, n);
- if (n = sb->sb_mb) {
+ if ((n = sb->sb_mb) != NULL) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = m;
n->m_next = m0; /* concatenate data to control */
for (m = control; m; m = m->m_next)
sballoc(sb, m);
- if (n = sb->sb_mb) {
+ if ((n = sb->sb_mb) != NULL) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = control;
do {
sbfree(sb, m);
MFREE(m, mn);
- } while (m = mn);
+ } while ((m = mn) != NULL);
}
}
-/* $NetBSD: uipc_syscalls.c,v 1.17 1995/10/10 01:27:05 mycroft Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.2 1996/03/03 17:20:21 niklas Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/signalvar.h>
+#include <sys/un.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
/*
* System call interface to the socket abstraction.
*/
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_LINUX) || \
- defined(COMPAT_HPUX) || defined(COMPAT_FREEBSD)
-#define COMPAT_OLDSOCK
-#define MSG_COMPAT 0x8000
-#endif
-
extern struct fileops socketops;
int
struct file *fp;
int fd, error;
- if (error = falloc(p, &fp, &fd))
+ if ((error = falloc(p, &fp, &fd)) != 0)
return (error);
fp->f_flag = FREAD|FWRITE;
fp->f_type = DTYPE_SOCKET;
fp->f_ops = &socketops;
- if (error = socreate(SCARG(uap, domain), &so, SCARG(uap, type),
- SCARG(uap, protocol))) {
+ error = socreate(SCARG(uap, domain), &so, SCARG(uap, type),
+ SCARG(uap, protocol));
+ if (error) {
fdp->fd_ofiles[fd] = 0;
ffree(fp);
} else {
struct mbuf *nam;
int error;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- if (error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
- MT_SONAME))
+ error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
+ MT_SONAME);
+ if (error)
return (error);
error = sobind((struct socket *)fp->f_data, nam);
m_freem(nam);
struct file *fp;
int error;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
return (solisten((struct socket *)fp->f_data, SCARG(uap, backlog)));
}
if (SCARG(uap, name) && (error = copyin((caddr_t)SCARG(uap, anamelen),
(caddr_t)&namelen, sizeof (namelen))))
return (error);
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
s = splsoftnet();
so = (struct socket *)fp->f_data;
so->so_error = ECONNABORTED;
break;
}
- if (error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
- netcon, 0)) {
+ error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
+ netcon, 0);
+ if (error) {
splx(s);
return (error);
}
splx(s);
return (error);
}
- if (error = falloc(p, &fp, &tmpfd)) {
+ if ((error = falloc(p, &fp, &tmpfd)) != 0) {
splx(s);
return (error);
}
struct mbuf *nam;
int error, s;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
so = (struct socket *)fp->f_data;
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING))
return (EALREADY);
- if (error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
- MT_SONAME))
+ error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
+ MT_SONAME);
+ if (error)
return (error);
error = soconnect(so, nam);
if (error)
return (EINPROGRESS);
}
s = splsoftnet();
- while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0)
- if (error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
- netcon, 0))
+ while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
+ error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
+ netcon, 0);
+ if (error)
break;
+ }
if (error == 0) {
error = so->so_error;
so->so_error = 0;
struct socket *so1, *so2;
int fd, error, sv[2];
- if (error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type),
- SCARG(uap, protocol)))
+ error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type),
+ SCARG(uap, protocol));
+ if (error)
return (error);
- if (error = socreate(SCARG(uap, domain), &so2, SCARG(uap, type),
- SCARG(uap, protocol)))
+ error = socreate(SCARG(uap, domain), &so2, SCARG(uap, type),
+ SCARG(uap, protocol));
+ if (error)
goto free1;
- if (error = falloc(p, &fp1, &fd))
+ if ((error = falloc(p, &fp1, &fd)) != 0)
goto free2;
sv[0] = fd;
fp1->f_flag = FREAD|FWRITE;
fp1->f_type = DTYPE_SOCKET;
fp1->f_ops = &socketops;
fp1->f_data = (caddr_t)so1;
- if (error = falloc(p, &fp2, &fd))
+ if ((error = falloc(p, &fp2, &fd)) != 0)
goto free3;
fp2->f_flag = FREAD|FWRITE;
fp2->f_type = DTYPE_SOCKET;
fp2->f_ops = &socketops;
fp2->f_data = (caddr_t)so2;
sv[1] = fd;
- if (error = soconnect2(so1, so2))
+ if ((error = soconnect2(so1, so2)) != 0)
goto free4;
if (SCARG(uap, type) == SOCK_DGRAM) {
/*
* Datagram socket connection is asymmetric.
*/
- if (error = soconnect2(so2, so1))
+ if ((error = soconnect2(so2, so1)) != 0)
goto free4;
}
error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, rsv),
struct iovec aiov[UIO_SMALLIOV], *iov;
int error;
- if (error = copyin(SCARG(uap, msg), (caddr_t)&msg, sizeof (msg)))
+ error = copyin(SCARG(uap, msg), (caddr_t)&msg, sizeof (msg));
+ if (error)
return (error);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
struct iovec *ktriov = NULL;
#endif
- if (error = getsock(p->p_fd, s, &fp))
+ if ((error = getsock(p->p_fd, s, &fp)) != 0)
return (error);
auio.uio_iov = mp->msg_iov;
auio.uio_iovcnt = mp->msg_iovlen;
auio.uio_resid = 0;
iov = mp->msg_iov;
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
+#if 0
+ /* cannot happen; iov_len is unsigned */
if (iov->iov_len < 0)
return (EINVAL);
+#endif
if ((auio.uio_resid += iov->iov_len) < 0)
return (EINVAL);
}
if (mp->msg_name) {
- if (error = sockargs(&to, mp->msg_name, mp->msg_namelen,
- MT_SONAME))
+ error = sockargs(&to, mp->msg_name, mp->msg_namelen,
+ MT_SONAME);
+ if (error)
return (error);
} else
to = 0;
error = EINVAL;
goto bad;
}
- if (error = sockargs(&control, mp->msg_control,
- mp->msg_controllen, MT_CONTROL))
+ error = sockargs(&control, mp->msg_control,
+ mp->msg_controllen, MT_CONTROL);
+ if (error)
goto bad;
#ifdef COMPAT_OLDSOCK
if (mp->msg_flags == MSG_COMPAT) {
}
#endif
len = auio.uio_resid;
- if (error = sosend((struct socket *)fp->f_data, to, &auio,
- (struct mbuf *)0, control, flags)) {
+ error = sosend((struct socket *)fp->f_data, to, &auio,
+ NULL, control, flags);
+ if (error) {
if (auio.uio_resid != len && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
int error;
if (SCARG(uap, fromlenaddr)) {
- if (error = copyin((caddr_t)SCARG(uap, fromlenaddr),
- (caddr_t)&msg.msg_namelen, sizeof (msg.msg_namelen)))
+ error = copyin((caddr_t)SCARG(uap, fromlenaddr),
+ (caddr_t)&msg.msg_namelen,
+ sizeof (msg.msg_namelen));
+ if (error)
return (error);
} else
msg.msg_namelen = 0;
msg.msg_control = 0;
msg.msg_flags = SCARG(uap, flags);
return (recvit(p, SCARG(uap, s), &msg,
- (caddr_t)SCARG(uap, fromlenaddr), retval));
+ (caddr_t)SCARG(uap, fromlenaddr), retval));
}
int
struct iovec aiov[UIO_SMALLIOV], *uiov, *iov;
register int error;
- if (error = copyin((caddr_t)SCARG(uap, msg), (caddr_t)&msg,
- sizeof (msg)))
+ error = copyin((caddr_t)SCARG(uap, msg), (caddr_t)&msg,
+ sizeof (msg));
+ if (error)
return (error);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
#endif
uiov = msg.msg_iov;
msg.msg_iov = iov;
- if (error = copyin((caddr_t)uiov, (caddr_t)iov,
- (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))
+ error = copyin((caddr_t)uiov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
+ if (error)
goto done;
if ((error = recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval)) == 0) {
msg.msg_iov = uiov;
struct iovec *ktriov = NULL;
#endif
- if (error = getsock(p->p_fd, s, &fp))
+ if ((error = getsock(p->p_fd, s, &fp)) != 0)
return (error);
auio.uio_iov = mp->msg_iov;
auio.uio_iovcnt = mp->msg_iovlen;
auio.uio_resid = 0;
iov = mp->msg_iov;
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
+#if 0
+ /* cannot happen iov_len is unsigned */
if (iov->iov_len < 0)
return (EINVAL);
+#endif
if ((auio.uio_resid += iov->iov_len) < 0)
return (EINVAL);
}
}
#endif
len = auio.uio_resid;
- if (error = soreceive((struct socket *)fp->f_data, &from, &auio,
- (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
- &mp->msg_flags)) {
+ error = soreceive((struct socket *)fp->f_data, &from, &auio,
+ NULL, mp->msg_control ? &control : NULL,
+ &mp->msg_flags);
+ if (error) {
if (auio.uio_resid != len && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
if (len > from->m_len)
len = from->m_len;
/* else if len < from->m_len ??? */
- if (error = copyout(mtod(from, caddr_t),
- (caddr_t)mp->msg_name, (unsigned)len))
+ error = copyout(mtod(from, caddr_t),
+ (caddr_t)mp->msg_name, (unsigned)len);
+ if (error)
goto out;
}
mp->msg_namelen = len;
struct file *fp;
int error;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
return (soshutdown((struct socket *)fp->f_data, SCARG(uap, how)));
}
struct mbuf *m = NULL;
int error;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
if (SCARG(uap, valsize) > MLEN)
return (EINVAL);
m = m_get(M_WAIT, MT_SOOPTS);
if (m == NULL)
return (ENOBUFS);
- if (error = copyin(SCARG(uap, val), mtod(m, caddr_t),
- (u_int)SCARG(uap, valsize))) {
+ error = copyin(SCARG(uap, val), mtod(m, caddr_t),
+ (u_int)SCARG(uap, valsize));
+ if (error) {
(void) m_free(m);
return (error);
}
m->m_len = SCARG(uap, valsize);
}
return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
- SCARG(uap, name), m));
+ SCARG(uap, name), m));
}
/* ARGSUSED */
struct mbuf *m = NULL;
int valsize, error;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
if (SCARG(uap, val)) {
- if (error = copyin((caddr_t)SCARG(uap, avalsize),
- (caddr_t)&valsize, sizeof (valsize)))
+ error = copyin((caddr_t)SCARG(uap, avalsize),
+ (caddr_t)&valsize, sizeof (valsize));
+ if (error)
return (error);
} else
valsize = 0;
struct socket *rso, *wso;
int fd, error;
- if (error = socreate(AF_UNIX, &rso, SOCK_STREAM, 0))
+ if ((error = socreate(AF_UNIX, &rso, SOCK_STREAM, 0)) != 0)
return (error);
- if (error = socreate(AF_UNIX, &wso, SOCK_STREAM, 0))
+ if ((error = socreate(AF_UNIX, &wso, SOCK_STREAM, 0)) != 0)
goto free1;
- if (error = falloc(p, &rf, &fd))
+ if ((error = falloc(p, &rf, &fd)) != 0)
goto free2;
retval[0] = fd;
rf->f_flag = FREAD;
rf->f_type = DTYPE_SOCKET;
rf->f_ops = &socketops;
rf->f_data = (caddr_t)rso;
- if (error = falloc(p, &wf, &fd))
+ if ((error = falloc(p, &wf, &fd)) != 0)
goto free3;
wf->f_flag = FWRITE;
wf->f_type = DTYPE_SOCKET;
wf->f_ops = &socketops;
wf->f_data = (caddr_t)wso;
retval[1] = fd;
- if (error = unp_connect2(wso, rso))
+ if ((error = unp_connect2(wso, rso)) != 0)
goto free4;
return (0);
free4:
struct mbuf *m;
int len, error;
- if (error = getsock(p->p_fd, SCARG(uap, fdes), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0)
return (error);
- if (error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len,
- sizeof (len)))
+ error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len));
+ if (error)
return (error);
so = (struct socket *)fp->f_data;
m = m_getclr(M_WAIT, MT_SONAME);
if (m == NULL)
return (ENOBUFS);
- if (error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0))
+ error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0);
+ if (error)
goto bad;
if (len > m->m_len)
len = m->m_len;
struct mbuf *m;
int len, error;
- if (error = getsock(p->p_fd, SCARG(uap, fdes), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0)
return (error);
so = (struct socket *)fp->f_data;
if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0)
return (ENOTCONN);
- if (error =
- copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len)))
+ error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len));
+ if (error)
return (error);
m = m_getclr(M_WAIT, MT_SONAME);
if (m == NULL)
return (ENOBUFS);
- if (error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0))
+ error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0);
+ if (error)
goto bad;
if (len > m->m_len)
len = m->m_len;
- if (error =
- copyout(mtod(m, caddr_t), (caddr_t)SCARG(uap, asa), (u_int)len))
+ error = copyout(mtod(m, caddr_t), (caddr_t)SCARG(uap, asa), (u_int)len);
+ if (error)
goto bad;
error = copyout((caddr_t)&len, (caddr_t)SCARG(uap, alen), sizeof (len));
bad:
-/* $NetBSD: uipc_usrreq.c,v 1.15 1995/08/17 02:57:20 mycroft Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.2 1996/03/03 17:20:22 niklas Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
return (0);
}
-int
+void
unp_detach(unp)
register struct unpcb *unp;
{
} else
*(mtod(nam, caddr_t) + nam->m_len) = 0;
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
vattr.va_type = VSOCK;
vattr.va_mode = ACCESSPERMS;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr))
+ error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ if (error)
return (error);
vp = nd.ni_vp;
vp->v_socket = unp->unp_socket;
return (EMSGSIZE);
} else
*(mtod(nam, caddr_t) + nam->m_len) = 0;
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VSOCK) {
error = ENOTSOCK;
goto bad;
}
- if (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p))
+ if ((error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) != 0)
goto bad;
so2 = vp->v_socket;
if (so2 == 0) {
-/* $NetBSD: vfs_cache.c,v 1.12 1995/09/08 14:15:07 ws Exp $ */
+/* $OpenBSD: vfs_cache.c,v 1.2 1996/03/03 17:20:23 niklas Exp $ */
+/* $NetBSD: vfs_cache.c,v 1.13 1996/02/04 02:18:09 christos Exp $ */
/*
* Copyright (c) 1989, 1993
/*
* Add an entry to the cache
*/
+void
cache_enter(dvp, vp, cnp)
struct vnode *dvp;
struct vnode *vp;
malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK);
bzero((char *)ncp, sizeof *ncp);
numcache++;
- } else if (ncp = nclruhead.tqh_first) {
+ } else if ((ncp = nclruhead.tqh_first) != NULL) {
TAILQ_REMOVE(&nclruhead, ncp, nc_lru);
if (ncp->nc_hash.le_prev != 0) {
LIST_REMOVE(ncp, nc_hash);
/*
* Name cache initialization, from vfs_init() when we are booting
*/
+void
nchinit()
{
* Cache flush, a particular vnode; called when a vnode is renamed to
* hide entries that would now be invalid
*/
+void
cache_purge(vp)
struct vnode *vp;
{
* if the cache lru chain is modified while we are dumping the
* inode. This makes the algorithm O(n^2), but do you think I care?
*/
+void
cache_purgevfs(mp)
struct mount *mp;
{
-/* $NetBSD: vfs_cluster.c,v 1.8 1995/07/24 21:19:50 cgd Exp $ */
+/* $OpenBSD: vfs_cluster.c,v 1.2 1996/03/03 17:20:25 niklas Exp $ */
+/* $NetBSD: vfs_cluster.c,v 1.10 1996/02/09 19:00:56 christos Exp $ */
/*-
* Copyright (c) 1993
#include <sys/mount.h>
#include <sys/trace.h>
#include <sys/malloc.h>
+#include <sys/systm.h>
#include <sys/resourcevar.h>
-#include <lib/libkern/libkern.h>
+#include <sys/cpu.h>
#ifdef DEBUG
#include <vm/vm.h>
* rbp is the read-ahead block.
* If either is NULL, then you don't have to do the I/O.
*/
+int
cluster_read(vp, filesize, lblkno, size, cred, bpp)
struct vnode *vp;
u_quad_t filesize;
* case we don't want to write it twice).
*/
if (!incore(vp, start_lbn) ||
- last_bp == NULL && start_lbn == lbn)
+ (last_bp == NULL && start_lbn == lbn))
break;
/*
-/* $NetBSD: vfs_lockf.c,v 1.6 1995/03/19 23:45:03 mycroft Exp $ */
+/* $OpenBSD: vfs_lockf.c,v 1.2 1996/03/03 17:20:26 niklas Exp $ */
+/* $NetBSD: vfs_lockf.c,v 1.7 1996/02/04 02:18:21 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
/*
* Scan lock list for this file looking for locks that would block us.
*/
- while (block = lf_getblock(lock)) {
+ while ((block = lf_getblock(lock)) != NULL) {
/*
* Free the structure and return if nonblocking.
*/
lf_printlist("lf_setlock", block);
}
#endif /* LOCKF_DEBUG */
- if (error = tsleep((caddr_t)lock, priority, lockstr, 0)) {
+ error = tsleep((caddr_t)lock, priority, lockstr, 0);
+ if (error) {
/*
* Delete ourselves from the waiting to lock list.
*/
block = *head;
needtolink = 1;
for (;;) {
- if (ovcase = lf_findoverlap(block, lock, SELF, &prev, &overlap))
+ ovcase = lf_findoverlap(block, lock, SELF, &prev, &overlap);
+ if (ovcase)
block = overlap->lf_next;
/*
* Six cases:
lf_print("lf_clearlock", unlock);
#endif /* LOCKF_DEBUG */
prev = head;
- while (ovcase = lf_findoverlap(lf, unlock, SELF, &prev, &overlap)) {
+ while ((ovcase = lf_findoverlap(lf, unlock, SELF,
+ &prev, &overlap)) != 0) {
/*
* Wakeup the list of locks to be retried.
*/
lf_print("lf_getlock", lock);
#endif /* LOCKF_DEBUG */
- if (block = lf_getblock(lock)) {
+ if ((block = lf_getblock(lock)) != NULL) {
fl->l_type = block->lf_type;
fl->l_whence = SEEK_SET;
fl->l_start = block->lf_start;
int ovcase;
prev = lock->lf_head;
- while (ovcase = lf_findoverlap(lf, lock, OTHERS, &prev, &overlap)) {
+ while ((ovcase = lf_findoverlap(lf, lock, OTHERS,
+ &prev, &overlap)) != 0) {
/*
* We've found an overlap, see if it blocks us
*/
-/* $NetBSD: vfs_lookup.c,v 1.15 1995/03/08 01:20:50 cgd Exp $ */
+/* $OpenBSD: vfs_lookup.c,v 1.2 1996/03/03 17:20:27 niklas Exp $ */
+/* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
VREF(dp);
}
ndp->ni_startdir = dp;
- if (error = lookup(ndp)) {
+ if ((error = lookup(ndp)) != 0) {
FREE(cnp->cn_pnbuf, M_NAMEI);
return (error);
}
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_procp = (struct proc *)0;
auio.uio_resid = MAXPATHLEN;
- if (error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred)) {
+ error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred);
+ if (error) {
if (ndp->ni_pathlen > 1)
free(cp, M_NAMEI);
break;
*/
unionlookup:
ndp->ni_dvp = dp;
- if (error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp)) {
+ if ((error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp)) != 0) {
#ifdef DIAGNOSTIC
if (ndp->ni_vp != NULL)
panic("leaf should be empty");
sleep((caddr_t)mp, PVFS);
continue;
}
- if (error = VFS_ROOT(dp->v_mountedhere, &tdp))
+ if ((error = VFS_ROOT(dp->v_mountedhere, &tdp)) != 0)
goto bad2;
vput(dp);
ndp->ni_vp = dp = tdp;
/*
* We now have a segment name to search for, and a directory to search.
*/
- if (error = VOP_LOOKUP(dp, vpp, cnp)) {
+ if ((error = VOP_LOOKUP(dp, vpp, cnp)) != 0) {
#ifdef DIAGNOSTIC
if (*vpp != NULL)
panic("leaf should be empty");
-/* $NetBSD: vfs_vnops.c,v 1.19 1995/05/23 06:11:29 mycroft Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.2 1996/03/03 17:20:28 niklas Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
* Common code for vnode open operations.
* Check permissions, and call the VOP_OPEN or VOP_CREATE routine.
*/
+int
vn_open(ndp, fmode, cmode)
register struct nameidata *ndp;
int fmode, cmode;
ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
if ((fmode & O_EXCL) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;
- if (error = namei(ndp))
+ if ((error = namei(ndp)) != 0)
return (error);
if (ndp->ni_vp == NULL) {
VATTR_NULL(&va);
va.va_type = VREG;
va.va_mode = cmode;
VOP_LEASE(ndp->ni_dvp, p, cred, LEASE_WRITE);
- if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
- &ndp->ni_cnd, &va))
+ error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
+ &ndp->ni_cnd, &va);
+ if (error)
return (error);
fmode &= ~O_TRUNC;
vp = ndp->ni_vp;
} else {
ndp->ni_cnd.cn_nameiop = LOOKUP;
ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF;
- if (error = namei(ndp))
+ if ((error = namei(ndp)) != 0)
return (error);
vp = ndp->ni_vp;
}
}
if ((fmode & O_CREAT) == 0) {
if (fmode & FREAD) {
- if (error = VOP_ACCESS(vp, VREAD, cred, p))
+ if ((error = VOP_ACCESS(vp, VREAD, cred, p)) != 0)
goto bad;
}
if (fmode & (FWRITE | O_TRUNC)) {
error = EISDIR;
goto bad;
}
- if ((error = vn_writechk(vp)) ||
- (error = VOP_ACCESS(vp, VWRITE, cred, p)))
+ if ((error = vn_writechk(vp)) != 0 ||
+ (error = VOP_ACCESS(vp, VWRITE, cred, p)) != 0)
goto bad;
}
}
VOP_LOCK(vp); /* XXX */
VATTR_NULL(&va);
va.va_size = 0;
- if (error = VOP_SETATTR(vp, &va, cred, p))
+ if ((error = VOP_SETATTR(vp, &va, cred, p)) != 0)
goto bad;
}
- if (error = VOP_OPEN(vp, fmode, cred, p))
+ if ((error = VOP_OPEN(vp, fmode, cred, p)) != 0)
goto bad;
if (fmode & FWRITE)
vp->v_writecount++;
* The read-only status of the file system is checked.
* Also, prototype text segments cannot be written.
*/
+int
vn_writechk(vp)
register struct vnode *vp;
{
switch (vp->v_type) {
case VREG: case VDIR: case VLNK:
return (EROFS);
+ case VNON: case VCHR: case VSOCK:
+ case VFIFO: case VBAD: case VBLK:
+ break;
}
}
/*
/*
* Vnode close call
*/
+int
vn_close(vp, flags, cred, p)
register struct vnode *vp;
int flags;
/*
* Package up an I/O request on a vnode into a uio and do it.
*/
+int
vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p)
enum uio_rw rw;
struct vnode *vp;
/*
* File table vnode read routine.
*/
+int
vn_read(fp, uio, cred)
struct file *fp;
struct uio *uio;
/*
* File table vnode write routine.
*/
+int
vn_write(fp, uio, cred)
struct file *fp;
struct uio *uio;
/*
* File table vnode stat routine.
*/
+int
vn_stat(vp, sb, p)
struct vnode *vp;
register struct stat *sb;
/*
* File table vnode ioctl routine.
*/
+int
vn_ioctl(fp, com, data, p)
struct file *fp;
u_long com;
case VREG:
case VDIR:
if (com == FIONREAD) {
- if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
+ error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
+ if (error)
return (error);
*(int *)data = vattr.va_size - fp->f_offset;
return (0);
/*
* File table vnode select routine.
*/
+int
vn_select(fp, which, p)
struct file *fp;
int which;
{
return (VOP_SELECT(((struct vnode *)fp->f_data), which, fp->f_flag,
- fp->f_cred, p));
+ fp->f_cred, p));
}
/*
* File table vnode close routine.
*/
+int
vn_closefile(fp, p)
struct file *fp;
struct proc *p;