@@ -39,6 +39,7 @@
#include "junction.h"
#include "nsdb.h"
#include "xlog.h"
+#include "gpl-boiler.h"
#include "nfsref.h"
/**
@@ -47,6 +48,39 @@
#define FSN_DEFAULT_TTL (300)
/**
+ * Display help message for "add" subcommand
+ *
+ * @param progname NUL-terminated C string containing name of program
+ * @return program exit status
+ */
+int
+nfsref_add_help(const char *progname)
+{
+ fprintf(stderr, " \n");
+
+ fprintf(stderr, "Usage: %s [ -t type ] add <junction path> "
+ "<server> <export> [ <server> <export> ... ]\n\n",
+ progname);
+
+ fprintf(stderr, "Add a new junction containing the specified list "
+ "of fileset locations.\n");
+ fprintf(stderr, "<junction path> is the filename of the new junction. "
+ "<server> is the hostname\n");
+ fprintf(stderr, "or IP address of an NFS server where the fileset is "
+ "located. <export> is the\n");
+ fprintf(stderr, "export pathname of the fileset on that server.\n\n");
+
+ fprintf(stderr, "For NFS basic junctions, the location list is stored "
+ "locally in the junction.\n");
+ fprintf(stderr, "For FedFS junctions, the location list is stored "
+ "as new FSN and FSL records\n");
+ fprintf(stderr, "on an NSDB.\n");
+
+ fprintf(stderr, "%s", fedfs_gpl_boilerplate);
+ return EXIT_SUCCESS;
+}
+
+/**
* Fill in default settings for NFSv4.0 fs_locations4
*
* @param new NFS location structure to fill in
@@ -32,9 +32,35 @@
#include "junction.h"
#include "nsdb.h"
#include "xlog.h"
+#include "gpl-boiler.h"
#include "nfsref.h"
/**
+ * Display help message for "lookup" subcommand
+ *
+ * @param progname NUL-terminated C string containing name of program
+ * @return program exit status
+ */
+int
+nfsref_lookup_help(const char *progname)
+{
+ fprintf(stderr, " \n");
+
+ fprintf(stderr, "Usage: %s [ -t type ] lookup <junction path>\n\n",
+ progname);
+
+ fprintf(stderr, "Display the contents of the junction at "
+ "<junction path>. For NFS basic\n");
+ fprintf(stderr, "junctions, the local contents of the junction "
+ "are displayed. For FedFS\n");
+ fprintf(stderr, "junctions, FSL records are retrieved from the "
+ "NSDB and displayed.\n");
+
+ fprintf(stderr, "%s", fedfs_gpl_boilerplate);
+ return EXIT_SUCCESS;
+}
+
+/**
* Convert a boolean value into a displayable string constant
*
* @param value boolean value
@@ -97,6 +97,7 @@ main(int argc, char **argv)
char *progname, *subcommand, *junct_path;
enum nfsref_type type;
int arg, exit_status;
+ _Bool help;
(void)umask(S_IWGRP | S_IWOTH);
@@ -124,6 +125,7 @@ main(int argc, char **argv)
goto out;
}
+ help = false;
type = NFSREF_TYPE_UNSPECIFIED;
while ((arg = getopt_long(argc, argv, nfsref_opts,
nfsref_longopts, NULL)) != -1) {
@@ -144,17 +146,16 @@ main(int argc, char **argv)
}
break;
case '?':
- nfsref_usage(progname);
- exit(EXIT_SUCCESS);
+ help = true;
}
}
- if (argc < optind + 2) {
- fprintf(stderr, "Not enough positional parameters\n");
+
+ if (argc < optind + 1) {
nfsref_usage(progname);
goto out;
}
- if (geteuid() != 0) {
+ if (!help && geteuid() != 0) {
fprintf(stderr, "Root permission is required\n");
goto out;
}
@@ -163,6 +164,10 @@ main(int argc, char **argv)
junct_path = argv[optind + 1];
if (strcasecmp(subcommand, "add") == 0) {
+ if (help) {
+ exit_status = nfsref_add_help(progname);
+ goto out;
+ }
if (argc < optind + 3) {
fprintf(stderr, "Not enough positional parameters\n");
nfsref_usage(progname);
@@ -172,12 +177,20 @@ main(int argc, char **argv)
if (exit_status == EXIT_SUCCESS)
(void)junction_flush_exports_cache();
} else if (strcasecmp(subcommand, "remove") == 0) {
+ if (help) {
+ exit_status = nfsref_remove_help(progname);
+ goto out;
+ }
exit_status = nfsref_remove(type, junct_path);
if (exit_status == EXIT_SUCCESS)
(void)junction_flush_exports_cache();
- } else if (strcasecmp(subcommand, "lookup") == 0)
+ } else if (strcasecmp(subcommand, "lookup") == 0) {
+ if (help) {
+ exit_status = nfsref_lookup_help(progname);
+ goto out;
+ }
exit_status = nfsref_lookup(type, junct_path);
- else {
+ } else {
xlog(L_ERROR, "Unrecognized subcommand: %s", subcommand);
nfsref_usage(progname);
}
@@ -40,4 +40,8 @@ int nfsref_add(enum nfsref_type type, const char *junct_path, char **argv,
int nfsref_remove(enum nfsref_type type, const char *junct_path);
int nfsref_lookup(enum nfsref_type type, const char *junct_path);
+int nfsref_add_help(const char *progname);
+int nfsref_remove_help(const char *progname);
+int nfsref_lookup_help(const char *progname);
+
#endif /* !FEDFS_NFSREF_H */
@@ -34,9 +34,32 @@
#include "fedfs.h"
#include "junction.h"
#include "xlog.h"
+#include "gpl-boiler.h"
#include "nfsref.h"
/**
+ * Display help message for "remove" subcommand
+ *
+ * @param progname NUL-terminated C string containing name of program
+ * @return program exit status
+ */
+int
+nfsref_remove_help(const char *progname)
+{
+ fprintf(stderr, " \n");
+
+ fprintf(stderr, "Usage: %s [ -t type ] remove <junction path>\n\n",
+ progname);
+
+ fprintf(stderr, "Remove the junction at <junction path>. For FedFS "
+ "junctions, FSL and FSN\n");
+ fprintf(stderr, "records are removed from the NSDB.\n");
+
+ fprintf(stderr, "%s", fedfs_gpl_boilerplate);
+ return EXIT_SUCCESS;
+}
+
+/**
* Remove any NFS junction information
*
*
The usage message of the "nfsref" command says that more information is available from invoking "nfsref SUBCOMMAND ?", but this currently produces just the same usage message. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- src/nfsref/add.c | 34 ++++++++++++++++++++++++++++++++++ src/nfsref/lookup.c | 26 ++++++++++++++++++++++++++ src/nfsref/nfsref.c | 27 ++++++++++++++++++++------- src/nfsref/nfsref.h | 4 ++++ src/nfsref/remove.c | 23 +++++++++++++++++++++++ 5 files changed, 107 insertions(+), 7 deletions(-)