+ /*
+ * If this is the same directory that this process
+ * previously searched, pick up where we last left off.
+ * We cache only lookups as these are the most common,
+ * and have the greatest payoff. Caching CREATE has little
+ * benefit as it usually must search the entire directory
+ * to determine that the entry does not exist. Caching the
+ * location of the last DELETE has not reduced profiling time
+ * and hence has been removed in the interest of simplicity.
+ */
+ if (flag != LOOKUP || dp->i_number != u.u_ncache.nc_inumber ||
+ dp->i_dev != u.u_ncache.nc_dev) {
+ u.u_offset = 0;
+ numdirpasses = 1;
+ } else {
+ if (dp->i_mtime >= u.u_ncache.nc_time) {
+ u.u_ncache.nc_prevoffset &= ~(DIRBLKSIZ - 1);
+ u.u_ncache.nc_time = time.tv_sec;
+ }
+ u.u_offset = u.u_ncache.nc_prevoffset;
+ entryoffsetinblock = blkoff(fs, u.u_offset);
+ if (entryoffsetinblock != 0) {
+ bp = blkatoff(dp, u.u_offset, (char **)0);
+ if (bp == 0)
+ goto bad;
+ }
+ numdirpasses = 2;
+ }
+ endsearch = roundup(dp->i_size, DIRBLKSIZ);