First pass at prototyping
This commit is contained in:
parent
7da3571dc9
commit
8a5b1b92e2
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec_aout.c,v 1.13 1994/08/01 18:49:49 pk Exp $ */
|
||||
/* $NetBSD: exec_aout.c,v 1.14 1996/02/04 02:15:01 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||
|
@ -87,7 +87,6 @@ exec_aout_makecmds(p, epp)
|
|||
if (error)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
||||
bad:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec_script.c,v 1.12 1995/04/10 18:27:59 mycroft Exp $ */
|
||||
/* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||
|
@ -105,6 +105,7 @@ exec_script_makecmds(p, epp)
|
|||
|
||||
shellname = NULL;
|
||||
shellarg = NULL;
|
||||
shellarglen = 0;
|
||||
|
||||
/* strip spaces before the shell name */
|
||||
for (cp = hdrstr + EXEC_SCRIPT_MAGICLEN; *cp == ' ' || *cp == '\t';
|
||||
|
@ -134,7 +135,6 @@ exec_script_makecmds(p, epp)
|
|||
* behaviour.
|
||||
*/
|
||||
shellarg = cp;
|
||||
shellarglen = 0;
|
||||
for ( /* cp = cp */ ; *cp != '\0'; cp++)
|
||||
shellarglen++;
|
||||
*cp++ = '\0';
|
||||
|
@ -263,7 +263,9 @@ check_shell:
|
|||
|
||||
/* 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;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init_main.c,v 1.80 1996/01/07 22:03:47 thorpej Exp $ */
|
||||
/* $NetBSD: init_main.c,v 1.81 1996/02/04 02:15:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -71,6 +71,12 @@
|
|||
#include <machine/cpu.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_pageout.h>
|
||||
|
||||
#include <kern/kern_extern.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";
|
||||
|
@ -96,6 +102,7 @@ struct timeval runtime;
|
|||
|
||||
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 */
|
||||
|
@ -131,11 +138,12 @@ struct emul emul_netbsd = {
|
|||
* 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 */
|
||||
{
|
||||
register struct proc *p;
|
||||
register struct filedesc0 *fdp;
|
||||
register struct pdevinit *pdev;
|
||||
register int i;
|
||||
int s;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_acct.c,v 1.41 1995/10/07 06:28:07 mycroft Exp $ */
|
||||
/* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -107,7 +107,7 @@ sys_acct(p, v, retval)
|
|||
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);
|
||||
|
||||
/*
|
||||
|
@ -117,7 +117,7 @@ sys_acct(p, v, retval)
|
|||
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) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_clock.c,v 1.24 1996/01/17 04:37:31 cgd Exp $ */
|
||||
/* $NetBSD: kern_clock.c,v 1.25 1996/02/04 02:15:15 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993
|
||||
|
@ -47,9 +47,12 @@
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/signalvar.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#ifdef GPROF
|
||||
#include <sys/gmon.h>
|
||||
#endif
|
||||
|
@ -530,6 +533,7 @@ statclock(frame)
|
|||
/*
|
||||
* Return information about system clocks.
|
||||
*/
|
||||
int
|
||||
sysctl_clockrate(where, sizep)
|
||||
register char *where;
|
||||
size_t *sizep;
|
||||
|
@ -550,10 +554,16 @@ sysctl_clockrate(where, 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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_descrip.c,v 1.37 1995/10/07 06:28:09 mycroft Exp $ */
|
||||
/* $NetBSD: kern_descrip.c,v 1.38 1996/02/04 02:15:17 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -60,13 +60,22 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
||||
#include <kern/kern_extern.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;
|
||||
|
@ -76,7 +85,7 @@ fd_used(fdp, fd)
|
|||
fdp->fd_lastfile = fd;
|
||||
}
|
||||
|
||||
static __inline
|
||||
static __inline void
|
||||
fd_unused(fdp, fd)
|
||||
register struct filedesc *fdp;
|
||||
register int fd;
|
||||
|
@ -104,6 +113,7 @@ fd_unused(fdp, fd)
|
|||
* Duplicate a file descriptor.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_dup(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -119,7 +129,7 @@ sys_dup(p, v, retval)
|
|||
|
||||
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));
|
||||
}
|
||||
|
@ -128,6 +138,7 @@ sys_dup(p, v, retval)
|
|||
* Duplicate a file descriptor to a particular value.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_dup2(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -150,7 +161,7 @@ sys_dup2(p, v, retval)
|
|||
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");
|
||||
|
@ -164,6 +175,7 @@ sys_dup2(p, v, retval)
|
|||
* The file control system call.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_fcntl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -192,7 +204,7 @@ sys_fcntl(p, v, retval)
|
|||
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));
|
||||
|
||||
|
@ -302,7 +314,8 @@ sys_fcntl(p, v, 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)));
|
||||
|
@ -359,6 +372,7 @@ fdrelease(p, fd)
|
|||
* Close a file descriptor.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_close(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -379,6 +393,7 @@ sys_close(p, v, retval)
|
|||
* Return status information about a file descriptor.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_fstat(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -421,6 +436,7 @@ sys_fstat(p, v, retval)
|
|||
* Return pathconf information about a file descriptor.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_fpathconf(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -461,6 +477,7 @@ sys_fpathconf(p, v, retval)
|
|||
*/
|
||||
int fdexpand;
|
||||
|
||||
int
|
||||
fdalloc(p, want, result)
|
||||
struct proc *p;
|
||||
int want;
|
||||
|
@ -527,6 +544,7 @@ fdalloc(p, want, result)
|
|||
* Check to see whether n user file descriptors
|
||||
* are available to the process p.
|
||||
*/
|
||||
int
|
||||
fdavail(p, n)
|
||||
struct proc *p;
|
||||
register int n;
|
||||
|
@ -549,6 +567,7 @@ fdavail(p, 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;
|
||||
|
@ -557,7 +576,7 @@ falloc(p, resultfp, resultfd)
|
|||
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");
|
||||
|
@ -572,7 +591,7 @@ falloc(p, resultfp, resultfd)
|
|||
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);
|
||||
|
@ -591,11 +610,10 @@ falloc(p, resultfp, resultfd)
|
|||
/*
|
||||
* 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
|
||||
|
@ -694,6 +712,7 @@ fdfree(p)
|
|||
* 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;
|
||||
|
@ -747,6 +766,7 @@ closef(fp, 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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_exec.c,v 1.73 1995/12/09 04:11:00 mycroft Exp $ */
|
||||
/* $NetBSD: kern_exec.c,v 1.74 1996/02/04 02:15:20 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1993, 1994 Christopher G. Demetriou
|
||||
|
@ -56,6 +56,8 @@
|
|||
#include <vm/vm.h>
|
||||
#include <vm/vm_kern.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/reg.h>
|
||||
|
||||
|
@ -90,7 +92,6 @@ check_exec(p, epp)
|
|||
{
|
||||
int error, i;
|
||||
struct vnode *vp;
|
||||
char *cp, *ep, *name;
|
||||
struct nameidata *ndp;
|
||||
int resid;
|
||||
|
||||
|
@ -98,7 +99,7 @@ check_exec(p, epp)
|
|||
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;
|
||||
|
||||
|
@ -109,7 +110,7 @@ check_exec(p, epp)
|
|||
}
|
||||
|
||||
/* 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 */
|
||||
|
@ -121,7 +122,7 @@ check_exec(p, epp)
|
|||
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;
|
||||
|
@ -129,12 +130,13 @@ check_exec(p, epp)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
|
@ -257,7 +259,7 @@ sys_execve(p, v, retval)
|
|||
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 */
|
||||
|
@ -280,7 +282,7 @@ sys_execve(p, v, retval)
|
|||
cp = *tmpfap;
|
||||
while (*cp)
|
||||
*dp++ = *cp++;
|
||||
*dp++;
|
||||
dp++;
|
||||
|
||||
FREE(*tmpfap, M_EXEC);
|
||||
tmpfap++; argc++;
|
||||
|
@ -300,11 +302,11 @@ sys_execve(p, v, retval)
|
|||
|
||||
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;
|
||||
|
@ -315,14 +317,15 @@ sys_execve(p, v, retval)
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -436,10 +439,8 @@ sys_execve(p, v, retval)
|
|||
* 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
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_exit.c,v 1.35 1995/12/24 11:23:33 mycroft Exp $ */
|
||||
/* $NetBSD: kern_exit.c,v 1.36 1996/02/04 02:15:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -59,6 +59,8 @@
|
|||
#include <sys/resourcevar.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/acct.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/signalvar.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
@ -68,8 +70,7 @@
|
|||
#include <vm/vm.h>
|
||||
#include <vm/vm_kern.h>
|
||||
|
||||
void cpu_exit __P((struct proc *)); /* XXX MOVE ME */
|
||||
void exit1 __P((struct proc *, int));
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
/*
|
||||
* exit --
|
||||
|
@ -253,7 +254,8 @@ exit1(p, rv)
|
|||
* 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
|
||||
|
@ -306,9 +308,10 @@ loop:
|
|||
|
||||
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) &&
|
||||
|
@ -389,7 +392,7 @@ loop:
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_fork.c,v 1.27 1995/12/10 08:26:02 mycroft Exp $ */
|
||||
/* $NetBSD: kern_fork.c,v 1.28 1996/02/04 02:15:32 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -55,6 +55,9 @@
|
|||
|
||||
int nprocs = 1; /* process 0 */
|
||||
|
||||
int fork1 __P((struct proc *, int, register_t *));
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
sys_fork(p, v, retval)
|
||||
struct proc *p;
|
||||
|
@ -65,6 +68,7 @@ sys_fork(p, v, retval)
|
|||
return (fork1(p, 0, retval));
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
sys_vfork(p, v, retval)
|
||||
struct proc *p;
|
||||
|
@ -84,7 +88,6 @@ fork1(p1, isvfork, retval)
|
|||
register struct proc *p2;
|
||||
register uid_t uid;
|
||||
struct proc *newproc;
|
||||
struct proc **hash;
|
||||
int count;
|
||||
static int nextpid, pidchecked = 0;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_ktrace.c,v 1.21 1995/10/22 00:35:06 christos Exp $ */
|
||||
/* $NetBSD: kern_ktrace.c,v 1.22 1996/02/04 02:15:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -50,6 +50,15 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.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;
|
||||
|
@ -266,7 +275,7 @@ sys_ktrace(curp, v, retval)
|
|||
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;
|
||||
|
@ -280,7 +289,7 @@ sys_ktrace(curp, v, retval)
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
@ -401,6 +410,7 @@ ktrops(curp, p, ops, facs, vp)
|
|||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
ktrsetchildren(curp, top, ops, facs, vp)
|
||||
struct proc *curp, *top;
|
||||
int ops, facs;
|
||||
|
@ -432,6 +442,7 @@ ktrsetchildren(curp, top, ops, facs, vp)
|
|||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
void
|
||||
ktrwrite(vp, kth)
|
||||
struct vnode *vp;
|
||||
register struct ktr_header *kth;
|
||||
|
@ -486,6 +497,7 @@ ktrwrite(vp, kth)
|
|||
*
|
||||
* TODO: check groups. use caller effective gid.
|
||||
*/
|
||||
int
|
||||
ktrcanset(callp, targetp)
|
||||
struct proc *callp, *targetp;
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_lkm.c,v 1.26 1995/10/10 00:23:20 thorpej Exp $ */
|
||||
/* $NetBSD: kern_lkm.c,v 1.27 1996/02/04 02:15:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -44,7 +44,6 @@
|
|||
#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>
|
||||
|
@ -53,6 +52,9 @@
|
|||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/exec.h>
|
||||
|
||||
#include <kern/kern_conf.h>
|
||||
|
||||
#include <sys/lkm.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
|
@ -60,6 +62,7 @@
|
|||
#include <vm/vm_param.h>
|
||||
#include <vm/vm_kern.h>
|
||||
|
||||
|
||||
#define PAGESIZE 1024 /* kmem_alloc() allocation quantum */
|
||||
|
||||
#define LKM_ALLOC 0x01
|
||||
|
@ -81,6 +84,18 @@ static int lkm_state = LKMS_IDLE;
|
|||
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)
|
||||
|
@ -107,7 +122,8 @@ 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;
|
||||
|
@ -120,7 +136,7 @@ lkmopen(dev, flag, devtype, p)
|
|||
* 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()
|
||||
{
|
||||
|
||||
|
@ -171,19 +187,19 @@ lkmclose(dev, flag, mode, p)
|
|||
|
||||
/*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) {
|
||||
|
@ -203,7 +219,7 @@ lkmioctl(dev, cmd, data, flag)
|
|||
if (!lkmods[i].used)
|
||||
break;
|
||||
if (i == MAXLKMS) {
|
||||
err = ENOMEM; /* no slots available */
|
||||
error = ENOMEM; /* no slots available */
|
||||
break;
|
||||
}
|
||||
curp = &lkmods[i];
|
||||
|
@ -243,12 +259,14 @@ lkmioctl(dev, cmd, data, flag)
|
|||
|| 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) {
|
||||
|
@ -302,10 +320,12 @@ lkmioctl(dev, cmd, data, flag)
|
|||
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...
|
||||
|
@ -337,8 +357,9 @@ lkmioctl(dev, cmd, data, flag)
|
|||
* 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;
|
||||
|
||||
/*
|
||||
|
@ -357,20 +378,20 @@ lkmioctl(dev, cmd, data, flag)
|
|||
* 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;
|
||||
}
|
||||
|
||||
|
@ -402,7 +423,7 @@ lkmioctl(dev, cmd, data, flag)
|
|||
}
|
||||
|
||||
if (i == MAXLKMS) { /* Not found */
|
||||
err = ENOENT;
|
||||
error = ENOENT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -411,14 +432,14 @@ lkmioctl(dev, cmd, data, flag)
|
|||
* 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;
|
||||
}
|
||||
|
||||
|
@ -440,11 +461,11 @@ lkmioctl(dev, cmd, data, flag)
|
|||
break;
|
||||
|
||||
default: /* bad ioctl()... */
|
||||
err = ENOTTY;
|
||||
error = ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -528,7 +549,7 @@ _lkm_syscall(lkmtp, cmd)
|
|||
{
|
||||
struct lkm_syscall *args = lkmtp->private.lkm_syscall;
|
||||
int i;
|
||||
int err = 0;
|
||||
int error = 0;
|
||||
|
||||
switch(cmd) {
|
||||
case LKM_E_LOAD:
|
||||
|
@ -545,12 +566,12 @@ _lkm_syscall(lkmtp, cmd)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +600,7 @@ _lkm_syscall(lkmtp, cmd)
|
|||
break;
|
||||
}
|
||||
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -593,7 +614,7 @@ _lkm_vfs(lkmtp, cmd)
|
|||
{
|
||||
struct lkm_vfs *args = lkmtp->private.lkm_vfs;
|
||||
int i;
|
||||
int err = 0;
|
||||
int error = 0;
|
||||
|
||||
switch(cmd) {
|
||||
case LKM_E_LOAD:
|
||||
|
@ -613,7 +634,7 @@ _lkm_vfs(lkmtp, cmd)
|
|||
if (vfssw[i] == (struct vfsops *)0)
|
||||
break;
|
||||
if (i == -1) { /* or if none, punt */
|
||||
err = EINVAL;
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -647,7 +668,7 @@ _lkm_vfs(lkmtp, cmd)
|
|||
break;
|
||||
}
|
||||
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -661,7 +682,7 @@ _lkm_dev(lkmtp, cmd)
|
|||
{
|
||||
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) {
|
||||
|
@ -681,12 +702,12 @@ _lkm_dev(lkmtp, 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;
|
||||
}
|
||||
}
|
||||
|
@ -711,12 +732,12 @@ _lkm_dev(lkmtp, cmd)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +754,7 @@ _lkm_dev(lkmtp, cmd)
|
|||
break;
|
||||
|
||||
default:
|
||||
err = ENODEV;
|
||||
error = ENODEV;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -754,7 +775,7 @@ _lkm_dev(lkmtp, cmd)
|
|||
break;
|
||||
|
||||
default:
|
||||
err = ENODEV;
|
||||
error = ENODEV;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -763,7 +784,7 @@ _lkm_dev(lkmtp, cmd)
|
|||
break;
|
||||
}
|
||||
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef STREAMS
|
||||
|
@ -778,7 +799,7 @@ _lkm_strmod(lkmtp, cmd)
|
|||
{
|
||||
struct lkm_strmod *args = lkmtp->private.lkm_strmod;
|
||||
int i;
|
||||
int err = 0;
|
||||
int error = 0;
|
||||
|
||||
switch(cmd) {
|
||||
case LKM_E_LOAD:
|
||||
|
@ -794,7 +815,7 @@ _lkm_strmod(lkmtp, cmd)
|
|||
break;
|
||||
}
|
||||
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
#endif /* STREAMS */
|
||||
|
||||
|
@ -809,7 +830,7 @@ _lkm_exec(lkmtp, cmd)
|
|||
{
|
||||
struct lkm_exec *args = lkmtp->private.lkm_exec;
|
||||
int i;
|
||||
int err = 0;
|
||||
int error = 0;
|
||||
|
||||
switch(cmd) {
|
||||
case LKM_E_LOAD:
|
||||
|
@ -826,12 +847,12 @@ _lkm_exec(lkmtp, cmd)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -866,7 +887,7 @@ _lkm_exec(lkmtp, cmd)
|
|||
break;
|
||||
}
|
||||
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -880,19 +901,19 @@ lkmdispatch(lkmtp, cmd)
|
|||
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
|
||||
|
@ -905,16 +926,16 @@ lkmdispatch(lkmtp, cmd)
|
|||
#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);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_malloc.c,v 1.11 1995/05/01 22:39:11 cgd Exp $ */
|
||||
/* $NetBSD: kern_malloc.c,v 1.12 1996/02/04 02:15:48 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1991, 1993
|
||||
|
@ -40,10 +40,13 @@
|
|||
#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>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
struct kmembuckets bucket[MINBUCKET + 16];
|
||||
struct kmemstats kmemstats[M_LAST];
|
||||
struct kmemusage *kmemusage;
|
||||
|
@ -65,7 +68,7 @@ long addrmask[] = { 0,
|
|||
* 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
|
||||
|
||||
/*
|
||||
|
@ -224,7 +227,8 @@ malloc(size, type, flags)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -359,6 +363,7 @@ free(addr, type)
|
|||
/*
|
||||
* Initialize the kernel memory allocator
|
||||
*/
|
||||
void
|
||||
kmeminit()
|
||||
{
|
||||
register long indx;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_physio.c,v 1.25 1995/10/10 02:51:45 mycroft Exp $ */
|
||||
/* $NetBSD: kern_physio.c,v 1.26 1996/02/04 02:15:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -47,6 +47,8 @@
|
|||
#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
|
||||
|
@ -96,7 +98,7 @@ physio(strategy, bp, dev, flags, minphys, uio)
|
|||
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;] */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_proc.c,v 1.12 1995/03/19 23:44:49 mycroft Exp $ */
|
||||
/* $NetBSD: kern_proc.c,v 1.13 1996/02/04 02:15:55 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -74,6 +74,8 @@ u_long pgrphash;
|
|||
struct proclist allproc;
|
||||
struct proclist zombproc;
|
||||
|
||||
static void orphanpg __P((struct pgrp *));
|
||||
|
||||
/*
|
||||
* Initialize global process hashing structures.
|
||||
*/
|
||||
|
@ -280,8 +282,6 @@ pgdelete(pgrp)
|
|||
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"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_prot.c,v 1.31 1995/10/10 01:26:53 mycroft Exp $ */
|
||||
/* $NetBSD: kern_prot.c,v 1.32 1996/02/04 02:15:57 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
|
||||
|
@ -56,7 +56,10 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_getpid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -72,6 +75,7 @@ sys_getpid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_getppid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -83,6 +87,7 @@ sys_getppid(p, v, retval)
|
|||
}
|
||||
|
||||
/* Get process group ID; note that POSIX getpgrp takes no parameter */
|
||||
int
|
||||
sys_getpgrp(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -94,6 +99,7 @@ sys_getpgrp(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_getuid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -109,6 +115,7 @@ sys_getuid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_geteuid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -120,6 +127,7 @@ sys_geteuid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_getgid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -139,6 +147,7 @@ sys_getgid(p, v, retval)
|
|||
* correctly in a library function.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_getegid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -149,6 +158,7 @@ sys_getegid(p, v, retval)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
sys_getgroups(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -169,14 +179,16 @@ sys_getgroups(p, v, retval)
|
|||
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;
|
||||
|
@ -206,6 +218,7 @@ sys_setsid(p, v, retval)
|
|||
* pid must not be session leader (EPERM)
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_setpgid(curp, v, retval)
|
||||
struct proc *curp;
|
||||
void *v;
|
||||
|
@ -244,6 +257,7 @@ sys_setpgid(curp, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_setuid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -280,6 +294,7 @@ sys_setuid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_seteuid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -311,6 +326,7 @@ sys_seteuid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_setgid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -339,6 +355,7 @@ sys_setgid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_setegid(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -366,6 +383,7 @@ sys_setegid(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_setgroups(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -379,14 +397,15 @@ sys_setgroups(p, v, retval)
|
|||
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;
|
||||
|
@ -396,6 +415,7 @@ sys_setgroups(p, v, retval)
|
|||
/*
|
||||
* Check if gid is a member of the group set.
|
||||
*/
|
||||
int
|
||||
groupmember(gid, cred)
|
||||
gid_t gid;
|
||||
register struct ucred *cred;
|
||||
|
@ -416,6 +436,7 @@ groupmember(gid, cred)
|
|||
* indicating use of super-powers.
|
||||
* Returns 0 or error.
|
||||
*/
|
||||
int
|
||||
suser(cred, acflag)
|
||||
struct ucred *cred;
|
||||
u_short *acflag;
|
||||
|
@ -495,6 +516,7 @@ crdup(cr)
|
|||
* Get login name, if available.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_getlogin(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -515,6 +537,7 @@ sys_getlogin(p, v, retval)
|
|||
* Set login name.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_setlogin(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -525,7 +548,7 @@ sys_setlogin(p, v, retval)
|
|||
} */ *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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_resource.c,v 1.32 1995/12/09 04:09:34 mycroft Exp $ */
|
||||
/* $NetBSD: kern_resource.c,v 1.33 1996/02/04 02:16:02 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993
|
||||
|
@ -53,9 +53,6 @@
|
|||
|
||||
#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));
|
||||
|
||||
/*
|
||||
* Resource controls and accounting.
|
||||
*/
|
||||
|
@ -214,8 +211,9 @@ sys_setrlimit(p, v, retval)
|
|||
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));
|
||||
}
|
||||
|
@ -235,7 +233,7 @@ dosetrlimit(p, which, limp)
|
|||
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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_sig.c,v 1.51 1996/01/04 22:23:14 jtc Exp $ */
|
||||
/* $NetBSD: kern_sig.c,v 1.52 1996/02/04 02:16:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -68,7 +68,10 @@
|
|||
#include <vm/vm.h>
|
||||
#include <sys/user.h> /* for coredump */
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
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?
|
||||
|
@ -82,6 +85,7 @@ void stop __P((struct proc *p));
|
|||
((signum) == SIGCONT && (q)->p_session == (p)->p_session))
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_sigaction(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -121,19 +125,22 @@ sys_sigaction(p, v, retval)
|
|||
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;
|
||||
|
@ -257,6 +264,7 @@ execsigs(p)
|
|||
* 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;
|
||||
|
@ -293,6 +301,7 @@ sys_sigprocmask(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_sigpending(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -337,6 +346,7 @@ sys_sigsuspend(p, v, retval)
|
|||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_sigaltstack(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -358,8 +368,8 @@ sys_sigaltstack(p, v, retval)
|
|||
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)
|
||||
|
@ -420,6 +430,7 @@ sys_kill(cp, v, retval)
|
|||
* 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;
|
||||
|
@ -991,6 +1002,7 @@ postsig(signum)
|
|||
/*
|
||||
* Kill the current process for stated reason.
|
||||
*/
|
||||
void
|
||||
killproc(p, why)
|
||||
struct proc *p;
|
||||
char *why;
|
||||
|
@ -1009,7 +1021,7 @@ killproc(p, 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;
|
||||
|
@ -1050,7 +1062,8 @@ coredump(p)
|
|||
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;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_synch.c,v 1.33 1995/06/08 23:51:03 mycroft Exp $ */
|
||||
/* $NetBSD: kern_synch.c,v 1.34 1996/02/04 02:16:17 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1991, 1993
|
||||
|
@ -47,16 +47,23 @@
|
|||
#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 <machine/cpu.h>
|
||||
|
||||
#include <kern/kern_extern.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.
|
||||
*/
|
||||
|
@ -335,7 +342,7 @@ tsleep(ident, priority, wmesg, timo)
|
|||
*/
|
||||
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;
|
||||
|
@ -369,7 +376,7 @@ resume:
|
|||
}
|
||||
} 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);
|
||||
|
@ -513,9 +520,9 @@ wakeup(ident)
|
|||
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) {
|
||||
|
@ -683,11 +690,16 @@ resetpriority(p)
|
|||
}
|
||||
|
||||
#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';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_sysctl.c,v 1.12 1995/10/07 06:28:27 mycroft Exp $ */
|
||||
/* $NetBSD: kern_sysctl.c,v 1.13 1996/02/04 02:16:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -60,15 +60,7 @@
|
|||
#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;
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
/*
|
||||
* Locking and stats
|
||||
|
@ -94,7 +86,7 @@ sys___sysctl(p, v, retval)
|
|||
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];
|
||||
|
||||
|
@ -106,8 +98,9 @@ sys___sysctl(p, v, retval)
|
|||
*/
|
||||
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]) {
|
||||
|
@ -162,7 +155,7 @@ sys___sysctl(p, v, retval)
|
|||
&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;
|
||||
|
@ -194,6 +187,7 @@ int securelevel;
|
|||
/*
|
||||
* kernel related system variables.
|
||||
*/
|
||||
int
|
||||
kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
|
@ -294,6 +288,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
|||
/*
|
||||
* hardware related system variables.
|
||||
*/
|
||||
int
|
||||
hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
|
@ -379,6 +374,7 @@ debug_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
|||
* 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;
|
||||
|
@ -403,6 +399,7 @@ sysctl_int(oldp, oldlenp, newp, newlen, valp)
|
|||
/*
|
||||
* As above, but read-only.
|
||||
*/
|
||||
int
|
||||
sysctl_rdint(oldp, oldlenp, newp, val)
|
||||
void *oldp;
|
||||
size_t *oldlenp;
|
||||
|
@ -425,6 +422,7 @@ sysctl_rdint(oldp, oldlenp, newp, val)
|
|||
* 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;
|
||||
|
@ -454,6 +452,7 @@ sysctl_string(oldp, oldlenp, newp, newlen, str, maxlen)
|
|||
/*
|
||||
* As above, but read-only.
|
||||
*/
|
||||
int
|
||||
sysctl_rdstring(oldp, oldlenp, newp, str)
|
||||
void *oldp;
|
||||
size_t *oldlenp;
|
||||
|
@ -477,6 +476,7 @@ sysctl_rdstring(oldp, oldlenp, newp, str)
|
|||
* 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;
|
||||
|
@ -504,6 +504,7 @@ sysctl_struct(oldp, oldlenp, newp, newlen, sp, len)
|
|||
* 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;
|
||||
|
@ -525,6 +526,7 @@ sysctl_rdstruct(oldp, oldlenp, newp, sp, len)
|
|||
/*
|
||||
* Get file structures.
|
||||
*/
|
||||
int
|
||||
sysctl_file(where, sizep)
|
||||
char *where;
|
||||
size_t *sizep;
|
||||
|
@ -549,7 +551,8 @@ sysctl_file(where, 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);
|
||||
|
@ -562,7 +565,8 @@ sysctl_file(where, sizep)
|
|||
*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);
|
||||
|
@ -576,6 +580,7 @@ sysctl_file(where, sizep)
|
|||
*/
|
||||
#define KERN_PROCSLOP (5 * sizeof (struct kinfo_proc))
|
||||
|
||||
int
|
||||
sysctl_doproc(name, namelen, where, sizep)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
|
@ -638,11 +643,13 @@ again:
|
|||
}
|
||||
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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_time.c,v 1.16 1995/10/07 06:28:28 mycroft Exp $ */
|
||||
/* $NetBSD: kern_time.c,v 1.17 1996/02/04 02:16:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -41,10 +41,13 @@
|
|||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/signalvar.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
|
||||
/*
|
||||
|
@ -73,8 +76,9 @@ sys_gettimeofday(p, v, retval)
|
|||
|
||||
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))
|
||||
|
@ -98,7 +102,7 @@ sys_settimeofday(p, v, retval)
|
|||
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),
|
||||
|
@ -145,10 +149,12 @@ sys_adjtime(p, v, retval)
|
|||
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);
|
||||
|
||||
/*
|
||||
|
@ -250,7 +256,7 @@ sys_getitimer(p, v, retval)
|
|||
int
|
||||
sys_setitimer(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
register struct sys_setitimer_args /* {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_xxx.c,v 1.29 1995/10/07 06:28:30 mycroft Exp $ */
|
||||
/* $NetBSD: kern_xxx.c,v 1.30 1996/02/04 02:16:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -46,6 +46,8 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_reboot(p, v, retval)
|
||||
|
@ -58,7 +60,7 @@ sys_reboot(p, v, retval)
|
|||
} */ *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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_autoconf.c,v 1.16 1994/11/04 06:40:11 mycroft Exp $ */
|
||||
/* $NetBSD: subr_autoconf.c,v 1.17 1996/02/04 02:16:35 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -49,7 +49,7 @@
|
|||
#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>
|
||||
|
||||
/*
|
||||
|
@ -74,6 +74,9 @@ struct matchinfo {
|
|||
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.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_log.c,v 1.8 1994/10/30 21:47:47 cgd Exp $ */
|
||||
/* $NetBSD: subr_log.c,v 1.9 1996/02/04 02:16:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
|
@ -46,6 +46,10 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <sys/msgbuf.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/signalvar.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
#include <kern/kern_conf.h>
|
||||
|
||||
#define LOG_RDPRI (PZERO + 1)
|
||||
|
||||
|
@ -93,7 +97,8 @@ logopen(dev, flags, mode, p)
|
|||
int
|
||||
logclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
|
||||
log_open = 0;
|
||||
|
@ -120,8 +125,9 @@ logread(dev, uio, flag)
|
|||
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);
|
||||
}
|
||||
|
@ -181,7 +187,7 @@ logwakeup()
|
|||
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) {
|
||||
|
@ -192,11 +198,12 @@ logwakeup()
|
|||
|
||||
/*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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_prf.c,v 1.19 1995/06/16 10:52:17 cgd Exp $ */
|
||||
/* $NetBSD: subr_prf.c,v 1.20 1996/02/04 02:16:42 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1988, 1991, 1993
|
||||
|
@ -55,6 +55,8 @@
|
|||
#include <sys/syslog.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
/*
|
||||
* Note that stdarg.h and the ANSI style va_start macro is used for both
|
||||
* ANSI and traditional C compilers.
|
||||
|
@ -65,18 +67,19 @@
|
|||
#include <machine/kdbparam.h>
|
||||
#endif
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#define TOCONS 0x01
|
||||
#define TOTTY 0x02
|
||||
#define TOLOG 0x04
|
||||
|
||||
struct tty *constty; /* pointer to console "window" tty */
|
||||
|
||||
extern cnputc(); /* standard console putc */
|
||||
int (*v_putc)() = cnputc; /* routine to putc on virtual console */
|
||||
void (*v_putc) __P((int)) = cnputc; /* routine to putc on virtual console */
|
||||
|
||||
static void putchar __P((int ch, int flags, struct tty *tp));
|
||||
static char *ksprintn __P((u_long num, int base, int *len));
|
||||
void kprintf __P((const char *fmt, int flags, struct tty *tp, va_list ap));
|
||||
static void putchar __P((int, int, struct tty *));
|
||||
static char *ksprintn __P((u_long, int, int *));
|
||||
void kprintf __P((const char *, int, struct tty *, va_list));
|
||||
|
||||
int consintr = 1; /* Ok to handle console interrupts? */
|
||||
|
||||
|
@ -101,10 +104,12 @@ panic(const char *fmt, ...)
|
|||
#else
|
||||
panic(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int bootopt;
|
||||
va_list ap;
|
||||
static const char fm[] = "panic: %r\n";
|
||||
|
||||
bootopt = RB_AUTOBOOT | RB_DUMP;
|
||||
if (panicstr)
|
||||
|
@ -113,7 +118,7 @@ panic(fmt, va_alist)
|
|||
panicstr = fmt;
|
||||
|
||||
va_start(ap, fmt);
|
||||
printf("panic: %r\n", fmt, ap);
|
||||
printf(fm, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
#ifdef KGDB
|
||||
|
@ -151,6 +156,7 @@ uprintf(const char *fmt, ...)
|
|||
#else
|
||||
uprintf(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
register struct proc *p = curproc;
|
||||
|
@ -195,6 +201,7 @@ tprintf(tpr_t tpr, const char *fmt, ...)
|
|||
tprintf(tpr, fmt, va_alist)
|
||||
tpr_t tpr;
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
register struct session *sess = (struct session *)tpr;
|
||||
|
@ -225,6 +232,7 @@ ttyprintf(struct tty *tp, const char *fmt, ...)
|
|||
ttyprintf(tp, fmt, va_alist)
|
||||
struct tty *tp;
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -248,6 +256,7 @@ log(int level, const char *fmt, ...)
|
|||
log(level, fmt, va_alist)
|
||||
int level;
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
register int s;
|
||||
|
@ -275,7 +284,7 @@ logpri(level)
|
|||
register char *p;
|
||||
|
||||
putchar('<', TOLOG, NULL);
|
||||
for (p = ksprintn((u_long)level, 10, NULL); ch = *p--;)
|
||||
for (p = ksprintn((u_long)level, 10, NULL); (ch = *p--) != 0;)
|
||||
putchar(ch, TOLOG, NULL);
|
||||
putchar('>', TOLOG, NULL);
|
||||
}
|
||||
|
@ -286,6 +295,7 @@ addlog(const char *fmt, ...)
|
|||
#else
|
||||
addlog(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
register int s;
|
||||
|
@ -310,6 +320,7 @@ printf(const char *fmt, ...)
|
|||
#else
|
||||
printf(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -402,13 +413,13 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||
case 'b':
|
||||
ul = va_arg(ap, int);
|
||||
p = va_arg(ap, char *);
|
||||
for (q = ksprintn(ul, *p++, NULL); ch = *q--;)
|
||||
for (q = ksprintn(ul, *p++, NULL); (ch = *q--) != 0;)
|
||||
putchar(ch, flags, tp);
|
||||
|
||||
if (!ul)
|
||||
break;
|
||||
|
||||
for (tmp = 0; n = *p++;) {
|
||||
for (tmp = 0; (n = *p++) != 0;) {
|
||||
if (ul & (1 << (n - 1))) {
|
||||
putchar(tmp ? ',' : '<', flags, tp);
|
||||
for (; (n = *p) > ' '; ++p)
|
||||
|
@ -431,7 +442,7 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||
case 's':
|
||||
if ((p = va_arg(ap, char *)) == NULL)
|
||||
p = "(null)";
|
||||
while (ch = *p++)
|
||||
while ((ch = *p++) != 0)
|
||||
putchar(ch, flags, tp);
|
||||
break;
|
||||
case 'd':
|
||||
|
@ -463,7 +474,7 @@ number: p = ksprintn(ul, base, &tmp);
|
|||
if (width && (width -= tmp) > 0)
|
||||
while (width--)
|
||||
putchar(padc, flags, tp);
|
||||
while (ch = *p--)
|
||||
while ((ch = *p--) != 0)
|
||||
putchar(ch, flags, tp);
|
||||
break;
|
||||
default:
|
||||
|
@ -518,11 +529,13 @@ putchar(c, flags, tp)
|
|||
/*
|
||||
* Scaled down version of sprintf(3).
|
||||
*/
|
||||
int
|
||||
#ifdef __STDC__
|
||||
sprintf(char *buf, const char *cfmt, ...)
|
||||
#else
|
||||
sprintf(buf, cfmt, va_alist)
|
||||
char *buf, *cfmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
register const char *fmt = cfmt;
|
||||
|
@ -565,7 +578,7 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||
/* case 'r': ... break; XXX */
|
||||
case 's':
|
||||
p = va_arg(ap, char *);
|
||||
while (*bp++ = *p++)
|
||||
while ((*bp++ = *p++) != 0)
|
||||
continue;
|
||||
--bp;
|
||||
break;
|
||||
|
@ -601,7 +614,7 @@ number: p = ksprintn(ul, base, &tmp);
|
|||
if (width && (width -= tmp) > 0)
|
||||
while (width--)
|
||||
*bp++ = padc;
|
||||
while (ch = *p--)
|
||||
while ((ch = *p--) != 0)
|
||||
*bp++ = ch;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_prof.c,v 1.8 1995/11/22 23:07:26 cgd Exp $ */
|
||||
/* $NetBSD: subr_prof.c,v 1.9 1996/02/04 02:16:46 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#ifdef GPROF
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/gmon.h>
|
||||
|
@ -57,6 +59,8 @@ struct gmonparam _gmonparam = { GMON_PROF_OFF };
|
|||
|
||||
extern char etext[];
|
||||
|
||||
|
||||
void
|
||||
kmstartup()
|
||||
{
|
||||
char *cp;
|
||||
|
@ -146,6 +150,7 @@ sysctl_doprof(name, namelen, oldp, oldlenp, newp, newlen, p)
|
|||
* 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;
|
||||
|
@ -153,8 +158,8 @@ sys_profil(p, v, retval)
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_rmap.c,v 1.9 1994/06/29 06:33:02 cgd Exp $ */
|
||||
/* $NetBSD: subr_rmap.c,v 1.10 1996/02/04 02:16:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1992, 1994 Wolfgang Solfrank.
|
||||
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/map.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
/*
|
||||
* Resource allocation map handling.
|
||||
|
@ -206,14 +207,15 @@ rmfree(mp, size, addr)
|
|||
*/
|
||||
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 */
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_xxx.c,v 1.9 1994/06/29 06:33:03 cgd Exp $ */
|
||||
/* $NetBSD: subr_xxx.c,v 1.10 1996/02/04 02:16:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1991, 1993
|
||||
|
@ -80,7 +80,7 @@ enoioctl()
|
|||
* that is not supported by the current system binary.
|
||||
*/
|
||||
int
|
||||
enosys()
|
||||
enosys ()
|
||||
{
|
||||
|
||||
return (ENOSYS);
|
||||
|
@ -100,8 +100,10 @@ eopnotsupp()
|
|||
/*
|
||||
* Generic null operation, always returns success.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
nullop()
|
||||
nullop(v)
|
||||
void *v;
|
||||
{
|
||||
|
||||
return (0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sys_generic.c,v 1.21 1995/10/07 06:28:34 mycroft Exp $ */
|
||||
/* $NetBSD: sys_generic.c,v 1.22 1996/02/04 02:16:53 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -47,6 +47,7 @@
|
|||
#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>
|
||||
|
@ -58,10 +59,16 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.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;
|
||||
|
@ -103,7 +110,8 @@ sys_read(p, v, retval)
|
|||
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;
|
||||
|
@ -120,6 +128,7 @@ sys_read(p, v, retval)
|
|||
/*
|
||||
* Scatter read system call.
|
||||
*/
|
||||
int
|
||||
sys_readv(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -162,14 +171,18 @@ sys_readv(p, v, retval)
|
|||
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;
|
||||
|
@ -187,7 +200,8 @@ sys_readv(p, v, retval)
|
|||
}
|
||||
#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;
|
||||
|
@ -210,6 +224,7 @@ done:
|
|||
/*
|
||||
* Write system call
|
||||
*/
|
||||
int
|
||||
sys_write(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -251,7 +266,8 @@ sys_write(p, v, retval)
|
|||
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;
|
||||
|
@ -271,6 +287,7 @@ sys_write(p, v, retval)
|
|||
/*
|
||||
* Gather write system call
|
||||
*/
|
||||
int
|
||||
sys_writev(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -313,14 +330,18 @@ sys_writev(p, v, retval)
|
|||
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;
|
||||
|
@ -338,7 +359,8 @@ sys_writev(p, v, retval)
|
|||
}
|
||||
#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;
|
||||
|
@ -365,6 +387,7 @@ done:
|
|||
* Ioctl system call
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
sys_ioctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
|
@ -437,7 +460,7 @@ sys_ioctl(p, v, retval)
|
|||
switch (com) {
|
||||
|
||||
case FIONBIO:
|
||||
if (tmp = *(int *)data)
|
||||
if ((tmp = *(int *)data) != 0)
|
||||
fp->f_flag |= FNONBLOCK;
|
||||
else
|
||||
fp->f_flag &= ~FNONBLOCK;
|
||||
|
@ -445,7 +468,7 @@ sys_ioctl(p, v, retval)
|
|||
break;
|
||||
|
||||
case FIOASYNC:
|
||||
if (tmp = *(int *)data)
|
||||
if ((tmp = *(int *)data) != 0)
|
||||
fp->f_flag |= FASYNC;
|
||||
else
|
||||
fp->f_flag &= ~FASYNC;
|
||||
|
@ -503,6 +526,7 @@ int selwait, nselcoll;
|
|||
/*
|
||||
* Select system call.
|
||||
*/
|
||||
int
|
||||
sys_select(p, v, retval)
|
||||
register struct proc *p;
|
||||
void *v;
|
||||
|
@ -568,7 +592,7 @@ retry:
|
|||
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;
|
||||
}
|
||||
|
@ -603,6 +627,7 @@ done:
|
|||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
selscan(p, ibits, obits, nfd, retval)
|
||||
struct proc *p;
|
||||
fd_set *ibits, *obits;
|
||||
|
@ -636,6 +661,7 @@ selscan(p, ibits, obits, nfd, retval)
|
|||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
seltrue(dev, flag, p)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sys_process.c,v 1.52 1995/10/07 06:28:36 mycroft Exp $ */
|
||||
/* $NetBSD: sys_process.c,v 1.53 1996/02/04 02:16:58 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -65,6 +65,13 @@
|
|||
|
||||
#include <machine/reg.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#ifdef notyet
|
||||
/* XXX: Fix the filesystem prototypes first */
|
||||
#include <miscfs/procfs/procfs.h>
|
||||
#endif
|
||||
|
||||
/* Macros to clear/set/test flags. */
|
||||
#define SET(t, f) (t) |= (f)
|
||||
#define CLR(t, f) (t) &= ~(f)
|
||||
|
@ -240,13 +247,14 @@ sys_ptrace(p, v, retval)
|
|||
/*
|
||||
* 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);
|
||||
|
@ -356,8 +364,10 @@ sys_ptrace(p, v, retval)
|
|||
#ifdef DIAGNOSTIC
|
||||
panic("ptrace: impossible");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
trace_req(a1)
|
||||
struct proc *a1;
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysv_msg.c,v 1.17 1995/10/07 06:28:40 mycroft Exp $ */
|
||||
/* $NetBSD: sysv_msg.c,v 1.18 1996/02/04 02:17:02 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Implementation of SVID messages
|
||||
|
@ -29,6 +29,8 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
#define MSG_DEBUG
|
||||
#undef MSG_DEBUG_OK
|
||||
|
||||
|
@ -36,11 +38,12 @@ int nfree_msgmaps; /* # of free map entries */
|
|||
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.
|
||||
|
@ -132,7 +135,7 @@ sys_msgctl(p, v, retval)
|
|||
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;
|
||||
|
||||
|
@ -173,7 +176,7 @@ sys_msgctl(p, v, retval)
|
|||
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;
|
||||
|
@ -265,7 +268,7 @@ sys_msgget(p, v, retval)
|
|||
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);
|
||||
|
@ -422,11 +425,11 @@ sys_msgsnd(p, v, retval)
|
|||
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
|
||||
|
@ -749,12 +752,15 @@ sys_msgrcv(p, v, retval)
|
|||
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) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysv_sem.c,v 1.24 1995/10/07 06:28:42 mycroft Exp $ */
|
||||
/* $NetBSD: sysv_sem.c,v 1.25 1996/02/04 02:17:06 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Implementation of SVID semaphores
|
||||
|
@ -18,14 +18,20 @@
|
|||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
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");
|
||||
|
@ -170,6 +176,7 @@ semu_alloc(p)
|
|||
panic("semu_alloc - second attempt failed");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -274,7 +281,7 @@ semundo_clear(semid, semnum)
|
|||
int
|
||||
sys___semctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
register struct sys___semctl_args /* {
|
||||
|
@ -313,7 +320,7 @@ sys___semctl(p, v, retval)
|
|||
|
||||
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;
|
||||
|
@ -565,12 +572,12 @@ sys_semop(p, v, retval)
|
|||
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);
|
||||
|
@ -641,7 +648,8 @@ sys_semop(p, v, retval)
|
|||
#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
|
||||
|
@ -824,6 +832,7 @@ done:
|
|||
* Go through the undo structures for this process and apply the adjustments to
|
||||
* semaphores.
|
||||
*/
|
||||
void
|
||||
semexit(p)
|
||||
struct proc *p;
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysv_shm.c,v 1.34 1995/12/09 04:12:56 mycroft Exp $ */
|
||||
/* $NetBSD: sysv_shm.c,v 1.35 1996/02/04 02:17:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
|
||||
|
@ -50,6 +50,11 @@
|
|||
#include <vm/vm_map.h>
|
||||
#include <vm/vm_kern.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
struct shmid_ds *shm_find_segment_by_shmid __P((int));
|
||||
void shmexit __P((struct proc *));
|
||||
|
||||
/*
|
||||
* Provides the following externally accessible functions:
|
||||
*
|
||||
|
@ -80,10 +85,13 @@ struct shmmap_state {
|
|||
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)
|
||||
|
@ -189,7 +197,7 @@ sys_shmat(p, v, retval)
|
|||
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;
|
||||
|
@ -210,8 +218,9 @@ sys_shmat(p, v, retval)
|
|||
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)
|
||||
|
@ -263,7 +272,7 @@ sys_shmctl(p, v, retval)
|
|||
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;
|
||||
|
@ -273,17 +282,19 @@ sys_shmctl(p, v, retval)
|
|||
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;
|
||||
|
@ -293,7 +304,7 @@ sys_shmctl(p, v, retval)
|
|||
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;
|
||||
|
@ -316,7 +327,7 @@ shmget_existing(p, uap, mode, segnum, retval)
|
|||
struct sys_shmget_args /* {
|
||||
syscallarg(key_t) key;
|
||||
syscallarg(int) size;
|
||||
syscallarg(int) shmflag;
|
||||
syscallarg(int) shmflg;
|
||||
} */ *uap;
|
||||
int mode;
|
||||
int segnum;
|
||||
|
@ -334,12 +345,12 @@ shmget_existing(p, uap, mode, segnum, retval)
|
|||
* 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;
|
||||
|
@ -356,7 +367,7 @@ shmget_allocate_segment(p, uap, mode, retval)
|
|||
struct sys_shmget_args /* {
|
||||
syscallarg(key_t) key;
|
||||
syscallarg(int) size;
|
||||
syscallarg(int) shmflag;
|
||||
syscallarg(int) shmflg;
|
||||
} */ *uap;
|
||||
int mode;
|
||||
register_t *retval;
|
||||
|
@ -439,10 +450,9 @@ sys_shmget(p, v, 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) {
|
||||
|
@ -482,7 +492,6 @@ shmexit(p)
|
|||
struct proc *p;
|
||||
{
|
||||
struct shmmap_state *shmmap_s;
|
||||
struct shmid_ds *shmseg;
|
||||
int i;
|
||||
|
||||
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty.c,v 1.64 1996/01/10 20:52:27 pk Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.65 1996/02/04 02:17:15 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1991, 1993
|
||||
|
@ -55,14 +55,18 @@
|
|||
#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));
|
||||
#include <kern/kern_extern.h>
|
||||
|
||||
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";
|
||||
|
@ -149,7 +153,7 @@ char const char_type[] = {
|
|||
|
||||
/* 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))
|
||||
|
||||
/*
|
||||
|
@ -208,7 +212,7 @@ ttyclose(tp)
|
|||
/* 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)))
|
||||
|
||||
|
||||
/*
|
||||
|
@ -221,7 +225,7 @@ ttyinput(c, tp)
|
|||
{
|
||||
register int iflag, lflag;
|
||||
register u_char *cc;
|
||||
int i, err;
|
||||
int i, error;
|
||||
|
||||
/*
|
||||
* If input is pending take it first.
|
||||
|
@ -244,9 +248,9 @@ ttyinput(c, tp)
|
|||
/* 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) &&
|
||||
|
@ -255,8 +259,8 @@ ttyinput(c, tp)
|
|||
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)) {
|
||||
|
@ -659,8 +663,9 @@ ttioctl(tp, cmd, data, flag, p)
|
|||
(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;
|
||||
|
@ -702,7 +707,7 @@ ttioctl(tp, cmd, data, flag, p)
|
|||
(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;
|
||||
|
@ -710,7 +715,7 @@ ttioctl(tp, cmd, data, flag, p)
|
|||
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 */
|
||||
|
@ -752,7 +757,7 @@ ttioctl(tp, cmd, data, flag, p)
|
|||
|
||||
s = spltty();
|
||||
if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
|
||||
if (error = ttywait(tp)) {
|
||||
if ((error = ttywait(tp)) != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
|
@ -862,8 +867,8 @@ ttioctl(tp, cmd, data, flag, p)
|
|||
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;
|
||||
|
@ -916,8 +921,8 @@ ttselect(device, rw, p)
|
|||
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;
|
||||
|
@ -966,8 +971,8 @@ ttywait(tp)
|
|||
&& 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);
|
||||
|
@ -1046,9 +1051,9 @@ ttyblock(tp)
|
|||
* 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) {
|
||||
|
@ -1212,7 +1217,7 @@ ttread(tp, uio, flag)
|
|||
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;
|
||||
|
@ -1233,7 +1238,8 @@ 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;
|
||||
}
|
||||
|
@ -1342,8 +1348,9 @@ read:
|
|||
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;
|
||||
}
|
||||
|
@ -1433,7 +1440,7 @@ ttwrite(tp, uio, flag)
|
|||
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;
|
||||
|
@ -1475,7 +1482,8 @@ loop:
|
|||
(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;
|
||||
}
|
||||
|
@ -1768,8 +1776,8 @@ ttyecho(c, tp)
|
|||
(!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);
|
||||
|
@ -2016,7 +2024,7 @@ ttysleep(tp, chan, pri, wmesg, timo)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty_conf.c,v 1.16 1995/10/10 01:27:01 mycroft Exp $ */
|
||||
/* $NetBSD: tty_conf.c,v 1.17 1996/02/04 02:17:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993
|
||||
|
@ -54,8 +54,7 @@
|
|||
#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
|
||||
|
@ -137,6 +136,7 @@ int nlinesw = sizeof (linesw) / sizeof (linesw[0]);
|
|||
* discipline specific ioctl command.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
nullioctl(tp, cmd, data, flags, p)
|
||||
struct tty *tp;
|
||||
u_long cmd;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty_pty.c,v 1.30 1995/10/10 01:27:03 mycroft Exp $ */
|
||||
/* $NetBSD: tty_pty.c,v 1.31 1996/02/04 02:17:28 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -46,11 +46,16 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#undef NPTY /* XXX */
|
||||
#include <kern/kern_conf.h>
|
||||
|
||||
|
||||
#if NPTY == 1
|
||||
#undef NPTY
|
||||
|
@ -78,7 +83,10 @@ int npty = NPTY; /* for pstat -t */
|
|||
#define PF_NOSTOP 0x40
|
||||
#define PF_UCNTL 0x80 /* user control mode */
|
||||
|
||||
void ptsstop __P((struct tty *, int));
|
||||
void ptyattach __P((int));
|
||||
void ptcwakeup __P((struct tty *, int));
|
||||
struct tty *ptytty __P((dev_t));
|
||||
void ptsstart __P((struct tty *));
|
||||
|
||||
/*
|
||||
* Establish n (or default if n is 1) ptys in the system.
|
||||
|
@ -99,6 +107,7 @@ ptyattach(n)
|
|||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
ptsopen(dev, flag, devtype, p)
|
||||
dev_t dev;
|
||||
int flag, devtype;
|
||||
|
@ -132,8 +141,9 @@ ptsopen(dev, flag, devtype, p)
|
|||
tp->t_state |= TS_WOPEN;
|
||||
if (flag&FNONBLOCK)
|
||||
break;
|
||||
if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
|
||||
ttopen, 0))
|
||||
error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
|
||||
ttopen, 0);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
||||
|
@ -141,6 +151,7 @@ ptsopen(dev, flag, devtype, p)
|
|||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
ptsclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
|
@ -148,14 +159,15 @@ ptsclose(dev, flag, mode, p)
|
|||
{
|
||||
register struct pt_softc *pti = &pt_softc[minor(dev)];
|
||||
register struct tty *tp = pti->pt_tty;
|
||||
int err;
|
||||
int error;
|
||||
|
||||
err = (*linesw[tp->t_line].l_close)(tp, flag);
|
||||
err |= ttyclose(tp);
|
||||
error = (*linesw[tp->t_line].l_close)(tp, flag);
|
||||
error |= ttyclose(tp);
|
||||
ptcwakeup(tp, FREAD|FWRITE);
|
||||
return (err);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
ptsread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
|
@ -175,15 +187,17 @@ again:
|
|||
p->p_flag & P_PPWAIT)
|
||||
return (EIO);
|
||||
pgsignal(p->p_pgrp, SIGTTIN, 1);
|
||||
if (error = ttysleep(tp, (caddr_t)&lbolt,
|
||||
TTIPRI | PCATCH, ttybg, 0))
|
||||
error = ttysleep(tp, (caddr_t)&lbolt,
|
||||
TTIPRI | PCATCH, ttybg, 0);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
if (tp->t_canq.c_cc == 0) {
|
||||
if (flag & IO_NDELAY)
|
||||
return (EWOULDBLOCK);
|
||||
if (error = ttysleep(tp, (caddr_t)&tp->t_canq,
|
||||
TTIPRI | PCATCH, ttyin, 0))
|
||||
error = ttysleep(tp, (caddr_t)&tp->t_canq,
|
||||
TTIPRI | PCATCH, ttyin, 0);
|
||||
if (error)
|
||||
return (error);
|
||||
goto again;
|
||||
}
|
||||
|
@ -208,6 +222,7 @@ again:
|
|||
* Wakeups of controlling tty will happen
|
||||
* indirectly, when tty driver calls ptsstart.
|
||||
*/
|
||||
int
|
||||
ptswrite(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
|
@ -240,6 +255,32 @@ ptsstart(tp)
|
|||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
|
||||
int
|
||||
ptsstop(tp, flush)
|
||||
register struct tty *tp;
|
||||
int flush;
|
||||
{
|
||||
struct pt_softc *pti = &pt_softc[minor(tp->t_dev)];
|
||||
int flag;
|
||||
|
||||
/* note: FLUSHREAD and FLUSHWRITE already ok */
|
||||
if (flush == 0) {
|
||||
flush = TIOCPKT_STOP;
|
||||
pti->pt_flags |= PF_STOPPED;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_STOPPED;
|
||||
pti->pt_send |= flush;
|
||||
/* change of perspective */
|
||||
flag = 0;
|
||||
if (flush & FREAD)
|
||||
flag |= FWRITE;
|
||||
if (flush & FWRITE)
|
||||
flag |= FREAD;
|
||||
ptcwakeup(tp, flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ptcwakeup(tp, flag)
|
||||
struct tty *tp;
|
||||
int flag;
|
||||
|
@ -286,9 +327,12 @@ ptcopen(dev, flag, devtype, p)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
ptcclose(dev)
|
||||
ptcclose(dev, flag, devtype, p)
|
||||
dev_t dev;
|
||||
int flag, devtype;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct pt_softc *pti = &pt_softc[minor(dev)];
|
||||
register struct tty *tp = pti->pt_tty;
|
||||
|
@ -299,6 +343,7 @@ ptcclose(dev)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptcread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
|
@ -324,7 +369,8 @@ ptcread(dev, uio, flag)
|
|||
if (pti->pt_send & TIOCPKT_IOCTL) {
|
||||
cc = min(uio->uio_resid,
|
||||
sizeof(tp->t_termios));
|
||||
uiomove(&tp->t_termios, cc, uio);
|
||||
uiomove((caddr_t) &tp->t_termios,
|
||||
cc, uio);
|
||||
}
|
||||
pti->pt_send = 0;
|
||||
return (0);
|
||||
|
@ -343,8 +389,9 @@ ptcread(dev, uio, flag)
|
|||
return (0); /* EOF */
|
||||
if (flag & IO_NDELAY)
|
||||
return (EWOULDBLOCK);
|
||||
if (error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
|
||||
ttyin, 0))
|
||||
error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
|
||||
ttyin, 0);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
|
||||
|
@ -365,84 +412,8 @@ ptcread(dev, uio, flag)
|
|||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
ptsstop(tp, flush)
|
||||
register struct tty *tp;
|
||||
int flush;
|
||||
{
|
||||
struct pt_softc *pti = &pt_softc[minor(tp->t_dev)];
|
||||
int flag;
|
||||
|
||||
/* note: FLUSHREAD and FLUSHWRITE already ok */
|
||||
if (flush == 0) {
|
||||
flush = TIOCPKT_STOP;
|
||||
pti->pt_flags |= PF_STOPPED;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_STOPPED;
|
||||
pti->pt_send |= flush;
|
||||
/* change of perspective */
|
||||
flag = 0;
|
||||
if (flush & FREAD)
|
||||
flag |= FWRITE;
|
||||
if (flush & FWRITE)
|
||||
flag |= FREAD;
|
||||
ptcwakeup(tp, flag);
|
||||
}
|
||||
|
||||
ptcselect(dev, rw, p)
|
||||
dev_t dev;
|
||||
int rw;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct pt_softc *pti = &pt_softc[minor(dev)];
|
||||
register struct tty *tp = pti->pt_tty;
|
||||
int s;
|
||||
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (1);
|
||||
switch (rw) {
|
||||
|
||||
case FREAD:
|
||||
/*
|
||||
* Need to block timeouts (ttrstart).
|
||||
*/
|
||||
s = spltty();
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
splx(s);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 0: /* exceptional */
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
(pti->pt_flags&PF_PKT && pti->pt_send ||
|
||||
pti->pt_flags&PF_UCNTL && pti->pt_ucntl))
|
||||
return (1);
|
||||
selrecord(p, &pti->pt_selr);
|
||||
break;
|
||||
|
||||
|
||||
case FWRITE:
|
||||
if (tp->t_state&TS_ISOPEN) {
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
if (tp->t_canq.c_cc == 0)
|
||||
return (1);
|
||||
} else {
|
||||
if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
|
||||
return (1);
|
||||
if (tp->t_canq.c_cc == 0 && (tp->t_iflag&ICANON))
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
selrecord(p, &pti->pt_selw);
|
||||
break;
|
||||
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptcwrite(dev, uio, flag)
|
||||
dev_t dev;
|
||||
register struct uio *uio;
|
||||
|
@ -450,7 +421,7 @@ ptcwrite(dev, uio, flag)
|
|||
{
|
||||
register struct pt_softc *pti = &pt_softc[minor(dev)];
|
||||
register struct tty *tp = pti->pt_tty;
|
||||
register u_char *cp;
|
||||
register u_char *cp = NULL;
|
||||
register int cc = 0;
|
||||
u_char locbuf[BUFSIZ];
|
||||
int cnt = 0;
|
||||
|
@ -521,8 +492,9 @@ block:
|
|||
return (EWOULDBLOCK);
|
||||
return (0);
|
||||
}
|
||||
if (error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH,
|
||||
ttyout, 0)) {
|
||||
error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH,
|
||||
ttyout, 0);
|
||||
if (error) {
|
||||
/* adjust for data copied in but not written */
|
||||
uio->uio_resid += cc;
|
||||
return (error);
|
||||
|
@ -530,6 +502,62 @@ block:
|
|||
goto again;
|
||||
}
|
||||
|
||||
int
|
||||
ptcselect(dev, rw, p)
|
||||
dev_t dev;
|
||||
int rw;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct pt_softc *pti = &pt_softc[minor(dev)];
|
||||
register struct tty *tp = pti->pt_tty;
|
||||
int s;
|
||||
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (1);
|
||||
switch (rw) {
|
||||
|
||||
case FREAD:
|
||||
/*
|
||||
* Need to block timeouts (ttrstart).
|
||||
*/
|
||||
s = spltty();
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
splx(s);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 0: /* exceptional */
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
(((pti->pt_flags & PF_PKT) && pti->pt_send) ||
|
||||
((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)))
|
||||
return (1);
|
||||
selrecord(p, &pti->pt_selr);
|
||||
break;
|
||||
|
||||
|
||||
case FWRITE:
|
||||
if (tp->t_state&TS_ISOPEN) {
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
if (tp->t_canq.c_cc == 0)
|
||||
return (1);
|
||||
} else {
|
||||
if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
|
||||
return (1);
|
||||
if (tp->t_canq.c_cc == 0 && (tp->t_iflag&ICANON))
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
selrecord(p, &pti->pt_selw);
|
||||
break;
|
||||
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
struct tty *
|
||||
ptytty(dev)
|
||||
dev_t dev;
|
||||
|
@ -541,6 +569,7 @@ ptytty(dev)
|
|||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
ptyioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty_subr.c,v 1.11 1994/10/30 21:48:03 cgd Exp $ */
|
||||
/* $NetBSD: tty_subr.c,v 1.12 1996/02/04 02:17:32 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Theo de Raadt
|
||||
|
@ -43,6 +43,7 @@
|
|||
#endif
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <kern/kern_extern.h>
|
||||
/*
|
||||
* At compile time, choose:
|
||||
* There are two ways the TTY_QUOTE bit can be stored. If QBITS is
|
||||
|
@ -64,6 +65,14 @@
|
|||
#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.
|
||||
|
@ -191,6 +200,7 @@ q_to_b(clp, cp, count)
|
|||
* Return count of contiguous characters in clist.
|
||||
* Stop counting if flag&character is non-null.
|
||||
*/
|
||||
int
|
||||
ndqb(clp, flag)
|
||||
struct clist *clp;
|
||||
int flag;
|
||||
|
@ -275,9 +285,7 @@ putc(c, clp)
|
|||
int c;
|
||||
struct clist *clp;
|
||||
{
|
||||
register u_char *q;
|
||||
register int i;
|
||||
int r = -1;
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
|
@ -371,9 +379,9 @@ b_to_q(cp, count, clp)
|
|||
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;
|
||||
|
@ -477,9 +485,7 @@ firstc(clp, c)
|
|||
struct clist *clp;
|
||||
int *c;
|
||||
{
|
||||
int empty = 0;
|
||||
register u_char *cp;
|
||||
register int i;
|
||||
|
||||
cc = clp->c_cc;
|
||||
if (cc == 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty_tb.c,v 1.17 1995/05/10 16:53:02 christos Exp $ */
|
||||
/* $NetBSD: tty_tb.c,v 1.18 1996/02/04 02:17:36 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993
|
||||
|
@ -43,11 +43,18 @@
|
|||
*/
|
||||
#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.
|
||||
*/
|
||||
|
@ -55,7 +62,8 @@ struct tbconf {
|
|||
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 */
|
||||
|
@ -65,22 +73,26 @@ struct tbconf {
|
|||
#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},
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -92,17 +104,22 @@ struct tb {
|
|||
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;
|
||||
|
@ -120,7 +137,7 @@ tbopen(dev, 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);
|
||||
|
@ -129,18 +146,20 @@ tbopen(dev, tp)
|
|||
/*
|
||||
* 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;
|
||||
|
@ -151,9 +170,9 @@ tbread(tp, 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);
|
||||
}
|
||||
|
||||
|
@ -165,6 +184,7 @@ tbread(tp, uio)
|
|||
* 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;
|
||||
|
@ -186,124 +206,129 @@ tbinput(c, 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;
|
||||
{
|
||||
struct polpos *pos = &u->polpos;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
@ -368,7 +393,8 @@ tbtioctl(tp, cmd, data, flag, p)
|
|||
return (0);
|
||||
}
|
||||
|
||||
void tbattach(dummy)
|
||||
void
|
||||
tbattach(dummy)
|
||||
int dummy;
|
||||
{
|
||||
/* stub to handle side effect of new config */
|
||||
|
|
Loading…
Reference in New Issue