Author: rmacklem
Date: Thu Dec 26 22:33:20 2019
New Revision: 356101
URL: https://svnweb.freebsd.org/changeset/base/356101
Log:
Fix mount_nfs to recognize the NFSv4 specific errors returned by nmount(2).
When mount_nfs calls nmount(2), certain NFSv4 specific errors such as
NFSERR_MINORVERMISMATCH can be returned.
Without this patch, 10021 is reported as an unknown error.
This is not particulcarily serious, but make it difficult for sysadmins
to figure out why the mount attempt is failing.
This patch uses nfsv4_errstr.h to convert 10021 and similar to error strings
that can be printed out.
A positive side effect of this patch is the removal of a reference to
sys/nfsclient/nfs.h, which should no longer be used, since it is
part of the old NFS client.
This patch should only affect reporting of failed mount attempts and not the
semantics of NFS mount attempts.
Modified:
head/sbin/mount_nfs/mount_nfs.c
Modified: head/sbin/mount_nfs/mount_nfs.c
==============================================================================
--- head/sbin/mount_nfs/mount_nfs.c Thu Dec 26 21:20:45 2019
(r356100)
+++ head/sbin/mount_nfs/mount_nfs.c Thu Dec 26 22:33:20 2019
(r356101)
@@ -61,7 +61,8 @@ __FBSDID("$FreeBSD$");
#include <rpcsvc/nfs_prot.h>
#include <rpcsvc/mount.h>
-#include <nfsclient/nfs.h>
+#include <fs/nfs/nfsproto.h>
+#include <fs/nfs/nfsv4_errstr.h>
#include <arpa/inet.h>
@@ -155,7 +156,7 @@ main(int argc, char *argv[])
char *mntname, *p, *spec, *tmp;
char mntpath[MAXPATHLEN], errmsg[255];
char hostname[MAXHOSTNAMELEN + 1], gssn[MAXHOSTNAMELEN + 50];
- const char *gssname;
+ const char *gssname, *nmount_errstr;
iov = NULL;
iovlen = 0;
@@ -462,9 +463,14 @@ main(int argc, char *argv[])
build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
- if (nmount(iov, iovlen, 0))
- err(1, "nmount: %s%s%s", mntpath, errmsg[0] ? ", " : "",
- errmsg);
+ if (nmount(iov, iovlen, 0)) {
+ nmount_errstr = nfsv4_geterrstr(errno);
+ if (mountmode == V4 && nmount_errstr != NULL)
+ errx(1, "nmount: %s, %s", mntpath, nmount_errstr);
+ else
+ err(1, "nmount: %s%s%s", mntpath, errmsg[0] ? ", " : "",
+ errmsg);
+ }
exit(0);
}
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"