Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -uNr 7th_ed_unix_tree/usr/sys/sys/sys1.c v7x86/usr/sys/sys/sys1.c
- --- 7th_ed_unix_tree/usr/sys/sys/sys1.c 1979-05-07 07:26:47.000000000 +0100
- +++ v7x86/usr/sys/sys/sys1.c 2007-10-03 20:51:23.000000000 +0200
- @@ -1,3 +1,6 @@
- +/* UNIX V7 source code: see /COPYRIGHT or www.tuhs.org for details. */
- +/* Changes: Copyright (c) 1999 Robert Nordier. All rights reserved. */
- +
- #include "../h/param.h"
- #include "../h/systm.h"
- #include "../h/map.h"
- @@ -100,9 +103,9 @@
- * copy back arglist
- */
- - ucp = -nc - NBPW;
- + ucp = USTK - nc - NBPW;
- ap = ucp - na*NBPW - 3*NBPW;
- - u.u_ar0[R6] = ap;
- + u.u_ar0[ESP] = ap;
- suword((caddr_t)ap, na-ne);
- nc = 0;
- for (;;) {
- @@ -145,20 +148,17 @@
- register struct inode *ip;
- {
- register unsigned ds;
- - register sep;
- register unsigned ts, ss;
- - register i, overlay;
- + register i;
- long lsize;
- /*
- * read in first few bytes
- * of file for segment
- * sizes:
- - * ux_mag = 407/410/411/405
- + * ux_mag = 407/410/...
- * 407 is plain executable
- * 410 is RO text
- - * 411 is separated ID
- - * 405 is overlaid text
- */
- u.u_base = (caddr_t)&u.u_exdata;
- @@ -173,8 +173,6 @@
- u.u_error = ENOEXEC;
- goto bad;
- }
- - sep = 0;
- - overlay = 0;
- if(u.u_exdata.ux_mag == 0407) {
- lsize = (long)u.u_exdata.ux_dsize + u.u_exdata.ux_tsize;
- u.u_exdata.ux_dsize = lsize;
- @@ -183,11 +181,7 @@
- goto bad;
- }
- u.u_exdata.ux_tsize = 0;
- - } else if (u.u_exdata.ux_mag == 0411)
- - sep++;
- - else if (u.u_exdata.ux_mag == 0405)
- - overlay++;
- - else if (u.u_exdata.ux_mag != 0410) {
- + } else if (u.u_exdata.ux_mag != 0410) {
- u.u_error = ENOEXEC;
- goto bad;
- }
- @@ -209,65 +203,51 @@
- }
- ds = btoc(lsize);
- ss = SSIZE + btoc(nargc);
- - if (overlay) {
- - if (u.u_sep==0 && ctos(ts) != ctos(u.u_tsize) || nargc) {
- - u.u_error = ENOMEM;
- - goto bad;
- - }
- - ds = u.u_dsize;
- - ss = u.u_ssize;
- - sep = u.u_sep;
- - xfree();
- - xalloc(ip);
- - u.u_ar0[PC] = u.u_exdata.ux_entloc & ~01;
- - } else {
- - if(estabur(ts, ds, ss, sep, RO))
- - goto bad;
- + if(estabur(ts, ds, ss, 0, RO))
- + goto bad;
- - /*
- - * allocate and clear core
- - * at this point, committed
- - * to the new image
- - */
- + /*
- + * allocate and clear core
- + * at this point, committed
- + * to the new image
- + */
- - u.u_prof.pr_scale = 0;
- - xfree();
- - i = USIZE+ds+ss;
- - expand(i);
- - while(--i >= USIZE)
- - clearseg(u.u_procp->p_addr+i);
- - xalloc(ip);
- + u.u_prof.pr_scale = 0;
- + xfree();
- + i = USIZE+ds+ss;
- + expand(i);
- + while(--i >= USIZE)
- + clearseg(u.u_procp->p_addr+i);
- + xalloc(ip);
- - /*
- - * read in data segment
- - */
- + /*
- + * read in data segment
- + */
- - estabur((unsigned)0, ds, (unsigned)0, 0, RO);
- - u.u_base = 0;
- - u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
- - u.u_count = u.u_exdata.ux_dsize;
- - readi(ip);
- - /*
- - * set SUID/SGID protections, if no tracing
- - */
- - if ((u.u_procp->p_flag&STRC)==0) {
- - if(ip->i_mode&ISUID)
- - if(u.u_uid != 0) {
- - u.u_uid = ip->i_uid;
- - u.u_procp->p_uid = ip->i_uid;
- - }
- - if(ip->i_mode&ISGID)
- - u.u_gid = ip->i_gid;
- - } else
- - psignal(u.u_procp, SIGTRC);
- - }
- + estabur((unsigned)0, ds, (unsigned)0, 0, RO);
- + u.u_base = 0;
- + u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
- + u.u_count = u.u_exdata.ux_dsize;
- + readi(ip);
- + /*
- + * set SUID/SGID protections, if no tracing
- + */
- + if ((u.u_procp->p_flag&STRC)==0) {
- + if(ip->i_mode&ISUID)
- + if(u.u_uid != 0) {
- + u.u_uid = ip->i_uid;
- + u.u_procp->p_uid = ip->i_uid;
- + }
- + if(ip->i_mode&ISGID)
- + u.u_gid = ip->i_gid;
- + } else
- + psignal(u.u_procp, SIGTRC);
- u.u_tsize = ts;
- u.u_dsize = ds;
- u.u_ssize = ss;
- - u.u_sep = sep;
- - estabur(ts, ds, ss, sep, RO);
- + estabur(ts, ds, ss, 0, RO);
- bad:
- - return(overlay);
- + return(0);
- }
- /*
- @@ -282,11 +262,9 @@
- for(rp = &u.u_signal[0]; rp < &u.u_signal[NSIG]; rp++)
- if((*rp & 1) == 0)
- *rp = 0;
- - for(cp = ®loc[0]; cp < ®loc[6];)
- + for(cp = ®loc[0]; cp < ®loc[7];)
- u.u_ar0[*cp++] = 0;
- - u.u_ar0[PC] = u.u_exdata.ux_entloc & ~01;
- - for(rp = (int *)&u.u_fps; rp < (int *)&u.u_fps.u_fpregs[6];)
- - *rp++ = 0;
- + u.u_ar0[EIP] = u.u_exdata.ux_entloc;
- for(i=0; i<NOFILE; i++) {
- if (u.u_pofile[i]&EXCLOSE) {
- closef(u.u_ofile[i]);
- @@ -467,7 +445,7 @@
- u.u_r.r_val1 = p2->p_pid;
- out:
- - u.u_ar0[R7] += NBPW;
- + u.u_ar0[EIP] += 2;
- }
- /*
- @@ -490,7 +468,7 @@
- n = btoc((int)((struct a *)u.u_ap)->nsiz);
- if(!u.u_sep)
- - n -= ctos(u.u_tsize) * stoc(1);
- + n -= u.u_tsize;
- if(n < 0)
- n = 0;
- d = n - u.u_dsize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement