aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2015-05-06 15:25:20 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2015-05-06 15:25:20 +0000
commitdf00427834fbbfc1757c1dddb685d0c5db8263fd (patch)
tree72cc4f5d21e8d91c78512f280a089ff80046026b /lib
parent56af72b16bfaf2aef0a715493fe38e46a5b3364f (diff)
downloadsrc-df00427834fbbfc1757c1dddb685d0c5db8263fd.tar.gz
src-df00427834fbbfc1757c1dddb685d0c5db8263fd.zip
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/telldir.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index 54cab5bdac67..c057cd651b6d 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -101,11 +101,12 @@ _seekdir(dirp, loc)
return;
if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
return;
- /* If it's within the same chunk of data, don't bother reloading */
+
+ /* If it's within the same chunk of data, don't bother reloading. */
if (lp->loc_seek == dirp->dd_seek) {
/*
* If we go back to 0 don't make the next readdir
- * trigger a call to getdirentries()
+ * trigger a call to getdirentries().
*/
if (lp->loc_loc == 0)
dirp->dd_flags |= __DTF_SKIPREAD;
@@ -124,10 +125,13 @@ _seekdir(dirp, loc)
}
/*
- * when we do a read and cross a boundary, any telldir we
- * just did will have wrong information in it.
- * We need to move it from "beyond the end of the previous chunk"
- * to "the beginning of the new chunk"
+ * A call to telldir after readdir returns the last entry in a block
+ * returns a location that is after the end of the last entry in that
+ * block. However, that location doesn't refer to a valid directory
+ * entry. Instead, these locations should refer to the first entry in
+ * the next block. That location is not known until the next block is
+ * read, so readdir calls this function after fetching a new block to
+ * fix any such telldir locations.
*/
void
_fixtelldir(DIR *dirp, long oldseek, long oldloc)