Definition of struct stat st_size for directories

From: raf <freebsd_at_raf.org>
Date: Sat, 12 Feb 2022 04:10:54 UTC
Hi,

The FreeBSD stat(2) manpage only defines st_size for
regular files and symlinks. But I've noticed that for
directories, it seems to always be the number of
entries within the directory (including . and ..). I'm
seeing this with 13.0-RELEASE and zfs.

Is this always the case on FreeBSD? Or just for zfs?
Or am I imagining things?

If I can rely on this behaviour, I can make a small
part of a program I'm writing faster when it's on
FreeBSD.

cheers,
raf