aboutsummaryrefslogtreecommitdiff
path: root/src/sg_rtpg.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-06-29 09:46:13 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-06-29 09:46:13 +0000
commit3ef8550a26c95c97f9fdc4ef249a5767fd573e7a (patch)
treeae1e82f2ff36a06a02184a3eeb19cffe217fcb2f /src/sg_rtpg.c
parent11f6f1f439415e57696f473b1475f190018741c7 (diff)
downloadsg3_utils-3ef8550a26c95c97f9fdc4ef249a5767fd573e7a.tar.gz
sg_opcode: support MLU, Multiple Logical Units (18-045r1); sg_lib: sg_simple_inquiry_pt(); ./configure: option --enable-debug added for testing
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@779 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_rtpg.c')
-rw-r--r--src/sg_rtpg.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/sg_rtpg.c b/src/sg_rtpg.c
index 2203c015..ab955987 100644
--- a/src/sg_rtpg.c
+++ b/src/sg_rtpg.c
@@ -31,7 +31,7 @@
* to the given SCSI device.
*/
-static const char * version_str = "1.26 20180513";
+static const char * version_str = "1.27 20180628";
#define REPORT_TGT_GRP_BUFF_LEN 1024
@@ -59,7 +59,9 @@ static struct option long_options[] = {
{0, 0, 0, 0},
};
-static void usage()
+
+static void
+usage()
{
pr2serr("Usage: sg_rtpg [--decode] [--extended] [--help] [--hex] "
"[--raw] [--readonly]\n"
@@ -78,7 +80,8 @@ static void usage()
}
-static void dStrRaw(const uint8_t * str, int len)
+static void
+dStrRaw(const uint8_t * str, int len)
{
int k;
@@ -86,7 +89,8 @@ static void dStrRaw(const uint8_t * str, int len)
printf("%c", str[k]);
}
-static void decode_status(const int st)
+static void
+decode_status(const int st)
{
switch (st) {
case STATUS_CODE_NOSTATUS:
@@ -106,7 +110,8 @@ static void decode_status(const int st)
}
}
-static void decode_tpgs_state(const int st)
+static void
+decode_tpgs_state(const int st)
{
switch (st) {
case TPGS_STATE_OPTIMIZED:
@@ -136,13 +141,16 @@ static void decode_tpgs_state(const int st)
}
}
-int main(int argc, char * argv[])
+int
+main(int argc, char * argv[])
{
bool decode = false;
- int hex = false;
+ bool hex = false;
bool raw = false;
bool o_readonly = false;
bool extended = false;
+ bool verbose_given = false;
+ bool version_given = false;
int k, j, off, res, c, report_len, tgt_port_count;
int sg_fd = -1;
int ret = 0;
@@ -180,11 +188,12 @@ int main(int argc, char * argv[])
o_readonly = true;
break;
case 'v':
+ verbose_given = true;
++verbose;
break;
case 'V':
- pr2serr("Version: %s\n", version_str);
- return 0;
+ version_given = true;
+ break;
default:
pr2serr("unrecognised option code 0x%x ??\n", c);
usage();
@@ -203,9 +212,28 @@ int main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
}
-
+#ifdef DEBUG
+ pr2serr("In DEBUG mode, ");
+ if (verbose_given && version_given) {
+ pr2serr("but override: '-vV' given, zero verbose and continue\n");
+ verbose_given = false;
+ version_given = false;
+ verbose = 0;
+ } else if (! verbose_given) {
+ pr2serr("set '-vv'\n");
+ verbose = 2;
+ } else
+ pr2serr("keep verbose=%d\n", verbose);
+#else
+ if (verbose_given && version_given)
+ pr2serr("Not in DEBUG mode, so '-vV' has no special action\n");
+#endif
+ if (version_given) {
+ pr2serr("Version: %s\n", version_str);
+ return 0;
+ }
if (NULL == device_name) {
- pr2serr("missing device name!\n");
+ pr2serr("Missing device name!\n\n");
usage();
return SG_LIB_SYNTAX_ERROR;
}