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.
This commit is contained in:
Rick Macklem 2019-12-26 22:33:20 +00:00
parent 4f58713dcc
commit 56c049a003
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356101

View File

@ -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);
}