Skip to contentSkip to conversation

nfsidmap: added the -h option

PATCH In review Steve Dickson 1 participant 2 messages Jun 8, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nfsidmap: added the -h option

Use the correct exit code when an invalid option
use or the -h option.

---
 utils/nfsidmap/nfsidmap.c   | 7 ++++---
 utils/nfsidmap/nfsidmap.man | 5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)
utils/nfsidmap/nfsidmap.c +4 -3
index 2abefe9..63545fc 100644
@@ -17,7 +17,7 @@
 #include "conffile.h"
 
 int verbose = 0;
-char *usage = "Usage: %s [-v] [-c || [-u|-g|-r key] || -d || -l || [-t timeout] key desc]";
+char *usage = "Usage: %s [-vh] [-c || [-u|-g|-r key] || -d || -l || [-t timeout] key desc]";
 
 #define MAX_ID_LEN   11
 #define IDMAP_NAMESZ 128
@@ -369,7 +369,7 @@ int main(int argc, char **argv)
 
 	xlog_open(progname);
 
-	while ((opt = getopt(argc, argv, "du:g:r:ct:vl")) != -1) {
+	while ((opt = getopt(argc, argv, "hdu:g:r:ct:vl")) != -1) {
 		switch (opt) {
 		case 'd':
 			display++;
@@ -398,9 +398,10 @@ int main(int argc, char **argv)
 		case 't':
 			timeout = atoi(optarg);
 			break;
+		case 'h':
 		default:
 			xlog_warn(usage, progname);
-			break;
+			exit(opt == 'h' ? 0 : 1);
 		}
 	}
 
utils/nfsidmap/nfsidmap.man +5 -0
index 0275bdf..2f17cf2 100644
@@ -15,6 +15,8 @@ nfsidmap \- The NFS idmapper upcall program
 .B "nfsidmap -d"
 .br
 .B "nfsidmap -l"
+.br
+.B "nfsidmap -h"
 .SH DESCRIPTION
 The NFSv4 protocol represents the local system's UID and GID values
 on the wire as strings of the form
@@ -71,6 +73,9 @@ Display the system's effective NFSv4 domain name on
 .B -g user
 Revoke the gid key of the given user.
 .TP
+.B -h
+Display usage message.
+.TP
 .B -l
 Display on
 .I stdout
Signature · 1 line
2.5.5
#1 lore raw
Quoted 4 lines · Steve Dickson

Use the correct exit code when an invalid option
use or the -h option.

Committed..

steved.

Quoted 63 lines
---
 utils/nfsidmap/nfsidmap.c   | 7 ++++---
 utils/nfsidmap/nfsidmap.man | 5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)
utils/nfsidmap/nfsidmap.c +4 -3
index 2abefe9..63545fc 100644
@@ -17,7 +17,7 @@
 #include "conffile.h"
 
 int verbose = 0;
-char *usage = "Usage: %s [-v] [-c || [-u|-g|-r key] || -d || -l || [-t timeout] key desc]";
+char *usage = "Usage: %s [-vh] [-c || [-u|-g|-r key] || -d || -l || [-t timeout] key desc]";
 
 #define MAX_ID_LEN   11
 #define IDMAP_NAMESZ 128
@@ -369,7 +369,7 @@ int main(int argc, char **argv)
 
 	xlog_open(progname);
 
-	while ((opt = getopt(argc, argv, "du:g:r:ct:vl")) != -1) {
+	while ((opt = getopt(argc, argv, "hdu:g:r:ct:vl")) != -1) {
 		switch (opt) {
 		case 'd':
 			display++;
@@ -398,9 +398,10 @@ int main(int argc, char **argv)
 		case 't':
 			timeout = atoi(optarg);
 			break;
+		case 'h':
 		default:
 			xlog_warn(usage, progname);
-			break;
+			exit(opt == 'h' ? 0 : 1);
 		}
 	}
 
utils/nfsidmap/nfsidmap.man +5 -0
index 0275bdf..2f17cf2 100644
@@ -15,6 +15,8 @@ nfsidmap \- The NFS idmapper upcall program
 .B "nfsidmap -d"
 .br
 .B "nfsidmap -l"
+.br
+.B "nfsidmap -h"
 .SH DESCRIPTION
 The NFSv4 protocol represents the local system's UID and GID values
 on the wire as strings of the form
@@ -71,6 +73,9 @@ Display the system's effective NFSv4 domain name on
 .B -g user
 Revoke the gid key of the given user.
 .TP
+.B -h
+Display usage message.
+.TP
 .B -l
 Display on
 .I stdout