- count = howmany(size, DEV_BSIZE);
- for (i = 0; i < count; i += CLSIZE)
- if (mfind(dev, bn + i))
- munhash(dev, bn + i);
- if (n == bsize)
- bp = getblk(dev, bn, size);
- else
- bp = bread(dev, bn, size);
- if (u.u_segflg != 1) {
- if (copyin(u.u_base, bp->b_un.b_addr + on, n)) {
- u.u_error = EFAULT;
- goto bad;
- }
- } else
- bcopy(u.u_base, bp->b_un.b_addr + on, n);
- u.u_base += n;
- u.u_offset += n;
- u.u_count -= n;
-bad:
- ;
- if (u.u_error != 0)
- brelse(bp);
- else {
- if ((ip->i_mode&IFMT) == IFDIR)
- /*
- * Writing to clear a directory entry.
- * Must insure the write occurs before
- * the inode is freed, or may end up
- * pointing at a new (different) file
- * if inode is quickly allocated again
- * and system crashes.
- */
- bwrite(bp);
- else if (n + on == bsize) {
- bp->b_flags |= B_AGE;
- bawrite(bp);
- } else
- bdwrite(bp);
- }
- ip->i_flag |= IUPD|ICHG;
- if (u.u_ruid != 0)
- ip->i_mode &= ~(ISUID|ISGID);
- } while (u.u_error == 0 && u.u_count != 0);
+ timeout(unselect, (caddr_t)u.u_procp, hzto(&atv));
+ }
+ sleep((caddr_t)&selwait, PZERO+1);
+ if (uap->tv) {
+ u.u_qsave = lqsave;
+ untimeout(unselect, (caddr_t)u.u_procp);
+ }
+ splx(s);
+ goto retry;
+done:
+#define putbits(name, x) \
+ if (uap->name) { \
+ int error = copyout((caddr_t)&obits[x], (caddr_t)uap->name, \
+ sizeof (obits[x])); \
+ if (error) \
+ u.u_error = error; \
+ }
+ putbits(in, 0);
+ putbits(ou, 1);
+ putbits(ex, 2);
+#undef putbits