summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-05-06 15:25:20 +0000
committerjhb <jhb@FreeBSD.org>2015-05-06 15:25:20 +0000
commit30a578b448b5dd1788bb2f727b33192c030c4e38 (patch)
tree72cc4f5d21e8d91c78512f280a089ff80046026b /lib
parentd1f9ba68ac3be42c01a34d354604cb2958b5cbf9 (diff)
downloadFreeBSD-src-30a578b448b5dd1788bb2f727b33192c030c4e38.zip
FreeBSD-src-30a578b448b5dd1788bb2f727b33192c030c4e38.tar.gz
A few style fixes and expand the comment a bit on what _fixtelldir() is
doing.
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 54cab5b..c057cd6 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)
OpenPOWER on IntegriCloud