From 0f193e93c8d435d47d4482e9fd8c7dbe86cf7753 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 31ce860b442c..6d3dac75484f 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. * @@ -1679,7 +1685,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; @@ -1701,7 +1707,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); @@ -1778,7 +1784,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; } @@ -4732,7 +4738,7 @@ struct vop_readdir_args { struct ucred *a_cred; int *a_eofflag; int *a_ncookies; - ulong_t **a_cookies; + cookie_t **a_cookies; }; #endif