aboutsummaryrefslogtreecommitdiff
path: root/src/sg_rdac.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2017-10-22 17:32:39 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2017-10-22 17:32:39 +0000
commit9a9577a3b7f0b0c82ad0e77b9f16b3afa238322c (patch)
tree9d756acc6206a1dbc5c0777efc8ce6f6a3b9366b /src/sg_rdac.c
parent23712b6e6d5ee067cf7a740ef10e4dbea90dd179 (diff)
downloadsg3_utils-9a9577a3b7f0b0c82ad0e77b9f16b3afa238322c.tar.gz
sg_lib: add sg_ll_log_sense_v2(), sg_ll_mode_sense10_v2() and sg_ll_receive_diag_v2(); documentation cleanup; sg_ses: filter join output on dpage element presence (AES dpage)
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@722 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_rdac.c')
-rw-r--r--src/sg_rdac.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/sg_rdac.c b/src/sg_rdac.c
index 3003f5a6..79a2831d 100644
--- a/src/sg_rdac.c
+++ b/src/sg_rdac.c
@@ -29,7 +29,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "1.13 20171008";
+static const char * version_str = "1.14 20171021";
unsigned char mode6_hdr[] = {
0x75, /* Length */
@@ -243,7 +243,7 @@ static int fail_this_path(int fd, int lun, bool use_6_byte)
return res;
}
-static void print_rdac_mode( unsigned char *ptr, int subpg)
+static void print_rdac_mode(unsigned char *ptr, bool exp_subpg)
{
int i, k, bd_len, lun_table_len;
unsigned char * lun_table = NULL;
@@ -251,7 +251,7 @@ static void print_rdac_mode( unsigned char *ptr, int subpg)
struct rdac_expanded_page *expanded;
struct rdac_page_common *rdac_ptr = NULL;
- if (subpg == 1) {
+ if (exp_subpg) {
bd_len = ptr[7];
expanded = (struct rdac_expanded_page *)(ptr + 8 + bd_len);
rdac_ptr = &expanded->attr;
@@ -265,7 +265,7 @@ static void print_rdac_mode( unsigned char *ptr, int subpg)
lun_table_len = 32;
}
- printf("RDAC %s page\n", (subpg == 1) ? "Expanded" : "Legacy");
+ printf("RDAC %s page\n", exp_subpg ? "Expanded" : "Legacy");
printf(" Controller serial: %s\n",
rdac_ptr->current_serial);
printf(" Alternate controller serial: %s\n",
@@ -388,7 +388,7 @@ int main(int argc, char * argv[])
bool fail_all = false;
bool fail_path = false;
bool use_6_byte = false;
- int res, fd, k, lun = -1;
+ int res, fd, k, resid, len, lun = -1;
int ret = 0;
char **argptr;
char * file_name = 0;
@@ -447,6 +447,7 @@ int main(int argc, char * argv[])
} else if (fail_path) {
res = fail_this_path(fd, lun, use_6_byte);
} else {
+ resid = 0;
if (use_6_byte)
res = sg_ll_mode_sense6(fd, /* DBD */ false,
/* PC */ 0,
@@ -455,17 +456,26 @@ int main(int argc, char * argv[])
rsp_buff, 252,
true, do_verbose);
else
- res = sg_ll_mode_sense10(fd, /* llbaa */ false,
- /* DBD */ false,
- /* page control */0,
- 0x2c, 0x1 /* subpage */,
- rsp_buff, 308,
- true, do_verbose);
-
- if (!res) {
- if (do_verbose)
- dump_mode_page(rsp_buff, rsp_buff[0]);
- print_rdac_mode(rsp_buff, !use_6_byte);
+ res = sg_ll_mode_sense10_v2(fd, /* llbaa */ false,
+ /* DBD */ false,
+ /* page control */0,
+ 0x2c, 0x1 /* subpage */,
+ rsp_buff, 308, 0, &resid,
+ true, do_verbose);
+
+ if (! res) {
+ len = use_6_byte ? (rsp_buff[0] + 1) :
+ (sg_get_unaligned_be16(rsp_buff + 0) + 2);
+ if (resid > 0) {
+ len = ((308 - resid) < len) ? (308 - resid) :
+ len;
+ if (len < 2)
+ pr2serr("MS(10) residual value (%d) "
+ "a worry\n", resid);
+ }
+ if (do_verbose && (len > 1))
+ dump_mode_page(rsp_buff, len);
+ print_rdac_mode(rsp_buff, ! use_6_byte);
} else {
if (SG_LIB_CAT_INVALID_OP == res)
pr2serr(">>>>>> try again without the '-6' "