Improve help/usage strings for iscsi-ls and iscsi-inq
For help output, also print the syntax for the iscsi url required.
This commit is contained in:
@@ -21,6 +21,14 @@
|
||||
struct iscsi_context;
|
||||
struct sockaddr;
|
||||
|
||||
/*
|
||||
* Syntax for normal and portal/discovery URLs.
|
||||
*/
|
||||
#define ISCSI_URL_SYNTAX "\"iscsi://[<username>[%<password>]@]" \
|
||||
"<host>[:<port>]/<target-iqn>/<lun>\""
|
||||
#define ISCSI_PORTAL_URL_SYNTAX "\"iscsi://[<username>[%<password>]@]" \
|
||||
"<host>[:<port>]\""
|
||||
|
||||
|
||||
/*
|
||||
* The following three functions are used to integrate libiscsi in an event
|
||||
|
||||
@@ -29,11 +29,6 @@
|
||||
#include "iscsi-private.h"
|
||||
#include "slist.h"
|
||||
|
||||
#define ISCSI_URL_SYNTAX "\"iscsi://[<username>[%<password>]@]" \
|
||||
"<host>[:<port>]/<target-iqn>/<lun>\""
|
||||
#define ISCSI_PURL_SYNTAX "\"iscsi://[<username>[%<password>]@]" \
|
||||
"<host>[:<port>]\""
|
||||
|
||||
struct iscsi_context *
|
||||
iscsi_create_context(const char *initiator_name)
|
||||
{
|
||||
@@ -431,7 +426,7 @@ iscsi_parse_portal_url(struct iscsi_context *iscsi, const char *url)
|
||||
iscsi_set_error(iscsi, "Invalid URL %s\niSCSI Portal URL must be of "
|
||||
"the form: %s",
|
||||
url,
|
||||
ISCSI_PURL_SYNTAX);
|
||||
ISCSI_PORTAL_URL_SYNTAX);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,30 @@ void do_inquiry(struct iscsi_context *iscsi, int lun, int evpd, int pc)
|
||||
}
|
||||
|
||||
|
||||
void print_usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: iscsi-inq [-?] [-?|--help] [--usage] [-i|--initiator-name=iqn-name]\n"
|
||||
"\t\t[-e|--evpd=integer] [-c|--pagecode=integer] <iscsi-url>\n");
|
||||
}
|
||||
|
||||
void print_help(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: iscsi-inq [OPTION...] <iscsi-url>\n");
|
||||
fprintf(stderr, " -i, --initiator-name=iqn-name Initiatorname to use\n");
|
||||
fprintf(stderr, " -e, --evpd=integer evpd\n");
|
||||
fprintf(stderr, " -c, --pagecode=integer page code\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Help options:\n");
|
||||
fprintf(stderr, " -?, --help Show this help message\n");
|
||||
fprintf(stderr, " --usage Display brief usage message\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "iSCSI URL format : %s\n", ISCSI_URL_SYNTAX);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "<host> is either of:\n");
|
||||
fprintf(stderr, " \"hostname\" iscsi.example\n");
|
||||
fprintf(stderr, " \"ipv4-address\" 10.1.1.27\n");
|
||||
fprintf(stderr, " \"ipv6-address\" [fce0::1]\n");
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
@@ -160,10 +184,12 @@ int main(int argc, const char *argv[])
|
||||
const char *url = NULL;
|
||||
struct iscsi_url *iscsi_url = NULL;
|
||||
int evpd = 0, pagecode = 0;
|
||||
int show_help = 0, show_usage = 0;
|
||||
int res;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
POPT_AUTOHELP
|
||||
{ "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL },
|
||||
{ "usage", 0, POPT_ARG_NONE, &show_usage, 0, "Display brief usage message", NULL },
|
||||
{ "initiator-name", 'i', POPT_ARG_STRING, &initiator, 0, "Initiatorname to use", "iqn-name" },
|
||||
{ "evpd", 'e', POPT_ARG_INT, &evpd, 0, "evpd", "integer" },
|
||||
{ "pagecode", 'c', POPT_ARG_INT, &pagecode, 0, "page code", "integer" },
|
||||
@@ -184,6 +210,17 @@ int main(int argc, const char *argv[])
|
||||
extra_argc++;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_help != 0) {
|
||||
print_help();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (show_usage != 0) {
|
||||
print_usage();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
poptFreeContext(pc);
|
||||
|
||||
iscsi = iscsi_create_context(initiator);
|
||||
@@ -194,8 +231,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
if (url == NULL) {
|
||||
fprintf(stderr, "You must specify the URL\n");
|
||||
fprintf(stderr, " iscsi://[<username>[%%<password>]@]<host>"
|
||||
"[:<port>]/<target-iqn>/<lun>\n");
|
||||
print_usage();
|
||||
exit(10);
|
||||
}
|
||||
iscsi_url = iscsi_parse_full_url(iscsi, url);
|
||||
|
||||
@@ -270,6 +270,29 @@ void discoveryconnect_cb(struct iscsi_context *iscsi, int status, void *command_
|
||||
}
|
||||
}
|
||||
|
||||
void print_usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: iscsi-ls [-?s] [-?|--help] [--usage] [-i|--initiator-name=iqn-name]\n"
|
||||
"\t\t[-s|--show-luns] <iscsi-portal-url>\n");
|
||||
}
|
||||
|
||||
void print_help(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: iscsi-ls [OPTION...] <iscsi-url>\n");
|
||||
fprintf(stderr, " -i, --initiator-name=iqn-name Initiatorname to use\n");
|
||||
fprintf(stderr, " -s, --show-luns Show the luns for each target\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Help options:\n");
|
||||
fprintf(stderr, " -?, --help Show this help message\n");
|
||||
fprintf(stderr, " --usage Display brief usage message\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "iSCSI Portal URL format : %s\n", ISCSI_PORTAL_URL_SYNTAX);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "<host> is either of:\n");
|
||||
fprintf(stderr, " \"hostname\" iscsi.example\n");
|
||||
fprintf(stderr, " \"ipv4-address\" 10.1.1.27\n");
|
||||
fprintf(stderr, " \"ipv6-address\" [fce0::1]\n");
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
@@ -281,9 +304,11 @@ int main(int argc, const char *argv[])
|
||||
const char *url = NULL;
|
||||
poptContext pc;
|
||||
int res;
|
||||
int show_help = 0, show_usage = 0;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
POPT_AUTOHELP
|
||||
{ "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL },
|
||||
{ "usage", 0, POPT_ARG_NONE, &show_usage, 0, "Display brief usage message", NULL },
|
||||
{ "initiator-name", 'i', POPT_ARG_STRING, &initiator, 0, "Initiatorname to use", "iqn-name" },
|
||||
{ "show-luns", 's', POPT_ARG_NONE, &showluns, 0, "Show the luns for each target", NULL },
|
||||
POPT_TABLEEND
|
||||
@@ -305,11 +330,23 @@ int main(int argc, const char *argv[])
|
||||
extra_argc++;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_help != 0) {
|
||||
print_help();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (show_usage != 0) {
|
||||
print_usage();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
poptFreeContext(pc);
|
||||
|
||||
|
||||
if (url == NULL) {
|
||||
fprintf(stderr, "You must specify iscsi target portal.\n");
|
||||
fprintf(stderr, "%s [options] iscsi://[<username>%%<password>@]<host>[:<port>]\n", argv[0]);
|
||||
print_usage();
|
||||
exit(10);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user