convert VOP_UNLOCK and vrele into vput's; add proc parameter to union_dircache
[unix-history] / usr / src / sys / kern / sys_process.c
index 5c09d76..041a40b 100644 (file)
@@ -1,19 +1,28 @@
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
  *
  * %sccs.include.proprietary.c%
  *
  *
  * %sccs.include.proprietary.c%
  *
- *     @(#)sys_process.c       8.2 (Berkeley) %G%
+ *     @(#)sys_process.c       8.6 (Berkeley) %G%
  */
 
 #define IPCREG
 #include <sys/param.h>
  */
 
 #define IPCREG
 #include <sys/param.h>
+#include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/vnode.h>
 #include <sys/buf.h>
 #include <sys/ptrace.h>
 
 #include <sys/proc.h>
 #include <sys/vnode.h>
 #include <sys/buf.h>
 #include <sys/ptrace.h>
 
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
 #include <machine/reg.h>
 #include <machine/psl.h>
 #include <vm/vm.h>
 #include <machine/reg.h>
 #include <machine/psl.h>
 #include <vm/vm.h>
@@ -44,38 +53,37 @@ struct {
 /*
  * Process debugging system call.
  */
 /*
  * Process debugging system call.
  */
-struct ptrace_args {
-       int     req;
-       pid_t   pid;
-       caddr_t addr;
-       int     data;
-};
 ptrace(curp, uap, retval)
        struct proc *curp;
 ptrace(curp, uap, retval)
        struct proc *curp;
-       register struct ptrace_args *uap;
-       int *retval;
+       struct ptrace_args /* {
+               syscallarg(int) req;
+               syscallarg(pid_t) pid;
+               syscallarg(caddr_t) addr;
+               syscallarg(int) data;
+       } */ *uap;
+       register_t *retval;
 {
        register struct proc *p;
        int error;
 
 {
        register struct proc *p;
        int error;
 
-       if (uap->req <= 0) {
-               curp->p_flag |= STRC;
+       if (SCARG(uap, req) <= 0) {
+               curp->p_flag |= P_TRACED;
                return (0);
        }
                return (0);
        }
-       p = pfind(uap->pid);
+       p = pfind(SCARG(uap, pid));
        if (p == 0)
                return (ESRCH);
        if (p == 0)
                return (ESRCH);
-       if (uap->req == PT_ATTACH) {
+       if (SCARG(uap, req) == PT_ATTACH) {
                /*
                 * Must be root if the process has used set user or group
                 * privileges or does not belong to the real user.  Must
                 * not be already traced.  Can't attach to ourselves.
                 */
                /*
                 * Must be root if the process has used set user or group
                 * privileges or does not belong to the real user.  Must
                 * not be already traced.  Can't attach to ourselves.
                 */
-               if ((p->p_flag & SUGID ||
+               if ((p->p_flag & P_SUGID ||
                    p->p_cred->p_ruid != curp->p_cred->p_ruid) &&
                    (error = suser(p->p_ucred, &p->p_acflag)) != 0)
                        return (error);
                    p->p_cred->p_ruid != curp->p_cred->p_ruid) &&
                    (error = suser(p->p_ucred, &p->p_acflag)) != 0)
                        return (error);
-               if (p->p_flag & STRC)
+               if (p->p_flag & P_TRACED)
                        return (EALREADY);      /* ??? */
                if (p->p_pid == curp->p_pid)
                        return (EINVAL);
                        return (EALREADY);      /* ??? */
                if (p->p_pid == curp->p_pid)
                        return (EINVAL);
@@ -88,21 +96,21 @@ ptrace(curp, uap, retval)
                 * The old parent is remembered so we can put things back
                 * on a "detach".
                 */
                 * The old parent is remembered so we can put things back
                 * on a "detach".
                 */
-               p->p_flag |= STRC;
+               p->p_flag |= P_TRACED;
                p->p_oppid = p->p_pptr->p_pid;
                proc_reparent(p, curp);
                psignal(p, SIGSTOP);
                return (0);
        }
                p->p_oppid = p->p_pptr->p_pid;
                proc_reparent(p, curp);
                psignal(p, SIGSTOP);
                return (0);
        }
-       if (p->p_stat != SSTOP || p->p_pptr != curp || !(p->p_flag & STRC))
+       if (p->p_stat != SSTOP || p->p_pptr != curp || !(p->p_flag & P_TRACED))
                return (ESRCH);
        while (ipc.ip_lock)
                sleep((caddr_t)&ipc, IPCPRI);
        ipc.ip_lock = p->p_pid;
                return (ESRCH);
        while (ipc.ip_lock)
                sleep((caddr_t)&ipc, IPCPRI);
        ipc.ip_lock = p->p_pid;
-       ipc.ip_data = uap->data;
-       ipc.ip_addr = uap->addr;
-       ipc.ip_req = uap->req;
-       p->p_flag &= ~SWTED;
+       ipc.ip_data = SCARG(uap, data);
+       ipc.ip_addr = SCARG(uap, addr);
+       ipc.ip_req = SCARG(uap, req);
+       p->p_flag &= ~P_WAITED;
        while (ipc.ip_req > 0) {
                if (p->p_stat==SSTOP)
                        setrunnable(p);
        while (ipc.ip_req > 0) {
                if (p->p_stat==SSTOP)
                        setrunnable(p);
@@ -142,7 +150,7 @@ ptrace(curp, uap, retval)
  * being debugged. This code runs in the context of the child process
  * to fulfill the command requested by the parent.
  */
  * being debugged. This code runs in the context of the child process
  * to fulfill the command requested by the parent.
  */
-procxmt(p)
+trace_req(p)
        register struct proc *p;
 {
        register int i, *poff, *regs;
        register struct proc *p;
 {
        register int i, *poff, *regs;
@@ -244,16 +252,23 @@ procxmt(p)
 
        case PT_STEP:                   /* single step the child */
        case PT_CONTINUE:               /* continue the child */
 
        case PT_STEP:                   /* single step the child */
        case PT_CONTINUE:               /* continue the child */
+#ifndef mips
                regs = (int *)((short *)regs + 1);
                regs = (int *)((short *)regs + 1);
+#endif
                if ((unsigned)ipc.ip_data >= NSIG)
                        goto error;
                if ((int)ipc.ip_addr != 1)
                        regs[PC] = (int)ipc.ip_addr;
                if ((unsigned)ipc.ip_data >= NSIG)
                        goto error;
                if ((int)ipc.ip_addr != 1)
                        regs[PC] = (int)ipc.ip_addr;
-               p->p_xstat = ipc.ip_data;       /* see issig */
+               p->p_xstat = ipc.ip_data;       /* see issignal */
+#ifdef mips
+               if (i == PT_STEP && cpu_singlestep(p))
+                       goto error;
+#else
 #ifdef PSL_T
                /* need something more machine independent here... */
                if (i == PT_STEP) 
                        regs[PS] |= PSL_T;
 #ifdef PSL_T
                /* need something more machine independent here... */
                if (i == PT_STEP) 
                        regs[PS] |= PSL_T;
+#endif
 #endif
                wakeup((caddr_t)&ipc);
                return (1);
 #endif
                wakeup((caddr_t)&ipc);
                return (1);
@@ -268,8 +283,8 @@ procxmt(p)
                        goto error;
                if ((int)ipc.ip_addr != 1)
                        regs[PC] = (int)ipc.ip_addr;
                        goto error;
                if ((int)ipc.ip_addr != 1)
                        regs[PC] = (int)ipc.ip_addr;
-               p->p_xstat = ipc.ip_data;       /* see issig */
-               p->p_flag &= ~STRC;
+               p->p_xstat = ipc.ip_data;       /* see issignal */
+               p->p_flag &= ~P_TRACED;
                if (p->p_oppid != p->p_pptr->p_pid) {
                         register struct proc *pp = pfind(p->p_oppid);
 
                if (p->p_oppid != p->p_pptr->p_pid) {
                         register struct proc *pp = pfind(p->p_oppid);