Change to includes. no more ../h
[unix-history] / usr / src / sys / kern / sys_process.c
index a1073d5..45fe2b3 100644 (file)
@@ -1,20 +1,20 @@
-/*     sys_process.c   5.3     82/09/04        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/inode.h"
-#include "../h/reg.h"
-#include "../h/text.h"
-#include "../h/seg.h"
-#include "../h/mtpr.h"
-#include "../h/pte.h"
-#include "../h/psl.h"
-#include "../h/vm.h"
-#include "../h/buf.h"
-#include "../h/acct.h"
+/*     sys_process.c   6.2     84/08/29        */
+
+#include "../machine/reg.h"
+#include "../machine/psl.h"
+#include "../machine/pte.h"
+
+#include "param.h"
+#include "systm.h"
+#include "dir.h"
+#include "user.h"
+#include "proc.h"
+#include "inode.h"
+#include "text.h"
+#include "seg.h"
+#include "vm.h"
+#include "buf.h"
+#include "acct.h"
 
 /*
  * Priority for tracing
 
 /*
  * Priority for tracing
@@ -55,7 +55,8 @@ ptrace()
                return;
        }
        p = pfind(uap->pid);
                return;
        }
        p = pfind(uap->pid);
-       if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid) {
+       if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid ||
+           !(p->p_flag & STRC)) {
                u.u_error = ESRCH;
                return;
        }
                u.u_error = ESRCH;
                return;
        }
@@ -78,7 +79,15 @@ ptrace()
        wakeup((caddr_t)&ipc);
 }
 
        wakeup((caddr_t)&ipc);
 }
 
-int ipcreg[] = {R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,AP,FP,SP,PC};
+#ifdef vax
+#define        NIPCREG 16
+int ipcreg[NIPCREG] =
+       {R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,AP,FP,SP,PC};
+#endif
+
+#define        PHYSOFF(p, o) \
+       ((physadr)(p)+((o)/sizeof(((physadr)0)->r[0])))
+
 /*
  * Code that the child process
  * executes to implement the command
 /*
  * Code that the child process
  * executes to implement the command
@@ -116,7 +125,7 @@ procxmt()
                i = (int)ipc.ip_addr;
                if (i<0 || i >= ctob(UPAGES))
                        goto error;
                i = (int)ipc.ip_addr;
                if (i<0 || i >= ctob(UPAGES))
                        goto error;
-               ipc.ip_data = ((physadr)&u)->r[i>>2];
+               ipc.ip_data = *(int *)PHYSOFF(&u, i);
                break;
 
        /* write user I */
                break;
 
        /* write user I */
@@ -131,11 +140,13 @@ procxmt()
                        xp->x_iptr->i_flag &= ~ITEXT;
                }
                i = -1;
                        xp->x_iptr->i_flag &= ~ITEXT;
                }
                i = -1;
-               if (chgprot((caddr_t)ipc.ip_addr, RW) &&
-                   chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RW))
-                       i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
-               (void) chgprot((caddr_t)ipc.ip_addr, RO);
-               (void) chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RO);
+               if ((i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data)) < 0) {
+                       if (chgprot((caddr_t)ipc.ip_addr, RW) &&
+                           chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RW))
+                               i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
+                       (void) chgprot((caddr_t)ipc.ip_addr, RO);
+                       (void) chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RO);
+               }
                if (i < 0)
                        goto error;
                if (xp)
                if (i < 0)
                        goto error;
                if (xp)
@@ -152,12 +163,12 @@ procxmt()
        /* write u */
        case 6:
                i = (int)ipc.ip_addr;
        /* write u */
        case 6:
                i = (int)ipc.ip_addr;
-               p = (int *)&((physadr)&u)->r[i>>2];
-               for (i=0; i<16; i++)
+               p = (int *)PHYSOFF(&u, i);
+               for (i=0; i<NIPCREG; i++)
                        if (p == &u.u_ar0[ipcreg[i]])
                                goto ok;
                if (p == &u.u_ar0[PS]) {
                        if (p == &u.u_ar0[ipcreg[i]])
                                goto ok;
                if (p == &u.u_ar0[PS]) {
-                       ipc.ip_data |= PSL_CURMOD|PSL_PRVMOD;
+                       ipc.ip_data |= PSL_USERSET;
                        ipc.ip_data &=  ~PSL_USERCLR;
                        goto ok;
                }
                        ipc.ip_data &=  ~PSL_USERCLR;
                        goto ok;
                }
@@ -176,7 +187,7 @@ procxmt()
                if ((unsigned)ipc.ip_data > NSIG)
                        goto error;
                u.u_procp->p_cursig = ipc.ip_data;      /* see issig */
                if ((unsigned)ipc.ip_data > NSIG)
                        goto error;
                u.u_procp->p_cursig = ipc.ip_data;      /* see issig */
-               if (i == 9)
+               if (i == 9) 
                        u.u_ar0[PS] |= PSL_T;
                wakeup((caddr_t)&ipc);
                return (1);
                        u.u_ar0[PS] |= PSL_T;
                wakeup((caddr_t)&ipc);
                return (1);