Skip to contentSkip to conversation

rpc.idmapd: Added a usage routine

PATCH In review Steve Dickson 1 participant 4 messages Dec 9, 2015 – Dec 12, 2015

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

PATCH 1/2 rpc.idmapd: Added a usage routine

Show the correct arguments when invalid
arguments are used.

---
 utils/idmapd/idmapd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
utils/idmapd/idmapd.c +10 -2
index 689608a..910b02e 100644
@@ -199,6 +199,12 @@ flush_nfsd_idmap_cache(void)
 	return ret;
 }
 
+void usage(char *progname)
+{
+	fprintf(stderr, "Usage: %s [-fvCS] [-p path] [-c path]\n",
+		basename(progname));
+}
+
 int
 main(int argc, char **argv)
 {
@@ -232,9 +238,11 @@ main(int argc, char **argv)
 			conf_path = optarg;
 		if (opt == '?') {
 			if (strchr(GETOPTSTR, optopt))
-				errx(1, "'-%c' option requires an argument.", optopt);
+				warnx("'-%c' option requires an argument.", optopt);
 			else
-				errx(1, "'-%c' is an invalid argument.", optopt);
+				warnx("'-%c' is an invalid argument.", optopt);
+			usage(progname);
+			exit(1);
 		}
 	}
 	optind = 1;
Signature · 1 line
2.4.3
#1 lore raw

PATCH 2/2 rpc.idmapd: Added the -C and -S flags

The C and S flags were missing for the SYNOPSIS

---
 utils/idmapd/idmapd.man | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
utils/idmapd/idmapd.man +3 -1
index c809f78..d45658e 100644
@@ -10,8 +10,10 @@
 .Sh SYNOPSIS
 .\" For a program:  program [-abc] file ...
 .Nm rpc.idmapd
-.Op Fl v
 .Op Fl f
+.Op Fl v
+.Op Fl C
+.Op Fl S
 .Op Fl p Ar path
 .Op Fl c Ar path
 .Sh DESCRIPTION
Signature · 1 line
2.4.3
#2 lore raw

Re: [PATCH 2/2] rpc.idmapd: Added the -C and -S flags

Quoted 3 lines · Steve Dickson

The C and S flags were missing for the SYNOPSIS

Committed....

steved.

Quoted 21 lines
---
 utils/idmapd/idmapd.man | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
utils/idmapd/idmapd.man +3 -1
index c809f78..d45658e 100644
@@ -10,8 +10,10 @@
 .Sh SYNOPSIS
 .\" For a program:  program [-abc] file ...
 .Nm rpc.idmapd
-.Op Fl v
 .Op Fl f
+.Op Fl v
+.Op Fl C
+.Op Fl S
 .Op Fl p Ar path
 .Op Fl c Ar path
 .Sh DESCRIPTION
#3 lore raw
In reply to Steve Dickson
Quoted 4 lines · Steve Dickson

Show the correct arguments when invalid
arguments are used.

Committed...

steved.

Quoted 36 lines
---
 utils/idmapd/idmapd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
utils/idmapd/idmapd.c +10 -2
index 689608a..910b02e 100644
@@ -199,6 +199,12 @@ flush_nfsd_idmap_cache(void)
 	return ret;
 }
 
+void usage(char *progname)
+{
+	fprintf(stderr, "Usage: %s [-fvCS] [-p path] [-c path]\n",
+		basename(progname));
+}
+
 int
 main(int argc, char **argv)
 {
@@ -232,9 +238,11 @@ main(int argc, char **argv)
 			conf_path = optarg;
 		if (opt == '?') {
 			if (strchr(GETOPTSTR, optopt))
-				errx(1, "'-%c' option requires an argument.", optopt);
+				warnx("'-%c' option requires an argument.", optopt);
 			else
-				errx(1, "'-%c' is an invalid argument.", optopt);
+				warnx("'-%c' is an invalid argument.", optopt);
+			usage(progname);
+			exit(1);
 		}
 	}
 	optind = 1;