From ca1b2bb4b5bd7d3c481f2a7c5e35bb2cfe6b5871 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 17 Dec 2021 10:50:12 -0700 Subject: [PATCH] FreeBSD: Update argument types for VOP_READDIR A recent commit to FreeBSD changed the type of vop_readdir_args.a_cookies to a uint64_t**. There is no functional impact to ZFS because ZFS only uses 32-bit cookies, which will be zero-extended to 64-bits by the existing code. https://github.com/freebsd/freebsd-src/commit/b214fcceacad6b842545150664bd2695c1c2b34f Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Alan Somers Closes #12874 --- module/os/freebsd/zfs/zfs_vnops_os.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 752e5b2f6..3db117525 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -113,6 +113,12 @@ VFS_SMR_DECLARE; #define VNCHECKREF(vp) #endif +#if __FreeBSD_version >= 1400045 +typedef uint64_t cookie_t; +#else +typedef ulong_t cookie_t; +#endif + /* * Programming rules. * @@ -1665,7 +1671,7 @@ zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd, cred_t *cr, int flags) /* ARGSUSED */ static int zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp, - int *ncookies, ulong_t **cookies) + int *ncookies, cookie_t **cookies) { znode_t *zp = VTOZ(vp); iovec_t *iovp; @@ -1687,7 +1693,7 @@ zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp, boolean_t check_sysattrs; uint8_t type; int ncooks; - ulong_t *cooks = NULL; + cookie_t *cooks = NULL; int flags = 0; ZFS_ENTER(zfsvfs); @@ -1764,7 +1770,7 @@ zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp, */ ncooks = zfs_uio_resid(uio) / (sizeof (struct dirent) - sizeof (((struct dirent *)NULL)->d_name) + 1); - cooks = malloc(ncooks * sizeof (ulong_t), M_TEMP, M_WAITOK); + cooks = malloc(ncooks * sizeof (*cooks), M_TEMP, M_WAITOK); *cookies = cooks; *ncookies = ncooks; } @@ -4718,7 +4724,7 @@ struct vop_readdir_args { struct ucred *a_cred; int *a_eofflag; int *a_ncookies; - ulong_t **a_cookies; + cookie_t **a_cookies; }; #endif