public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Scott Mayhew <smayhew@redhat.com>
To: steved@redhat.com
Cc: jlayton@kernel.org, yoyang@redhat.com, linux-nfs@vger.kernel.org
Subject: [nfs-utils PATCH v3 1/3] nfsdctl: tweak the version subcommand behavior
Date: Mon, 13 Jan 2025 18:13:17 -0500	[thread overview]
Message-ID: <20250113231319.951885-2-smayhew@redhat.com> (raw)
In-Reply-To: <20250113231319.951885-1-smayhew@redhat.com>

The section for the 'nfsdctl version' subcommand on the man page states
that the minorversion is optional, and if omitted it will cause all
minorversions to be enabled/disabled.  Make it work that way.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdctl/nfsdctl.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c
index 003daba5..88b728e0 100644
--- a/utils/nfsdctl/nfsdctl.c
+++ b/utils/nfsdctl/nfsdctl.c
@@ -783,6 +783,19 @@ static int update_nfsd_version(int major, int minor, bool enabled)
 	return -EINVAL;
 }
 
+static int get_max_minorversion(void)
+{
+	int i, max = 0;
+
+	for (i = 0; i < MAX_NFS_VERSIONS; ++i) {
+		if (nfsd_versions[i].major == 0)
+			break;
+		if (nfsd_versions[i].major == 4 && nfsd_versions[i].minor > max)
+			max = nfsd_versions[i].minor;
+	}
+	return max;
+}
+
 static void version_usage(void)
 {
 	printf("Usage: %s version { {+,-}major.minor } ...\n", taskname);
@@ -800,7 +813,7 @@ static void version_usage(void)
 
 static int version_func(struct nl_sock *sock, int argc, char ** argv)
 {
-	int ret, i;
+	int ret, i, j, max_minor;
 
 	/* help is only valid as first argument after command */
 	if (argc > 1 &&
@@ -814,6 +827,8 @@ static int version_func(struct nl_sock *sock, int argc, char ** argv)
 		return ret;
 
 	if (argc > 1) {
+		max_minor = get_max_minorversion();
+
 		for (i = 1; i < argc; ++i) {
 			int ret, major, minor = 0;
 			char sign = '\0', *str = argv[i];
@@ -837,9 +852,22 @@ static int version_func(struct nl_sock *sock, int argc, char ** argv)
 				return -EINVAL;
 			}
 
-			ret = update_nfsd_version(major, minor, enabled);
-			if (ret)
-				return ret;
+			/*
+			 * The minorversion field is optional. If omitted, it should
+			 * cause all the minor versions for that major version to be
+			 * enabled/disabled.
+			 */
+			if (major == 4 && ret == 2) {
+				for (j = 0; j <= max_minor; ++j) {
+					ret = update_nfsd_version(major, j, enabled);
+					if (ret)
+						return ret;
+				}
+			} else {
+				ret = update_nfsd_version(major, minor, enabled);
+				if (ret)
+					return ret;
+			}
 		}
 		return set_nfsd_versions(sock);
 	}
-- 
2.45.2


  reply	other threads:[~2025-01-13 23:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 23:13 [nfs-utils PATCH v3 0/3] version handling fixes for nfsdctl and rpc.nfsd Scott Mayhew
2025-01-13 23:13 ` Scott Mayhew [this message]
2025-01-13 23:13 ` [nfs-utils PATCH v3 2/3] nfsdctl: tweak the nfs.conf version handling Scott Mayhew
2025-01-13 23:13 ` [nfs-utils PATCH v3 3/3] nfsd: fix version sanity check Scott Mayhew
2025-01-13 23:20 ` [nfs-utils PATCH v3 0/3] version handling fixes for nfsdctl and rpc.nfsd Scott Mayhew
2025-01-18 12:12   ` Steve Dickson
2025-01-18 12:08 ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250113231319.951885-2-smayhew@redhat.com \
    --to=smayhew@redhat.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    --cc=yoyang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox