+ * 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);
+ error = balloc(oip, lbn, offset, &bn, B_CLRBUF);
+ if (error)
+ return (error);
+ if ((long)bn < 0)
+ panic("itrunc: hole");
+ oip->i_size = length;
+ size = blksize(fs, oip, lbn);
+ count = howmany(size, CLBYTES);
+ munhash(oip->i_devvp, bn + i * CLBYTES / DEV_BSIZE);
+ error = bread(oip->i_devvp, bn, size, NOCRED, &bp);
+ if (error) {
+ oip->i_size = osize;
+ brelse(bp);
+ return (error);
+ }
+ bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset));
+ bdwrite(bp);
+ }
+ /*
+ * Update file and block pointers