+ * Update the size of the file. If the file is not being
+ * truncated to a block boundry, the contents of the
+ * partial block following the end of the file must be
+ * zero'ed in case it ever become accessable again because
+ * of subsequent file growth.
+ */
+ osize = oip->i_size;
+ offset = blkoff(fs, length);
+ if (offset == 0) {
+ oip->i_size = length;
+ } else {
+ lbn = lblkno(fs, length);
+ bn = fsbtodb(fs, bmap(oip, lbn, B_WRITE, offset));
+ if (u.u_error || (long)bn < 0)
+ return;
+ oip->i_size = length;
+ size = blksize(fs, oip, lbn);
+ count = howmany(size, DEV_BSIZE);
+ dev = oip->i_dev;
+ s = splimp();
+ for (i = 0; i < count; i += CLSIZE)
+ if (mfind(dev, bn + i))
+ munhash(dev, bn + i);
+ splx(s);
+ bp = bread(dev, bn, size);
+ if (bp->b_flags & B_ERROR) {
+ u.u_error = EIO;
+ oip->i_size = osize;
+ brelse(bp);
+ return;
+ }
+ bzero(bp->b_un.b_addr + offset, size - offset);
+ bdwrite(bp);
+ }
+ /*
+ * Update file and block pointers