Files
AnyPS5/docs/dev/debt/changes/fix-libkernel-socket-stat-blksize.md
brajankwandClaude Opus 5.5 ff941dbf41 fix(libkernel): report a socket's guest send buffer size as st_blksize, as FreeBSD 11.4 does
fstat on a guest socket filled st_blksize from the host's SO_SNDBUF,
which Linux reports as twice the size that was set and which does not
follow the guest's own buffer sizes. FreeBSD 11.4's pru_sense_null and
uipc_sense report so_snd.sb_hiwat, the value getsockopt(SO_SNDBUF)
returns, so st_blksize now comes from the same guest option state:
8192 for a local stream socket, 2048 for a local datagram socket,
32768 for TCP, 9216 for UDP, or what setsockopt set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 01:06:43 +01:00

861 B

libkernel

change [fstat on a guest socket]

  • fstat on a guest socket (libkernel) fills the fields FreeBSD 11's soo_stat and pru_sense_null fill and zeroes the rest: S_IFSOCK, the read bits while the receive side is open or data is queued, the write bits while the send side is open, st_size and st_blksize. Only this process's shutdown closes a side here; a peer's shutdown, close or reset does not clear the bits as FreeBSD's socantrcvmore and socantsendmore do. st_size is the host's FIONREAD, which for a Linux datagram socket is the size of the next datagram where FreeBSD counts every queued byte. A socketpair end's st_ino comes from a counter this process starts at 1, where FreeBSD's uipc_sense uses one counter for every local socket on the system, so the numbers differ from the console's