aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/Makefile.am20
-rw-r--r--doc/Makefile.in20
-rw-r--r--doc/sg_stpg.835
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/Makefile.am19
-rw-r--r--src/Makefile.in63
-rw-r--r--src/sg_format.c13
-rw-r--r--src/sg_get_config.c12
-rw-r--r--src/sg_ident.c12
-rw-r--r--src/sg_inq.c4
-rw-r--r--src/sg_luns.c12
-rw-r--r--src/sg_persist.c15
-rw-r--r--src/sg_prevent.c12
-rw-r--r--src/sg_read_buffer.c12
-rw-r--r--src/sg_read_long.c14
-rw-r--r--src/sg_reassign.c12
-rw-r--r--src/sg_requests.c12
-rw-r--r--src/sg_rmsn.c12
-rw-r--r--src/sg_rtpg.c12
-rw-r--r--src/sg_sat_identify.c12
-rw-r--r--src/sg_sat_set_features.c12
-rw-r--r--src/sg_ses.c12
-rw-r--r--src/sg_stpg.c88
-rw-r--r--src/sg_sync.c12
-rw-r--r--src/sg_test_rwbuf.c13
-rw-r--r--src/sg_verify.c12
-rw-r--r--src/sg_vpd.c12
-rw-r--r--src/sg_wr_mode.c12
-rw-r--r--src/sg_write_buffer.c12
-rw-r--r--src/sg_write_long.c12
33 files changed, 267 insertions, 262 deletions
diff --git a/ChangeLog b/ChangeLog
index 28207019..a80cfb26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,11 +2,12 @@ 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.25 [20070916]
+Changelog for sg3_utils-1.25 [20070919]
- sg_stpg: new utility to Set Target Port Groups
- sg_cmds_extra: add sg_ll_set_tgt_prt_grp()
- sg_sat_set_features: new utility (actually copied from examples
directory); renamed examples version: sg__sat_set_features
+ - sg_read_buffer: restore (had fallen out of build scripts)
- sg_dd: add oflag=sparse to step over bs*bpt number of zeros;
- with oflag=sparse, write last bs*bpt segment at end or after
error so file length of OFILE is appropriate
diff --git a/README b/README
index 94a625ca..0e6f71d4 100644
--- a/README
+++ b/README
@@ -327,4 +327,4 @@ See http://www.torque.net/sg/tools.html
Doug Gilbert
-16th September 2007
+19th September 2007
diff --git a/debian/changelog b/debian/changelog
index f6343870..e9ecd81a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.25-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Sun, 16 Sep 2007 13:00:00 -0400
+ -- Doug Gilbert <dgilbert@interlog.com> Wed, 19 Sep 2007 09:00:00 -0400
sg3-utils (1.24-1) unstable; urgency=low
diff --git a/doc/Makefile.am b/doc/Makefile.am
index d69354c3..91f67d45 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -13,11 +13,11 @@ man_MANS = \
sginfo.8 sg_inq.8 sg_logs.8 sg_luns.8 sg_map26.8 sg_map.8 \
sgm_dd.8 sg_modes.8 sg_opcodes.8 sgp_dd.8 sg_persist.8 \
sg_prevent.8 sg_raw.8 sg_rbuf.8 sg_rdac.8 sg_read.8 sg_readcap.8 \
- sg_read_long.8 sg_reassign.8 sg_requests.8 sg_reset.8 sg_rmsn.8 \
- sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
- sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 sg_test_rwbuf.8 \
- sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
- sg_wr_mode.8
+ sg_read_buffer.8 sg_read_long.8 sg_reassign.8 sg_requests.8 \
+ sg_reset.8 sg_rmsn.8 sg_rtpg.8 sg_sat_identify.8 \
+ sg_sat_set_features.8 sg_scan.8 sg_senddiag.8 sg_ses.8 sg_start.8 \
+ sg_stpg.8 sg_sync.8 sg_test_rwbuf.8 sg_turs.8 sg_verify.8 sg_vpd.8 \
+ sg_write_buffer.8 sg_write_long.8 sg_wr_mode.8
endif
@@ -29,7 +29,7 @@ man_MANS = \
sg_format.8 sg_get_config.8 sg_ident.8 \
sg_inq.8 sg_logs.8 sg_luns.8 \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
- sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -46,7 +46,7 @@ man_MANS = \
sg_format.8 sg_get_config.8 sg_ident.8 \
sg_inq.8 sg_logs.8 sg_luns.8 \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
- sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -63,7 +63,7 @@ man_MANS = \
sg_format.8 sg_get_config.8 sg_ident.8 \
sg_inq.8 sg_logs.8 sg_luns.8 \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
- sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -80,7 +80,7 @@ man_MANS = \
sg_format.8 sg_get_config.8 sg_ident.8 \
sg_inq.8 sg_logs.8 sg_luns.8 \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
- sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -97,7 +97,7 @@ man_MANS = \
sg_format.8 sg_get_config.8 sg_ident.8 \
sg_inq.8 sg_logs.8 sg_luns.8 \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
- sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 71c21d19..75786cbf 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -160,7 +160,7 @@ top_srcdir = @top_srcdir@
@OS_FREEBSD_TRUE@ sg_format.8 sg_get_config.8 sg_ident.8 \
@OS_FREEBSD_TRUE@ sg_inq.8 sg_logs.8 sg_luns.8 \
@OS_FREEBSD_TRUE@ sg_modes.8 sg_opcodes.8 sg_persist.8 \
-@OS_FREEBSD_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+@OS_FREEBSD_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
@OS_FREEBSD_TRUE@ sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
@OS_FREEBSD_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
@OS_FREEBSD_TRUE@ sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -179,18 +179,18 @@ top_srcdir = @top_srcdir@
@OS_LINUX_TRUE@ sginfo.8 sg_inq.8 sg_logs.8 sg_luns.8 sg_map26.8 sg_map.8 \
@OS_LINUX_TRUE@ sgm_dd.8 sg_modes.8 sg_opcodes.8 sgp_dd.8 sg_persist.8 \
@OS_LINUX_TRUE@ sg_prevent.8 sg_raw.8 sg_rbuf.8 sg_rdac.8 sg_read.8 sg_readcap.8 \
-@OS_LINUX_TRUE@ sg_read_long.8 sg_reassign.8 sg_requests.8 sg_reset.8 sg_rmsn.8 \
-@OS_LINUX_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
-@OS_LINUX_TRUE@ sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 sg_test_rwbuf.8 \
-@OS_LINUX_TRUE@ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
-@OS_LINUX_TRUE@ sg_wr_mode.8
+@OS_LINUX_TRUE@ sg_read_buffer.8 sg_read_long.8 sg_reassign.8 sg_requests.8 \
+@OS_LINUX_TRUE@ sg_reset.8 sg_rmsn.8 sg_rtpg.8 sg_sat_identify.8 \
+@OS_LINUX_TRUE@ sg_sat_set_features.8 sg_scan.8 sg_senddiag.8 sg_ses.8 sg_start.8 \
+@OS_LINUX_TRUE@ sg_stpg.8 sg_sync.8 sg_test_rwbuf.8 sg_turs.8 sg_verify.8 sg_vpd.8 \
+@OS_LINUX_TRUE@ sg_write_buffer.8 sg_write_long.8 sg_wr_mode.8
@OS_OSF_TRUE@man_MANS = \
@OS_OSF_TRUE@ sg3_utils.8 \
@OS_OSF_TRUE@ sg_format.8 sg_get_config.8 sg_ident.8 \
@OS_OSF_TRUE@ sg_inq.8 sg_logs.8 sg_luns.8 \
@OS_OSF_TRUE@ sg_modes.8 sg_opcodes.8 sg_persist.8 \
-@OS_OSF_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+@OS_OSF_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
@OS_OSF_TRUE@ sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
@OS_OSF_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
@OS_OSF_TRUE@ sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -202,7 +202,7 @@ top_srcdir = @top_srcdir@
@OS_SOLARIS_TRUE@ sg_format.8 sg_get_config.8 sg_ident.8 \
@OS_SOLARIS_TRUE@ sg_inq.8 sg_logs.8 sg_luns.8 \
@OS_SOLARIS_TRUE@ sg_modes.8 sg_opcodes.8 sg_persist.8 \
-@OS_SOLARIS_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+@OS_SOLARIS_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
@OS_SOLARIS_TRUE@ sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
@OS_SOLARIS_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
@OS_SOLARIS_TRUE@ sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -214,7 +214,7 @@ top_srcdir = @top_srcdir@
@OS_WIN32_CYGWIN_TRUE@ sg_format.8 sg_get_config.8 sg_ident.8 \
@OS_WIN32_CYGWIN_TRUE@ sg_inq.8 sg_logs.8 sg_luns.8 \
@OS_WIN32_CYGWIN_TRUE@ sg_modes.8 sg_opcodes.8 sg_persist.8 \
-@OS_WIN32_CYGWIN_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+@OS_WIN32_CYGWIN_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
@OS_WIN32_CYGWIN_TRUE@ sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
@OS_WIN32_CYGWIN_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
@OS_WIN32_CYGWIN_TRUE@ sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
@@ -226,7 +226,7 @@ top_srcdir = @top_srcdir@
@OS_WIN32_MINGW_TRUE@ sg_format.8 sg_get_config.8 sg_ident.8 \
@OS_WIN32_MINGW_TRUE@ sg_inq.8 sg_logs.8 sg_luns.8 \
@OS_WIN32_MINGW_TRUE@ sg_modes.8 sg_opcodes.8 sg_persist.8 \
-@OS_WIN32_MINGW_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
+@OS_WIN32_MINGW_TRUE@ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 sg_read_buffer.8 \
@OS_WIN32_MINGW_TRUE@ sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
@OS_WIN32_MINGW_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
@OS_WIN32_MINGW_TRUE@ sg_senddiag.8 sg_ses.8 sg_start.8 sg_stpg.8 sg_sync.8 \
diff --git a/doc/sg_stpg.8 b/doc/sg_stpg.8
index 02cc99fd..5b676e8b 100644
--- a/doc/sg_stpg.8
+++ b/doc/sg_stpg.8
@@ -1,4 +1,4 @@
-.TH SG_STPG "8" "August 2007" "sg3_utils\-1.25" SG3_UTILS
+.TH SG_STPG "8" "September 2007" "sg3_utils\-1.25" SG3_UTILS
.SH NAME
sg_stpg \- sends a SCSI SET TARGET PORT GROUPS command
.SH SYNOPSIS
@@ -9,24 +9,46 @@ sg_stpg \- sends a SCSI SET TARGET PORT GROUPS command
.SH DESCRIPTION
.\" Add any additional description here
.PP
-Send a SCSI SET TARGET PORT GROUPS command to \fIDEVICE\fR.
+Send a SCSI SET TARGET PORT GROUPS command to \fIDEVICE\fR.
+.PP
+A sequence of SCSI commands are sent to the \fIDEVICE\fR leading up to the
+SET TARGET PORT GROUPS command. First a INQUIRY is sent to fetch the device
+identification VPD page to find the (primary) target port group. Then a
+REPORT TARGET PORT GROUPS command is issued to find the current state and
+whether a transition to the requested state is supported. If so the
+SET TARGET PORT GROUPS command is sent.
.PP
Target port group access is described in SPC\-4 found at www.t10.org
in section 5.8 (in rev 11 dated 2007/5/14). The Set Target Port
Groups command is also described in that document.
.PP
-xxxxxxxxxxxxxx Placeholder more to add xxxxxxxxxxxxxxxxxx
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
.TP
+\fB\-a\fR, \fB\-\-active\fR
+set active/non-optimized state.
+.TP
\fB\-h\fR, \fB\-\-help\fR
output the usage message then exit.
.TP
\fB\-H\fR, \fB\-\-hex\fR
-output response in hex (rather than partially or fully decode it).
+output response to the REPORT TARGET PORT GROUPS command in hex then exit.
+.TP
+\fB\-o\fR, \fB\-\-optimized\fR
+set active/optimized state.
+.TP
+\fB\-O\fR, \fB\-l\fR, \fB\-\-offline\fR
+set active/non-optimized state.
.TP
\fB\-r\fR, \fB\-\-raw\fR
-output response in binary to stdout.
+output response to the REPORT TARGET PORT GROUPS command in binary to stdout
+then exit.
+.TP
+\fB\-s\fR, \fB\-\-standby\fR
+set standby state.
+.TP
+\fB\-u\fR, \fB\-\-unavailable\fR
+set unavailable state.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
increase the level of verbosity, (i.e. debug output).
@@ -35,8 +57,7 @@ increase the level of verbosity, (i.e. debug output).
print the version string and then exit.
.SH NOTES
The Set Target Port Groups command should be supported whenever the TPGS
-bits in a standard INQUIRY response are greater than zero. [View with
-sg_inq utility.]
+value in a standard INQUIRY response is 2 or 3. [View with sg_inq utility.]
.SH EXIT STATUS
The exit status of sg_stpg is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 2db4806f..72e46aa1 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Sep 16 2007 - dgilbert at interlog dot com
+* Wed Sep 19 2007 - dgilbert at interlog dot com
- add sg_sat_set_features, sg_stpg; sg_dd oflag=sparse,null
* sg3_utils-1.25
diff --git a/src/Makefile.am b/src/Makefile.am
index d956a01f..4edf7c22 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,9 +12,9 @@ bin_PROGRAMS = \
sginfo sg_inq sg_logs sg_luns sg_map26 sg_map \
sgm_dd sg_modes sg_opcodes sgp_dd sg_persist \
sg_prevent sg_raw sg_rbuf sg_rdac sg_read sg_readcap \
- sg_read_long sg_reassign sg_requests sg_reset sg_rmsn \
- sg_rtpg sg_sat_identify sg_sat_set_features sg_scan \
- sg_senddiag sg_ses sg_start sg_stpg sg_sync sg_test_rwbuf \
+ sg_read_buffer sg_read_long sg_reassign sg_requests \
+ sg_reset sg_rmsn sg_rtpg sg_sat_identify sg_sat_set_features \
+ sg_scan sg_senddiag sg_ses sg_start sg_stpg sg_sync sg_test_rwbuf \
sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
sg_wr_mode
@@ -28,7 +28,7 @@ bin_PROGRAMS = \
sg_inq sg_logs sg_luns \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
- sg_read_long sg_reassign sg_requests sg_rmsn \
+ sg_read_buffer sg_read_long sg_reassign sg_requests sg_rmsn \
sg_rtpg sg_sat_identify sg_sat_set_features sg_scan \
sg_senddiag sg_ses sg_start sg_stpg sg_sync \
sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
@@ -44,7 +44,7 @@ bin_PROGRAMS = \
sg_inq sg_logs sg_luns \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
- sg_read_long sg_reassign sg_requests sg_rmsn \
+ sg_read_buffer sg_read_long sg_reassign sg_requests sg_rmsn \
sg_rtpg sg_sat_identify sg_sat_set_features sg_scan \
sg_senddiag sg_ses sg_start sg_stpg sg_sync \
sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
@@ -60,7 +60,7 @@ bin_PROGRAMS = \
sg_inq sg_logs sg_luns \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
- sg_read_long sg_reassign sg_requests sg_rmsn \
+ sg_read_buffer sg_read_long sg_reassign sg_requests sg_rmsn \
sg_rtpg sg_sat_identify sg_sat_set_features \
sg_senddiag sg_ses sg_start sg_stpg sg_sync \
sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
@@ -76,7 +76,7 @@ bin_PROGRAMS = \
sg_inq sg_logs sg_luns \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
- sg_read_long sg_reassign sg_requests sg_rmsn \
+ sg_read_buffer sg_read_long sg_reassign sg_requests sg_rmsn \
sg_rtpg sg_sat_identify sg_sat_set_features \
sg_senddiag sg_ses sg_start sg_stpg sg_sync \
sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
@@ -92,7 +92,7 @@ bin_PROGRAMS = \
sg_inq sg_logs sg_luns \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
- sg_read_long sg_reassign sg_requests sg_rmsn \
+ sg_read_buffer sg_read_long sg_reassign sg_requests sg_rmsn \
sg_rtpg sg_sat_identify sg_sat_set_features \
sg_senddiag sg_ses sg_start sg_stpg sg_sync \
sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
@@ -170,6 +170,9 @@ sg_read_LDADD = ../lib/libsgutils.la @os_libs@
sg_readcap_SOURCES = sg_readcap.c
sg_readcap_LDADD = ../lib/libsgutils.la @os_libs@
+sg_read_buffer_SOURCES = sg_read_buffer.c
+sg_read_buffer_LDADD = ../lib/libsgutils.la @os_libs@
+
sg_read_long_SOURCES = sg_read_long.c
sg_read_long_LDADD = ../lib/libsgutils.la @os_libs@
diff --git a/src/Makefile.in b/src/Makefile.in
index c77106e5..9a4d0918 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -45,6 +45,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_raw$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_rdac$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_readcap$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_read_buffer$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_read_long$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_reassign$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_requests$(EXEEXT) \
@@ -77,6 +78,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_raw$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_rdac$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_readcap$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_read_buffer$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_read_long$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_reassign$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_requests$(EXEEXT) \
@@ -109,6 +111,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_raw$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_rdac$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_readcap$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_read_buffer$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_read_long$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_reassign$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_requests$(EXEEXT) \
@@ -140,6 +143,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_raw$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_rdac$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_readcap$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_read_buffer$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_read_long$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_reassign$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_requests$(EXEEXT) \
@@ -180,6 +184,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_rdac$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_read$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_readcap$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_read_buffer$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_read_long$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_reassign$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_requests$(EXEEXT) \
@@ -208,9 +213,10 @@ host_triplet = @host@
@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_read_long$(EXEEXT) sg_reassign$(EXEEXT) \
-@OS_FREEBSD_TRUE@ sg_requests$(EXEEXT) sg_rmsn$(EXEEXT) \
-@OS_FREEBSD_TRUE@ sg_rtpg$(EXEEXT) sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_read_buffer$(EXEEXT) sg_read_long$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_reassign$(EXEEXT) sg_requests$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_rmsn$(EXEEXT) sg_rtpg$(EXEEXT) \
+@OS_FREEBSD_TRUE@ sg_sat_identify$(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) \
@@ -284,6 +290,9 @@ sg_rdac_DEPENDENCIES = ../lib/libsgutils.la
am_sg_read_OBJECTS = sg_read.$(OBJEXT) sg_io_linux.$(OBJEXT)
sg_read_OBJECTS = $(am_sg_read_OBJECTS)
sg_read_DEPENDENCIES = ../lib/libsgutils.la
+am_sg_read_buffer_OBJECTS = sg_read_buffer.$(OBJEXT)
+sg_read_buffer_OBJECTS = $(am_sg_read_buffer_OBJECTS)
+sg_read_buffer_DEPENDENCIES = ../lib/libsgutils.la
am_sg_read_long_OBJECTS = sg_read_long.$(OBJEXT)
sg_read_long_OBJECTS = $(am_sg_read_long_OBJECTS)
sg_read_long_DEPENDENCIES = ../lib/libsgutils.la
@@ -379,16 +388,17 @@ SOURCES = $(sg_dd_SOURCES) $(sg_emc_trespass_SOURCES) \
$(sg_modes_SOURCES) $(sg_opcodes_SOURCES) \
$(sg_persist_SOURCES) $(sg_prevent_SOURCES) $(sg_raw_SOURCES) \
$(sg_rbuf_SOURCES) $(sg_rdac_SOURCES) $(sg_read_SOURCES) \
- $(sg_read_long_SOURCES) $(sg_readcap_SOURCES) \
- $(sg_reassign_SOURCES) $(sg_requests_SOURCES) \
- $(sg_reset_SOURCES) $(sg_rmsn_SOURCES) $(sg_rtpg_SOURCES) \
- $(sg_sat_identify_SOURCES) $(sg_sat_set_features_SOURCES) \
- $(sg_scan_SOURCES) $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) \
- $(sg_start_SOURCES) $(sg_stpg_SOURCES) $(sg_sync_SOURCES) \
- $(sg_test_rwbuf_SOURCES) $(sg_turs_SOURCES) \
- $(sg_verify_SOURCES) $(sg_vpd_SOURCES) $(sg_wr_mode_SOURCES) \
- $(sg_write_buffer_SOURCES) $(sg_write_long_SOURCES) \
- $(sginfo_SOURCES) $(sgm_dd_SOURCES) $(sgp_dd_SOURCES)
+ $(sg_read_buffer_SOURCES) $(sg_read_long_SOURCES) \
+ $(sg_readcap_SOURCES) $(sg_reassign_SOURCES) \
+ $(sg_requests_SOURCES) $(sg_reset_SOURCES) $(sg_rmsn_SOURCES) \
+ $(sg_rtpg_SOURCES) $(sg_sat_identify_SOURCES) \
+ $(sg_sat_set_features_SOURCES) $(sg_scan_SOURCES) \
+ $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) $(sg_start_SOURCES) \
+ $(sg_stpg_SOURCES) $(sg_sync_SOURCES) $(sg_test_rwbuf_SOURCES) \
+ $(sg_turs_SOURCES) $(sg_verify_SOURCES) $(sg_vpd_SOURCES) \
+ $(sg_wr_mode_SOURCES) $(sg_write_buffer_SOURCES) \
+ $(sg_write_long_SOURCES) $(sginfo_SOURCES) $(sgm_dd_SOURCES) \
+ $(sgp_dd_SOURCES)
DIST_SOURCES = $(sg_dd_SOURCES) $(sg_emc_trespass_SOURCES) \
$(sg_format_SOURCES) $(sg_get_config_SOURCES) \
$(sg_ident_SOURCES) $(sg_inq_SOURCES) $(sg_logs_SOURCES) \
@@ -396,16 +406,17 @@ DIST_SOURCES = $(sg_dd_SOURCES) $(sg_emc_trespass_SOURCES) \
$(sg_modes_SOURCES) $(sg_opcodes_SOURCES) \
$(sg_persist_SOURCES) $(sg_prevent_SOURCES) $(sg_raw_SOURCES) \
$(sg_rbuf_SOURCES) $(sg_rdac_SOURCES) $(sg_read_SOURCES) \
- $(sg_read_long_SOURCES) $(sg_readcap_SOURCES) \
- $(sg_reassign_SOURCES) $(sg_requests_SOURCES) \
- $(sg_reset_SOURCES) $(sg_rmsn_SOURCES) $(sg_rtpg_SOURCES) \
- $(sg_sat_identify_SOURCES) $(sg_sat_set_features_SOURCES) \
- $(sg_scan_SOURCES) $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) \
- $(sg_start_SOURCES) $(sg_stpg_SOURCES) $(sg_sync_SOURCES) \
- $(sg_test_rwbuf_SOURCES) $(sg_turs_SOURCES) \
- $(sg_verify_SOURCES) $(sg_vpd_SOURCES) $(sg_wr_mode_SOURCES) \
- $(sg_write_buffer_SOURCES) $(sg_write_long_SOURCES) \
- $(sginfo_SOURCES) $(sgm_dd_SOURCES) $(sgp_dd_SOURCES)
+ $(sg_read_buffer_SOURCES) $(sg_read_long_SOURCES) \
+ $(sg_readcap_SOURCES) $(sg_reassign_SOURCES) \
+ $(sg_requests_SOURCES) $(sg_reset_SOURCES) $(sg_rmsn_SOURCES) \
+ $(sg_rtpg_SOURCES) $(sg_sat_identify_SOURCES) \
+ $(sg_sat_set_features_SOURCES) $(sg_scan_SOURCES) \
+ $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) $(sg_start_SOURCES) \
+ $(sg_stpg_SOURCES) $(sg_sync_SOURCES) $(sg_test_rwbuf_SOURCES) \
+ $(sg_turs_SOURCES) $(sg_verify_SOURCES) $(sg_vpd_SOURCES) \
+ $(sg_wr_mode_SOURCES) $(sg_write_buffer_SOURCES) \
+ $(sg_write_long_SOURCES) $(sginfo_SOURCES) $(sgm_dd_SOURCES) \
+ $(sgp_dd_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -563,6 +574,8 @@ sg_read_SOURCES = sg_read.c sg_io_linux.c
sg_read_LDADD = ../lib/libsgutils.la @os_libs@
sg_readcap_SOURCES = sg_readcap.c
sg_readcap_LDADD = ../lib/libsgutils.la @os_libs@
+sg_read_buffer_SOURCES = sg_read_buffer.c
+sg_read_buffer_LDADD = ../lib/libsgutils.la @os_libs@
sg_read_long_SOURCES = sg_read_long.c
sg_read_long_LDADD = ../lib/libsgutils.la @os_libs@
sg_reassign_SOURCES = sg_reassign.c
@@ -720,6 +733,9 @@ sg_rdac$(EXEEXT): $(sg_rdac_OBJECTS) $(sg_rdac_DEPENDENCIES)
sg_read$(EXEEXT): $(sg_read_OBJECTS) $(sg_read_DEPENDENCIES)
@rm -f sg_read$(EXEEXT)
$(LINK) $(sg_read_OBJECTS) $(sg_read_LDADD) $(LIBS)
+sg_read_buffer$(EXEEXT): $(sg_read_buffer_OBJECTS) $(sg_read_buffer_DEPENDENCIES)
+ @rm -f sg_read_buffer$(EXEEXT)
+ $(LINK) $(sg_read_buffer_OBJECTS) $(sg_read_buffer_LDADD) $(LIBS)
sg_read_long$(EXEEXT): $(sg_read_long_OBJECTS) $(sg_read_long_DEPENDENCIES)
@rm -f sg_read_long$(EXEEXT)
$(LINK) $(sg_read_long_OBJECTS) $(sg_read_long_LDADD) $(LIBS)
@@ -821,6 +837,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_rbuf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_rdac.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_read.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_read_buffer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_read_long.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_readcap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_reassign.Po@am__quote@
diff --git a/src/sg_format.c b/src/sg_format.c
index 32ff0bed..bdfb1a25 100644
--- a/src/sg_format.c
+++ b/src/sg_format.c
@@ -72,7 +72,7 @@
#define MAX_BUFF_SZ 252
static unsigned char dbuff[MAX_BUFF_SZ];
-static char * version_str = "1.14 20070830";
+static char * version_str = "1.15 20070918";
static struct option long_options[] = {
{"count", 1, 0, 'c'},
@@ -326,12 +326,11 @@ int main(int argc, char **argv)
int dcrt = 0;
int do_si = 0;
int early = 0;
- char device_name[256];
+ const char * device_name = NULL;
char pdt_name[64];
struct sg_simple_inquiry_resp inq_out;
int ret = 0;
- device_name[0] = '\0';
while (1) {
int option_index = 0;
int c;
@@ -425,10 +424,8 @@ int main(int argc, char **argv)
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind],
- sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
}
@@ -439,7 +436,7 @@ int main(int argc, char **argv)
usage();
return SG_LIB_SYNTAX_ERROR;
}
- if ('\0' == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "no device name given\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_get_config.c b/src/sg_get_config.c
index 11bc2e2a..dccde24b 100644
--- a/src/sg_get_config.c
+++ b/src/sg_get_config.c
@@ -49,7 +49,7 @@
*/
-static char * version_str = "0.30 20070714";
+static char * version_str = "0.30 20070919";
#define MX_ALLOC_LEN 8192
#define NAME_BUFF_SZ 64
@@ -885,13 +885,12 @@ int main(int argc, char * argv[])
int rt = 0;
int starting = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
char buff[64];
const char * cp;
struct sg_simple_inquiry_resp inq_resp;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -947,9 +946,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -965,7 +963,7 @@ int main(int argc, char * argv[])
list_known(brief);
return 0;
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_ident.c b/src/sg_ident.c
index f5605b50..fe695995 100644
--- a/src/sg_ident.c
+++ b/src/sg_ident.c
@@ -49,7 +49,7 @@
* DEVICE IDENTIFIER and SET DEVICE IDENTIFIER prior to spc4r07.
*/
-static char * version_str = "1.06 20070714";
+static char * version_str = "1.07 20070918";
#define ME "sg_ident: "
@@ -128,10 +128,9 @@ int main(int argc, char * argv[])
int raw = 0;
int do_set = 0;
int verbose = 0;
- char device_name[512];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -178,9 +177,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -192,7 +190,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_inq.c b/src/sg_inq.c
index b5320be7..9bca6187 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -66,7 +66,7 @@
* information [MAINTENANCE IN, service action = 0xc]; see sg_opcodes.
*/
-static char * version_str = "0.70 20070906"; /* spc-4 rev 11 */
+static char * version_str = "0.70 20070919"; /* spc-4 rev 11 */
#define VPD_SUPPORTED_VPDS 0x0
@@ -1716,7 +1716,7 @@ static int process_std_inq(int sg_fd, const struct opts_t * optsp)
!!(rsp_buff[3] & 0x80), !!(rsp_buff[3] & 0x40),
!!(rsp_buff[3] & 0x20), !!(rsp_buff[3] & 0x10),
rsp_buff[3] & 0x0f, !!(rsp_buff[5] & 0x80));
- printf("ACC=%d TGPS=%d 3PC=%d Protect=%d ",
+ printf("ACC=%d TPGS=%d 3PC=%d Protect=%d ",
!!(rsp_buff[5] & 0x40), ((rsp_buff[5] & 0x30) >> 4),
!!(rsp_buff[5] & 0x08), !!(rsp_buff[5] & 0x01));
printf(" BQue=%d\n EncServ=%d ", !!(rsp_buff[6] & 0x80),
diff --git a/src/sg_luns.c b/src/sg_luns.c
index 15758de9..109eb53e 100644
--- a/src/sg_luns.c
+++ b/src/sg_luns.c
@@ -48,7 +48,7 @@
* This program issues the SCSI command REPORT LUNS to the given SCSI device.
*/
-static char * version_str = "1.12 20070714";
+static char * version_str = "1.12 20070919";
#define REPORT_LUNS_BUFF_LEN (1024*64)
@@ -224,10 +224,9 @@ int main(int argc, char * argv[])
int do_raw = 0;
int select_rep = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -273,9 +272,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -287,7 +285,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_persist.c b/src/sg_persist.c
index 2b16562f..60092130 100644
--- a/src/sg_persist.c
+++ b/src/sg_persist.c
@@ -27,7 +27,7 @@
*/
-static char * version_str = "0.33 20070714";
+static char * version_str = "0.33 20070919";
#define PRIN_RKEY_SA 0x0
@@ -692,7 +692,7 @@ int main(int argc, char * argv[])
unsigned long long param_rk = 0;
unsigned long long param_sark = 0;
unsigned int param_rtp = 0;
- char device_name[256];
+ const char * device_name = NULL;
char buff[48];
int num_prin_sa = 0;
int num_prout_sa = 0;
@@ -716,7 +716,6 @@ int main(int argc, char * argv[])
struct sg_simple_inquiry_resp inq_resp;
const char * cp;
- device_name[0] = '\0';
while (1) {
int option_index = 0;
@@ -739,8 +738,7 @@ int main(int argc, char * argv[])
++num_prout_sa;
break;
case 'd':
- strncpy(device_name, optarg, sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ device_name = optarg;
break;
case 'G':
prout_sa = PROUT_REG_SA;
@@ -865,9 +863,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -879,7 +876,7 @@ int main(int argc, char * argv[])
}
}
- if ('\0' == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "No device name given\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_prevent.c b/src/sg_prevent.c
index 030890a8..5f23b11d 100644
--- a/src/sg_prevent.c
+++ b/src/sg_prevent.c
@@ -46,7 +46,7 @@
* given SCSI device.
*/
-static char * version_str = "1.06 20070714";
+static char * version_str = "1.06 20070919";
#define ME "sg_prevent: "
@@ -87,10 +87,9 @@ int main(int argc, char * argv[])
int allow = 0;
int prevent = -1;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -127,9 +126,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -140,7 +138,7 @@ int main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index 3e0b4df7..9a8b5bfb 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -46,7 +46,7 @@
* This utility issues the SCSI READ BUFFER command to the given device.
*/
-static char * version_str = "1.03 20070714";
+static char * version_str = "1.03 20070919";
#define ME "sg_read_buffer: "
@@ -147,11 +147,10 @@ int main(int argc, char * argv[])
int rb_offset = 0;
int do_raw = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
unsigned char * resp;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -237,9 +236,8 @@ int main(int argc, char * argv[])
return 0;
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -251,7 +249,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_read_long.c b/src/sg_read_long.c
index 7b7a22ab..fef37cc8 100644
--- a/src/sg_read_long.c
+++ b/src/sg_read_long.c
@@ -29,7 +29,7 @@
the sector data and the ECC bytes.
*/
-static char * version_str = "1.14 20070714";
+static char * version_str = "1.14 20070919";
#define MAX_XFER_LEN 10000
@@ -141,12 +141,11 @@ int main(int argc, char * argv[])
int verbose = 0;
long long ll;
int got_stdout;
- char device_name[256];
+ const char * device_name = NULL;
char out_fname[256];
char ebuff[EBUFF_SZ];
int ret = 0;
- memset(device_name, 0, sizeof device_name);
memset(out_fname, 0, sizeof out_fname);
while (1) {
int option_index = 0;
@@ -173,7 +172,7 @@ int main(int argc, char * argv[])
llba = (unsigned long long)ll;
break;
case 'o':
- strncpy(out_fname, optarg, sizeof(out_fname));
+ strncpy(out_fname, optarg, sizeof(out_fname) - 1);
break;
case 'p':
pblock = 1;
@@ -201,9 +200,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -215,7 +213,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_reassign.c b/src/sg_reassign.c
index 2057a347..2c83748f 100644
--- a/src/sg_reassign.c
+++ b/src/sg_reassign.c
@@ -54,7 +54,7 @@
* vendor specific data is written.
*/
-static char * version_str = "1.11 20070714";
+static char * version_str = "1.11 20070919";
#define ME "sg_reassign: "
@@ -267,13 +267,12 @@ int main(int argc, char * argv[])
int longlist = 0;
int primary = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
unsigned long long addr_arr[MAX_NUM_ADDR];
unsigned char param_arr[4 + (MAX_NUM_ADDR * 8)];
int param_len = 4;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -339,9 +338,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -352,7 +350,7 @@ int main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_requests.c b/src/sg_requests.c
index 193ba78c..0be47f00 100644
--- a/src/sg_requests.c
+++ b/src/sg_requests.c
@@ -47,7 +47,7 @@
* This program issues the SCSI command REQUEST SENSE to the given SCSI device.
*/
-static char * version_str = "1.17 20070714";
+static char * version_str = "1.18 20070919";
#define REQUEST_SENSE_BUFF_LEN 252
@@ -112,13 +112,12 @@ int main(int argc, char * argv[])
int do_status = 0;
int do_time = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
#ifndef SG3_UTILS_MINGW
struct timeval start_tm, end_tm;
#endif
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -167,9 +166,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -181,7 +179,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_rmsn.c b/src/sg_rmsn.c
index 375672bc..9f2bb79c 100644
--- a/src/sg_rmsn.c
+++ b/src/sg_rmsn.c
@@ -48,7 +48,7 @@
* to the given SCSI device.
*/
-static char * version_str = "1.06 20070714";
+static char * version_str = "1.07 20070918";
#define ME "sg_rmsn: "
@@ -84,10 +84,9 @@ int main(int argc, char * argv[])
unsigned char * ucp = NULL;
int raw = 0;
int verbose = 0;
- char device_name[512];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -117,9 +116,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -131,7 +129,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_rtpg.c b/src/sg_rtpg.c
index c31ccea6..34dc346f 100644
--- a/src/sg_rtpg.c
+++ b/src/sg_rtpg.c
@@ -48,7 +48,7 @@
* to the given SCSI device.
*/
-static char * version_str = "1.12 20070714";
+static char * version_str = "1.12 20070918";
#define REPORT_TGT_GRP_BUFF_LEN 1024
@@ -176,10 +176,9 @@ int main(int argc, char * argv[])
int hex = 0;
int raw = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -215,9 +214,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -229,7 +227,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_sat_identify.c b/src/sg_sat_identify.c
index 9e98df16..10ecba3d 100644
--- a/src/sg_sat_identify.c
+++ b/src/sg_sat_identify.c
@@ -64,7 +64,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.03 20070719";
+static char * version_str = "1.04 20070918";
static struct option long_options[] = {
{"chk_cond", no_argument, 0, 'c'},
@@ -284,7 +284,7 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
int main(int argc, char * argv[])
{
int sg_fd, c, res;
- char device_name[256];
+ const char * device_name = NULL;
int cdb_len = SAT_ATA_PASS_THROUGH16_LEN;
int do_packet = 0;
int do_hex = 0;
@@ -293,7 +293,6 @@ int main(int argc, char * argv[])
int chk_cond = 0; /* set to 1 to read register(s) back */
int ret = 0;
- memset(device_name, 0, sizeof(device_name));
while (1) {
int option_index = 0;
@@ -339,9 +338,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -353,7 +351,7 @@ int main(int argc, char * argv[])
}
}
- if ('\0' == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return 1;
diff --git a/src/sg_sat_set_features.c b/src/sg_sat_set_features.c
index 02d28392..3b1f58f7 100644
--- a/src/sg_sat_set_features.c
+++ b/src/sg_sat_set_features.c
@@ -61,7 +61,7 @@
#define DEF_TIMEOUT 20
-static char * version_str = "1.03 20070719";
+static char * version_str = "1.04 20070918";
static struct option long_options[] = {
{"count", required_argument, 0, 'c'},
@@ -266,7 +266,7 @@ static int do_set_features(int sg_fd, int feature, int count, int lba,
int main(int argc, char * argv[])
{
int sg_fd, c, ret, res;
- char device_name[256];
+ const char * device_name = NULL;
int count = 0;
int feature = 0;
int lba = 0;
@@ -274,7 +274,6 @@ int main(int argc, char * argv[])
int chk_cond = 0;
int cdb_len = SAT_ATA_PASS_THROUGH16_LEN;
- memset(device_name, 0, sizeof(device_name));
while (1) {
int option_index = 0;
@@ -332,9 +331,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -346,7 +344,7 @@ int main(int argc, char * argv[])
}
}
- if ('\0' == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return 1;
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 75231862..23773573 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -46,7 +46,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static char * version_str = "1.36 20070717"; /* ses2r18 */
+static char * version_str = "1.37 20070919"; /* ses2r18 */
#define MX_ALLOC_LEN 4096
#define MX_ELEM_HDR 1024
@@ -1692,7 +1692,7 @@ int main(int argc, char * argv[])
int verbose = 0;
int inner_hex = 0;
int byte1 = 0;
- char device_name[256];
+ const char * device_name = NULL;
char buff[48];
unsigned char data_arr[1024];
int arr_len = 0;
@@ -1701,7 +1701,6 @@ int main(int argc, char * argv[])
struct sg_simple_inquiry_resp inq_resp;
const char * cp;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -1773,9 +1772,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -1816,7 +1814,7 @@ int main(int argc, char * argv[])
} else if (0 == do_status)
do_status = 1; /* default to receiving status pages */
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_stpg.c b/src/sg_stpg.c
index c4039e52..b6b7b58f 100644
--- a/src/sg_stpg.c
+++ b/src/sg_stpg.c
@@ -45,7 +45,7 @@
* to the given SCSI device.
*/
-static char * version_str = "1.1 20070903";
+static char * version_str = "1.2 20070918";
#define TGT_GRP_BUFF_LEN 1024
#define MX_ALLOC_LEN (0xc000 + 0x80)
@@ -57,6 +57,9 @@ static char * version_str = "1.1 20070903";
#define TPGS_STATE_OFFLINE 0xe /* SPC-4 rev 9 */
#define TPGS_STATE_TRANSITIONING 0xf
+#define VPD_DEVICE_ID 0x83
+#define DEF_VPD_DEVICE_ID_LEN 252
+
struct tgtgrp {
int id;
int current;
@@ -77,7 +80,8 @@ static struct option long_options[] = {
{0, 0, 0, 0},
};
-static void usage()
+static void
+usage()
{
fprintf(stderr, "Usage: "
"sg_stpg [--active] [--help] [--hex] [--offline] [--optimized] "
@@ -88,11 +92,13 @@ static void usage()
" --active|-a set asymm. access state to "
"active/non-optimized\n"
" --help|-h print out usage message\n"
- " --hex|-H print out response in hex\n"
- " --offline|-l set asymm. access state to unavailable\n"
+ " --hex|-H print out report response in hex, then "
+ "exit\n"
+ " --offline|-l set asymm. access state to offline\n"
" --optimized|-o set asymm. access state to "
"active/optimized\n"
- " --raw|-r output response in binary to stdout\n"
+ " --raw|-r output report response in binary to "
+ "stdout, then exit\n"
" --standby|-s set asymm. access state to standby\n"
" --unavailable|-u set asymm. access state to unavailable\n"
" --verbose|-v increase verbosity\n"
@@ -102,7 +108,8 @@ static void usage()
}
-static void dStrRaw(const char* str, int len)
+static void
+dStrRaw(const char* str, int len)
{
int k;
@@ -110,8 +117,8 @@ static void dStrRaw(const char* str, int len)
printf("%c", str[k]);
}
-static int decode_target_port(unsigned char * buff,
- int len, int *d_id, int *d_tpg)
+static int
+decode_target_port(unsigned char * buff, int len, int *d_id, int *d_tpg)
{
int c_set, piv, assoc, desig_type, i_len;
int off, u;
@@ -164,7 +171,8 @@ static int decode_target_port(unsigned char * buff,
return 0;
}
-static void decode_tpgs_state(const int st)
+static void
+decode_tpgs_state(const int st)
{
switch (st) {
case TPGS_STATE_OPTIMIZED:
@@ -186,13 +194,14 @@ static void decode_tpgs_state(const int st)
printf(" (transitioning between states)");
break;
default:
- printf(" (unknown)");
+ printf(" (unknown: 0x%x)", st);
break;
}
}
-int transition_tpgs_states(struct tgtgrp *tgtState, int numgrp,
- int portgroup, int newstate)
+static int
+transition_tpgs_states(struct tgtgrp *tgtState, int numgrp, int portgroup,
+ int newstate)
{
int i,oldstate;
@@ -241,7 +250,8 @@ int transition_tpgs_states(struct tgtgrp *tgtState, int numgrp,
return 0;
}
-void encode_tpgs_states(unsigned char *buff, struct tgtgrp *tgtState, int numgrp)
+static void
+encode_tpgs_states(unsigned char *buff, struct tgtgrp *tgtState, int numgrp)
{
int i;
unsigned char *desc;
@@ -253,7 +263,8 @@ void encode_tpgs_states(unsigned char *buff, struct tgtgrp *tgtState, int numgrp
}
}
-int main(int argc, char * argv[])
+int
+main(int argc, char * argv[])
{
int sg_fd, k, off, res, c, report_len, tgt_port_count, trunc, numgrp;
unsigned char reportTgtGrpBuff[TGT_GRP_BUFF_LEN];
@@ -267,14 +278,13 @@ int main(int argc, char * argv[])
int verbose = 0;
int portgroup = -1;
int relport = -1;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "aosuhHrvV", long_options,
+ c = getopt_long(argc, argv, "ahHloOrsuvV", long_options,
&option_index);
if (c == -1)
break;
@@ -283,18 +293,6 @@ int main(int argc, char * argv[])
case 'a':
state = TPGS_STATE_NONOPTIMIZED;
break;
- case 'o':
- state = TPGS_STATE_OPTIMIZED;
- break;
- case 's':
- state = TPGS_STATE_STANDBY;
- break;
- case 'u':
- state = TPGS_STATE_UNAVAILABLE;
- break;
- case 'l':
- state = TPGS_STATE_OFFLINE;
- break;
case 'h':
case '?':
usage();
@@ -302,9 +300,22 @@ int main(int argc, char * argv[])
case 'H':
hex = 1;
break;
+ case 'l':
+ case 'O':
+ state = TPGS_STATE_OFFLINE;
+ break;
+ case 'o':
+ state = TPGS_STATE_OPTIMIZED;
+ break;
case 'r':
raw = 1;
break;
+ case 's':
+ state = TPGS_STATE_STANDBY;
+ break;
+ case 'u':
+ state = TPGS_STATE_UNAVAILABLE;
+ break;
case 'v':
++verbose;
break;
@@ -318,9 +329,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -332,7 +342,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
@@ -344,11 +354,11 @@ int main(int argc, char * argv[])
return SG_LIB_FILE_ERROR;
}
- res = sg_ll_inquiry(sg_fd, 0, 1, 0x83, rsp_buff,
- 252, 1, verbose);
+ res = sg_ll_inquiry(sg_fd, 0, 1, VPD_DEVICE_ID, rsp_buff,
+ DEF_VPD_DEVICE_ID_LEN, 1, verbose);
if (0 == res) {
report_len = ((rsp_buff[2] << 8) + rsp_buff[3]) + 4;
- if (0x83 != rsp_buff[1]) {
+ if (VPD_DEVICE_ID != rsp_buff[1]) {
fprintf(stderr, "invalid VPD response; probably a STANDARD "
"INQUIRY response\n");
if (verbose) {
@@ -361,9 +371,9 @@ int main(int argc, char * argv[])
fprintf(stderr, "response length too long: %d > %d\n", report_len,
MX_ALLOC_LEN);
return SG_LIB_CAT_MALFORMED;
- } else if (report_len > 252) {
- if (sg_ll_inquiry(sg_fd, 0, 1, 0x83, rsp_buff, report_len,
- 1, verbose))
+ } else if (report_len > DEF_VPD_DEVICE_ID_LEN) {
+ if (sg_ll_inquiry(sg_fd, 0, 1, VPD_DEVICE_ID, rsp_buff,
+ report_len, 1, verbose))
return SG_LIB_CAT_OTHER;
}
decode_target_port(rsp_buff + 4, report_len - 4, &relport, &portgroup);
diff --git a/src/sg_sync.c b/src/sg_sync.c
index 3ace34cd..31eb2d8d 100644
--- a/src/sg_sync.c
+++ b/src/sg_sync.c
@@ -45,7 +45,7 @@
* (e.g. disks).
*/
-static char * version_str = "1.07 20070419";
+static char * version_str = "1.08 20070919";
#define ME "sg_sync: "
@@ -100,10 +100,9 @@ int main(int argc, char * argv[])
int immed = 0;
int sync_nv = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -157,9 +156,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -171,7 +169,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_test_rwbuf.c b/src/sg_test_rwbuf.c
index 9ec684cb..c76f2d4b 100644
--- a/src/sg_test_rwbuf.c
+++ b/src/sg_test_rwbuf.c
@@ -39,7 +39,7 @@
#include "sg_io_linux.h"
-static char * version_str = "1.05 20070714";
+static char * version_str = "1.06 20070919";
#define BPI (signed)(sizeof(int))
@@ -359,12 +359,11 @@ void usage ()
int main (int argc, char * argv[])
{
int sg_fd, res;
- char device_name[256];
+ const char * device_name = NULL;
int times = 1;
int ret = 0;
int k = 0;
- device_name[0] = '\0';
while (1) {
int option_index = 0;
int c;
@@ -422,10 +421,8 @@ int main (int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind],
- sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
}
@@ -464,7 +461,7 @@ int main (int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
}
- if ('\0' == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "no device name given\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_verify.c b/src/sg_verify.c
index b5de97b0..58b93fcf 100644
--- a/src/sg_verify.c
+++ b/src/sg_verify.c
@@ -48,7 +48,7 @@
* This program issues the SCSI VERIFY command to the given SCSI block device.
*/
-static char * version_str = "1.09 20070714";
+static char * version_str = "1.10 20070919";
#define ME "sg_verify: "
@@ -98,11 +98,10 @@ int main(int argc, char * argv[])
unsigned long long lba = 0;
unsigned long long orig_lba;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
unsigned long info = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -154,9 +153,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -180,7 +178,7 @@ int main(int argc, char * argv[])
orig_count = count;
orig_lba = lba;
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index f9848197..75c1791a 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -52,7 +52,7 @@
*/
-static char * version_str = "0.20 20070829"; /* spc-4 rev 11 */
+static char * version_str = "0.21 20070918"; /* spc-4 rev 11 */
extern void svpd_enumerate_vendor(void);
extern int svpd_decode_vendor(int sg_fd, int num_vpd, int subvalue,
@@ -1765,7 +1765,7 @@ static int svpd_decode_standard(int sg_fd, int num_vpd, int subvalue,
int main(int argc, char * argv[])
{
int sg_fd, c, res;
- char device_name[256];
+ const char * device_name = NULL;
const struct svpd_values_name_t * vnp;
const char * page_str = NULL;
const char * cp;
@@ -1780,7 +1780,6 @@ int main(int argc, char * argv[])
int req_pdt = -1;
int subvalue = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -1834,9 +1833,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -1898,7 +1896,7 @@ int main(int argc, char * argv[])
subvalue = VPD_DI_SEL_LU;
}
}
- if ('\0' == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "No DEVICE argument given\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_wr_mode.c b/src/sg_wr_mode.c
index 58702c66..9cadbec2 100644
--- a/src/sg_wr_mode.c
+++ b/src/sg_wr_mode.c
@@ -46,7 +46,7 @@
* mode page on the given device.
*/
-static char * version_str = "1.08 20070714";
+static char * version_str = "1.09 20070919";
#define ME "sg_wr_mode: "
@@ -294,7 +294,7 @@ int main(int argc, char * argv[])
int save = 0;
int verbose = 0;
int read_in_len = 0;
- char device_name[256];
+ const char * device_name = NULL;
unsigned char read_in[MX_ALLOC_LEN];
unsigned char mask_in[MX_ALLOC_LEN];
unsigned char ref_md[MX_ALLOC_LEN];
@@ -302,7 +302,6 @@ int main(int argc, char * argv[])
struct sg_simple_inquiry_resp inq_data;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -388,9 +387,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -401,7 +399,7 @@ int main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_write_buffer.c b/src/sg_write_buffer.c
index 7c97ca36..13fde8d6 100644
--- a/src/sg_write_buffer.c
+++ b/src/sg_write_buffer.c
@@ -46,7 +46,7 @@
* This utility issues the SCSI WRITE BUFFER command to the given device.
*/
-static char * version_str = "1.04 20070714"; /* spc4r08 */
+static char * version_str = "1.05 20070919"; /* spc4r08 */
#define ME "sg_write_buffer: "
#define DEF_XFER_LEN (8 * 1024 * 1024)
@@ -167,13 +167,12 @@ int main(int argc, char * argv[])
int wb_offset = 0;
int wb_skip = 0;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
const char * file_name = NULL;
unsigned char * dop = NULL;
char ebuff[EBUFF_SZ];
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -267,9 +266,8 @@ int main(int argc, char * argv[])
return 0;
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -281,7 +279,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_write_long.c b/src/sg_write_long.c
index ff088c9f..4e6112fc 100644
--- a/src/sg_write_long.c
+++ b/src/sg_write_long.c
@@ -31,7 +31,7 @@
This code was contributed by Saeed Bishara
*/
-static char * version_str = "1.14 20070714";
+static char * version_str = "1.15 20070919";
#define MAX_XFER_LEN 10000
@@ -100,13 +100,12 @@ int main(int argc, char * argv[])
int verbose = 0;
long long ll;
int got_stdin;
- char device_name[256];
+ const char * device_name = NULL;
char file_name[256];
char ebuff[EBUFF_SZ];
const char * ten_or;
int ret = 1;
- memset(device_name, 0, sizeof device_name);
memset(file_name, 0, sizeof file_name);
while (1) {
int option_index = 0;
@@ -164,9 +163,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -178,7 +176,7 @@ int main(int argc, char * argv[])
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;