- register size_t ts, ds, ss;
- int pagi = 0;
-
- /*
- * read in first few bytes
- * of file for segment
- * sizes:
- * ux_mag = 407/410/413
- * 407 is plain executable
- * 410 is RO text
- * 413 is demand paged RO text
- */
-
- u.u_base = (caddr_t)&u.u_exdata;
- u.u_count = sizeof(u.u_exdata);
- u.u_offset = 0;
- u.u_segflg = 1;
- readi(ip);
- u.u_segflg = 0;
- if(u.u_error)
- goto bad;
- if (u.u_count!=0) {
- u.u_error = ENOEXEC;
- goto bad;
- }
- switch (u.u_exdata.ux_mag) {
-
- case 0407:
- u.u_exdata.ux_dsize += u.u_exdata.ux_tsize;
- u.u_exdata.ux_tsize = 0;
- break;
-
- case 0413:
- pagi = SPAGI;
- /* fall into ... */
-
- case 0410:
- if (u.u_exdata.ux_tsize == 0) {
- u.u_error = ENOEXEC;
- goto bad;
- }
- break;
-
- default:
- u.u_error = ENOEXEC;
- goto bad;
- }
- if(u.u_exdata.ux_tsize!=0 && (ip->i_flag&ITEXT)==0 && ip->i_count!=1) {
- register struct file *fp;
-
- for (fp = file; fp < &file[NFILE]; fp++)
- if (fp->f_inode == ip && (fp->f_flag&FWRITE)) {
- u.u_error = ETXTBSY;
- goto bad;
- }
- }
-
- /*
- * find text and data sizes
- * try them out for possible
- * exceed of max sizes
- */
-
- ts = clrnd(btoc(u.u_exdata.ux_tsize));
- ds = clrnd(btoc((u.u_exdata.ux_dsize+u.u_exdata.ux_bsize)));
- ss = clrnd(SSIZE + btoc(nargc));
- if (chksize(ts, ds, ss))
- goto bad;
- u.u_cdmap = zdmap;
- u.u_csmap = zdmap;
- if (swpexpand(ds, ss, &u.u_cdmap, &u.u_csmap) == NULL)
- goto bad;
-
- /*
- * At this point, committed to the new image!
- * Release virtual memory resources of old process, and
- * initialize the virtual memory of the new process.
- * If we resulted from vfork(), instead wakeup our
- * parent who will set SVFDONE when he has taken back
- * our resources.
- */
- u.u_prof.pr_scale = 0;
- if ((u.u_procp->p_flag & SVFORK) == 0)
- vrelvm();
- else {
- u.u_procp->p_flag &= ~SVFORK;
- u.u_procp->p_flag |= SKEEP;
- wakeup((caddr_t)u.u_procp);
- while ((u.u_procp->p_flag & SVFDONE) == 0)
- sleep((caddr_t)u.u_procp, PZERO - 1);
- u.u_procp->p_flag &= ~(SVFDONE|SKEEP);
- }
- u.u_procp->p_flag &= ~(SPAGI|SANOM|SUANOM|SNUSIG);
- u.u_procp->p_flag |= pagi;
- u.u_dmap = u.u_cdmap;
- u.u_smap = u.u_csmap;
- vgetvm(ts, ds, ss);