From owner-svn-src-all@freebsd.org Thu Dec 26 22:33:20 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8A121DAB89; Thu, 26 Dec 2019 22:33:20 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kPqh4RLMz4Pbt; Thu, 26 Dec 2019 22:33:20 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93888781A; Thu, 26 Dec 2019 22:33:20 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBQMXKff060024; Thu, 26 Dec 2019 22:33:20 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBQMXKME060023; Thu, 26 Dec 2019 22:33:20 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201912262233.xBQMXKME060023@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 26 Dec 2019 22:33:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356101 - head/sbin/mount_nfs X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sbin/mount_nfs X-SVN-Commit-Revision: 356101 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Dec 2019 22:33:20 -0000 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 #include -#include +#include +#include #include @@ -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); }