git: 8073a5137f22 - main - getmntpoint: Don't compare st_rdev for non-devices

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Sun, 17 Aug 2025 17:30:00 UTC
The branch main has been updated by des:

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

commit 8073a5137f223bb481606b15edaa5ecb93ceffcb
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-08-17 17:07:45 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-08-17 17:29:27 +0000

    getmntpoint: Don't compare st_rdev for non-devices
    
    If the mntfromname of a mountpoint is not a device (e.g. nullfs, tarfs,
    procfs) we shouldn't compare st_rdev, as any match will be spurious.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Sponsored by:   NetApp, Inc.
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D51945
---
 lib/libutil/mntopts.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libutil/mntopts.c b/lib/libutil/mntopts.c
index 1d9347e3108a..07d3dd6d98a3 100644
--- a/lib/libutil/mntopts.c
+++ b/lib/libutil/mntopts.c
@@ -185,6 +185,7 @@ getmntpoint(const char *name)
 				strncpy(statfsp->f_mntfromname, device, len);
 		}
 		if (stat(ddevname, &mntdevstat) == 0 &&
+		    S_ISCHR(mntdevstat.st_mode) &&
 		    mntdevstat.st_rdev == devstat.st_rdev)
 			return (statfsp);
 	}