All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Yanfei <zhangyanfei.yes@gmail.com>
To: fujita.tomonori@lab.ntt.co.jp
Cc: stgt@vger.kernel.org, Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Subject: [PATCH 2/2] tgtadm: display unsupported operation name explicitly
Date: Sat, 18 Jan 2014 13:28:38 +0800	[thread overview]
Message-ID: <52DA1106.5050008@gmail.com> (raw)
In-Reply-To: <52DA10B3.7010309@gmail.com>

From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>

When we specify an unsupported operation type for some mode,
tgtadm will display the error message which contains the
unsupported operation type value. The patch changes to
display the operation name which is more explicit. Also
change the word 'option' to 'operation'.

Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
---
 usr/tgtadm.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index d708a65..cc63fbf 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -493,6 +493,7 @@ int main(int argc, char **argv)
 	char *user, *password;
 	struct tgtadm_req adm_req = {0}, *req = &adm_req;
 	struct concat_buf b;
+	char *op_name;
 
 	op = tid = mode = -1;
 	cid = hostno = sid = 0;
@@ -503,7 +504,7 @@ int main(int argc, char **argv)
 	ac_dir = ACCOUNT_TYPE_INCOMING;
 	name = value = path = targetname = address = iqnname = NULL;
 	targetOps = portalOps = bstype = bsopts = NULL;
-	bsoflags = blocksize = user = password = NULL;
+	bsoflags = blocksize = user = password = op_name = NULL;
 	force = 0;
 
 	optind = 1;
@@ -516,6 +517,7 @@ int main(int argc, char **argv)
 			break;
 		case 'o':
 			op = str_to_op(optarg);
+			op_name = optarg;
 			break;
 		case 'm':
 			mode = str_to_mode(optarg);
@@ -653,7 +655,8 @@ int main(int argc, char **argv)
 		case OP_STATS:
 			break;
 		default:
-			eprintf("option %d not supported in system mode\n", op);
+			eprintf("operation %s not supported in system mode\n",
+				op_name);
 			exit(EINVAL);
 			break;
 		}
@@ -709,8 +712,8 @@ int main(int argc, char **argv)
 			}
 			if (!address && !iqnname && !hostno) {
 				eprintf("%s operation requires"
-					" initiator-address, initiator-name or bus\n",
-					op == OP_BIND ? "bind" : "unbind");
+					" initiator-address, initiator-name"
+					"or bus\n", op_name);
 				exit(EINVAL);
 			}
 			break;
@@ -728,7 +731,8 @@ int main(int argc, char **argv)
 			}
 			break;
 		default:
-			eprintf("option %d not supported in target mode\n", op);
+			eprintf("operation %s not supported in target mode\n",
+				op_name);
 			exit(EINVAL);
 			break;
 		}
@@ -794,8 +798,8 @@ int main(int argc, char **argv)
 				tid = GLOBAL_TID;
 			break;
 		default:
-			eprintf("option %d not supported in account mode\n",
-				op);
+			eprintf("operation %s not supported in account mode\n",
+				op_name);
 			exit(EINVAL);
 			break;
 		}
@@ -847,8 +851,8 @@ int main(int argc, char **argv)
 			}
 			break;
 		default:
-			eprintf("option %d not supported in "
-				"logicalunit mode\n", op);
+			eprintf("operation %s not supported in "
+				"logicalunit mode\n", op_name);
 			exit(EINVAL);
 			break;
 		}
@@ -891,8 +895,8 @@ int main(int argc, char **argv)
 			}
 			break;
 		default:
-			eprintf("option %d not supported in "
-					"portal mode\n", op);
+			eprintf("operation %s not supported in portal mode\n",
+				op_name);
 			exit(EINVAL);
 			break;
 		}
-- 
1.7.1

  reply	other threads:[~2014-01-18  5:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-18  5:27 [PATCH 1/2] tgtadm: Correct mode names in the option error message Zhang Yanfei
2014-01-18  5:28 ` Zhang Yanfei [this message]
2014-01-18  6:22 ` FUJITA Tomonori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52DA1106.5050008@gmail.com \
    --to=zhangyanfei.yes@gmail.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=stgt@vger.kernel.org \
    --cc=zhangyanfei@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.