From ac13a90c4b9d346391a6ddb81f39f55ae9ad8f5b Mon Sep 17 00:00:00 2001 From: Gleb Kurtsou Date: Wed, 16 May 2012 10:44:09 +0000 Subject: [PATCH] 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 --- sys/fs/unionfs/union_subr.c | 2 +- sys/kern/vfs_default.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index dbdaa8e9996b..528271cda4db 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -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]; for (dp = (struct dirent*)buf; !error && dp < edp; 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 == 2 && !bcmp(dp->d_name, "..", 2))) continue; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 4e6276583888..91b30a814ed9 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -343,8 +343,8 @@ dirent_exists(struct vnode *vp, const char *dirname, struct thread *td) if (error) goto out; - if ((dp->d_type != DT_WHT) && - !strcmp(dp->d_name, dirname)) { + if (dp->d_type != DT_WHT && dp->d_fileno != 0 && + strcmp(dp->d_name, dirname) == 0) { found = 1; goto out; }