- * 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) {
-printf("bad reclen: dir#=<%d,%d>, e#=%d, reclen=%d, i=%d, loc=%d\n",
- dp->i_dev, dp->i_number, ep->d_ino, ep->d_reclen, i, loc);
- 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;
- }
- }
- /*
- * String compare the directory entry
- * and the current component.
- * If they do not match, continue to the next entry.
- */
- prevoff = curoff;
- curoff = u.u_offset;
- u.u_offset += ep->d_reclen;
- if (ep->d_ino == 0)
- continue;
- if (ep->d_namlen != u.u_dent.d_namlen)
- continue;
- if (bcmp(u.u_dent.d_name, ep->d_name, ep->d_namlen))
- continue;
- /*
- * Here a component matched in a directory.
- * If there is more pathname, go back to
- * dirloop, otherwise return.