tgtadm: Correct mode names in the option error message
PATCH 1/2 tgtadm: Correct mode names in the option error message
From: Zhang Yanfei <[email protected]>
When an error option is specified for some mode and operation, tgtadm outputs an error message which contains the mode name. But some of the mode names are obviously wrong so the patch fixes them.
--- usr/tgtadm.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
usr/tgtadm.c +8 -8
@@ -739,7 +739,7 @@ int main(int argc, char **argv)case OP_NEW : rc =verify_mode_params (argc, argv,"LmoupfC" );if (rc) { -eprintf ("logicalunit mode: option '-%c' is " +eprintf ("account mode: option '-%c' is " "not allowed/supported\n" , rc);exit (EINVAL ); }
@@ -752,7 +752,7 @@ int main(int argc, char **argv)case OP_SHOW : rc =verify_mode_params (argc, argv,"LmoC" );if (rc) { -eprintf ("target mode: option '-%c' is not " +eprintf ("account mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
@@ -760,7 +760,7 @@ int main(int argc, char **argv)case OP_DELETE : rc =verify_mode_params (argc, argv,"LmouC" );if (rc) { -eprintf ("target mode: option '-%c' is not " +eprintf ("account mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
@@ -768,7 +768,7 @@ int main(int argc, char **argv)case OP_BIND : rc =verify_mode_params (argc, argv,"LmotuOC" );if (rc) { -eprintf ("target mode: option '-%c' is not " +eprintf ("account mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
@@ -782,7 +782,7 @@ int main(int argc, char **argv)case OP_UNBIND : rc =verify_mode_params (argc, argv,"LmotuOC" );if (rc) { -eprintf ("target mode: option '-%c' is not " +eprintf ("account mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
@@ -817,7 +817,7 @@ int main(int argc, char **argv)case OP_NEW : rc =verify_mode_params (argc, argv,"LmofytlbEYCS" );if (rc) { -eprintf ("target mode: option '-%c' is not " +eprintf ("logicalunit mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
@@ -833,7 +833,7 @@ int main(int argc, char **argv)case OP_STATS : rc =verify_mode_params (argc, argv,"LmotlC" );if (rc) { -eprintf ("target mode: option '-%c' is not " +eprintf ("logicalunit mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
@@ -905,7 +905,7 @@ int main(int argc, char **argv)case OP_SHOW : rc =verify_mode_params (argc, argv,"LmoC" );if (rc) { -eprintf ("system mode: option '-%c' is not " +eprintf ("lld mode: option '-%c' is not " "allowed/supported\n" , rc);exit (EINVAL ); }
Signature · 1 line
1.7.1
PATCH 2/2 tgtadm: display unsupported operation name explicitly
From: Zhang Yanfei <[email protected]>
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'.
--- usr/tgtadm.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-)
usr/tgtadm.c +15 -11
@@ -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 ; }
Signature · 1 line
1.7.1
Quoted 11 lines · On Sat, 18 Jan 2014 13:27:15 +0800 Zhang Yanfei <[email protected]>…
From: Zhang Yanfei <[email protected]>
When an error option is specified for some mode and operation, tgtadm outputs an error message which contains the mode name. But some of the mode names are obviously wrong so the patch fixes them.
Signed-off-by Zhang Yanfei <[email protected]>--- usr/tgtadm.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
Both look good. Applied, thanks!