- if (!access(ip, IWRITE) &&
- (ip->i_mode&IFMT) == IFREG &&
- ip->i_nlink == 1) {
- itrunc(ip);
- u.u_acflag |= ACORE;
- u.u_offset = 0;
- u.u_base = (caddr_t)&u;
- u.u_count = ctob(UPAGES);
- u.u_segflg = 1;
- writei(ip);
- u.u_base = (char *)ctob(u.u_tsize);
- u.u_count = ctob(u.u_dsize);
- u.u_segflg = 0;
- writei(ip);
- u.u_base = (char *)(USRSTACK - ctob(u.u_ssize));
- u.u_count = ctob(u.u_ssize);
- writei(ip);
- } else
- u.u_error = EFAULT;
- iput(ip);
- return (u.u_error==0);
-}
-/*
- * alarm clock signal
- */
-oalarm()
-{
- register struct proc *p;
- register c;
- register struct a {
- int deltat;
- } *uap;
-
- uap = (struct a *)u.u_ap;
- p = u.u_procp;
- c = p->p_clktim;
- p->p_clktim = uap->deltat;
- u.u_r.r_val1 = c;
-}
-
-/*
- * indefinite wait.
- * no one should wakeup(&u)
- */
-opause()
-{
-
- for (;;)
- sleep((caddr_t)&u, PSLEP);
+#ifdef MMAP
+ { register int fd;
+ /* unmasp funky devices in the user's address space */
+ for (fd = 0; fd < u.u_lastfile; fd++)
+ if (u.u_ofile[fd] && (u.u_pofile[fd] & UF_MAPPED))
+ munmapfd(fd);
+ }
+#endif
+ vattr_null(&vattr);
+ vattr.va_size = 0;
+ vop_setattr(vp, &vattr, u.u_cred);
+ u.u_acflag |= ACORE;
+ error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&u, ctob(UPAGES), (off_t)0,
+ UIO_SYSSPACE, IO_UNIT, (int *)0);
+ if (error == 0)
+ error = vn_rdwr(UIO_WRITE, vp,
+ (caddr_t)ctob(dptov(u.u_procp, 0)),
+ (int)ctob(u.u_dsize), (off_t)ctob(UPAGES),
+ UIO_USERSPACE, IO_UNIT, (int *)0);
+ if (error == 0)
+ error = vn_rdwr(UIO_WRITE, vp,
+ (caddr_t)ctob(sptov(u.u_procp, u.u_ssize - 1)),
+ (int)ctob(u.u_ssize),
+ (off_t)ctob(UPAGES) + ctob(u.u_dsize),
+ UIO_USERSPACE, IO_UNIT, (int *)0);
+out:
+ if (vp)
+ vrele(vp);
+ return (error);