+ iput(dp);
+ brelse(nbp);
+ return (NULL);
+ }
+ loc = 0;
+ } else {
+ loc += ep->d_reclen;
+ }
+ /*
+ * calculate the next directory entry and run
+ * some rudimentary bounds checks to make sure
+ * that it is reasonable. If the check fails
+ * resync at the beginning of the next directory
+ * block.
+ */
+ ep = (struct direct *)(bp->b_un.b_addr + loc);
+ i = DIRBLKSIZ - (loc & (DIRBLKSIZ - 1));
+ if (ep->d_reclen <= 0 || ep->d_reclen > i) {
+ loc += i;
+ u.u_offset += i;
+ continue;
+ }
+ /*
+ * If an appropriate sized hole has not yet been found,
+ * check to see if one is available. Also accumulate space
+ * in the current block so that we can determine if
+ * compaction is viable.
+ */
+ if (slot != FOUND) {
+ size = ep->d_reclen;
+ if (ep->d_ino != 0)
+ size -= DIRSIZ(ep);
+ if (size > 0) {
+ if (size >= newsize) {
+ slot = FOUND;
+ entryfree = u.u_offset;
+ entrysize = DIRSIZ(ep) + newsize;
+ }
+ if (entryfree == NULL)
+ entryfree = u.u_offset;
+ spccnt += size;