[Bug 253428] getdirentries does not work correctly on NFS mounts
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat Feb 13 20:28:14 UTC 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253428
--- Comment #10 from Konstantin Belousov <kib at FreeBSD.org> ---
(In reply to Konstantin Belousov from comment #9)
Like this, untested.
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 301c583291d1..bfdc16a1df72 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -2391,11 +2391,23 @@ ufs_readdir(ap)
error = EIO;
break;
}
- if (offset < startoffset || dp->d_ino == 0)
+ if (offset < startoffset)
goto nextentry;
+
+ /*
+ * In case of NFS server calling us, do not
+ * skip empty entries, since this keeps
+ * offsets consistent.
+ */
+ if (cookies == NULL && dp->d_ino == 0)
+ goto nextentry;
+
dstdp.d_fileno = dp->d_ino;
dstdp.d_reclen = GENERIC_DIRSIZ(&dstdp);
- bcopy(dp->d_name, dstdp.d_name, dstdp.d_namlen);
+ if (dp->d_ino == 0)
+ bzero(dp->d_name, dstdp.d_namlen);
+ else
+ bcopy(dp->d_name, dstdp.d_name,
dstdp.d_namlen);
/* NOTE: d_off is the offset of the *next* entry. */
dstdp.d_off = offset + dp->d_reclen;
dirent_terminate(&dstdp);
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-fs
mailing list