Skip to content

Commit

Permalink
FreeBSD: fix up EINVAL from getdirentries on .zfs
Browse files Browse the repository at this point in the history
Without the change:
/.zfs
/.zfs/snapshot
find: /.zfs: Invalid argument

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #14774
  • Loading branch information
mjguzik authored and behlendorf committed Apr 26, 2023
1 parent 88b8777 commit e37a89d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions module/os/freebsd/zfs/zfs_ctldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,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) {
Expand Down

0 comments on commit e37a89d

Please sign in to comment.