aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-07-14 12:10:34 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-07-14 12:10:34 +0000
commit11f2735930974f7590e713d5b564f01bd7722cdd (patch)
tree3fa437e959124931a5701ccaa7ef618e24162130
parentde7b4b82446c7a297781106bd0fb6c09eebed0a4 (diff)
downloadsg3_utils-11f2735930974f7590e713d5b564f01bd7722cdd.tar.gz
add sg_sat_set_features to main directory + build
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@87 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--COPYING8
-rw-r--r--COVERAGE14
-rw-r--r--ChangeLog4
-rw-r--r--Makefile.am87
-rw-r--r--Makefile.in71
-rw-r--r--NEWS1
-rw-r--r--README23
-rw-r--r--debian/changelog2
-rw-r--r--debian/control1
-rw-r--r--examples/Makefile10
-rw-r--r--examples/sg_sat_set_features.c280
-rw-r--r--pre_configure/README22
-rw-r--r--sg3_utils.spec6
-rw-r--r--sg_sat_identify.c6
-rw-r--r--sg_sat_set_features.8 (renamed from examples/sg_sat_set_features.8)26
-rw-r--r--sg_sat_set_features.c372
16 files changed, 547 insertions, 386 deletions
diff --git a/COPYING b/COPYING
index 4fc6be3b..4c5be745 100644
--- a/COPYING
+++ b/COPYING
@@ -12,17 +12,17 @@ Upstream Authors: Douglas Gilbert <dgilbert at interlog dot com>,
Copyright:
-This software is copyright(c) 1994-2005 by the authors
+This software is copyright(c) 1994-2007 by the authors
You are free to distribute this software under the terms of
the GNU General Public License.
On Debian systems, the complete text of the GNU General Public
License can be found in /usr/share/common-licenses/GPL file.
-Some parts of this package are covered by the BSD license.
+many parts of this package are covered by the BSD license.
These include central error processing code (sg_lib.[hc]),
-common command code (sg_cmds.[hc]) and later utilities. They
-are Copyright: Douglas Gilbert.
+common command code (sg_cmds_basic.[hc] and sg_cmds_extra.[hc])
+and later utilities. They are Copyright: Douglas Gilbert.
The author's intention is that the BSD licensed code can be used
freely by others. On Debian systems, the complete text of the
BSD License can be found in `/usr/share/common-licenses/BSD'.
diff --git a/COVERAGE b/COVERAGE
index afdc7010..39cff60f 100644
--- a/COVERAGE
+++ b/COVERAGE
@@ -6,10 +6,11 @@ on the right. The second table lists supported ATA commands.
SCSI command sg3_utils utilities that use this SCSI command
------------ -------------------------------------------------
-ATA COMMAND PASS-THROUGH(16) sg_sat_identify (main directory)
- sg_sat_chk_power, sg__sat_identify,
- sg_sat_set_features, sg_sat_smart_rd_data
- (last four in the examples directory), ++
+ATA COMMAND PASS-THROUGH(16) sg_sat_identify, sg_sat_set_features
+ (main directory); sg_sat_chk_power, sg__sat_identify,
+ sg_sat_phy_event, sg__sat_set_features,
+ sg_sat_smart_rd_data (previous five in the examples
+ directory), ++
ATA COMMAND PASS-THROUGH(12) sg_sat_identify, ++
GET CONFIGURATION sg_get_config, ++
INQUIRY sg_dd, sg_format, sg_inq, sginfo,
@@ -73,7 +74,8 @@ IDENTIFY DEVICE sg_inq, sg_scan, sg_sat_identify,
IDENTIFY PACKET DEVICE sg_inq, sg_sat_identify,
examples/sg__sat_identify
READ LOG EXT examples/sg_sat_phy_event
-SET FEATURES examples/sg_sat_set_features
+SET FEATURES sg_sat_set_features
+ examples/sg__sat_set_features
SMART READ DATA examples/sg_sat_smart_rd_data
@@ -84,4 +86,4 @@ SMART READ DATA examples/sg_sat_smart_rd_data
Doug Gilbert
-21st April 2007
+18th July 2007
diff --git a/ChangeLog b/ChangeLog
index d6e6135c..39e9ce8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,9 @@ 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 [20070718]
+Changelog for sg3_utils-1.25 [20070719]
+ - sg_sat_set_features: new utility (actually copied from examples
+ directory); renamed examples version: sg__sat_set_features
- 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/Makefile.am b/Makefile.am
index 92a935fe..74f0783e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,9 +17,10 @@ bin_PROGRAMS = \
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_scan sg_senddiag sg_ses \
- sg_start sg_sync sg_test_rwbuf sg_turs sg_verify \
- sg_vpd sg_write_buffer sg_write_long sg_wr_mode
+ sg_rtpg sg_sat_identify sg_sat_set_features sg_scan \
+ sg_senddiag sg_ses sg_start sg_sync sg_test_rwbuf \
+ sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
+ sg_wr_mode
man_MANS = \
sg3_utils.8 \
@@ -28,9 +29,10 @@ man_MANS = \
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_scan.8 sg_senddiag.8 sg_ses.8 \
- sg_start.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_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 sg_scan.8 \
+ sg_senddiag.8 sg_ses.8 sg_start.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
libsgutils_la_SOURCES = \
sg_lib.c sg_lib.h \
@@ -69,9 +71,10 @@ bin_PROGRAMS = \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
sg_read_long sg_reassign sg_requests sg_rmsn \
- sg_rtpg sg_sat_identify sg_scan sg_senddiag sg_ses \
- sg_start sg_sync sg_turs sg_verify \
- sg_vpd sg_write_buffer sg_write_long sg_wr_mode
+ sg_rtpg sg_sat_identify sg_sat_set_features sg_scan \
+ sg_senddiag sg_ses sg_start sg_sync \
+ sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
+ sg_wr_mode
man_MANS = \
sg3_utils.8 \
@@ -80,9 +83,10 @@ man_MANS = \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
- sg_rtpg.8 sg_sat_identify.8 sg_scan.8 sg_senddiag.8 sg_ses.8 \
- sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
- sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+ sg_wr_mode.8
libsgutils_la_SOURCES = \
sg_lib.c sg_lib.h \
@@ -121,9 +125,10 @@ bin_PROGRAMS = \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
sg_read_long sg_reassign sg_requests sg_rmsn \
- sg_rtpg sg_sat_identify sg_scan sg_senddiag sg_ses \
- sg_start sg_sync sg_turs sg_verify \
- sg_vpd sg_write_buffer sg_write_long sg_wr_mode
+ sg_rtpg sg_sat_identify sg_sat_set_features sg_scan \
+ sg_senddiag sg_ses sg_start sg_sync \
+ sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
+ sg_wr_mode
man_MANS = \
sg3_utils.8 \
@@ -132,9 +137,10 @@ man_MANS = \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
- sg_rtpg.8 sg_sat_identify.8 sg_scan.8 sg_senddiag.8 sg_ses.8 \
- sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
- sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+ sg_wr_mode.8
libsgutils_la_SOURCES = \
sg_lib.c sg_lib.h \
@@ -173,9 +179,10 @@ bin_PROGRAMS = \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
sg_read_long sg_reassign sg_requests sg_rmsn \
- sg_rtpg sg_sat_identify sg_senddiag sg_ses \
- sg_start sg_sync sg_turs sg_verify \
- sg_vpd sg_write_buffer sg_write_long sg_wr_mode
+ sg_rtpg sg_sat_identify sg_sat_set_features \
+ sg_senddiag sg_ses sg_start sg_sync \
+ sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
+ sg_wr_mode
man_MANS = \
sg3_utils.8 \
@@ -184,9 +191,10 @@ man_MANS = \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
- sg_rtpg.8 sg_sat_identify.8 sg_senddiag.8 sg_ses.8 \
- sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
- sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.8
+ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
+ sg_senddiag.8 sg_ses.8 sg_start.8 sg_sync.8 \
+ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+ sg_wr_mode.8
libsgutils_la_SOURCES = \
sg_lib.c sg_lib.h \
@@ -225,9 +233,10 @@ bin_PROGRAMS = \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
sg_read_long sg_reassign sg_requests sg_rmsn \
- sg_rtpg sg_sat_identify sg_senddiag sg_ses \
- sg_start sg_sync sg_turs sg_verify \
- sg_vpd sg_write_buffer sg_write_long sg_wr_mode
+ sg_rtpg sg_sat_identify sg_sat_set_features \
+ sg_senddiag sg_ses sg_start sg_sync \
+ sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
+ sg_wr_mode
man_MANS = \
sg3_utils.8 \
@@ -236,9 +245,10 @@ man_MANS = \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
- sg_rtpg.8 sg_sat_identify.8 sg_senddiag.8 sg_ses.8 \
- sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
- sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.8
+ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
+ sg_senddiag.8 sg_ses.8 sg_start.8 sg_sync.8 \
+ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+ sg_wr_mode.8
libsgutils_la_SOURCES = \
sg_lib.c sg_lib.h \
@@ -277,9 +287,10 @@ bin_PROGRAMS = \
sg_modes sg_opcodes sg_persist \
sg_prevent sg_raw sg_rdac sg_readcap \
sg_read_long sg_reassign sg_requests sg_rmsn \
- sg_rtpg sg_sat_identify sg_senddiag sg_ses \
- sg_start sg_sync sg_turs sg_verify \
- sg_vpd sg_write_buffer sg_write_long sg_wr_mode
+ sg_rtpg sg_sat_identify sg_sat_set_features \
+ sg_senddiag sg_ses sg_start sg_sync \
+ sg_turs sg_verify sg_vpd sg_write_buffer sg_write_long \
+ sg_wr_mode
man_MANS = \
sg3_utils.8 \
@@ -288,9 +299,10 @@ man_MANS = \
sg_modes.8 sg_opcodes.8 sg_persist.8 \
sg_prevent.8 sg_raw.8 sg_rdac.8 sg_readcap.8 \
sg_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
- sg_rtpg.8 sg_sat_identify.8 sg_senddiag.8 sg_ses.8 \
- sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
- sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.8
+ sg_rtpg.8 sg_sat_identify.8 sg_sat_set_features.8 \
+ sg_senddiag.8 sg_ses.8 sg_start.8 sg_sync.8 \
+ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+ sg_wr_mode.8
libsgutils_la_SOURCES = \
sg_lib.c sg_lib.h \
@@ -419,6 +431,9 @@ sg_rtpg_LDADD = libsgutils.la @os_libs@
sg_sat_identify_SOURCES = sg_sat_identify.c
sg_sat_identify_LDADD = libsgutils.la @os_libs@
+sg_sat_set_features_SOURCES = sg_sat_set_features.c
+sg_sat_set_features_LDADD = libsgutils.la @os_libs@
+
sg_scan_SOURCES = sg_scan.c sg_io_linux.c
sg_scan_LDADD = libsgutils.la @os_libs@
diff --git a/Makefile.in b/Makefile.in
index 0e98b0d0..eb2aef63 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -53,6 +53,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_rmsn$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_rtpg$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_sat_set_features$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_scan$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_senddiag$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_ses$(EXEEXT) \
@@ -83,6 +84,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_rmsn$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_rtpg$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_sat_set_features$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_scan$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_senddiag$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_ses$(EXEEXT) \
@@ -113,6 +115,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_rmsn$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_rtpg$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_sat_set_features$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_senddiag$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_ses$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_start$(EXEEXT) \
@@ -142,6 +145,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_rmsn$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_rtpg$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_sat_set_features$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_senddiag$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_ses$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_start$(EXEEXT) \
@@ -181,6 +185,7 @@ host_triplet = @host@
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_rmsn$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_rtpg$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_sat_identify$(EXEEXT) \
+@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_sat_set_features$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_scan$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_senddiag$(EXEEXT) \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_ses$(EXEEXT) \
@@ -203,6 +208,7 @@ host_triplet = @host@
@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_sat_set_features$(EXEEXT) \
@OS_FREEBSD_TRUE@ sg_senddiag$(EXEEXT) sg_ses$(EXEEXT) \
@OS_FREEBSD_TRUE@ sg_start$(EXEEXT) sg_sync$(EXEEXT) \
@OS_FREEBSD_TRUE@ sg_turs$(EXEEXT) sg_verify$(EXEEXT) \
@@ -346,6 +352,9 @@ sg_rtpg_DEPENDENCIES = libsgutils.la
am_sg_sat_identify_OBJECTS = sg_sat_identify.$(OBJEXT)
sg_sat_identify_OBJECTS = $(am_sg_sat_identify_OBJECTS)
sg_sat_identify_DEPENDENCIES = libsgutils.la
+am_sg_sat_set_features_OBJECTS = sg_sat_set_features.$(OBJEXT)
+sg_sat_set_features_OBJECTS = $(am_sg_sat_set_features_OBJECTS)
+sg_sat_set_features_DEPENDENCIES = libsgutils.la
am_sg_scan_OBJECTS = sg_scan.$(OBJEXT) sg_io_linux.$(OBJEXT)
sg_scan_OBJECTS = $(am_sg_scan_OBJECTS)
sg_scan_DEPENDENCIES = libsgutils.la
@@ -415,9 +424,10 @@ SOURCES = $(libsgutils_la_SOURCES) $(EXTRA_libsgutils_la_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_scan_SOURCES) \
- $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) $(sg_start_SOURCES) \
- $(sg_sync_SOURCES) $(sg_test_rwbuf_SOURCES) $(sg_turs_SOURCES) \
+ $(sg_sat_identify_SOURCES) $(sg_sat_set_features_SOURCES) \
+ $(sg_scan_SOURCES) $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) \
+ $(sg_start_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)
@@ -432,9 +442,10 @@ DIST_SOURCES = $(am__libsgutils_la_SOURCES_DIST) \
$(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_scan_SOURCES) \
- $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) $(sg_start_SOURCES) \
- $(sg_sync_SOURCES) $(sg_test_rwbuf_SOURCES) $(sg_turs_SOURCES) \
+ $(sg_sat_identify_SOURCES) $(sg_sat_set_features_SOURCES) \
+ $(sg_scan_SOURCES) $(sg_senddiag_SOURCES) $(sg_ses_SOURCES) \
+ $(sg_start_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)
@@ -579,9 +590,10 @@ scsiincludedir = $(includedir)/scsi
@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_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
-@OS_FREEBSD_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_senddiag.8 sg_ses.8 \
-@OS_FREEBSD_TRUE@ sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
-@OS_FREEBSD_TRUE@ sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+@OS_FREEBSD_TRUE@ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+@OS_FREEBSD_TRUE@ sg_wr_mode.8
@OS_LINUX_TRUE@man_MANS = \
@OS_LINUX_TRUE@ sg3_utils.8 \
@@ -590,9 +602,10 @@ scsiincludedir = $(includedir)/scsi
@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_scan.8 sg_senddiag.8 sg_ses.8 \
-@OS_LINUX_TRUE@ sg_start.8 sg_sync.8 sg_test_rwbuf.8 sg_turs.8 sg_verify.8 \
-@OS_LINUX_TRUE@ sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_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_OSF_TRUE@man_MANS = \
@OS_OSF_TRUE@ sg3_utils.8 \
@@ -601,9 +614,10 @@ scsiincludedir = $(includedir)/scsi
@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_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
-@OS_OSF_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_senddiag.8 sg_ses.8 \
-@OS_OSF_TRUE@ sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
-@OS_OSF_TRUE@ sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+@OS_OSF_TRUE@ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+@OS_OSF_TRUE@ sg_wr_mode.8
@OS_SOLARIS_TRUE@man_MANS = \
@OS_SOLARIS_TRUE@ sg3_utils.8 \
@@ -612,9 +626,10 @@ scsiincludedir = $(includedir)/scsi
@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_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
-@OS_SOLARIS_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_senddiag.8 sg_ses.8 \
-@OS_SOLARIS_TRUE@ sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
-@OS_SOLARIS_TRUE@ sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+@OS_SOLARIS_TRUE@ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+@OS_SOLARIS_TRUE@ sg_wr_mode.8
@OS_WIN32_CYGWIN_TRUE@man_MANS = \
@OS_WIN32_CYGWIN_TRUE@ sg3_utils.8 \
@@ -623,9 +638,10 @@ scsiincludedir = $(includedir)/scsi
@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_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
-@OS_WIN32_CYGWIN_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_scan.8 sg_senddiag.8 sg_ses.8 \
-@OS_WIN32_CYGWIN_TRUE@ sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
-@OS_WIN32_CYGWIN_TRUE@ sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+@OS_WIN32_CYGWIN_TRUE@ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+@OS_WIN32_CYGWIN_TRUE@ sg_wr_mode.8
@OS_WIN32_MINGW_TRUE@man_MANS = \
@OS_WIN32_MINGW_TRUE@ sg3_utils.8 \
@@ -634,9 +650,10 @@ scsiincludedir = $(includedir)/scsi
@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_read_long.8 sg_reassign.8 sg_requests.8 sg_rmsn.8 \
-@OS_WIN32_MINGW_TRUE@ sg_rtpg.8 sg_sat_identify.8 sg_scan.8 sg_senddiag.8 sg_ses.8 \
-@OS_WIN32_MINGW_TRUE@ sg_start.8 sg_sync.8 sg_turs.8 sg_verify.8 \
-@OS_WIN32_MINGW_TRUE@ sg_vpd.8 sg_write_buffer.8 sg_write_long.8 sg_wr_mode.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_sync.8 \
+@OS_WIN32_MINGW_TRUE@ sg_turs.8 sg_verify.8 sg_vpd.8 sg_write_buffer.8 sg_write_long.8 \
+@OS_WIN32_MINGW_TRUE@ sg_wr_mode.8
@OS_FREEBSD_TRUE@libsgutils_la_SOURCES = \
@OS_FREEBSD_TRUE@ sg_lib.c sg_lib.h \
@@ -858,6 +875,8 @@ sg_rtpg_SOURCES = sg_rtpg.c
sg_rtpg_LDADD = libsgutils.la @os_libs@
sg_sat_identify_SOURCES = sg_sat_identify.c
sg_sat_identify_LDADD = libsgutils.la @os_libs@
+sg_sat_set_features_SOURCES = sg_sat_set_features.c
+sg_sat_set_features_LDADD = libsgutils.la @os_libs@
sg_scan_SOURCES = sg_scan.c sg_io_linux.c
sg_scan_LDADD = libsgutils.la @os_libs@
sg_senddiag_SOURCES = sg_senddiag.c
@@ -1072,6 +1091,9 @@ sg_rtpg$(EXEEXT): $(sg_rtpg_OBJECTS) $(sg_rtpg_DEPENDENCIES)
sg_sat_identify$(EXEEXT): $(sg_sat_identify_OBJECTS) $(sg_sat_identify_DEPENDENCIES)
@rm -f sg_sat_identify$(EXEEXT)
$(LINK) $(sg_sat_identify_OBJECTS) $(sg_sat_identify_LDADD) $(LIBS)
+sg_sat_set_features$(EXEEXT): $(sg_sat_set_features_OBJECTS) $(sg_sat_set_features_DEPENDENCIES)
+ @rm -f sg_sat_set_features$(EXEEXT)
+ $(LINK) $(sg_sat_set_features_OBJECTS) $(sg_sat_set_features_LDADD) $(LIBS)
sg_scan$(EXEEXT): $(sg_scan_OBJECTS) $(sg_scan_DEPENDENCIES)
@rm -f sg_scan$(EXEEXT)
$(LINK) $(sg_scan_OBJECTS) $(sg_scan_LDADD) $(LIBS)
@@ -1159,6 +1181,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_rmsn.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_rtpg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_sat_identify.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_sat_set_features.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_scan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_senddiag.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_ses.Po@am__quote@
diff --git a/NEWS b/NEWS
index e69de29b..6a959142 100644
--- a/NEWS
+++ b/NEWS
@@ -0,0 +1 @@
+See the ChangeLog file.
diff --git a/README b/README
index 63a558fa..cfd6de1b 100644
--- a/README
+++ b/README
@@ -150,9 +150,10 @@ of the sg3_utils directory:
sg_format, sg_ident, sg_inq, sg_logs, sg_luns, sg_map, sg_map26,
sg_modes, sg_opcodes, sg_persist, sg_prevent, sg_raw, sg_rbuf, sg_rdac,
sg_read, sg_readcap, sg_read_buffer, sg_read_long, sg_reassign,
- sg_request, sg_reset, sg_rmsn, sg_rtpg, sg_sat_identify, sg_scan,
- sg_senddiag, sg_ses, sg_start, sg_sync, sg_test_rwbuff, sg_turs,
- sg_verify, sg_vpd, sg_write_buffer, sg_write_long, sg_wr_mode
+ sg_request, sg_reset, sg_rmsn, sg_rtpg, sg_sat_identify,
+ sg_sat_set_features, sg_scan, sg_senddiag, sg_ses, sg_start, sg_sync,
+ sg_test_rwbuff, sg_turs, sg_verify, sg_vpd, sg_write_buffer,
+ sg_write_long, sg_wr_mode
These utilities and the libsgutils.so library which they depend on are built
by the build scripts in the main directory. Only the code in the main
@@ -179,9 +180,8 @@ Some of these utilities have man pages.
Here is a list in alphabetical order of utilities found in the examples
subdirectory:
- sg_excl, scsi_inquiry, sg_iovec_tst, sg_sat_chk_power,
- sg__sat_identify, sg_sat_phy_event, sg_sat_set_features,
- sg_sat_smart_rd_data, sg_simple1, sg_simple2, sg_simple3, sg_simple4,
- sg_simple5 and sg_simple16
+ sg__sat_identify, sg_sat_phy_event, sg_sat_smart_rd_data, sg_simple1,
+ sg_simple2, sg_simple3, sg_simple4, sg_simple5 and sg_simple16
Also in that subdirectory is a script to test sg_persist, an example
data file for sg_persist (called "transport_ids.txt") and an example
@@ -252,9 +252,6 @@ descriptor (as defined in SAT).
through the SAT-defined ATA PASS_THROUGH (16) SCSI command. If
successful, the 256 word (512 byte) response is output.
-"sg_sat_set_features" attempts to push an ATA SET FEATURES command
-through the SAT-defined ATA PASS_THROUGH (16) SCSI command.
-
Command line processing
=======================
@@ -283,9 +280,9 @@ or using '-O' as the first command line option.
The more recent utilities that use "getopt_long" only are:
- sg_format sg_get_config sg_ident sg_luns sg_map26 sg_persist
sg_prevent sg_raw sg_read_buffer sg_read_long sg_reassign sg_requests
- sg_rmsn sg_rtpg sg_sat_identify sg_scan (w), sg_ses sg_sync
- sg_test_rwbuf sg_verify sg_vpd sg_write_buffer sg_write_long
- sg_wr_mode
+ sg_rmsn sg_rtpg sg_sat_identify sg_sat_set_features
+ sg_sat_set_features sg_scan(w) sg_ses sg_sync sg_test_rwbuf sg_verify
+ sg_vpd sg_write_buffer sg_write_long sg_wr_mode
Linux header file problems
@@ -322,4 +319,4 @@ See http://www.torque.net/sg/tools.html
Doug Gilbert
-16th July 2007
+18th July 2007
diff --git a/debian/changelog b/debian/changelog
index 3e36d563..86c08020 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, 15 Jul 2007 15:00:00 -0400
+ -- Doug Gilbert <dgilbert@interlog.com> Thu, 19 Jul 2007 23:00:00 -0400
sg3-utils (1.24-0.1) unstable; urgency=low
diff --git a/debian/control b/debian/control
index 31672eeb..5f9ba2df 100644
--- a/debian/control
+++ b/debian/control
@@ -48,6 +48,7 @@ Description: Collection of Linux utilities for devices that use the
* sg_rmsn - READ SERIAL SERIAL NUMBER
* sg_rtpg - REPORT TARGET PORT GROUPS
* sg_sat_identify - ATA IDENTIFY (PACKET) DEVICE via SATL
+ * sg_sat_set_features - ATA SET FEATURES via SATL
* sg_scan - displays the SCSI bus on stdout
* sg_senddiag - runs SCSI self tests
* sg_ses - fetches status and send control to a SES device
diff --git a/examples/Makefile b/examples/Makefile
index 91c98242..feea3da7 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -9,8 +9,8 @@ LD = gcc
EXECS = sg_simple1 sg_simple2 sg_simple3 sg_simple4 sg_simple16 \
sg_iovec_tst scsi_inquiry sg_excl sg_sense_test sg_simple5 \
- sg__sat_identify sg_sat_chk_power sg_sat_smart_rd_data \
- sg_sat_set_features sg_sat_phy_event
+ sg__sat_identify sg__sat_set_features sg_sat_chk_power \
+ sg_sat_smart_rd_data sg_sat_phy_event
# EXECS = sg_simple1 sg_simple2 sg_simple3 sg_simple4 sg_simple16 \
# sg_simple_aio sg_iovec_tst scsi_inquiry sg_excl
@@ -71,13 +71,13 @@ sg_simple5: sg_simple5.o ../sg_lib.o ../sg_pt_linux.o
sg__sat_identify: sg__sat_identify.o ../sg_lib.o ../sg_io_linux.o
$(LD) -o $@ $(LDFLAGS) $^
-sg_sat_chk_power: sg_sat_chk_power.o ../sg_lib.o ../sg_io_linux.o
+sg__sat_set_features: sg__sat_set_features.o ../sg_lib.o ../sg_io_linux.o
$(LD) -o $@ $(LDFLAGS) $^
-sg_sat_smart_rd_data: sg_sat_smart_rd_data.o ../sg_lib.o ../sg_io_linux.o
+sg_sat_chk_power: sg_sat_chk_power.o ../sg_lib.o ../sg_io_linux.o
$(LD) -o $@ $(LDFLAGS) $^
-sg_sat_set_features: sg_sat_set_features.o ../sg_lib.o ../sg_io_linux.o
+sg_sat_smart_rd_data: sg_sat_smart_rd_data.o ../sg_lib.o ../sg_io_linux.o
$(LD) -o $@ $(LDFLAGS) $^
sg_sat_phy_event: sg_sat_phy_event.o ../sg_lib.o ../sg_io_linux.o
diff --git a/examples/sg_sat_set_features.c b/examples/sg_sat_set_features.c
deleted file mode 100644
index b7257737..00000000
--- a/examples/sg_sat_set_features.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2006-2007 Douglas Gilbert.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <getopt.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "sg_lib.h"
-#include "sg_io_linux.h"
-
-/* This program performs a ATA PASS-THROUGH (16) SCSI command in order
- to perform an ATA SET FEATURES command. See http://www.t10.org
- SAT draft at time of writing: sat-r09.pdf
-
- Invocation:
- sg_sat_set_features [-c <n>] [-f <n>] [-h] [-l <n>] [-v] [-V] <device>
-
-*/
-
-#define SAT_ATA_PASS_THROUGH16 0x85
-#define SAT_ATA_PASS_THROUGH16_LEN 16
-#define SAT_ATA_RETURN_DESC 9 /* ATA Return (sense) Descriptor */
-
-#define ATA_SET_FEATURES 0xef
-
-#define EBUFF_SZ 256
-
-static char * version_str = "1.02 20070406";
-
-static struct option long_options[] = {
- {"count", required_argument, 0, 'c'},
- {"chk_cond", no_argument, 0, 'C'},
- {"feature", required_argument, 0, 'f'},
- {"help", no_argument, 0, 'h'},
- {"lba", required_argument, 0, 'l'},
- {"verbose", no_argument, 0, 'v'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0},
-};
-
-void usage()
-{
- fprintf(stderr, "Usage: "
- "sg_sat_set_features [--count=C] [--chk_cond] [--feature=F] "
- "[--help]\n"
- " [-lba=LBA] [--verbose] [--version] "
- "DEVICE\n"
- " where:\n"
- " --count=C|-c C count field contents (def: 0)\n"
- " --chk_cond|-C set chk_cond field in pass-through "
- "(def: 0)\n"
- " --feature=F|-f F feature field contents (def: 0)\n"
- " --help|-h output this usage message\n"
- " --lba=LBA| -l LBA LBA field contents (def: 0)\n"
- " --verbose|-v increase verbosity\n"
- " --version|-V print version string and exit\n\n"
- "Sends an ATA SET FEATURES command via a SAT pass through.\n"
- "Primary feature code is placed in '--feature=F' with '--count=C' "
- "and\n"
- "'--lba=LBA' being auxiliaries for some features. The arguments C, "
- "F and LBA\n"
- "are decimal unless prefixed by '0x' or have a trailing 'h'.\n"
- "Example enabling write cache: 'sg_sat_set_feature --feature=2 "
- "/dev/sdc'\n");
-}
-
-int main(int argc, char * argv[])
-{
- int sg_fd, c, k;
- unsigned char aptCmdBlk[SAT_ATA_PASS_THROUGH16_LEN] =
- {SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0};
- sg_io_hdr_t io_hdr;
- char device_name[256];
- char ebuff[EBUFF_SZ];
- unsigned char sense_buffer[64];
- int count = 0;
- int feature = 0;
- int lba = 0;
- int verbose = 0;
- int extend = 0;
- int chk_cond = 0; /* set to 1 to read register(s) back */
- int protocol = 3; /* non-dat data-in */
- int t_dir = 1; /* 0 -> to device, 1 -> from device */
- int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
- int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * ucp = NULL;
-
- memset(device_name, 0, sizeof(device_name));
- while (1) {
- int option_index = 0;
-
- c = getopt_long(argc, argv, "c:Cf:hl:vV", long_options,
- &option_index);
- if (c == -1)
- break;
-
- switch (c) {
- case 'c':
- count = sg_get_num(optarg);
- if ((count < 0) || (count > 255)) {
- fprintf(stderr, "bad argument for '--count'\n");
- return SG_LIB_SYNTAX_ERROR;
- }
- break;
- case 'C':
- chk_cond = 1;
- break;
- case 'f':
- feature = sg_get_num(optarg);
- if ((feature < 0) || (feature > 255)) {
- fprintf(stderr, "bad argument for '--feature'\n");
- return SG_LIB_SYNTAX_ERROR;
- }
- break;
- case 'h':
- case '?':
- usage();
- return 0;
- case 'l':
- lba = sg_get_num(optarg);
- if ((lba < 0) || (lba > 255)) {
- fprintf(stderr, "bad argument for '--lba'\n");
- return SG_LIB_SYNTAX_ERROR;
- }
- break;
- case 'v':
- ++verbose;
- break;
- case 'V':
- fprintf(stderr, "version: %s\n", version_str);
- return 0;
- default:
- fprintf(stderr, "unrecognised option code 0x%x ??\n", c);
- usage();
- return SG_LIB_SYNTAX_ERROR;
- }
- }
- if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
- ++optind;
- }
- if (optind < argc) {
- for (; optind < argc; ++optind)
- fprintf(stderr, "Unexpected extra argument: %s\n",
- argv[optind]);
- usage();
- return SG_LIB_SYNTAX_ERROR;
- }
- }
-
- if ('\0' == device_name[0]) {
- fprintf(stderr, "missing device name!\n");
- usage();
- return 1;
- }
-
- if ((sg_fd = open(device_name, O_RDWR)) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- "sg_sat_set_features: error opening file: %s", device_name);
- perror(ebuff);
- return 1;
- }
-
- /* Prepare ATA PASS-THROUGH COMMAND (16) command */
- aptCmdBlk[14] = ATA_SET_FEATURES;
- aptCmdBlk[1] = (protocol << 1) | extend;
- aptCmdBlk[2] = (chk_cond << 5) | (t_dir << 3) |
- (byte_block << 2) | t_length;
- aptCmdBlk[4] = feature;
- aptCmdBlk[6] = count;
- aptCmdBlk[8] = lba & 0xff;
- aptCmdBlk[10] = (lba >> 8) & 0xff;
- aptCmdBlk[12] = (lba >> 16) & 0xff;
- if (verbose) {
- fprintf(stderr, " ata pass through(16) cdb: ");
- for (k = 0; k < SAT_ATA_PASS_THROUGH16_LEN; ++k)
- fprintf(stderr, "%02x ", aptCmdBlk[k]);
- fprintf(stderr, "\n");
- }
-
- memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
- io_hdr.interface_id = 'S';
- io_hdr.cmd_len = sizeof(aptCmdBlk);
- /* io_hdr.iovec_count = 0; */ /* memset takes care of this */
- io_hdr.mx_sb_len = sizeof(sense_buffer);
- io_hdr.dxfer_direction = SG_DXFER_NONE;
- io_hdr.dxfer_len = 0;
- io_hdr.dxferp = NULL;
- io_hdr.cmdp = aptCmdBlk;
- io_hdr.sbp = sense_buffer;
- io_hdr.timeout = 20000; /* 20000 millisecs == 20 seconds */
- /* io_hdr.flags = 0; */ /* take defaults: indirect IO, etc */
- /* io_hdr.pack_id = 0; */
- /* io_hdr.usr_ptr = NULL; */
-
- if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) {
- perror("sg_sat_set_features: SG_IO ioctl error");
- close(sg_fd);
- return 1;
- }
-
- /* error processing: N.B. expect check condition, no sense ... !! */
- switch (sg_err_category3(&io_hdr)) {
- case SG_LIB_CAT_CLEAN:
- break;
- case SG_LIB_CAT_RECOVERED: /* sat-r09 uses this sk */
- case SG_LIB_CAT_NO_SENSE: /* earlier SAT drafts used this */
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp) {
- if (verbose > 1)
- printf("ATA Return Descriptor expected in sense but not "
- "found\n");
- sg_chk_n_print3("ATA_16 command error", &io_hdr, 1);
- } else if (verbose)
- sg_chk_n_print3("ATA Return Descriptor", &io_hdr, 1);
- if (ucp && ucp[3]) {
- if (ucp[3] & 0x4)
- printf("error in returned FIS: aborted command\n");
- else
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
- }
- break;
- default:
- fprintf(stderr, "unexpected SCSI sense category\n");
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp)
- sg_chk_n_print3("ATA_16 command error", &io_hdr, 1);
- else if (verbose)
- sg_chk_n_print3("ATA Return Descriptor, as expected",
- &io_hdr, 1);
- if (ucp && ucp[3]) {
- if (ucp[3] & 0x4)
- printf("error in returned FIS: aborted command\n");
- else
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
- }
- break;
- }
-
- close(sg_fd);
- return 0;
-}
diff --git a/pre_configure/README b/pre_configure/README
new file mode 100644
index 00000000..1585e48d
--- /dev/null
+++ b/pre_configure/README
@@ -0,0 +1,22 @@
+The contents of this "pre_configure" subdirectory are the hand-crafted
+Makefiles and associated scripts that were used prior to their replacment
+by the autotools based logic. The autotools suite is associated with the
+build sequence: "./configure ; make ; make install" that many users are
+coming to expect. While it might be easier for users (especially on
+lesser used architectures) autotools is a pain to setup. It can also
+be sensitive to which versions of build tools (e.g. autoconf and automake)
+are being used.
+
+Hence the old hand-crafted Makefiles and associated scripts are archived
+in this directory. They represent the state of the build system during
+the development of sg3_utils version 1.25 . This older build system
+won't be maintained past this point and is put here for reference and
+may be helpful if autotools breaks down (or at least they may show the
+author's intentions).
+
+Note that various other subdirectories (e.g. utils and examples) still
+use hand-crafted Makefiles.
+
+Douglas Gilbert
+18th July 2007
+
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 91c5c4fb..c232a006 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -63,7 +63,7 @@ fi
%files
%defattr(-,root,root)
-%doc AUTHORS ChangeLog COVERAGE CREDITS INSTALL NEWS README README.sg_start
+%doc AUTHORS ChangeLog COPYING COVERAGE CREDITS INSTALL NEWS README README.sg_start
%attr(755,root,root) %{_bindir}/*
%{_mandir}/man8/*
@@ -79,8 +79,8 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Jul 15 2007 - dgilbert at interlog dot com
-- sg_dd oflag=sparse,null
+* Thu Jul 19 2007 - dgilbert at interlog dot com
+- add sg_sat_set_features, sg_dd oflag=sparse,null
* sg3_utils-1.25
* Mon May 07 2007 - dgilbert at interlog dot com
diff --git a/sg_sat_identify.c b/sg_sat_identify.c
index 1fdb2d6c..9e98df16 100644
--- a/sg_sat_identify.c
+++ b/sg_sat_identify.c
@@ -64,7 +64,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.03 20070714";
+static char * version_str = "1.03 20070719";
static struct option long_options[] = {
{"chk_cond", no_argument, 0, 'c'},
@@ -135,7 +135,7 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
memset(sense_buffer, 0, sb_sz);
memset(ata_return_desc, 0, sizeof(ata_return_desc));
ok = 0;
- if (16 == cdb_len) {
+ if (SAT_ATA_PASS_THROUGH16_LEN == cdb_len) {
/* Prepare ATA PASS-THROUGH COMMAND (16) command */
aptCmdBlk[6] = 1; /* sector count */
aptCmdBlk[14] = (do_packet ? ATA_IDENTIFY_PACKET_DEVICE :
@@ -285,7 +285,7 @@ int main(int argc, char * argv[])
{
int sg_fd, c, res;
char device_name[256];
- int cdb_len = 16;
+ int cdb_len = SAT_ATA_PASS_THROUGH16_LEN;
int do_packet = 0;
int do_hex = 0;
int do_raw = 0;
diff --git a/examples/sg_sat_set_features.8 b/sg_sat_set_features.8
index 8cced221..ed7683b6 100644
--- a/examples/sg_sat_set_features.8
+++ b/sg_sat_set_features.8
@@ -1,12 +1,12 @@
-.TH SG_SAT_SET_FEATURES "8" "May 2007" "sg3_utils\-1.24" SG3_UTILS
+.TH SG_SAT_SET_FEATURES "8" "July 2007" "sg3_utils\-1.25" SG3_UTILS
.SH NAME
sg_sat_set_featutes \- sends a ATA SET FEATURES command via a
SCSI to ATA Translation (SAT) layer
.SH SYNOPSIS
.B sg_sat_set_features
-[\fI\-\-count=\fRC] [\fI\-\-chk_cond\fR] [\fI\-\-feature=\fRF] [\fI\-\-help\fR]
-[\fI\-\-lba=\fRLBA] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
-\fIDEVICE\fR
+[\fI\-\-count=\fRCO] [\fI\-\-chk_cond\fR] [\fI\-\-feature=\fRFEA]
+[\fI\-\-help\fR] [\fI\-\-len=\fR12|16] [\fI\-\-lba=\fRLBA]
+[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -17,7 +17,8 @@ command directly to the device it is sent via a SCSI transport which is
assumed to contain a SCSI to ATA Translation (SAT) Layer (SATL). The SAT
standard (SAT ANSI INCITS 431-2007; prior draft: sat\-r09.pdf at www.t10.org)
defines two SCSI "ATA PASS\-THROUGH" commands: one using a 16 byte "cdb" and
-the other with a 12 byte cdb. This utility uses the 16 byte cdb variant.
+the other with a 12 byte cdb. This utility defaults to the 16 byte cdb
+variant.
.PP
The SATL may be in an operating system driver, in host bus adapter firmware
or in some external enclosure.
@@ -28,8 +29,8 @@ DEVICE (for packet devices) command.
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
.TP
-\fB\-c\fR, \fB\-\-count\fR=\fIC\fR
-the number \fIC\fR is placed in the "count" field in the ATA SET
+\fB\-c\fR, \fB\-\-count\fR=\fICO\fR
+the number \fICO\fR is placed in the "count" field in the ATA SET
FEATURES command. Only some subcommands (a term used for the value
placed in the "feature" field) require the count field to be set.
The default value placed in the "count" field is 0.
@@ -41,8 +42,8 @@ sense buffer containing a ATA Result descriptor irrespective of whether
the command succeeded or failed. When clear the SATL should only yield
a sense buffer containing a ATA Result descriptor if the command failed.
.TP
-\fB\-f\fR, \fB\-\-feature\fR=\fIF\fR
-the number \fIF\fR is placed in the "feature" field in the ATA SET
+\fB\-f\fR, \fB\-\-feature\fR=\fIFEA\fR
+the number \fIFEA\fR is placed in the "feature" field in the ATA SET
FEATURES command. The term "subcommand" is sometimes used for this
value. The default value placed in the "feature" field is 0 which
is reserved and hence should not change anything.
@@ -51,7 +52,12 @@ is reserved and hence should not change anything.
outputs the usage message summarizing command line options
then exits. Ignores \fIDEVICE\fR if given.
.TP
-\fB\-l\fR, \fB\-\-lba\fR=\fILBA\fR
+\fB\-l\fR, \fB\-\-len\fR=12 | 16
+this is the length of the SCSI cdb used for the ATA PASS\-THROUGH commands.
+The argument can either be 12 or 16. The default is 16. Some SCSI
+transports cannot convey SCSI commands longer than 12 bytes.
+.TP
+\fB\-L\fR, \fB\-\-lba\fR=\fILBA\fR
the number \fILBA\fR is placed in the "lba" field in the ATA SET
FEATURES command. Only some subcommands (a term used for the value
placed in the "feature" field) require the lba field to be set.
diff --git a/sg_sat_set_features.c b/sg_sat_set_features.c
new file mode 100644
index 00000000..02d28392
--- /dev/null
+++ b/sg_sat_set_features.c
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2006-2007 Douglas Gilbert.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "sg_lib.h"
+#include "sg_cmds_basic.h"
+#include "sg_cmds_extra.h"
+
+/* This program performs a ATA PASS-THROUGH (16) SCSI command in order
+ to perform an ATA SET FEATURES command. See http://www.t10.org
+ SAT draft at time of writing: sat-r09.pdf
+
+ See man page (sg_sat_set_features.8) for details.
+
+*/
+
+#define SAT_ATA_PASS_THROUGH16 0x85
+#define SAT_ATA_PASS_THROUGH16_LEN 16
+#define SAT_ATA_PASS_THROUGH12 0xa1 /* clashes with MMC BLANK comand */
+#define SAT_ATA_PASS_THROUGH12_LEN 12
+#define SAT_ATA_RETURN_DESC 9 /* ATA Return (sense) Descriptor */
+#define ASCQ_ATA_PT_INFO_AVAILABLE 0x1d
+
+#define ATA_SET_FEATURES 0xef
+
+#define DEF_TIMEOUT 20
+
+static char * version_str = "1.03 20070719";
+
+static struct option long_options[] = {
+ {"count", required_argument, 0, 'c'},
+ {"chk_cond", no_argument, 0, 'C'},
+ {"feature", required_argument, 0, 'f'},
+ {"help", no_argument, 0, 'h'},
+ {"len", required_argument, 0, 'l'},
+ {"lba", required_argument, 0, 'L'},
+ {"verbose", no_argument, 0, 'v'},
+ {"version", no_argument, 0, 'V'},
+ {0, 0, 0, 0},
+};
+
+void usage()
+{
+ fprintf(stderr, "Usage: "
+ "sg_sat_set_features [--count=CO] [--chk_cond] [--feature=FEA] "
+ "[--help]\n"
+ " [--lba=LBA] [--len=16|12] [--verbose] "
+ "[--version]\n"
+ " DEVICE\n"
+ " where:\n"
+ " --count=CO | -c CO count field contents (def: 0)\n"
+ " --chk_cond | -C set chk_cond field in pass-through "
+ "(def: 0)\n"
+ " --feature=FEA|-f FEA feature field contents\n"
+ " (def: 0 (which is reserved))\n"
+ " --help | -h output this usage message\n"
+ " --lba=LBA | -L LBA LBA field contents (def: 0)\n"
+ " --len=16|12 | -l 16|12 cdb length: 16 or 12 bytes "
+ "(def: 16)\n"
+ " --verbose | -v increase verbosity\n"
+ " --version | -V print version string and exit\n\n"
+ "Sends an ATA SET FEATURES command via a SAT pass through.\n"
+ "Primary feature code is placed in '--feature=FEA' with "
+ "'--count=CO' and\n"
+ "'--lba=LBA' being auxiliaries for some features. The arguments "
+ "CO, FEA\n"
+ "and LBA are decimal unless prefixed by '0x' or have a trailing "
+ "'h'.\n"
+ "Example enabling write cache: 'sg_sat_set_feature --feature=2 "
+ "/dev/sdc'\n");
+}
+
+
+
+static int do_set_features(int sg_fd, int feature, int count, int lba,
+ int cdb_len, int chk_cond, int verbose)
+{
+ int res, ret;
+ int extend = 0;
+ int protocol = 3; /* non-data */
+ int t_dir = 1; /* 0 -> to device, 1 -> from device */
+ int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
+ int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
+ int resid = 0;
+ int got_ard = 0; /* got ATA result descriptor */
+ int sb_sz;
+ struct sg_scsi_sense_hdr ssh;
+ unsigned char sense_buffer[64];
+ unsigned char ata_return_desc[16];
+ unsigned char aptCmdBlk[SAT_ATA_PASS_THROUGH16_LEN] =
+ {SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0};
+ unsigned char apt12CmdBlk[SAT_ATA_PASS_THROUGH12_LEN] =
+ {SAT_ATA_PASS_THROUGH12, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0};
+
+ sb_sz = sizeof(sense_buffer);
+ memset(sense_buffer, 0, sb_sz);
+ memset(ata_return_desc, 0, sizeof(ata_return_desc));
+ if (16 == cdb_len) {
+ /* Prepare ATA PASS-THROUGH COMMAND (16) command */
+ aptCmdBlk[14] = ATA_SET_FEATURES;
+ aptCmdBlk[4] = feature;
+ aptCmdBlk[6] = count;
+ aptCmdBlk[8] = lba & 0xff;
+ aptCmdBlk[10] = (lba >> 8) & 0xff;
+ aptCmdBlk[12] = (lba >> 16) & 0xff;
+ aptCmdBlk[1] = (protocol << 1) | extend;
+ aptCmdBlk[2] = (chk_cond << 5) | (t_dir << 3) |
+ (byte_block << 2) | t_length;
+ res = sg_ll_ata_pt(sg_fd, aptCmdBlk, cdb_len, DEF_TIMEOUT, NULL,
+ NULL /* doutp */, 0, sense_buffer,
+ sb_sz, ata_return_desc,
+ sizeof(ata_return_desc), &resid, verbose);
+ } else {
+ /* Prepare ATA PASS-THROUGH COMMAND (12) command */
+ apt12CmdBlk[9] = ATA_SET_FEATURES;
+ apt12CmdBlk[3] = feature;
+ apt12CmdBlk[4] = count;
+ apt12CmdBlk[5] = lba & 0xff;
+ apt12CmdBlk[6] = (lba >> 8) & 0xff;
+ apt12CmdBlk[7] = (lba >> 16) & 0xff;
+ apt12CmdBlk[1] = (protocol << 1);
+ apt12CmdBlk[2] = (chk_cond << 5) | (t_dir << 3) |
+ (byte_block << 2) | t_length;
+ res = sg_ll_ata_pt(sg_fd, apt12CmdBlk, cdb_len, DEF_TIMEOUT, NULL,
+ NULL /* doutp */, 0, sense_buffer,
+ sb_sz, ata_return_desc,
+ sizeof(ata_return_desc), &resid, verbose);
+ }
+ if (0 == res) {
+ if (verbose > 2)
+ fprintf(stderr, "command completed with SCSI GOOD status\n");
+ } else if ((res > 0) && (res & SAM_STAT_CHECK_CONDITION)) {
+ if (verbose > 1)
+ sg_print_sense("ATA pass through", sense_buffer, sb_sz,
+ ((verbose > 2) ? 1 : 0));
+ if (sg_scsi_normalize_sense(sense_buffer, sb_sz, &ssh)) {
+ switch (ssh.sense_key) {
+ case SPC_SK_ILLEGAL_REQUEST:
+ if ((0x20 == ssh.asc) && (0x0 == ssh.ascq)) {
+ ret = SG_LIB_CAT_INVALID_OP;
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d) not "
+ "supported\n", cdb_len);
+ } else {
+ ret = SG_LIB_CAT_ILLEGAL_REQ;
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d), bad "
+ "field in cdb\n", cdb_len);
+ }
+ return ret;
+ case SPC_SK_NO_SENSE:
+ case SPC_SK_RECOVERED_ERROR:
+ if ((0x0 == ssh.asc) &&
+ (ASCQ_ATA_PT_INFO_AVAILABLE == ssh.ascq)) {
+ if (SAT_ATA_RETURN_DESC != ata_return_desc[0]) {
+ if (verbose)
+ fprintf(stderr, "did not find ATA Return "
+ "(sense) Descriptor\n");
+ return SG_LIB_CAT_RECOVERED;
+ }
+ got_ard = 1;
+ break;
+ } else if (SPC_SK_RECOVERED_ERROR == ssh.sense_key)
+ return SG_LIB_CAT_RECOVERED;
+ else {
+ if ((0x0 == ssh.asc) && (0x0 == ssh.ascq))
+ break;
+ return SG_LIB_CAT_SENSE;
+ }
+ case SPC_SK_UNIT_ATTENTION:
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d), Unit Attention "
+ "detected\n", cdb_len);
+ return SG_LIB_CAT_UNIT_ATTENTION;
+ case SPC_SK_NOT_READY:
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d), device not "
+ "ready\n", cdb_len);
+ return SG_LIB_CAT_NOT_READY;
+ case SPC_SK_MEDIUM_ERROR:
+ case SPC_SK_HARDWARE_ERROR:
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d), medium or "
+ "hardware error\n", cdb_len);
+ return SG_LIB_CAT_MEDIUM_HARD;
+ case SPC_SK_ABORTED_COMMAND:
+ fprintf(stderr, "Aborted command\n");
+ return SG_LIB_CAT_ABORTED_COMMAND;
+ default:
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d), some sense "
+ "data, use '-v' for more information\n", cdb_len);
+ return SG_LIB_CAT_SENSE;
+ }
+ } else {
+ fprintf(stderr, "CHECK CONDITION without response code ??\n");
+ return SG_LIB_CAT_SENSE;
+ }
+ if (0x72 != (sense_buffer[0] & 0x7f)) {
+ fprintf(stderr, "expected descriptor sense format, response "
+ "code=0x%x\n", sense_buffer[0]);
+ return SG_LIB_CAT_MALFORMED;
+ }
+ } else if (res > 0) {
+ fprintf(stderr, "Unexpected SCSI status=0x%x\n", res);
+ return SG_LIB_CAT_MALFORMED;
+ } else {
+ fprintf(stderr, "ATA pass through (%d) failed\n", cdb_len);
+ if (verbose < 2)
+ fprintf(stderr, " try adding '-v' for more information\n");
+ return -1;
+ }
+
+ if ((SAT_ATA_RETURN_DESC == ata_return_desc[0]) && (0 == got_ard))
+ fprintf(stderr, "Seem to have got ATA Result Descriptor but "
+ "it was not indicated\n");
+ if (got_ard) {
+ if (ata_return_desc[3] & 0x4) {
+ fprintf(stderr, "error indication in returned FIS: aborted "
+ "command\n");
+ return SG_LIB_CAT_ABORTED_COMMAND;
+ }
+ }
+ return 0;
+}
+
+
+int main(int argc, char * argv[])
+{
+ int sg_fd, c, ret, res;
+ char device_name[256];
+ int count = 0;
+ int feature = 0;
+ int lba = 0;
+ int verbose = 0;
+ 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;
+
+ c = getopt_long(argc, argv, "c:Cf:hl:L:vV", long_options,
+ &option_index);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'c':
+ count = sg_get_num(optarg);
+ if ((count < 0) || (count > 255)) {
+ fprintf(stderr, "bad argument for '--count'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
+ case 'C':
+ chk_cond = 1;
+ break;
+ case 'f':
+ feature = sg_get_num(optarg);
+ if ((feature < 0) || (feature > 255)) {
+ fprintf(stderr, "bad argument for '--feature'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
+ case 'h':
+ case '?':
+ usage();
+ return 0;
+ case 'l':
+ cdb_len = sg_get_num(optarg);
+ if (! ((cdb_len == 12) || (cdb_len == 16))) {
+ fprintf(stderr, "argument to '--len' should be 12 or 16\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
+ case 'L':
+ lba = sg_get_num(optarg);
+ if ((lba < 0) || (lba > 255)) {
+ fprintf(stderr, "bad argument for '--lba'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
+ case 'v':
+ ++verbose;
+ break;
+ case 'V':
+ fprintf(stderr, "version: %s\n", version_str);
+ return 0;
+ default:
+ fprintf(stderr, "unrecognised option code 0x%x ??\n", c);
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ }
+ if (optind < argc) {
+ if ('\0' == device_name[0]) {
+ strncpy(device_name, argv[optind], sizeof(device_name) - 1);
+ device_name[sizeof(device_name) - 1] = '\0';
+ ++optind;
+ }
+ if (optind < argc) {
+ for (; optind < argc; ++optind)
+ fprintf(stderr, "Unexpected extra argument: %s\n",
+ argv[optind]);
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ }
+
+ if ('\0' == device_name[0]) {
+ fprintf(stderr, "missing device name!\n");
+ usage();
+ return 1;
+ }
+
+ if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */,
+ verbose)) < 0) {
+ fprintf(stderr, "error opening file: %s: %s\n",
+ device_name, safe_strerror(-sg_fd));
+ return SG_LIB_FILE_ERROR;
+ }
+
+ ret = do_set_features(sg_fd, feature, count, lba, cdb_len, chk_cond,
+ verbose);
+
+ res = sg_cmds_close_device(sg_fd);
+ if (res < 0) {
+ fprintf(stderr, "close error: %s\n", safe_strerror(-res));
+ if (0 == ret)
+ return SG_LIB_FILE_ERROR;
+ }
+ return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
+}