--- src/sys/kern/vfs_cache.c 2005/04/03 01:59:10 1.53 +++ src/sys/kern/vfs_cache.c 2005/09/15 18:14:15 1.53.2.1 @@ -966,15 +966,11 @@ cache_inefficient_scan(struct namecache struct vattr vat; struct iovec iov; struct uio uio; - u_long *cookies; - off_t baseoff; - int ncookies; int blksize; int eofflag; + int bytes; char *rbuf; int error; - int xoff; - int i; vat.va_blocksize = 0; if ((error = VOP_GETATTR(dvp, &vat, curthread)) != 0) @@ -990,9 +986,7 @@ cache_inefficient_scan(struct namecache eofflag = 0; uio.uio_offset = 0; - cookies = NULL; again: - baseoff = uio.uio_offset; iov.iov_base = rbuf; iov.iov_len = blksize; uio.uio_iov = &iov; @@ -1002,32 +996,19 @@ again: uio.uio_rw = UIO_READ; uio.uio_td = curthread; - if (cookies) { - free(cookies, M_TEMP); - cookies = NULL; - } if (ncvp_debug >= 2) - printf("cache_inefficient_scan: readdir @ %08x\n", (int)baseoff); - error = VOP_READDIR(pvp, &uio, cred, &eofflag, &ncookies, &cookies); - if (error == 0 && cookies == NULL) - error = EPERM; + printf("cache_inefficient_scan: readdir @ %08x\n", (int)uio.uio_offset); + error = VOP_READDIR(pvp, &uio, cred, &eofflag, NULL, NULL); if (error == 0) { - for (i = 0; i < ncookies; ++i) { - xoff = (int)(cookies[i] - (u_long)baseoff); - /* - * UFS plays a little trick to skip the first entry - * in a directory ("."), by assigning the cookie to - * dpoff + dp->d_reclen in the loop. This causes - * the last cookie to be assigned to the data-end of - * the directory. XXX - */ - if (xoff == blksize) - break; - KKASSERT(xoff >= 0 && xoff <= blksize); - den = (struct dirent *)(rbuf + xoff); - if (ncvp_debug >= 2) + den = (struct dirent *)rbuf; + bytes = blksize - uio.uio_resid; + + while (bytes > 0) { + if (ncvp_debug >= 2) { printf("cache_inefficient_scan: %*.*s\n", - den->d_namlen, den->d_namlen, den->d_name); + den->d_namlen, den->d_namlen, + den->d_name); + } if (den->d_type != DT_WHT && den->d_fileno == vat.va_fileid) { if (ncvp_debug) @@ -1039,14 +1020,12 @@ again: KKASSERT(rncp != NULL); break; } + bytes -= den->d_reclen; + den = (void *)((char *)den + den->d_reclen); } if (rncp == NULL && eofflag == 0 && uio.uio_resid != blksize) goto again; } - if (cookies) { - free(cookies, M_TEMP); - cookies = NULL; - } if (rncp) { vrele(pvp); if (rncp->nc_flag & NCF_UNRESOLVED) {