From patchwork Fri May 19 22:25:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 9738289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6B156020B for ; Fri, 19 May 2017 22:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5B7928593 for ; Fri, 19 May 2017 22:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6CA0285A9; Fri, 19 May 2017 22:25:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D9228593 for ; Fri, 19 May 2017 22:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751743AbdESWZM (ORCPT ); Fri, 19 May 2017 18:25:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38276 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbdESWZM (ORCPT ); Fri, 19 May 2017 18:25:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECC8E4ACAA for ; Fri, 19 May 2017 22:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ECC8E4ACAA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=steved@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ECC8E4ACAA Received: from steved.boston.devel.redhat.com (ovpn-124-229.rdu2.redhat.com [10.10.124.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C0CD60BE5 for ; Fri, 19 May 2017 22:25:11 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 1/2] mount.nfs: v4 mounts should fail when -o flag is used. Date: Fri, 19 May 2017 18:25:09 -0400 Message-Id: <20170519222510.31205-1-steved@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 19 May 2017 22:25:12 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the pseudo root is set with fsid=0, explicit v4 mounts (via the -o flag) should fail when the incorrect export is tried instead of rolling back to v3. Signed-off-by: Steve Dickson --- utils/mount/network.c | 3 ++- utils/mount/network.h | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/mount/network.c b/utils/mount/network.c index 281e935..e39263e 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -1299,7 +1299,8 @@ nfs_nfs_version(struct mount_options *options, struct nfs_version *version) if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val) goto ret_error; version->v_mode = V_SPECIFIC; - } else if (version->major > 3 && *cptr == '\0') + } else if (version->major > 3 && *cptr == '\0' && + version->v_mode == V_DEFAULT) /* v_mode has not been set */ version->v_mode = V_GENERAL; if (*cptr != '\0') diff --git a/utils/mount/network.h b/utils/mount/network.h index 9cc5dec..45e2b24 100644 --- a/utils/mount/network.h +++ b/utils/mount/network.h @@ -58,10 +58,10 @@ int clnt_ping(struct sockaddr_in *, const unsigned long, struct mount_options; enum { - V_DEFAULT = 0, - V_GENERAL, - V_SPECIFIC, - V_PARSE_ERR, + V_DEFAULT = 0, /* not set */ + V_GENERAL, /* single digit => 4 */ + V_SPECIFIC, /* single digit < 4 or decimal included */ + V_PARSE_ERR, /* miss all others */ }; struct nfs_version {