aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_luns.896
-rw-r--r--doc/sg_scan.8.linux15
-rw-r--r--lib/sg_lib.c13
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_format.c14
-rw-r--r--src/sg_luns.c31
-rw-r--r--src/sg_requests.c4
-rw-r--r--src/sg_turs.c4
12 files changed, 108 insertions, 88 deletions
diff --git a/ChangeLog b/ChangeLog
index 91af9d32..be00bd8e 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.36 [20130517] [svn: r496]
+Changelog for sg3_utils-1.36 [20130531] [svn: r497]
- sg_vpd: Protocol-specific port information VPD page
for SAS SSP, persistent connection (spl3r2), power
disable (spl3r3)
@@ -12,13 +12,12 @@ Changelog for sg3_utils-1.36 [20130517] [svn: r496]
improve skip/seek handling; allow xcopy on destination
- sg_reset: and --no-esc option to stop reset escalation
- clean up cli, add long option names
- - sg_luns: add --test=LUNHEX option for decoding LUNs
+ - sg_luns: add --test=ALUN option for decoding LUNs
- decoded luns output in decimal or hex (if -HH given)
- - can map between T10 and Linux LUN representations
- add '--linux' option to show Linux LUN after T10
- representation
- - sg_inq: add --vendor option to show vendor specific
- fields in ASCII
+ representation, can map one to the other
+ - sg_inq: add --vendor option to show standard inquiry's
+ vendor specific fields in ASCII
- take resid into account with response output
- sg_sync: add --16 (for 16 byte command) and --timeout=
- sg_logs: add data compression page (ssc4)
diff --git a/README b/README
index 4bbb449a..bcca1ced 100644
--- a/README
+++ b/README
@@ -376,4 +376,4 @@ See http://sg.danny.cz/sg/tools.html
Douglas Gilbert
-8th May 2013
+31st May 2013
diff --git a/debian/changelog b/debian/changelog
index b1f0dbab..7f8c50c3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.36-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Wed, 08 May 2013 09:00:00 -0400
+ -- Douglas Gilbert <dgilbert@interlog.com> Fri, 31 May 2013 10:00:00 -0400
sg3-utils (1.35-0.1) unstable; urgency=low
diff --git a/doc/sg_luns.8 b/doc/sg_luns.8
index f79ceac2..77d8226d 100644
--- a/doc/sg_luns.8
+++ b/doc/sg_luns.8
@@ -1,6 +1,6 @@
-.TH SG_LUNS "8" "March 2013" "sg3_utils\-1.36" SG3_UTILS
+.TH SG_LUNS "8" "May 2013" "sg3_utils\-1.36" SG3_UTILS
.SH NAME
-sg_luns \- send SCSI REPORT LUNS command or decode LUN
+sg_luns \- send SCSI REPORT LUNS command or decode given LUN
.SH SYNOPSIS
.B sg_luns
[\fI\-\-decode\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-linux\fR]
@@ -8,7 +8,7 @@ sg_luns \- send SCSI REPORT LUNS command or decode LUN
[\fI\-\-select=SR\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.PP
.B sg_luns
-\fI\-\-test=LUNHEX\fR [\fI\-\-hex\fR] [\fI\-\-verbose\fR]
+\fI\-\-test=ALUN\fR [\fI\-\-hex\fR] [\fI\-\-verbose\fR]
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -16,12 +16,15 @@ In the first form shown in the SYNOPSIS this utility sends the SCSI REPORT
LUNS command to the \fIDEVICE\fR and outputs the response. The response
should be a list of LUNs ("a LUN inventory") for the I_T nexus associated
with the \fIDEVICE\fR. Roughly speaking that is all LUNs that share the
-target device the REPORT LUNS command is sent through. In the SPC\-3 and
-SPC\-4 SCSI standards support for the REPORT LUNS command is mandatory.
+target device that the REPORT LUNS command is sent through. In the SPC\-3
+and SPC\-4 SCSI standards support for the REPORT LUNS command is mandatory.
.PP
-When the \fI\-\-test=LUNHEX\fR option is given (the second form in the
-SYNOPSIS), the \fILUNHEX\fR value is decoded as outlined in SAM\-3,
+When the \fI\-\-test=ALUN\fR option is given (the second form in the
+SYNOPSIS), then the \fIALUN\fR value is decoded as outlined in SAM\-3,
SAM\-4 and SAM\-5 (revision 13, section 4.7) .
+.PP
+Where required below the first form shown in the SYNOPSIS is called "device
+mode" and the second form is called "test mode".
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
.TP
@@ -33,10 +36,14 @@ of SAM\-3, SAM\-4 and SAM\-5.
output the usage message then exit.
.TP
\fB\-H\fR, \fB\-\-hex\fR
-when given once this utility will output response to the REPORT LUNS command
-in ASCII hex then exit. When given twice it causes the decode option to
-output values in hex rather than decimal. When this option is used with
-\fI\-\-test=LUNHEX\fR then decoded component fields are output in hex.
+[device mode] when given once this utility will output the SCSI
+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
+[test mode] when this option is given, then decoded component fields of
+\fIALUN\fR are output in hex.
.TP
\fB\-l\fR, \fB\-\-linux\fR
this option is only available in Linux. After the T10 representation of
@@ -48,20 +55,22 @@ Linux LUN integer is output in hexadecimal.
\fB\-m\fR, \fB\-\-maxlen\fR=\fILEN\fR
where \fILEN\fR is the (maximum) response length in bytes. It is placed in
the cdb's "allocation length" field. If not given (or \fILEN\fR is zero)
-then 8192 is used. The maximum allowed value of \fILEN\fR is 65536.
+then 8192 is used. The maximum allowed value of \fILEN\fR is 1048576.
.TP
\fB\-q\fR, \fB\-\-quiet\fR
-output ASCII hex rendering of each report LUN, one per line.
+output only the ASCII hex rendering of each report LUN, one per line.
+Without the \fI\-\-quiet\fR option, there is header information printed
+before the LUN listing.
.TP
\fB\-r\fR, \fB\-\-raw\fR
-output response in binary (to stdout).
+output the SCSI response (i.e. the data-out buffer) in binary (to stdout).
.TP
\fB\-s\fR, \fB\-\-select\fR=\fISR\fR
-this option sets the 'select report' field (\fISR\fR) in the SCSI REPORT
+this option sets the SELECT REPORT field (\fISR\fR) in the SCSI REPORT
LUNS command. The default value is 0. For detailed information see the
REPORT LUNS command in SPC (most recent is SPC\-4 revision 36e in section
6.33). To simplify, for the I_T nexus associated with the \fIDEVICE\fR, the
-meanings of the \fISR\fR values and the corresponding responses are:
+meanings of the \fISR\fR values defined to date for SPC\-4 are:
.br
\fB0\fR : all LUNs excluding well known logical units
.br
@@ -70,23 +79,24 @@ meanings of the \fISR\fR values and the corresponding responses are:
\fB2\fR : all LUNs
.br
Values between 0xf8 and 0xff (inclusive) are vendor specific (SPC\-4 rev
-36e), other values greater than 2 are reserved.
+36e), other values greater than 2 are reserved. This utility will accept
+any value between 0 and 255 (0xff) for \fISR\fR .
.TP
-\fB\-t\fR, \fB\-\-test\fR=\fILUNHEX\fR
-\fILUNHEX\fR is assumed to be a hexadecimal number in ASCII hex or the
-letter 'L' followed by a decimal number (see further down this paragraph).
-The hexadecimal number can be up to 64 bits in size (i.e. 16 hexadecimal
-digits). All \fILUNHEX\fR values are padded to the right if less than 16
-hexadecimal digits are given (e.g. \fI\-\-test=0122003a\fR becomes
-0122003a00000000). \fILUNHEX\fR may be prefixed by '0x' or '0X' (e.g. the
-last example could have been \fI\-\-test=0x0122003a\fR). \fILUNHEX\fR may
-also be given with spaces or tabs between each byte (or anywhere else) but
-then \fILUNHEX\fR would need to be surrounded by single or double quotes.
+\fB\-t\fR, \fB\-\-test\fR=\fIALUN\fR
+\fIALUN\fR is assumed to be a hexadecimal number in ASCII hex or the
+letter 'L' followed by a decimal number (see below). The hexadecimal number
+can be up to 64 bits in size (i.e. 16 hexadecimal digits) and is padded to
+the right if less than 16 hexadecimal digits are given (e.g.
+\fI\-\-test=0122003a\fR represents T10 LUN 0122003a00000000). \fIALUN\fR
+may be prefixed by '0x' or '0X' (e.g. the previous example could have been
+\fI\-\-test=0x0122003a\fR). \fIALUN\fR may also be given with spaces or
+tabs between each byte (or other grouping) but then \fIALUN\fR would need
+to be surrounded by single or double quotes.
In the decimal number case (i.e. following a 'L') that number is assumed
-to be a Linux "word flipped" LUN which is converted into a t10 LUN
+to be a Linux "word flipped" LUN which is converted into a T10 LUN
representation and printed. In both cases the number is interpreted as a
LUN and decoded as if the \fI\-\-decode\fR option had been given.
-Also when \fILUNHEX\fR is a hexadecimal number it can have a trailing 'L'
+Also when \fIALUN\fR is a hexadecimal number it can have a trailing 'L'
in which case the corresponding Linux "word flipped" LUN value is output.
The LUN is decoded in all cases.
.TP
@@ -96,22 +106,17 @@ increase the level of verbosity, (i.e. debug output).
\fB\-V\fR, \fB\-\-version\fR
print the version string and then exit.
.SH NOTES
-The REPORT LUNS command is important for Logical Unit (LU) discovery.
+The SCSI REPORT LUNS command is important for Logical Unit (LU) discovery.
After a target device is discovered (usually via some transport specific
mechanism), a REPORT LUNS command should either be sent to LUN 0 (which
is Peripheral device addressing method with bus_id=0 and target/lun=0)
-or the REPORT LUNS well known LUN (i.e. 0xc101000000000000). SAM\-5 requires
-that one of these responds with an inventory of LUNS that are contained
-in this target device.
+or to the REPORT LUNS well known LUN (i.e. 0xc101000000000000). SAM\-5
+requires that one of these responds with an inventory of LUNS that are
+contained in this target device.
.PP
-If the \fI\-\-hex\fR option is given once for the version of this utility
-that sends a REPORT LUNS command to \fIDEVICE\fR then the response is
-printed in hexadecimal. If the \fI\-\-hex\fR option is given twice then
-in the decoded output (if requested) some of the component fields (e.g. the
-actual LUN) are printed in hex with leading zeros. If the \fI\-\-hex\fR
-option is given once for the \fI\-\-test=\fR form of this utility then in
-the decoded output some of the component fields are printed in hex with
-leading zeros. This is to indicate the size of the component field. For
+In test mode, if the \fI\-\-hex\fR option is given once then in the decoded
+output, some of the component fields are printed in hex with leading zeros.
+The leading zeros are to indicate the size of the component field. For
example: in the Peripheral device addressing method (16 bits overall), the
bus ID is 6 bits wide and the target/LUN field is 8 bits wide; so both are
shown with two hex digits (e.g. bus_id=0x02, target=0x3a).
@@ -120,7 +125,7 @@ Typically by the time user space programs get to run, SCSI LUs have been
discovered. In Linux the lsscsi utility lists the LUs that are currently
present. The LUN of a device (LU) is the fourth element in the tuple at the
beginning of each line. Below we see a target (or "I_T Nexus": "6:0:0") has
-two LUNS: 1 and 49409. If 49409 is converted into t10 LUN format it is
+two LUNS: 1 and 49409. If 49409 is converted into T10 LUN format it is
0xc101000000000000 which is the REPORT LUNS well known LUN.
.PP
# lsscsi \-g
@@ -146,7 +151,7 @@ That is a bit noisy so cut down the clutter with \fI\-\-quiet\fR:
.br
0001000000000000
.PP
-Now decode that LUN:
+Now decode that LUN into its component parts:
.PP
# sg_luns \-d \-q /dev/sg1
.br
@@ -189,7 +194,8 @@ I_T Nexus):
REPORT LUNS well known logical unit
.PP
The following example uses the \fI\-\-linux\fR option and is not available
-in other operating systems.
+in other operating systems. The extra number in square brackets is the
+Linux version of T10 LUN shown at the start of the line.
.PP
# sg_luns \-q \-s 2 \-l /dev/sg1
.br
@@ -222,7 +228,7 @@ line (rather than send a REPORT LUNS command and act on the response):
.br
Peripheral device addressing: lun=0x4b
.PP
-This next example is Linux specific as we try to find out what the
+The next example is Linux specific as we try to find out what the
Linux LUN 49409 translates to in the T10 world:
.PP
# sg_luns \-\-test=L49409
diff --git a/doc/sg_scan.8.linux b/doc/sg_scan.8.linux
index c494deca..b42761a0 100644
--- a/doc/sg_scan.8.linux
+++ b/doc/sg_scan.8.linux
@@ -1,4 +1,4 @@
-.TH SG_SCAN "8" "November 2012" "sg3_utils\-1.35" SG3_UTILS
+.TH SG_SCAN "8" "May 2013" "sg3_utils\-1.36" SG3_UTILS
.SH NAME
sg_scan \- scans sg devices (or SCSI/ATAPI/ATA devices) and prints
results
@@ -27,11 +27,16 @@ and /dev/st0m) are suitable. Devices names associated with ATAPI
devices (e.g. most CD/DVD drives and ATAPI tape drives) are also suitable.
If the device does not fall into the above categories then an ATA
IDENTIFY command is tried.
+.PP
+In Linux 2.6 and 3 series kernels, the lsscsi utility may be helpful. Apart
+from providing more information (by data\-mining in the sysfs pseudo file
+system), it does not need root permissions to execute, as this utility
+would typically need.
.SH OPTIONS
.TP
\fB\-a\fR
do alphabetical scan (i.e. sga, sgb, sgc). Note that sg device nodes with
-an alphabetical index have been deprecated since the linux kernel 2.2
+an alphabetical index have been deprecated since the Linux kernel 2.2
series.
.TP
\fB\-i\fR
@@ -52,7 +57,7 @@ was not supported in Linux. It used a simple algorithm to scan sg
device nodes in ascending numeric or alphabetical order, stopping
after there were 4 consecutive errors.
.PP
-In the linux kernel 2.6 series, this utility uses sysfs to find which
+In the Linux kernel 2.6 series, this utility uses sysfs to find which
sg device nodes are active and only checks those. Hence there can be
large "holes" in the numbering of sg device nodes (e.g. after an
adapter has been removed) and still all active sg device nodes will
@@ -65,7 +70,9 @@ the sg3_utils(8) man page.
.SH AUTHORS
Written by D. Gilbert and F. Jansen
.SH COPYRIGHT
-Copyright \(co 1999\-2012 Douglas Gilbert
+Copyright \(co 1999\-2013 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+.SH "SEE ALSO"
+.B lsscsi(8)
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 748d9831..3284ee97 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -343,9 +343,10 @@ sg_get_sense_filemark_eom_ili(const unsigned char * sensep, int sb_len,
/* Returns 1 if SKSV is set and sense key is NO_SENSE or NOT_READY. Also
* returns 1 if progress indication sense data descriptor found. Places
* progress field from sense data where progress_outp points. If progress
- * field is not available returns 0. Handles both fixed and descriptor
- * sense formats. N.B. App should multiply by 100 and divide by 65536
- * to get percentage completion from given value. */
+ * field is not available returns 0 and *progress_outp is unaltered. Handles
+ * both fixed and descriptor sense formats.
+ * Hint: if 1 is returned *progress_outp may be multiplied by 100 then
+ * divided by 65536 to get the percentage completion. */
int
sg_get_sense_progress_fld(const unsigned char * sensep, int sb_len,
int * progress_outp)
@@ -588,7 +589,7 @@ sg_get_sense_descriptors_str(const unsigned char * sense_buffer, int sb_len,
}
progress = (descp[5] << 8) + descp[6];
pr = (progress * 100) / 65536;
- rem = ((progress * 100) % 65536) / 655;
+ rem = ((progress * 100) % 65536) / 656;
n += my_snprintf(b + n, blen - n, "%d.%02d%%\n", pr, rem);
break;
case SPC_SK_COPY_ABORTED:
@@ -711,7 +712,7 @@ sg_get_sense_descriptors_str(const unsigned char * sense_buffer, int sb_len,
}
progress = (descp[6] << 8) + descp[7];
pr = (progress * 100) / 65536;
- rem = ((progress * 100) % 65536) / 655;
+ rem = ((progress * 100) % 65536) / 656;
n += my_snprintf(b + n, blen - n, " %d.02%d%%", pr, rem);
n += my_snprintf(b + n, blen - n, " [sense_key=0x%x "
"asc,ascq=0x%x,0x%x]\n",
@@ -945,7 +946,7 @@ sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer,
case SPC_SK_NOT_READY:
progress = (sense_buffer[16] << 8) + sense_buffer[17];
pr = (progress * 100) / 65536;
- rem = ((progress * 100) % 65536) / 655;
+ rem = ((progress * 100) % 65536) / 656;
r += my_snprintf(b + r, blen - r, " Progress "
"indication: %d.%02d%%\n", pr, rem);
break;
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index bc3b6216..c2330ad4 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -15,7 +15,7 @@
#endif
-const char * sg_lib_version_str = "1.82 20130507"; /* spc4r36, sbc3r32 */
+const char * sg_lib_version_str = "1.83 20130530"; /* spc4r36, sbc3r32 */
#ifdef SG_SCSI_STRINGS
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
diff --git a/sg3_utils.spec b/sg3_utils.spec
index fcf5f910..05fbe2f4 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Wed May 08 2013 - dgilbert at interlog dot com
+* Fri May 31 2013 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.36
diff --git a/src/sg_format.c b/src/sg_format.c
index 69033a41..77f6f81a 100644
--- a/src/sg_format.c
+++ b/src/sg_format.c
@@ -47,7 +47,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-static const char * version_str = "1.22 20130507";
+static const char * version_str = "1.23 20130530";
#define RW_ERROR_RECOVERY_PAGE 1 /* every disk should have one */
#define FORMAT_DEV_PAGE 3 /* Format Device Mode Page [now obsolete] */
@@ -55,9 +55,9 @@ static const char * version_str = "1.22 20130507";
#define THIS_MPAGE_EXISTS RW_ERROR_RECOVERY_PAGE
-#define SHORT_TIMEOUT 20 /* 20 seconds unless immed=0 ... */
-#define FORMAT_TIMEOUT (15 * 3600) /* 15 hours ! */
- /* Seagate ST32000444SS 2TB disk takes 9.5 hours */
+#define SHORT_TIMEOUT 20 /* 20 seconds unless --wait given */
+#define FORMAT_TIMEOUT (20 * 3600) /* 20 hours ! */
+/* Seagate ST32000444SS 2TB disk takes 9.5 hours, now there are 4TB disks */
#define POLL_DURATION_SECS 60
#define DEF_POLL_TYPE 0
@@ -255,7 +255,7 @@ scsi_format(int fd, int fmtpinfo, int cmplst, int pf_usage, int immed,
1, verb);
if (progress >= 0) {
pr = (progress * 100) / 65536;
- rem = ((progress * 100) % 65536) / 655;
+ rem = ((progress * 100) % 65536) / 656;
printf("Format in progress, %d.%02d%% done\n",
pr, rem);
} else
@@ -283,7 +283,7 @@ scsi_format(int fd, int fmtpinfo, int cmplst, int pf_usage, int immed,
&progress);
if (progress >= 0) {
pr = (progress * 100) / 65536;
- rem = ((progress * 100) % 65536) / 655;
+ rem = ((progress * 100) % 65536) / 656;
printf("Format in progress, %d.%02d%% done\n",
pr, rem);
} else
@@ -333,7 +333,7 @@ scsi_format(int fd, int fmtpinfo, int cmplst, int pf_usage, int immed,
} else
printf("Progress indication: %d.%02d%% done\n",
(progress * 100) / 65536,
- ((progress * 100) % 65536) / 655);
+ ((progress * 100) % 65536) / 656);
}
#endif
printf("FORMAT Complete\n");
diff --git a/src/sg_luns.c b/src/sg_luns.c
index 002beddd..060b9acd 100644
--- a/src/sg_luns.c
+++ b/src/sg_luns.c
@@ -28,12 +28,11 @@
* and decodes the response.
*/
-static const char * version_str = "1.21 20130507";
+static const char * version_str = "1.22 20130528";
-#define MAX_RLUNS_BUFF_LEN (1024 * 64)
+#define MAX_RLUNS_BUFF_LEN (1024 * 1024)
#define DEF_RLUNS_BUFF_LEN (1024 * 8)
-static unsigned char reportLunsBuff[MAX_RLUNS_BUFF_LEN];
static struct option long_options[] = {
@@ -73,7 +72,7 @@ usage()
#endif
fprintf(stderr,
" or\n"
- " sg_luns --test=LUNHEX [--hex] [--verbose]\n"
+ " sg_luns --test=ALUN [--hex] [--verbose]\n"
" where:\n"
" --decode|-d decode all luns into component parts\n"
" --help|-h print out usage message\n"
@@ -97,13 +96,13 @@ usage()
" 1 -> only 'well known' "
"logical unit numbers\n"
" 2 -> all luns\n"
- " --test=LUNHEX|-t LUNHEX decode LUNHEX and ignore "
- "other options\n"
- " and DEVICE (apart from '-H')\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=LUNHEX "
- "option is\ngiven, decodes LUNHEX rather than sending a "
+ "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 );
}
@@ -354,6 +353,7 @@ main(int argc, char * argv[])
const char * device_name = NULL;
const char * cp;
unsigned char lun_arr[8];
+ unsigned char * reportLunsBuff = NULL;
int ret = 0;
while (1) {
@@ -525,8 +525,7 @@ main(int argc, char * argv[])
usage();
return SG_LIB_SYNTAX_ERROR;
}
- if (0 == maxlen)
- maxlen = DEF_RLUNS_BUFF_LEN;
+
if (do_raw) {
if (sg_set_binary_mode(STDOUT_FILENO) < 0) {
perror("sg_set_binary_mode");
@@ -541,7 +540,13 @@ main(int argc, char * argv[])
return SG_LIB_FILE_ERROR;
}
- memset(reportLunsBuff, 0x0, maxlen);
+ if (0 == maxlen)
+ maxlen = DEF_RLUNS_BUFF_LEN;
+ reportLunsBuff = (unsigned char *)calloc(1, maxlen);
+ if (NULL == reportLunsBuff) {
+ fprintf(stderr, "unable to malloc %d bytes\n", maxlen);
+ return SG_LIB_CAT_OTHER;
+ }
trunc = 0;
res = sg_ll_report_luns(sg_fd, select_rep, reportLunsBuff, maxlen, 1,
@@ -611,6 +616,8 @@ main(int argc, char * argv[])
}
the_end:
+ if (reportLunsBuff)
+ free(reportLunsBuff);
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
fprintf(stderr, "close error: %s\n", safe_strerror(-res));
diff --git a/src/sg_requests.c b/src/sg_requests.c
index d331a018..f6865ef1 100644
--- a/src/sg_requests.c
+++ b/src/sg_requests.c
@@ -25,7 +25,7 @@
* This program issues the SCSI command REQUEST SENSE to the given SCSI device.
*/
-static const char * version_str = "1.23 20130507";
+static const char * version_str = "1.23 20130530";
#define MAX_REQS_RESP_LEN 255
#define DEF_REQS_RESP_LEN 252
@@ -257,7 +257,7 @@ main(int argc, char * argv[])
} else
printf("Progress indication: %d.%02d%% done\n",
(progress * 100) / 65536,
- ((progress * 100) % 65536) / 655);
+ ((progress * 100) % 65536) / 656);
}
goto finish;
}
diff --git a/src/sg_turs.c b/src/sg_turs.c
index b7adfc42..7bd41a3e 100644
--- a/src/sg_turs.c
+++ b/src/sg_turs.c
@@ -30,7 +30,7 @@
#include "sg_cmds_basic.h"
-static const char * version_str = "3.29 20130507";
+static const char * version_str = "3.29 20130530";
#if defined(MSC_VER) || defined(__MINGW32__)
#define HAVE_MS_SLEEP
@@ -313,7 +313,7 @@ int main(int argc, char * argv[])
break;
} else {
pr = (progress * 100) / 65536;
- rem = ((progress * 100) % 65536) / 655;
+ rem = ((progress * 100) % 65536) / 656;
printf("Progress indication: %d.%02d%% done\n", pr, rem);
}
}