linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 4/7] mountd: Fix up version and usage messages
Date: Mon, 20 Sep 2010 12:33:04 -0400	[thread overview]
Message-ID: <20100920163304.3170.42195.stgit@ellison.1015granger.net> (raw)
In-Reply-To: <20100920162616.3170.24625.stgit@ellison.1015granger.net>

Clean up: rpc.mountd is no longer known as kmountd.  Use the program's
basename rather than the full pathname for the usage message.  Display
a version message at start up similar to statd's.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mountd/mountd.c |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
index 9c7caf9..1a14a85 100644
--- a/utils/mountd/mountd.c
+++ b/utils/mountd/mountd.c
@@ -692,6 +692,7 @@ main(int argc, char **argv)
 {
 	char	*export_file = _PATH_EXPORTS;
 	char    *state_dir = NFS_STATEDIR;
+	char	*progname;
 	unsigned int listeners = 0;
 	int	foreground = 0;
 	int	port = 0;
@@ -701,6 +702,12 @@ main(int argc, char **argv)
 	struct sigaction sa;
 	struct rlimit rlim;
 
+	/* Set the basename */
+	if ((progname = strrchr(argv[0], '/')) != NULL)
+		progname++;
+	else
+		progname = argv[0];
+
 	/* Parse the command line options and arguments. */
 	opterr = 0;
 	while ((c = getopt_long(argc, argv, "o:nFd:f:p:P:hH:N:V:vrs:t:g", longopts, NULL)) != EOF)
@@ -712,8 +719,8 @@ main(int argc, char **argv)
 			descriptors = atoi(optarg);
 			if (descriptors <= 0) {
 				fprintf(stderr, "%s: bad descriptors: %s\n",
-					argv [0], optarg);
-				usage(argv [0], 1);
+					progname, optarg);
+				usage(progname, 1);
 			}
 			break;
 		case 'F':
@@ -729,15 +736,15 @@ main(int argc, char **argv)
 			ha_callout_prog = optarg;
 			break;
 		case 'h':
-			usage(argv [0], 0);
+			usage(progname, 0);
 			break;
 		case 'P':	/* XXX for nfs-server compatibility */
 		case 'p':
 			port = atoi(optarg);
 			if (port <= 0 || port > 65535) {
 				fprintf(stderr, "%s: bad port number: %s\n",
-					argv [0], optarg);
-				usage(argv [0], 1);
+					progname, optarg);
+				usage(progname, 1);
 			}
 			break;
 		case 'N':
@@ -758,7 +765,7 @@ main(int argc, char **argv)
 		case 's':
 			if ((state_dir = xstrdup(optarg)) == NULL) {
 				fprintf(stderr, "%s: xstrdup(%s) failed!\n",
-					argv[0], optarg);
+					progname, optarg);
 				exit(1);
 			}
 			break;
@@ -775,30 +782,28 @@ main(int argc, char **argv)
 			nfs_version |= NFSVERSBIT(vers);
 			break;
 		case 'v':
-			printf("kmountd %s\n", VERSION);
+			printf("%s version " VERSION "\n", progname);
 			exit(0);
 		case 0:
 			break;
 		case '?':
 		default:
-			usage(argv [0], 1);
+			usage(progname, 1);
 		}
 
-	/* No more arguments allowed.
-	 * Require at least one valid version (2, 3, or 4)
-	 */
+	/* No more arguments allowed. */
 	if (optind != argc || !version_any())
-		usage(argv [0], 1);
+		usage(progname, 1);
 
 	if (chdir(state_dir)) {
 		fprintf(stderr, "%s: chdir(%s) failed: %s\n",
-			argv [0], state_dir, strerror(errno));
+			progname, state_dir, strerror(errno));
 		exit(1);
 	}
 
 	if (getrlimit (RLIMIT_NOFILE, &rlim) != 0)
 		fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
-				argv [0], strerror(errno));
+				progname, strerror(errno));
 	else {
 		/* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */
 		if ((descriptors == 0 && rlim.rlim_cur > FD_SETSIZE) ||
@@ -808,14 +813,14 @@ main(int argc, char **argv)
 			rlim.rlim_cur = descriptors;
 			if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
 				fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
-					argv [0], strerror(errno));
+					progname, strerror(errno));
 				exit(1);
 			}
 		}
 	}
 	/* Initialize logging. */
 	if (!foreground) xlog_stderr(0);
-	xlog_open("mountd");
+	xlog_open(progname);
 
 	sa.sa_handler = SIG_IGN;
 	sa.sa_flags = 0;
@@ -886,6 +891,7 @@ main(int argc, char **argv)
 	if (num_threads > 1)
 		fork_workers();
 
+	xlog(L_NOTICE, "Version " VERSION " starting");
 	my_svc_run();
 
 	xlog(L_ERROR, "RPC service loop terminated unexpectedly. Exiting...\n");


  parent reply	other threads:[~2010-09-20 16:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 16:32 [PATCH 0/7] The final patches for mountd IPv6 support Chuck Lever
2010-09-20 16:32 ` [PATCH 1/7] mountd: Make NFS version checks more strict Chuck Lever
2010-09-20 16:32 ` [PATCH 2/7] mountd: Support TI-RPC mountd listener Chuck Lever
2010-09-20 16:32 ` [PATCH 3/7] mountd: Unregister mountd if my_svc_run() returns Chuck Lever
2010-09-20 16:33 ` Chuck Lever [this message]
2010-09-20 16:33 ` [PATCH 5/7] mountd: Use MNT status values instead of NFSERR Chuck Lever
2010-09-20 16:33 ` [PATCH 6/7] mountd: Update mountd/exportfs man pages to reflect IPv6 changes Chuck Lever
2010-09-20 16:33 ` [PATCH 7/7] nfsd: Enable IPv6 support in rpc.nfsd again Chuck Lever
     [not found] ` <20100920162616.3170.24625.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2010-09-28 12:08   ` [PATCH 0/7] The final patches for mountd IPv6 support 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=20100920163304.3170.42195.stgit@ellison.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@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;
as well as URLs for NNTP newsgroup(s).