aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_luns.877
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in24
-rw-r--r--src/sg_luns.c55
8 files changed, 104 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index 13b8cf72..72fb0e81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.39 [20140606] [svn: r586]
+Changelog for sg3_utils-1.39 [20140608] [svn: r587]
- sg_rep_zones: new utility for ZBC REPORT ZONES
- sg_reset_wp: new utility, ZBC RESET WRITE POINTER
- sg_ses: add --eiioe=auto|force option
@@ -23,7 +23,7 @@ Changelog for sg3_utils-1.39 [20140606] [svn: r586]
when --verbose is given
- add new SCSI_IDENT_*_ATA pair to --export output
- sg_luns: add decoding for conglomerate LUNS
- - add --lu_cong option for test mode
+ - add --lu_cong option to simulate the LU_CONG bit
- sg_vpd: add --vendor=VP option, re-order vendor
specific pages, split lto into lto5 and lto6
- add Supported block lengths and protection types
diff --git a/README b/README
index 240bd0ce..29e775f6 100644
--- a/README
+++ b/README
@@ -403,4 +403,4 @@ See http://sg.danny.cz/sg/tools.html
Douglas Gilbert
-17th May 2014
+8th June 2014
diff --git a/debian/changelog b/debian/changelog
index 6f7481fc..0635ca6f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.39-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Sat, 17 May 2014 01:00:00 +0200
+ -- Douglas Gilbert <dgilbert@interlog.com> Sun, 08 June 2014 13:00:00 -0400
sg3-utils (1.38-0.1) unstable; urgency=low
diff --git a/doc/sg_luns.8 b/doc/sg_luns.8
index 0ab74642..e383a750 100644
--- a/doc/sg_luns.8
+++ b/doc/sg_luns.8
@@ -9,7 +9,7 @@ sg_luns \- send SCSI REPORT LUNS command or decode given LUN
[\fI\-\-version\fR] \fIDEVICE\fR
.PP
.B sg_luns
-\fI\-\-test=ALUN\fR [\fI\-\-hex\fR] [\fI\-\-verbose\fR]
+\fI\-\-test=ALUN\fR [\fI\-\-hex\fR] [\fI\-\-lu_cong\fR] [\fI\-\-verbose\fR]
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -41,8 +41,7 @@ output the usage message then exit.
response (i.e. the data\-out buffer) to the REPORT LUNS command in ASCII
hex then exit. When given twice it causes \fI\-\-decode\fR to output
component fields in hex rather than decimal.
-.TP
-\fB\-H\fR, \fB\-\-hex\fR
+.br
[test mode] when this option is given, then decoded component fields of
\fIALUN\fR are output in hex.
.TP
@@ -54,9 +53,18 @@ If the \fI\-\-hex\fR option is given twice (e.g. \-HH) as well then the
Linux LUN integer is output in hexadecimal.
.TP
\fB\-L\fR, \fB\-\-lu_cong\fR
+this option is only considered with \fI\-\-decode\fR. When given once
+then the list of LUNs is decoded as if the LU_CONG bit was set in
+each LU's coresponding INQUIRY response. When given twice the list of
+LUNs is decoded as if the LU_CONG bit was clear in each LU's coresponding
+INQUIRY response. When this option is not given and \fI\-\-decode\fR is
+given then an INQUIRY is sent to the \fIDEVICE\fR and the setting of
+its LU_CONG bit is used to decode the list of LUNs.
+.br
[test mode] decode \fIALUN\fR as if the LU_CONG bit is set in its
corresponding standard INQUIRY response. In other words treat \fIALUN\fR
-as if it is a conglomerate LUN.
+as if it is a conglomerate LUN. If not given (or given twice) then decode
+\fIALUN\fR as if the LU_CONG bit is clear.
.TP
\fB\-m\fR, \fB\-\-maxlen\fR=\fILEN\fR
where \fILEN\fR is the (maximum) response length in bytes. It is placed in
@@ -76,30 +84,31 @@ open the \fIDEVICE\fR read\-only (e.g. in Unix with the O_RDONLY flag).
The default is to open it read\-write.
.TP
\fB\-s\fR, \fB\-\-select\fR=\fISR\fR
-this option sets the SELECT REPORT field (\fISR\fR) in the SCSI REPORT
-LUNS command. The default value is 0. Hexadecimal values may be given with
+\fISR\fR is placed in the SELECT REPORT field of the SCSI REPORT LUNS
+command. The default value is 0. Hexadecimal values may be given with
a leading "0x" or a trailing "h". For detailed information see the
REPORT LUNS command in SPC (most recent is SPC\-4 revision 37 in section
6.33). To simplify, for the I_T nexus associated with the \fIDEVICE\fR, the
meanings of the \fISR\fR values defined to date for SPC\-4 are:
.br
- \fB0\fR : most LUs excluding well known logical units
+ \fB0\fR : most luns excluding well known logical unit numbers
.br
- \fB1\fR : well known logical units
+ \fB1\fR : well known logical unit numbers
.br
- \fB2\fR : all LUs accessible to this I_T nexus
+ \fB2\fR : all luns accessible to this I_T nexus
.br
- \fB0x10\fR : only accessible administrative LUs
+ \fB0x10\fR : only accessible administrative luns
.br
- \fB0x11\fR : administrative LUs and associated LUs (see SPC\-4)
+ \fB0x11\fR : administrative luns plus non-conglomerate luns (see SPC\-4)
.br
- \fB0x12\fR : if the addressed LU is administrative, then reports its
+ \fB0x12\fR : if \fIDEVICE\fR is an administrative LU, then report its
.br
- subsidiary LUs
-.br
-Values between 0xf8 and 0xff (inclusive) are vendor specific (added
-SPC\-4 rev 36e), other values greater than 2 are reserved. This utility
-will accept any value between 0 and 255 (0xff) for \fISR\fR .
+ lun plus its subsidiary luns
+.PP
+For \fISR\fR values 0x10 and 0x11, the \fIDEVICE\fR must be either LUN 0 or
+the REPORT LUNS well known logical unit. Values between 0xf8 and
+0xff (inclusive) are vendor specific, other values are reserved. This
+utility will accept any value between 0 and 255 (0xff) for \fISR\fR .
.TP
\fB\-t\fR, \fB\-\-test\fR=\fIALUN\fR
\fIALUN\fR is assumed to be a hexadecimal number in ASCII hex or the
@@ -151,24 +160,30 @@ two LUNS: 1 and 49409. If 49409 is converted into T10 LUN format it is
.br
[6:0:0:1] disk Linux scsi_debug 0004 /dev/sdb /dev/sg1
.br
- [6:0:0:49409]wlun Linux scsi_debug 0004 \- /dev/sg2
+ [6:0:0:2] disk Linux scsi_debug 0004 /dev/sdc /dev/sg2
+.br
+ [6:0:0:49409]wlun Linux scsi_debug 0004 \- /dev/sg3
.PP
-We could send a REPORT LUNS command to either /dev/sdb, /dev/sg1 or
-/dev/sg2 and get the same result. Below we use /dev/sg1 :
+We could send a REPORT LUNS command (with \fISR\fR 0x0, 0x1 or 0x2) to any
+of those file device nodes and get the same result. Below we use /dev/sg1 :
.PP
# sg_luns /dev/sg1
.br
- Lun list length = 8 which imples 1 lun entry
+ Lun list length = 16 which imples 2 lun entry
.br
Report luns [select_report=0x0]:
.br
0001000000000000
+.br
+ 0002000000000000
.PP
That is a bit noisy so cut down the clutter with \fI\-\-quiet\fR:
.PP
# sg_luns \-q /dev/sg1
.br
0001000000000000
+.br
+ 0002000000000000
.PP
Now decode that LUN into its component parts:
.PP
@@ -177,15 +192,11 @@ Now decode that LUN into its component parts:
0001000000000000
.br
Peripheral device addressing: lun=1
-.PP
-Would like to see how wide that component LUN field is:
- # sg_luns \-d \-q \-HH /dev/sg1
.br
- 0001000000000000
+ 0002000000000000
.br
- Peripheral device addressing: lun=0x01
+ Peripheral device addressing: lun=2
.PP
-So it is 8 bits wide (actually between 5 and 8 bits wide, inclusive).
Now use \fI\-\-select=1\fR to find out if there are any well known
LUNs:
.PP
@@ -200,6 +211,8 @@ I_T Nexus):
.br
0001000000000000
.br
+ 0002000000000000
+.br
c101000000000000
.PP
# sg_luns \-q \-s 2 \-d /dev/sg1
@@ -208,6 +221,10 @@ I_T Nexus):
.br
Peripheral device addressing: lun=1
.br
+ 0002000000000000
+.br
+ Peripheral device addressing: lun=1
+.br
c101000000000000
.br
REPORT LUNS well known logical unit
@@ -220,16 +237,18 @@ Linux version of T10 LUN shown at the start of the line.
.br
0001000000000000 [1]
.br
+ 0002000000000000 [2]
+.br
c101000000000000 [49409]
.PP
Now we use the \fI\-\-test=\fR option to decode LUNS input on the command
line (rather than send a REPORT LUNS command and act on the response):
.PP
- # sg_luns \-\-test=0001000000000000
+ # sg_luns \-\-test=0002000000000000
.br
Decoded LUN:
.br
- Peripheral device addressing: lun=1
+ Peripheral device addressing: lun=2
.PP
# sg_luns \-\-test="c1 01"
.br
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 975532d3..7e3894ba 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sat May 17 2014 - dgilbert at interlog dot com
+* Sun June 08 2014 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.39
diff --git a/src/Makefile.am b/src/Makefile.am
index 50b1fa3b..483c7724 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -78,7 +78,7 @@ if OS_FREEBSD
bin_PROGRAMS = \
sg_compare_and_write sg_decode_sense sg_format sg_get_config \
sg_get_lba_status sg_ident sg_inq sg_logs sg_luns sg_modes \
- sg_opcodes sg_persist sg_prevent sg_raw sg_rdac sg_readcap
+ sg_opcodes sg_persist sg_prevent sg_raw sg_rdac sg_readcap \
sg_read_block_limits sg_read_buffer sg_read_long sg_reassign \
sg_referrals sg_rep_zones sg_requests sg_reset_wp sg_rmsn \
sg_rtpg sg_safte sg_sanitize sg_sat_identify sg_sat_phy_event \
diff --git a/src/Makefile.in b/src/Makefile.in
index 0c496526..cad4f2e1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -322,7 +322,23 @@ host_triplet = @host@
@OS_FREEBSD_TRUE@ sg_luns$(EXEEXT) sg_modes$(EXEEXT) \
@OS_FREEBSD_TRUE@ sg_opcodes$(EXEEXT) sg_persist$(EXEEXT) \
@OS_FREEBSD_TRUE@ sg_prevent$(EXEEXT) sg_raw$(EXEEXT) \
-@OS_FREEBSD_TRUE@ sg_rdac$(EXEEXT) sg_readcap$(EXEEXT)
+@OS_FREEBSD_TRUE@ sg_rdac$(EXEEXT) sg_readcap$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_read_block_limits$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_read_buffer$(EXEEXT) sg_read_long$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_reassign$(EXEEXT) sg_referrals$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_rep_zones$(EXEEXT) sg_requests$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_reset_wp$(EXEEXT) sg_rmsn$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_rtpg$(EXEEXT) sg_safte$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_sanitize$(EXEEXT) sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_sat_phy_event$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_sat_set_features$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_senddiag$(EXEEXT) sg_ses$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_start$(EXEEXT) sg_stpg$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_sync$(EXEEXT) sg_turs$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_unmap$(EXEEXT) sg_verify$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_vpd$(EXEEXT) sg_write_buffer$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_write_long$(EXEEXT) sg_write_same$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_wr_mode$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
@@ -1497,12 +1513,6 @@ uninstall-am: uninstall-binPROGRAMS
@OS_WIN32_CYGWIN_TRUE@sg_scan.c : sg_scan.c.win32
@OS_WIN32_CYGWIN_TRUE@ cp sg_scan.c.win32 sg_scan.c
-@OS_FREEBSD_TRUE@ sg_read_block_limits sg_read_buffer sg_read_long sg_reassign \
-@OS_FREEBSD_TRUE@ sg_referrals sg_rep_zones sg_requests sg_reset_wp sg_rmsn \
-@OS_FREEBSD_TRUE@ sg_rtpg sg_safte sg_sanitize sg_sat_identify sg_sat_phy_event \
-@OS_FREEBSD_TRUE@ sg_sat_set_features sg_senddiag sg_ses sg_start sg_stpg sg_sync \
-@OS_FREEBSD_TRUE@ sg_turs sg_unmap sg_verify sg_vpd sg_write_buffer sg_write_long \
-@OS_FREEBSD_TRUE@ sg_write_same sg_wr_mode
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/sg_luns.c b/src/sg_luns.c
index 9e5c1c0d..91ac7e9a 100644
--- a/src/sg_luns.c
+++ b/src/sg_luns.c
@@ -29,7 +29,7 @@
* and decodes the response.
*/
-static const char * version_str = "1.26 20140606";
+static const char * version_str = "1.27 20140607";
#define MAX_RLUNS_BUFF_LEN (1024 * 1024)
#define DEF_RLUNS_BUFF_LEN (1024 * 8)
@@ -80,17 +80,18 @@ usage()
#ifdef SG_LIB_LINUX
pr2serr("Usage: "
"sg_luns [--decode] [--help] [--hex] [--linux] "
+ "[--lu_cong]\n"
+ " [--maxlen=LEN] [--quiet] [--raw] "
+ "[--readonly]\n"
+ " [--select=SR] [--verbose] [--version] "
+ "DEVICE\n");
+#else
+ pr2serr("Usage: "
+ "sg_luns [--decode] [--help] [--hex] [--lu_cong] "
"[--maxlen=LEN]\n"
" [--quiet] [--raw] [--readonly] "
"[--select=SR]\n"
" [--verbose] [--version] DEVICE\n");
-#else
- pr2serr("Usage: "
- "sg_luns [--decode] [--help] [--hex] [--maxlen=LEN] "
- "[--quiet]\n"
- " [--raw] [--readonly] [--select=SR] "
- "[--verbose]\n"
- " [--version] DEVICE\n");
#endif
pr2serr(" or\n"
" sg_luns --test=ALUN [--hex] [--lu_cong] [--verbose]\n"
@@ -104,7 +105,9 @@ usage()
pr2serr(" --linux|-l show Linux integer lun after T10 "
"representation\n");
#endif
- pr2serr(" --lu_cong decode ALUN as if LU_CONG is set\n"
+ pr2serr(" --lu_cong decode as if LU_CONG is set; used "
+ "twice:\n"
+ " decode as if LU_CONG is clear\n"
" --maxlen=LEN|-m LEN max response length (allocation "
"length in cdb)\n"
" (def: 0 -> %d bytes)\n"
@@ -117,15 +120,22 @@ usage()
" 1 -> only 'well known' "
"logical unit numbers\n"
" 2 -> all luns\n"
- " spc4r36 added 0x10, 0x11 and 0x12\n"
+ " 0x10 -> administrative luns\n"
+ " 0x11 -> admin luns + "
+ "non-conglomerate luns\n"
+ " 0x12 -> admin lun + its "
+ "subsidiary luns\n"
" --test=ALUN|-t ALUN decode ALUN and ignore most other "
"options\n"
" and DEVICE (apart from '-H')\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
- "Performs a SCSI REPORT LUNS command. When the --test=ALUN "
- "option is\ngiven, decodes ALUN rather than sending a "
- "REPORT LUNS command.\n", DEF_RLUNS_BUFF_LEN );
+ "Performs a SCSI REPORT LUNS command or decodes the given ALUN. "
+ "When SR is\n0x10 or 0x11 DEVICE must be LUN 0 or REPORT LUNS "
+ "well known logical unit;\nwhen SR is 0x12 DEVICE must be an "
+ "administrative logical unit. When the\n--test=ALUN option is "
+ "given, decodes ALUN rather than sending a REPORT\nLUNS "
+ "command.\n", DEF_RLUNS_BUFF_LEN );
}
/* Decoded according to SAM-5 rev 10. Note that one draft: BCC rev 0,
@@ -398,8 +408,8 @@ main(int argc, char * argv[])
#ifdef SG_LIB_LINUX
int do_linux = 0;
#endif
- int asif_lu_cong = 0;
- int ir_lu_cong = 0;
+ int lu_cong = 0;
+ int lu_cong_given = 0;
int maxlen = 0;
int do_quiet = 0;
int do_raw = 0;
@@ -450,7 +460,8 @@ main(int argc, char * argv[])
break;
#endif
case 'L':
- ++asif_lu_cong;
+ ++lu_cong;
+ ++lu_cong_given;
break;
case 'm':
maxlen = sg_get_num(optarg);
@@ -586,7 +597,7 @@ main(int argc, char * argv[])
}
#endif
printf("Decoded LUN:\n");
- decode_lun(" ", lun_arr, asif_lu_cong, do_hex, verbose);
+ decode_lun(" ", lun_arr, (lu_cong % 2), do_hex, verbose);
return 0;
}
if (NULL == device_name) {
@@ -607,7 +618,7 @@ main(int argc, char * argv[])
pr2serr("open error: %s: %s\n", device_name, safe_strerror(-sg_fd));
return SG_LIB_FILE_ERROR;
}
- if (decode) {
+ if (decode && (! lu_cong_given)) {
/* check if LU_CONG set in standard INQUIRY response */
res = sg_simple_inquiry(sg_fd, &sir, 0, verbose);
ret = res;
@@ -615,8 +626,8 @@ main(int argc, char * argv[])
pr2serr("fetching standard INQUIRY response failed\n");
goto the_end;
}
- ir_lu_cong = !!(0x40 & sir.byte_1);
- if (verbose && ir_lu_cong)
+ lu_cong = !!(0x40 & sir.byte_1);
+ if (verbose && lu_cong)
pr2serr("LU_CONG bit set in standard INQUIRY response\n");
}
@@ -682,8 +693,8 @@ main(int argc, char * argv[])
#endif
printf("\n");
if (decode)
- decode_lun(" ", reportLunsBuff + off, ir_lu_cong, do_hex,
- verbose);
+ decode_lun(" ", reportLunsBuff + off, (lu_cong % 2),
+ do_hex, verbose);
}
} else if (SG_LIB_CAT_INVALID_OP == res)
pr2serr("Report Luns command not supported (support mandatory in "