aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjguzik@gmail.com>2023-04-20 09:00:03 +0000
committerBrian Behlendorf <behlendorf1@llnl.gov>2023-05-30 15:53:21 +0000
commitaef1324d598a9e0ff98d4215d05b0132ff027cf7 (patch)
treed0729f2b81be2bba67ad902bf7a81b1e5c672cc6
parentd1e05c68564b95e936998a43d30b1350af745e63 (diff)
downloadsrc-aef1324d598a9e0ff98d4215d05b0132ff027cf7.tar.gz
src-aef1324d598a9e0ff98d4215d05b0132ff027cf7.zip
FreeBSD: fix up EINVAL from getdirentries on .zfs
Without the change: /.zfs /.zfs/snapshot find: /.zfs: Invalid argument Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Closes #14774
-rw-r--r--module/os/freebsd/zfs/zfs_ctldir.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c
index 5bd2e1510ddb..6e49fff9a110 100644
--- a/module/os/freebsd/zfs/zfs_ctldir.c
+++ b/module/os/freebsd/zfs/zfs_ctldir.c
@@ -675,6 +675,17 @@ zfsctl_root_readdir(struct vop_readdir_args *ap)
ASSERT3S(vp->v_type, ==, VDIR);
+ /*
+ * FIXME: this routine only ever emits 3 entries and does not tolerate
+ * being called with a buffer too small to handle all of them.
+ *
+ * The check below facilitates the idiom of repeating calls until the
+ * count to return is 0.
+ */
+ if (zfs_uio_offset(&uio) == 3 * sizeof(entry)) {
+ return (0);
+ }
+
error = sfs_readdir_common(zfsvfs->z_root, ZFSCTL_INO_ROOT, ap, &uio,
&dots_offset);
if (error != 0) {