Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Feb 2023 23:17:58 GMT
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 975ebddbf547 - stable/13 - Fix for getmntpoint(3) when checking for NFS mount points.
Message-ID:  <202302062317.316NHwf3037649@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mckusick:

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

commit 975ebddbf5475cbe7748a37cd0308606525f9956
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-01-29 23:12:48 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-02-06 23:17:39 +0000

    Fix for getmntpoint(3) when checking for NFS mount points.
    
    Sponsored by: The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D37907
    
    (cherry picked from commit ad055467bec35885dc3eff2f4dd765f5b2f53259)
---
 sbin/mount/getmntopts.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c
index 7702da903749..3a5cac0d9bac 100644
--- a/sbin/mount/getmntopts.c
+++ b/sbin/mount/getmntopts.c
@@ -177,6 +177,11 @@ getmntpoint(const char *name)
 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
 	for (i = 0; i < mntsize; i++) {
 		statfsp = &mntbuf[i];
+		if (isdev == 0) {
+			if (strcmp(name, statfsp->f_mntonname))
+				continue;
+			return (statfsp);
+		}
 		ddevname = statfsp->f_mntfromname;
 		if (*ddevname != '/') {
 			if ((len = strlen(_PATH_DEV) + strlen(ddevname) + 1) >
@@ -185,12 +190,8 @@ getmntpoint(const char *name)
 				continue;
 			strncpy(device, _PATH_DEV, len);
 			strncat(device, ddevname, len);
-			strncpy(statfsp->f_mntfromname, device, len);
-		}
-		if (isdev == 0) {
-			if (strcmp(name, statfsp->f_mntonname))
-				continue;
-			return (statfsp);
+			if (stat(device, &mntdevstat) == 0)
+				strncpy(statfsp->f_mntfromname, device, len);
 		}
 		if (stat(ddevname, &mntdevstat) == 0 &&
 		    mntdevstat.st_rdev == devstat.st_rdev)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302062317.316NHwf3037649>