diff --git a/lsscsi.c b/lsscsi.c index 0db0587..067004a 100644 --- a/lsscsi.c +++ b/lsscsi.c @@ -86,6 +86,7 @@ struct lsscsi_opt_coll { int transport; int verbose; int protection; /* data integrity */ + int protmode; /* data integrity */ int size; }; @@ -140,6 +141,7 @@ static struct option long_options[] = { {"list", 0, 0, 'L'}, /* {"name", 0, 0, 'n'}, */ {"protection", 0, 0, 'p'}, + {"protmode", 0, 0, 'P'}, {"size", 0, 0, 's'}, {"sysfsroot", 1, 0, 'y'}, {"transport", 0, 0, 't'}, @@ -273,7 +275,8 @@ static const char * usage_message = " --list|-L additional information output one\n" " attribute=value per line\n" " --long|-l additional information output\n" -" --protection|-p show data integrity (protection) information\n" +" --protection|-p show target and initiator protection information\n" +" --protmode|-P show negotiated protection information mode\n" " --size|-s show disk size\n" " --sysfsroot=PATH|-y PATH set sysfs mount point to PATH (def: /sys)\n" " --transport|-t transport information for target or, if '--hosts'\n" @@ -2185,24 +2188,24 @@ one_sdev_entry(const char * dir_name, const char * devname, if (if_directory_chdir(buff,aa_sd.name)) { char value[NAME_LEN_MAX]; char sddir[NAME_LEN_MAX]; - strncpy(sddir,buff,NAME_LEN_MAX); + strncpy(sddir, buff, NAME_LEN_MAX); strcat(sddir,"/"); - strcat(sddir,aa_sd.name); - if (!get_value(sddir, "protection_type", value, + strcat(sddir, aa_sd.name); + if (!get_value(sddir, "protection_type", value, NAME_LEN_MAX)) { /* kernel < 2.6.27 */ if (opts->verbose) - printf(" No Data Integrity " - "Support\n"); + printf("No Data Integrity " + "Support\n"); } else { kernel_dif_support = 1; if (strncmp(value, "0", 1)) - printf(" DIF/Type%1s ",value); + printf(" DIF/Type%1s ", value); else - printf(" - "); + printf(" - "); } } else { - printf(" - "); + printf(" - "); } } @@ -2230,6 +2233,31 @@ one_sdev_entry(const char * dir_name, const char * devname, } } + if (opts->protmode) { + if (sd_scan(buff,opts)) { + if (if_directory_chdir(buff,aa_sd.name)) { + char value[NAME_LEN_MAX]; + char sddir[NAME_LEN_MAX]; + strncpy(sddir, buff, NAME_LEN_MAX); + strcat(sddir, "/"); + strcat(sddir, aa_sd.name); + if (!get_value(sddir, "protection_mode", value, + NAME_LEN_MAX)) { + /* kernel < 2.6.37 */ + if (opts->verbose) + printf("Kernel too old\n"); + } else { + if (!strcmp(value, "none")) + printf(" %-4s ", "-"); + else + printf(" %-4s ", value); + } + } else { + printf(" - "); + } + } + } + if (opts->size && block_scan(buff, opts) && if_directory_chdir(buff, aa_block.name)) { char value[NAME_LEN_MAX]; @@ -2697,7 +2725,7 @@ main(int argc, char **argv) while (1) { int option_index = 0; - c = getopt_long(argc, argv, "cdghHklLpstvVy:", long_options, + c = getopt_long(argc, argv, "cdghHklLpPstvVy:", long_options, &option_index); if (c == -1) break; @@ -2730,6 +2758,9 @@ main(int argc, char **argv) case 'p': ++opts.protection; break; + case 'P': + ++opts.protmode; + break; case 's': ++opts.size; break;