lib/libprocstat/zfs.c uses old ZFS znode_t layout that is not compatible with what is currently in kernel when it extracts vn_mode and vn_size. In particular, the code assumes that znode_t contains a pointer to a znode_phys_t object, which is not the case. I think that the required information can be extracted from z_size and z_mode fields in znode_t. While here, there is a comment in zfs_filestat() that talks about two byte offsets, while in reality the offsets are 2 * sizeof(pointer), e.g. 16 bytes on 64-bit systems. The code itself is correct.
A commit references this bug: Author: avg Date: Fri May 22 11:20:25 UTC 2020 New revision: 361363 URL: https://svnweb.freebsd.org/changeset/base/361363 Log: libprocstat: fix ZFS support First of all, znode_phys_t hasn't been used for storing file attributes for a long time now. Modern ZFS versions use a System Attribute table with a flexible layout. But more importantly all the required information is available in znode_t itself. It's not easy to include zfs_znode.h in userland without breaking code because the most interesting parts of the header are kernel-only. And hardcoding field offsets is too fragile. So, I created a new compilation unit that includes zfs_znode.h using some mild kludges to get it and its dependencies to compile in userland. The compilation unit exports interesting field offsets and does not have any other code. PR: 194117 Reviewed by: markj MFC after: 2 weeks Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D24941 Changes: head/lib/libprocstat/Makefile head/lib/libprocstat/zfs/Makefile head/lib/libprocstat/zfs.c head/lib/libprocstat/zfs_defs.c head/lib/libprocstat/zfs_defs.h
A commit references this bug: Author: avg Date: Fri Jun 5 06:34:05 UTC 2020 New revision: 361823 URL: https://svnweb.freebsd.org/changeset/base/361823 Log: MFC r361363,r361434: libprocstat: fix ZFS support First of all, znode_phys_t hasn't been used for storing file attributes for a long time now. Modern ZFS versions use a System Attribute table with a flexible layout. But more importantly all the required information is available in znode_t itself. It's not easy to include zfs_znode.h in userland without breaking code because the most interesting parts of the header are kernel-only. And hardcoding field offsets is too fragile. So, I created a new compilation unit that includes zfs_znode.h using some mild kludges to get it and its dependencies to compile in userland. The compilation unit exports interesting field offsets and does not have any other code. PR: 194117 Sponsored by: Panzura Changes: _U stable/12/ stable/12/lib/libprocstat/Makefile stable/12/lib/libprocstat/zfs/Makefile stable/12/lib/libprocstat/zfs.c stable/12/lib/libprocstat/zfs_defs.c stable/12/lib/libprocstat/zfs_defs.h