From patchwork Thu Dec 6 17:02:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 204289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "aserp1040.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1BDFC2C0134 for ; Fri, 7 Dec 2012 04:02:27 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qB6H2O0S003943 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 6 Dec 2012 17:02:25 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qB6H2Otl018791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Dec 2012 17:02:24 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tgeq8-0000uD-8q; Thu, 06 Dec 2012 09:02:24 -0800 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tgeq6-0000tz-5r for fedfs-utils-devel@oss.oracle.com; Thu, 06 Dec 2012 09:02:22 -0800 Received: from acsinet12.oracle.com (acsinet12.oracle.com [141.146.126.234]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qB6H2LCM027183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Dec 2012 17:02:22 GMT Received: from mail-ia0-f175.google.com (mail-ia0-f175.google.com [209.85.210.175]) by acsinet12.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qB6H2H1f013575 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 6 Dec 2012 17:02:21 GMT Received: by mail-ia0-f175.google.com with SMTP id z3so5029819iad.6 for ; Thu, 06 Dec 2012 09:02:17 -0800 (PST) Received: by 10.50.36.198 with SMTP id s6mr2205388igj.23.1354813337244; Thu, 06 Dec 2012 09:02:17 -0800 (PST) Received: from seurat.1015granger.net ([99.26.161.222]) by mx.google.com with ESMTPS id xn10sm15923064igb.4.2012.12.06.09.02.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Dec 2012 09:02:16 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Thu, 06 Dec 2012 12:02:15 -0500 Message-ID: <20121206170215.5988.50231.stgit@seurat.1015granger.net> In-Reply-To: <20121206165049.5988.56806.stgit@seurat.1015granger.net> References: <20121206165049.5988.56806.stgit@seurat.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=Default reputation=ipRepBelow100 ip=209.85.210.175 ct-class=R5 ct-vol1=0 ct-vol2=8 ct-vol3=7 ct-risk=48 ct-spam1=75 ct-spam2=7 ct-bulk=6 rcpts=1 size=6857 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090202.50C0CF9D.0098,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 3/3] nfsref: "nfsref SUBCOMMAND -?" should display useful information X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] 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 --- 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(-) diff --git a/src/nfsref/add.c b/src/nfsref/add.c index e0e347f..ce7f813 100644 --- a/src/nfsref/add.c +++ b/src/nfsref/add.c @@ -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 " + " [ ... ]\n\n", + progname); + + fprintf(stderr, "Add a new junction containing the specified list " + "of fileset locations.\n"); + fprintf(stderr, " is the filename of the new junction. " + " is the hostname\n"); + fprintf(stderr, "or IP address of an NFS server where the fileset is " + "located. 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 diff --git a/src/nfsref/lookup.c b/src/nfsref/lookup.c index ef4a87d..96454fd 100644 --- a/src/nfsref/lookup.c +++ b/src/nfsref/lookup.c @@ -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 \n\n", + progname); + + fprintf(stderr, "Display the contents of the junction at " + ". 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 diff --git a/src/nfsref/nfsref.c b/src/nfsref/nfsref.c index be05bda..ef7c5a7 100644 --- a/src/nfsref/nfsref.c +++ b/src/nfsref/nfsref.c @@ -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); } diff --git a/src/nfsref/nfsref.h b/src/nfsref/nfsref.h index 8e40fd9..e9dd9ae 100644 --- a/src/nfsref/nfsref.h +++ b/src/nfsref/nfsref.h @@ -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 */ diff --git a/src/nfsref/remove.c b/src/nfsref/remove.c index 7dd5997..7bee9de 100644 --- a/src/nfsref/remove.c +++ b/src/nfsref/remove.c @@ -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 \n\n", + progname); + + fprintf(stderr, "Remove the junction at . 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 * *