git: ad3fdab6e507 - stable/15 - stat(2): report mount points using st_bsdflags SFBSD_MNTPOINT flag

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 07 Oct 2026 03:27:11 UTC
The branch stable/15 has been updated by kib:

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

commit ad3fdab6e507e4ef73b705c86930846859cb41af
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-22 16:16:36 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-10-07 03:26:32 +0000

    stat(2): report mount points using st_bsdflags SFBSD_MNTPOINT flag
    
    (cherry picked from commit 0d5d8872931c2659692b5e59db2190b715ff314c)
---
 sys/kern/vfs_syscalls.c | 2 ++
 sys/kern/vfs_vnops.c    | 2 ++
 sys/sys/stat.h          | 1 +
 3 files changed, 5 insertions(+)

diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 5bc8dd5c5f91..620fbcc1def9 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2570,6 +2570,8 @@ kern_statat(struct thread *td, int flag, int fd, const char *path,
 	}
 	error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED);
 	NDFREE_PNBUF(&nd);
+	if (error == 0 && (nd.ni_vp->v_vflag & VV_ROOT) != 0)
+		sbp->st_bsdflags |= SFBSD_MNTPOINT;
 	vput(nd.ni_vp);
 #ifdef __STAT_TIME_T_EXT
 	sbp->st_atim_ext = 0;
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index a3ee9216645c..a06af14e587a 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1842,6 +1842,8 @@ vn_statfile(struct file *fp, struct stat *sb, struct ucred *active_cred)
 
 	vn_lock(vp, LK_SHARED | LK_RETRY);
 	error = VOP_STAT(vp, sb, active_cred, fp->f_cred);
+	if (error == 0 && (vp->v_vflag & VV_ROOT) != 0)
+		sb->st_bsdflags |= SFBSD_MNTPOINT;
 	VOP_UNLOCK(vp);
 
 	return (error);
diff --git a/sys/sys/stat.h b/sys/sys/stat.h
index 6aa536732efd..2fa6c9e8f54a 100644
--- a/sys/sys/stat.h
+++ b/sys/sys/stat.h
@@ -342,6 +342,7 @@ struct nstat {
 
 /* st_bsdflags */
 #define	SFBSD_NAMEDATTR	0x0001		/* file is named attribute or dir */
+#define	SFBSD_MNTPOINT	0x0002		/* file is a mount point */
 
 #ifdef _KERNEL
 /*