git: 975ebddbf547 - stable/13 - Fix for getmntpoint(3) when checking for NFS mount points.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Feb 2023 23:17:58 UTC
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)