diff options
author | peter <peter@FreeBSD.org> | 1997-03-11 11:29:42 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-03-11 11:29:42 +0000 |
commit | e0e06d68d52707cbac25844a417ab6919613e9eb (patch) | |
tree | 21479b686e8fe46544082e319ecfa70f9bd25fc6 /lib/libc/gen/readdir.c | |
parent | 53b81178e2d0aa56f51f680543678a3d7ef8aecd (diff) | |
download | FreeBSD-src-e0e06d68d52707cbac25844a417ab6919613e9eb.zip FreeBSD-src-e0e06d68d52707cbac25844a417ab6919613e9eb.tar.gz |
Import CSRG 4.4BSD-Lite2 lib/libc onto vendor branch
Diffstat (limited to 'lib/libc/gen/readdir.c')
-rw-r--r-- | lib/libc/gen/readdir.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index d0651da..2e97661 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)readdir.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -48,25 +48,28 @@ readdir(dirp) register struct dirent *dp; for (;;) { - if (dirp->dd_loc == 0) { + if (dirp->dd_loc >= dirp->dd_size) { + if (dirp->dd_flags & __DTF_READALL) + return (NULL); + dirp->dd_loc = 0; + } + if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) { dirp->dd_size = getdirentries(dirp->dd_fd, dirp->dd_buf, dirp->dd_len, &dirp->dd_seek); if (dirp->dd_size <= 0) - return NULL; - } - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - continue; + return (NULL); } dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); if ((int)dp & 03) /* bogus pointer check */ - return NULL; + return (NULL); if (dp->d_reclen <= 0 || dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) - return NULL; + return (NULL); dirp->dd_loc += dp->d_reclen; if (dp->d_ino == 0) continue; + if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW)) + continue; return (dp); } } |