Advertisement
Guest User

sys1.c diffing V7/x86 against UNIX V7

a guest
Dec 26th, 2017
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.59 KB | None | 0 0
  1. diff -uNr 7th_ed_unix_tree/usr/sys/sys/sys1.c v7x86/usr/sys/sys/sys1.c
  2. --- 7th_ed_unix_tree/usr/sys/sys/sys1.c 1979-05-07 07:26:47.000000000 +0100
  3. +++ v7x86/usr/sys/sys/sys1.c    2007-10-03 20:51:23.000000000 +0200
  4. @@ -1,3 +1,6 @@
  5. +/* UNIX V7 source code: see /COPYRIGHT or www.tuhs.org for details. */
  6. +/* Changes: Copyright (c) 1999 Robert Nordier. All rights reserved. */
  7. +
  8.  #include "../h/param.h"
  9.  #include "../h/systm.h"
  10.  #include "../h/map.h"
  11. @@ -100,9 +103,9 @@
  12.      * copy back arglist
  13.      */
  14.  
  15. -   ucp = -nc - NBPW;
  16. +   ucp = USTK - nc - NBPW;
  17.     ap = ucp - na*NBPW - 3*NBPW;
  18. -   u.u_ar0[R6] = ap;
  19. +   u.u_ar0[ESP] = ap;
  20.     suword((caddr_t)ap, na-ne);
  21.     nc = 0;
  22.     for (;;) {
  23. @@ -145,20 +148,17 @@
  24.  register struct inode *ip;
  25.  {
  26.     register unsigned ds;
  27. -   register sep;
  28.     register unsigned ts, ss;
  29. -   register i, overlay;
  30. +   register i;
  31.     long lsize;
  32.  
  33.     /*
  34.      * read in first few bytes
  35.      * of file for segment
  36.      * sizes:
  37. -    * ux_mag = 407/410/411/405
  38. +    * ux_mag = 407/410/...
  39.      *  407 is plain executable
  40.      *  410 is RO text
  41. -    *  411 is separated ID
  42. -    *  405 is overlaid text
  43.      */
  44.  
  45.     u.u_base = (caddr_t)&u.u_exdata;
  46. @@ -173,8 +173,6 @@
  47.         u.u_error = ENOEXEC;
  48.         goto bad;
  49.     }
  50. -   sep = 0;
  51. -   overlay = 0;
  52.     if(u.u_exdata.ux_mag == 0407) {
  53.         lsize = (long)u.u_exdata.ux_dsize + u.u_exdata.ux_tsize;
  54.         u.u_exdata.ux_dsize = lsize;
  55. @@ -183,11 +181,7 @@
  56.             goto bad;
  57.         }
  58.         u.u_exdata.ux_tsize = 0;
  59. -   } else if (u.u_exdata.ux_mag == 0411)
  60. -       sep++;
  61. -   else if (u.u_exdata.ux_mag == 0405)
  62. -       overlay++;
  63. -   else if (u.u_exdata.ux_mag != 0410) {
  64. +   } else if (u.u_exdata.ux_mag != 0410) {
  65.         u.u_error = ENOEXEC;
  66.         goto bad;
  67.     }
  68. @@ -209,65 +203,51 @@
  69.     }
  70.     ds = btoc(lsize);
  71.     ss = SSIZE + btoc(nargc);
  72. -   if (overlay) {
  73. -       if (u.u_sep==0 && ctos(ts) != ctos(u.u_tsize) || nargc) {
  74. -           u.u_error = ENOMEM;
  75. -           goto bad;
  76. -       }
  77. -       ds = u.u_dsize;
  78. -       ss = u.u_ssize;
  79. -       sep = u.u_sep;
  80. -       xfree();
  81. -       xalloc(ip);
  82. -       u.u_ar0[PC] = u.u_exdata.ux_entloc & ~01;
  83. -   } else {
  84. -       if(estabur(ts, ds, ss, sep, RO))
  85. -           goto bad;
  86. +   if(estabur(ts, ds, ss, 0, RO))
  87. +       goto bad;
  88.    
  89. -       /*
  90. -        * allocate and clear core
  91. -        * at this point, committed
  92. -        * to the new image
  93. -        */
  94. +   /*
  95. +    * allocate and clear core
  96. +    * at this point, committed
  97. +    * to the new image
  98. +    */
  99.    
  100. -       u.u_prof.pr_scale = 0;
  101. -       xfree();
  102. -       i = USIZE+ds+ss;
  103. -       expand(i);
  104. -       while(--i >= USIZE)
  105. -           clearseg(u.u_procp->p_addr+i);
  106. -       xalloc(ip);
  107. +   u.u_prof.pr_scale = 0;
  108. +   xfree();
  109. +   i = USIZE+ds+ss;
  110. +   expand(i);
  111. +   while(--i >= USIZE)
  112. +       clearseg(u.u_procp->p_addr+i);
  113. +   xalloc(ip);
  114.    
  115. -       /*
  116. -        * read in data segment
  117. -        */
  118. +   /*
  119. +    * read in data segment
  120. +    */
  121.    
  122. -       estabur((unsigned)0, ds, (unsigned)0, 0, RO);
  123. -       u.u_base = 0;
  124. -       u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
  125. -       u.u_count = u.u_exdata.ux_dsize;
  126. -       readi(ip);
  127. -       /*
  128. -        * set SUID/SGID protections, if no tracing
  129. -        */
  130. -       if ((u.u_procp->p_flag&STRC)==0) {
  131. -           if(ip->i_mode&ISUID)
  132. -               if(u.u_uid != 0) {
  133. -                   u.u_uid = ip->i_uid;
  134. -                   u.u_procp->p_uid = ip->i_uid;
  135. -               }
  136. -           if(ip->i_mode&ISGID)
  137. -               u.u_gid = ip->i_gid;
  138. -       } else
  139. -           psignal(u.u_procp, SIGTRC);
  140. -   }
  141. +   estabur((unsigned)0, ds, (unsigned)0, 0, RO);
  142. +   u.u_base = 0;
  143. +   u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
  144. +   u.u_count = u.u_exdata.ux_dsize;
  145. +   readi(ip);
  146. +   /*
  147. +    * set SUID/SGID protections, if no tracing
  148. +    */
  149. +   if ((u.u_procp->p_flag&STRC)==0) {
  150. +       if(ip->i_mode&ISUID)
  151. +           if(u.u_uid != 0) {
  152. +               u.u_uid = ip->i_uid;
  153. +               u.u_procp->p_uid = ip->i_uid;
  154. +           }
  155. +       if(ip->i_mode&ISGID)
  156. +           u.u_gid = ip->i_gid;
  157. +   } else
  158. +       psignal(u.u_procp, SIGTRC);
  159.     u.u_tsize = ts;
  160.     u.u_dsize = ds;
  161.     u.u_ssize = ss;
  162. -   u.u_sep = sep;
  163. -   estabur(ts, ds, ss, sep, RO);
  164. +   estabur(ts, ds, ss, 0, RO);
  165.  bad:
  166. -   return(overlay);
  167. +   return(0);
  168.  }
  169.  
  170.  /*
  171. @@ -282,11 +262,9 @@
  172.     for(rp = &u.u_signal[0]; rp < &u.u_signal[NSIG]; rp++)
  173.         if((*rp & 1) == 0)
  174.             *rp = 0;
  175. -   for(cp = &regloc[0]; cp < &regloc[6];)
  176. +   for(cp = &regloc[0]; cp < &regloc[7];)
  177.         u.u_ar0[*cp++] = 0;
  178. -   u.u_ar0[PC] = u.u_exdata.ux_entloc & ~01;
  179. -   for(rp = (int *)&u.u_fps; rp < (int *)&u.u_fps.u_fpregs[6];)
  180. -       *rp++ = 0;
  181. +   u.u_ar0[EIP] = u.u_exdata.ux_entloc;
  182.     for(i=0; i<NOFILE; i++) {
  183.         if (u.u_pofile[i]&EXCLOSE) {
  184.             closef(u.u_ofile[i]);
  185. @@ -467,7 +445,7 @@
  186.     u.u_r.r_val1 = p2->p_pid;
  187.  
  188.  out:
  189. -   u.u_ar0[R7] += NBPW;
  190. +   u.u_ar0[EIP] += 2;
  191.  }
  192.  
  193.  /*
  194. @@ -490,7 +468,7 @@
  195.  
  196.     n = btoc((int)((struct a *)u.u_ap)->nsiz);
  197.     if(!u.u_sep)
  198. -       n -= ctos(u.u_tsize) * stoc(1);
  199. +       n -= u.u_tsize;
  200.     if(n < 0)
  201.         n = 0;
  202.     d = n - u.u_dsize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement