git: fbac0abdc5ab - main - mqueuefs: set *a_eofflag in VOP_READDIR

From: Xin LI <delphij_at_FreeBSD.org>
Date: Tue, 03 Nov 2026 03:04:13 UTC
The branch main has been updated by delphij:

URL: https://cgit.FreeBSD.org/src/commit/?id=fbac0abdc5ab1fe867ac85635662ef06b2ee9d10

commit fbac0abdc5ab1fe867ac85635662ef06b2ee9d10
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2026-11-03 03:02:03 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2026-11-03 03:02:03 +0000

    mqueuefs: set *a_eofflag in VOP_READDIR
    
    mqfs_readdir() never reported end of directory.  Since 77b273d8f5f4
    VOP_READDIR_APV() asserts that a readdir which returns no entries also
    sets *a_eofflag, so with INVARIANTS the final zero-length
    getdirentries(2) that ls(1) issues on a mounted mqueuefs panics:
    
        panic: VOP_READDIR: eofflag not set
    
    Report end of directory when the child list was walked to its end;
    leave the flag clear when the walk stopped because the buffer was full.
    
    MFC after:      1 week
---
 sys/kern/uipc_mqueue.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index 68eda5ecb039..cd402fa3e80b 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -1459,6 +1459,8 @@ mqfs_readdir(struct vop_readdir_args *ap)
 	sx_xunlock(&mi->mi_lock);
 
 	uio->uio_offset = offset;
+	if (ap->a_eofflag != NULL)
+		*ap->a_eofflag = (pn == NULL);
 
 	if (tmp_ncookies != NULL)
 		ap->a_ncookies = tmp_ncookies;