Skip directory entries with zero inode number during traversal.

Entries with zero inode number are considered placeholders by libc and
UFS.  Fix remaining uses of VOP_READDIR in kernel: vop_stdvptocnp,
unionfs.

Sponsored by:	Google Summer of Code 2011
This commit is contained in:
Gleb Kurtsou 2012-05-16 10:44:09 +00:00
parent 9e460a98e6
commit ac13a90c4b
2 changed files with 3 additions and 3 deletions

View File

@ -1184,7 +1184,7 @@ unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td)
edp = (struct dirent*)&buf[sizeof(buf) - uio.uio_resid]; edp = (struct dirent*)&buf[sizeof(buf) - uio.uio_resid];
for (dp = (struct dirent*)buf; !error && dp < edp; for (dp = (struct dirent*)buf; !error && dp < edp;
dp = (struct dirent*)((caddr_t)dp + dp->d_reclen)) { dp = (struct dirent*)((caddr_t)dp + dp->d_reclen)) {
if (dp->d_type == DT_WHT || if (dp->d_type == DT_WHT || dp->d_fileno == 0 ||
(dp->d_namlen == 1 && dp->d_name[0] == '.') || (dp->d_namlen == 1 && dp->d_name[0] == '.') ||
(dp->d_namlen == 2 && !bcmp(dp->d_name, "..", 2))) (dp->d_namlen == 2 && !bcmp(dp->d_name, "..", 2)))
continue; continue;

View File

@ -343,8 +343,8 @@ dirent_exists(struct vnode *vp, const char *dirname, struct thread *td)
if (error) if (error)
goto out; goto out;
if ((dp->d_type != DT_WHT) && if (dp->d_type != DT_WHT && dp->d_fileno != 0 &&
!strcmp(dp->d_name, dirname)) { strcmp(dp->d_name, dirname) == 0) {
found = 1; found = 1;
goto out; goto out;
} }