aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING16
-rw-r--r--COVERAGE6
-rw-r--r--ChangeLog3
-rw-r--r--INSTALL5
-rw-r--r--README38
-rw-r--r--debian/changelog2
-rw-r--r--include/Makefile.am6
-rw-r--r--include/Makefile.in10
-rw-r--r--include/sg_cmds.h7
-rw-r--r--include/sg_cmds_extra.h26
-rw-r--r--include/sg_cmds_mmc.h67
-rw-r--r--include/sg_lib.h22
-rw-r--r--include/sg_lib_data.h12
-rw-r--r--lib/Makefile.am6
-rw-r--r--lib/Makefile.in21
-rw-r--r--lib/sg_cmds_extra.c260
-rw-r--r--lib/sg_cmds_mmc.c306
-rw-r--r--lib/sg_lib.c10
-rw-r--r--lib/sg_lib_data.c97
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_get_config.c4
-rw-r--r--src/sg_inq.c34
-rw-r--r--src/sg_logs.c32
-rw-r--r--src/sg_modes.c24
24 files changed, 586 insertions, 430 deletions
diff --git a/COPYING b/COPYING
index 4c5be745..94503583 100644
--- a/COPYING
+++ b/COPYING
@@ -12,7 +12,7 @@ Upstream Authors: Douglas Gilbert <dgilbert at interlog dot com>,
Copyright:
-This software is copyright(c) 1994-2007 by the authors
+This software is copyright(c) 1994-2008 by the authors
You are free to distribute this software under the terms of
the GNU General Public License.
@@ -21,9 +21,13 @@ License can be found in /usr/share/common-licenses/GPL file.
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_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'.
+common command code (sg_cmds_basic.[hc], sg_cmds_mmc.[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'.
+
+Doug Gilbert
+18th February 2008
diff --git a/COVERAGE b/COVERAGE
index ebd39497..1985e4f0 100644
--- a/COVERAGE
+++ b/COVERAGE
@@ -81,11 +81,11 @@ SET FEATURES sg_sat_set_features
SMART READ DATA examples/sg_sat_smart_rd_data
-++ command wrapper found in sg_cmds_basic.c or sg_cmds_extra.c for
- this command
+++ command wrapper found in sg_cmds_basic.c, sg_cmds_mmc.c or
+ sg_cmds_extra.c for this command
(2) this command was known as REPORT DEVICE IDENTIFIER prior to spc4r07
(3) this command was known as SET DEVICE IDENTIFIER prior to spc4r07
Doug Gilbert
-2nd December 2007
+18th February 2008
diff --git a/ChangeLog b/ChangeLog
index c0fa17c3..d9716382 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.26 [20080217]
+Changelog for sg3_utils-1.26 [20080218]
- sg_ses: sync with ses2r19b
- sg_get_config: sync with mmc6r01
- allow Microcode upgrade and DVD read feature descriptors
@@ -24,6 +24,7 @@ Changelog for sg3_utils-1.26 [20080217]
uint64_t to stress that 64 bit integer wanted, not larger
- sg_lib: update asc/ascq code pending spc4r12
- split sg_lib into sg_lib_data.[hc] and sg_lib.[hc]
+ - split sg_cmds_extra into sg_cmds_extra and sg_cmds_mmc
- add osd2r03 service actions (all different from osd-r10)
- add sg_get_trans_proto_str()
- add sg_get_sense_filemark_eom_ili() function (MMC uses ILI)
diff --git a/INSTALL b/INSTALL
index f5d6615e..871fb984 100644
--- a/INSTALL
+++ b/INSTALL
@@ -58,7 +58,8 @@ the main directory. When the sg3_utils binary rpm is installed the executables
and their associated man pages should be placed in appropriate places. The
sg3_utils.spec file also builds a libsgutils shared object (shared library)
and a libsgutils-*-devel shared object with a static library and the sg_lib.h,
-sg_cmds.h sg_cmds_basic.h, sg_cmds_extra.h and sg_pt.h header files.
+sg_cmds.h sg_cmds_basic.h, sg_cmds_mmc.h, sg_cmds_extra.h and sg_pt.h header
+files.
Binary rpms (at least in the RedHat distribution) tend to install
executables in /usr/bin and libraries in /usr/lib .
@@ -137,5 +138,5 @@ Makefile.am file for a definitive list. The executables have a '.exe'
extension and can be executed in a MSYS or "cmd" shell.
-16th September 2007
Doug Gilbert
+18th February 2008
diff --git a/README b/README
index 7a647379..0198528b 100644
--- a/README
+++ b/README
@@ -70,23 +70,25 @@ The "sg_lib_data.[hc]" files contain ASCII text corresponding to most of the
SCSI commands, errors and warning conditions. The interface to this data
plus several related helper functions are found in the sg_lib.[hc] files.
The "sg_cmds_basic.[hc]" files contains code to invoke common SCSI commands
-and associated response processing. The "sg_cmds_extra.[hc]" files contains
-code to invoke lesser used SCSI commands and associated response processing.
-All are guided by recent drafts at www.t10.org which is the home site of
-SCSI (draft) standards. Linux specific code has been removed from sg_lib.[hc],
-sg_cmds_basic.[hc] and sg_cmds_extra.[hc] . The SCSI command implementations
-in sg_cmds_basic.c and sg_cmds_extra.c access the OS pass through mechanism
-via the function based interface defined in sg_pt.h . The linux specific
-implementation of that pass through is found in the sg_pt_linux.c file. Since
-almost all of the utilities use these files, a shared library called
-"libsgutils.so" is built. Use of this library cuts down the size of the
-binary distributions of sg3_utils significantly. In sg3_utils version 1.25
-then header files mentioned in this paragraph were relocated in the 'include'
-subdirectory while the source code files (i.e. those ending in ".c") were
-reloacted in the 'lib' subdirectory. The build scripts provided in the 'lib'
-subdirectory builds libsgutils.so The rest of the source code files have
-been relocated to the 'src' subdirectory. See the INSTALL file for more
-information.
+and associated response processing. The "sg_cmds_mmc.[hc]" files contain
+code to invoke SCSI commands specific to MMC (fro cd/dvd/bd devices).
+The "sg_cmds_extra.[hc]" files contains code to invoke lesser used SCSI
+commands and associated response processing. All are guided by recent drafts
+at www.t10.org which is the home site of SCSI (draft) standards. Linux
+specific code has been removed from sg_lib.[hc], sg_cmds_basic.[hc],
+sg_cmds_mmc.[hc] and sg_cmds_extra.[hc] . The SCSI command implementations
+in sg_cmds_basic.c, sg_cmds_mmc.c and sg_cmds_extra.c access the OS
+pass-through mechanism via the function based interface defined in sg_pt.h .
+The linux specific implementation of that pass through is found in the
+sg_pt_linux.c file. Since almost all of the utilities use these files, a
+shared library called "libsgutils.so" is built. Use of this library cuts
+down the size of the binary distributions of sg3_utils significantly. In
+sg3_utils version 1.25 then header files mentioned in this paragraph were
+relocated in the 'include' subdirectory while the source code files (i.e.
+those ending in ".c") were relocated in the 'lib' subdirectory. The build
+scripts provided in the 'lib' subdirectory builds libsgutils.so The rest
+of the source code files have been relocated to the 'src' subdirectory.
+See the INSTALL file for more information.
All the utilities in the 'src' subdirectory have "man" pages that are now
placed in the 'doc' subdirectory. There is also a sg3_utils (8) man page that
@@ -328,4 +330,4 @@ See http://www.torque.net/sg/tools.html
Doug Gilbert
-17th February 2008
+18th February 2008
diff --git a/debian/changelog b/debian/changelog
index 9d9029ab..99eef2e4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.26-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Sun, 17 Feb 2008 23:00:00 -0500
+ -- Doug Gilbert <dgilbert@interlog.com> Mon, 18 Feb 2008 14:00:00 -0500
sg3-utils (1.25-0.1) unstable; urgency=low
diff --git a/include/Makefile.am b/include/Makefile.am
index bf5c12f2..b24700f3 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -9,6 +9,7 @@ scsiinclude_HEADERS = \
sg_cmds.h \
sg_cmds_basic.h \
sg_cmds_extra.h \
+ sg_cmds_mmc.h \
sg_pt.h \
sg_linux_inc.h \
sg_io_linux.h
@@ -27,6 +28,7 @@ scsiinclude_HEADERS = \
sg_cmds.h \
sg_cmds_basic.h \
sg_cmds_extra.h \
+ sg_cmds_mmc.h \
sg_pt.h \
sg_pt_win32.h
@@ -45,6 +47,7 @@ scsiinclude_HEADERS = \
sg_cmds.h \
sg_cmds_basic.h \
sg_cmds_extra.h \
+ sg_cmds_mmc.h \
sg_pt.h \
sg_pt_win32.h
@@ -63,6 +66,7 @@ scsiinclude_HEADERS = \
sg_cmds.h \
sg_cmds_basic.h \
sg_cmds_extra.h \
+ sg_cmds_mmc.h \
sg_pt.h
noinst_HEADERS = \
@@ -81,6 +85,7 @@ scsiinclude_HEADERS = \
sg_cmds.h \
sg_cmds_basic.h \
sg_cmds_extra.h \
+ sg_cmds_mmc.h \
sg_pt.h
noinst_HEADERS = \
@@ -99,6 +104,7 @@ scsiinclude_HEADERS = \
sg_cmds.h \
sg_cmds_basic.h \
sg_cmds_extra.h \
+ sg_cmds_mmc.h \
sg_pt.h
noinst_HEADERS = \
diff --git a/include/Makefile.in b/include/Makefile.in
index 877323f3..7623fff6 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -47,8 +47,8 @@ SOURCES =
DIST_SOURCES =
am__noinst_HEADERS_DIST = sg_linux_inc.h sg_io_linux.h sg_pt_win32.h
am__scsiinclude_HEADERS_DIST = sg_lib.h sg_lib_data.h sg_cmds.h \
- sg_cmds_basic.h sg_cmds_extra.h sg_pt.h sg_linux_inc.h \
- sg_io_linux.h sg_pt_win32.h
+ sg_cmds_basic.h sg_cmds_extra.h sg_cmds_mmc.h sg_pt.h \
+ sg_linux_inc.h sg_io_linux.h sg_pt_win32.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -176,6 +176,7 @@ scsiincludedir = $(includedir)/scsi
@OS_FREEBSD_TRUE@ sg_cmds.h \
@OS_FREEBSD_TRUE@ sg_cmds_basic.h \
@OS_FREEBSD_TRUE@ sg_cmds_extra.h \
+@OS_FREEBSD_TRUE@ sg_cmds_mmc.h \
@OS_FREEBSD_TRUE@ sg_pt.h
@OS_LINUX_TRUE@scsiinclude_HEADERS = \
@@ -184,6 +185,7 @@ scsiincludedir = $(includedir)/scsi
@OS_LINUX_TRUE@ sg_cmds.h \
@OS_LINUX_TRUE@ sg_cmds_basic.h \
@OS_LINUX_TRUE@ sg_cmds_extra.h \
+@OS_LINUX_TRUE@ sg_cmds_mmc.h \
@OS_LINUX_TRUE@ sg_pt.h \
@OS_LINUX_TRUE@ sg_linux_inc.h \
@OS_LINUX_TRUE@ sg_io_linux.h
@@ -194,6 +196,7 @@ scsiincludedir = $(includedir)/scsi
@OS_OSF_TRUE@ sg_cmds.h \
@OS_OSF_TRUE@ sg_cmds_basic.h \
@OS_OSF_TRUE@ sg_cmds_extra.h \
+@OS_OSF_TRUE@ sg_cmds_mmc.h \
@OS_OSF_TRUE@ sg_pt.h
@OS_SOLARIS_TRUE@scsiinclude_HEADERS = \
@@ -202,6 +205,7 @@ scsiincludedir = $(includedir)/scsi
@OS_SOLARIS_TRUE@ sg_cmds.h \
@OS_SOLARIS_TRUE@ sg_cmds_basic.h \
@OS_SOLARIS_TRUE@ sg_cmds_extra.h \
+@OS_SOLARIS_TRUE@ sg_cmds_mmc.h \
@OS_SOLARIS_TRUE@ sg_pt.h
@OS_WIN32_CYGWIN_TRUE@scsiinclude_HEADERS = \
@@ -210,6 +214,7 @@ scsiincludedir = $(includedir)/scsi
@OS_WIN32_CYGWIN_TRUE@ sg_cmds.h \
@OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic.h \
@OS_WIN32_CYGWIN_TRUE@ sg_cmds_extra.h \
+@OS_WIN32_CYGWIN_TRUE@ sg_cmds_mmc.h \
@OS_WIN32_CYGWIN_TRUE@ sg_pt.h \
@OS_WIN32_CYGWIN_TRUE@ sg_pt_win32.h
@@ -219,6 +224,7 @@ scsiincludedir = $(includedir)/scsi
@OS_WIN32_MINGW_TRUE@ sg_cmds.h \
@OS_WIN32_MINGW_TRUE@ sg_cmds_basic.h \
@OS_WIN32_MINGW_TRUE@ sg_cmds_extra.h \
+@OS_WIN32_MINGW_TRUE@ sg_cmds_mmc.h \
@OS_WIN32_MINGW_TRUE@ sg_pt.h \
@OS_WIN32_MINGW_TRUE@ sg_pt_win32.h
diff --git a/include/sg_cmds.h b/include/sg_cmds.h
index 3f10b30a..690f53ab 100644
--- a/include/sg_cmds.h
+++ b/include/sg_cmds.h
@@ -8,11 +8,14 @@
* "sg_cmds_basic.h" header and the 'extra' ones found in the
* "sg_cmds_extra.h" header. This header now simply includes those two
* headers.
- * The corresponding function definitions are found in the "sg_cmds_basic.c"
- * and "sg_cmds_extra.c" files.
+ * In sg3_utils version 1.26 the sg_cmds_mmc.h header was added and
+ * contains some MMC specific commands.
+ * The corresponding function definitions are found in the sg_cmds_basic.c,
+ * sg_cmds_extra.c and sg_cmds_mmc.c files.
********************************************************************/
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
+#include "sg_cmds_mmc.h"
#endif
diff --git a/include/sg_cmds_extra.h b/include/sg_cmds_extra.h
index 195195b5..164c40a1 100644
--- a/include/sg_cmds_extra.h
+++ b/include/sg_cmds_extra.h
@@ -2,7 +2,7 @@
#define SG_CMDS_EXTRA_H
/*
- * Copyright (c) 2004-2007 Douglas Gilbert.
+ * Copyright (c) 2004-2008 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,22 +69,6 @@ extern int sg_ll_format_unit(int sg_fd, int fmtpinfo, int rto_req,
void * paramp, int param_len, int noisy,
int verbose);
-/* Invokes a SCSI GET CONFIGURATION command (MMC-3...6).
- * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
- * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
- * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
-extern int sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
- int mx_resp_len, int noisy, int verbose);
-
-/* Invokes a SCSI GET PERFORMANCE command (MMC-3...6).
- * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
- * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
- * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
-extern int sg_ll_get_performance(int sg_fd, int data_type,
- unsigned long starting_lba, int max_num_desc,
- int type, void * resp, int mx_resp_len,
- int noisy, int verbose);
-
/* Invokes a SCSI PERSISTENT RESERVE IN command (SPC). Returns 0
* when successful, SG_LIB_CAT_INVALID_OP if command not supported,
* SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
@@ -203,14 +187,6 @@ extern int sg_ll_send_diag(int sg_fd, int sf_code, int pf_bit, int sf_bit,
void * paramp, int param_len, int noisy,
int verbose);
-/* Invokes a SCSI SET CD SPEED command (MMC).
- * Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> command not supported,
- * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
- * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
- * -1 -> other failure */
-extern int sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed,
- int drv_write_speed, int noisy, int verbose);
-
/* Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was
* called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Set identifying information not supported,
diff --git a/include/sg_cmds_mmc.h b/include/sg_cmds_mmc.h
new file mode 100644
index 00000000..cf196e58
--- /dev/null
+++ b/include/sg_cmds_mmc.h
@@ -0,0 +1,67 @@
+#ifndef SG_CMDS_MMC_H
+#define SG_CMDS_MMC_H
+
+/*
+ * Copyright (c) 2008 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.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Invokes a SCSI GET CONFIGURATION command (MMC-3...6).
+ * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
+ * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
+ * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
+extern int sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
+ int mx_resp_len, int noisy, int verbose);
+
+/* Invokes a SCSI GET PERFORMANCE command (MMC-3...6).
+ * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
+ * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
+ * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
+extern int sg_ll_get_performance(int sg_fd, int data_type,
+ unsigned long starting_lba, int max_num_desc,
+ int type, void * resp, int mx_resp_len,
+ int noisy, int verbose);
+
+/* Invokes a SCSI SET CD SPEED command (MMC).
+ * Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> command not supported,
+ * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
+ * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
+ * -1 -> other failure */
+extern int sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed,
+ int drv_write_speed, int noisy, int verbose);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sg_lib.h b/include/sg_lib.h
index 4a4f562f..db9d1baa 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -58,6 +58,28 @@
extern "C" {
#endif
+/* SCSI Peripheral Device Types (PDT) [5 bit field] */
+#define PDT_DISK 0x0 /* direct access block device (disk) */
+#define PDT_TAPE 0x1 /* sequential access device (magnetic tape) */
+#define PDT_PRINTER 0x2 /* printer device (see SSC-1) */
+#define PDT_PROCESSOR 0x3 /* processor device (e.g. SAFTE device) */
+#define PDT_WO 0x4 /* write once device (some optical disks) */
+#define PDT_MMC 0x5 /* CD/DVD/BD (multi-media) */
+#define PDT_SCANNER 0x6 /* obsolete */
+#define PDT_OPTICAL 0x7 /* optical memory device (some optical disks) */
+#define PDT_MCHANGER 0x8 /* media changer device (e.g. tape robot) */
+#define PDT_COMMS 0x9 /* communications device (obsolete) */
+#define PDT_SAC 0xc /* storage array controller device */
+#define PDT_SES 0xd /* SCSI Enclosure Services (SES) device */
+#define PDT_RBC 0xe /* Reduced Block Commands (simplified PDT_DISK) */
+#define PDT_OCRW 0xf /* optical card read/write device */
+#define PDT_BCC 0x10 /* bridge controller commands */
+#define PDT_OSD 0x11 /* Object Storage Device (OSD) */
+#define PDT_ADC 0x12 /* Automation/drive commands (ADC) */
+#define PDT_SMD 0x13 /* Security Manager Device (SMD) */
+#define PDT_WLUN 0x1e /* Well known logical unit (WLUN) */
+#define PDT_UNKNOWN 0x1f /* Unknown or no device type */
+
#ifndef SAM_STAT_GOOD
/* The SCSI status codes as found in SAM-4 at www.t10.org */
#define SAM_STAT_GOOD 0x0
diff --git a/include/sg_lib_data.h b/include/sg_lib_data.h
index 7b8f15ed..75b7b479 100644
--- a/include/sg_lib_data.h
+++ b/include/sg_lib_data.h
@@ -57,20 +57,20 @@ extern "C" {
struct sg_lib_value_name_t {
int value;
- int peri_dev_type; /* only non-zero to disambiguate by command set */
+ int peri_dev_type; /* 0 -> SPC and/or PDT_DISK, >0 -> PDT */
const char * name;
};
struct sg_lib_asc_ascq_t {
- unsigned char code1;
- unsigned char code2;
+ unsigned char asc; /* additional sense code */
+ unsigned char ascq; /* additional sense code qualifier */
const char * text;
};
struct sg_lib_asc_ascq_range_t {
- unsigned char code1;
- unsigned char code2_min;
- unsigned char code2_max;
+ unsigned char asc; /* additional sense code (ASC) */
+ unsigned char ascq_min; /* ASCQ minimum in range */
+ unsigned char ascq_max; /* ASCQ maximum in range */
const char * text;
};
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b5e7c136..59e18052 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -7,6 +7,7 @@ libsgutils_la_SOURCES = \
sg_lib_data.c \
sg_cmds_basic.c \
sg_cmds_extra.c \
+ sg_cmds_mmc.c \
sg_pt_linux.c \
sg_io_linux.c
@@ -27,6 +28,7 @@ libsgutils_la_SOURCES = \
sg_lib_data.c \
sg_cmds_basic.c \
sg_cmds_extra.c \
+ sg_cmds_mmc.c \
sg_pt_win32.c
EXTRA_libsgutils_la_SOURCES = \
@@ -47,6 +49,7 @@ libsgutils_la_SOURCES = \
sg_lib_data.c \
sg_cmds_basic.c \
sg_cmds_extra.c \
+ sg_cmds_mmc.c \
sg_pt_win32.c
EXTRA_libsgutils_la_SOURCES = \
@@ -67,6 +70,7 @@ libsgutils_la_SOURCES = \
sg_lib_data.c \
sg_cmds_basic.c \
sg_cmds_extra.c \
+ sg_cmds_mmc.c \
sg_pt_freebsd.c
EXTRA_libsgutils_la_SOURCES = \
@@ -88,6 +92,7 @@ libsgutils_la_SOURCES = \
sg_lib_data.c \
sg_cmds_basic.c \
sg_cmds_extra.c \
+ sg_cmds_mmc.c \
sg_pt_solaris.c
EXTRA_libsgutils_la_SOURCES = \
@@ -109,6 +114,7 @@ libsgutils_la_SOURCES = \
sg_lib_data.c \
sg_cmds_basic.c \
sg_cmds_extra.c \
+ sg_cmds_mmc.c \
sg_pt_osf1.c
EXTRA_libsgutils_la_SOURCES = \
diff --git a/lib/Makefile.in b/lib/Makefile.in
index b255c900..8cf8c0ad 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -51,37 +51,43 @@ am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
am__libsgutils_la_SOURCES_DIST = sg_lib.c sg_lib_data.c \
- sg_cmds_basic.c sg_cmds_extra.c sg_pt_freebsd.c sg_pt_linux.c \
- sg_io_linux.c sg_pt_osf1.c sg_pt_solaris.c sg_pt_win32.c
+ sg_cmds_basic.c sg_cmds_extra.c sg_cmds_mmc.c sg_pt_freebsd.c \
+ sg_pt_linux.c sg_io_linux.c sg_pt_osf1.c sg_pt_solaris.c \
+ sg_pt_win32.c
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@am_libsgutils_la_OBJECTS = sg_lib.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_lib_data.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_basic.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_extra.lo \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_mmc.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_pt_win32.lo
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@am_libsgutils_la_OBJECTS = sg_lib.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_lib_data.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_extra.lo \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_mmc.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_pt_win32.lo
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@am_libsgutils_la_OBJECTS = sg_lib.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_lib_data.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_basic.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_extra.lo \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_mmc.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_pt_solaris.lo
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@am_libsgutils_la_OBJECTS = \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_lib.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_lib_data.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_basic.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_extra.lo \
+@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_mmc.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_pt_osf1.lo
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@am_libsgutils_la_OBJECTS = sg_lib.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_lib_data.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_basic.lo \
@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_extra.lo \
-@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_pt_linux.lo sg_io_linux.lo
+@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_mmc.lo sg_pt_linux.lo \
+@OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_io_linux.lo
@OS_FREEBSD_TRUE@am_libsgutils_la_OBJECTS = sg_lib.lo sg_lib_data.lo \
@OS_FREEBSD_TRUE@ sg_cmds_basic.lo sg_cmds_extra.lo \
-@OS_FREEBSD_TRUE@ sg_pt_freebsd.lo
+@OS_FREEBSD_TRUE@ sg_cmds_mmc.lo sg_pt_freebsd.lo
am__EXTRA_libsgutils_la_SOURCES_DIST = sg_pt_linux.c sg_io_linux.c \
sg_linux_inc.h sg_pt_osf1.c sg_pt_solaris.c sg_pt_win32.c \
getopt_long.c sg_pt_freebsd.c
@@ -220,6 +226,7 @@ top_srcdir = @top_srcdir@
@OS_FREEBSD_TRUE@ sg_lib_data.c \
@OS_FREEBSD_TRUE@ sg_cmds_basic.c \
@OS_FREEBSD_TRUE@ sg_cmds_extra.c \
+@OS_FREEBSD_TRUE@ sg_cmds_mmc.c \
@OS_FREEBSD_TRUE@ sg_pt_freebsd.c
@OS_LINUX_TRUE@libsgutils_la_SOURCES = \
@@ -227,6 +234,7 @@ top_srcdir = @top_srcdir@
@OS_LINUX_TRUE@ sg_lib_data.c \
@OS_LINUX_TRUE@ sg_cmds_basic.c \
@OS_LINUX_TRUE@ sg_cmds_extra.c \
+@OS_LINUX_TRUE@ sg_cmds_mmc.c \
@OS_LINUX_TRUE@ sg_pt_linux.c \
@OS_LINUX_TRUE@ sg_io_linux.c
@@ -235,6 +243,7 @@ top_srcdir = @top_srcdir@
@OS_OSF_TRUE@ sg_lib_data.c \
@OS_OSF_TRUE@ sg_cmds_basic.c \
@OS_OSF_TRUE@ sg_cmds_extra.c \
+@OS_OSF_TRUE@ sg_cmds_mmc.c \
@OS_OSF_TRUE@ sg_pt_osf1.c
@OS_SOLARIS_TRUE@libsgutils_la_SOURCES = \
@@ -242,6 +251,7 @@ top_srcdir = @top_srcdir@
@OS_SOLARIS_TRUE@ sg_lib_data.c \
@OS_SOLARIS_TRUE@ sg_cmds_basic.c \
@OS_SOLARIS_TRUE@ sg_cmds_extra.c \
+@OS_SOLARIS_TRUE@ sg_cmds_mmc.c \
@OS_SOLARIS_TRUE@ sg_pt_solaris.c
@OS_WIN32_CYGWIN_TRUE@libsgutils_la_SOURCES = \
@@ -249,6 +259,7 @@ top_srcdir = @top_srcdir@
@OS_WIN32_CYGWIN_TRUE@ sg_lib_data.c \
@OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic.c \
@OS_WIN32_CYGWIN_TRUE@ sg_cmds_extra.c \
+@OS_WIN32_CYGWIN_TRUE@ sg_cmds_mmc.c \
@OS_WIN32_CYGWIN_TRUE@ sg_pt_win32.c
@OS_WIN32_MINGW_TRUE@libsgutils_la_SOURCES = \
@@ -256,6 +267,7 @@ top_srcdir = @top_srcdir@
@OS_WIN32_MINGW_TRUE@ sg_lib_data.c \
@OS_WIN32_MINGW_TRUE@ sg_cmds_basic.c \
@OS_WIN32_MINGW_TRUE@ sg_cmds_extra.c \
+@OS_WIN32_MINGW_TRUE@ sg_cmds_mmc.c \
@OS_WIN32_MINGW_TRUE@ sg_pt_win32.c
@OS_FREEBSD_TRUE@EXTRA_libsgutils_la_SOURCES = \
@@ -385,6 +397,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt_long.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_basic.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_extra.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_mmc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_io_linux.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_lib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_lib_data.Plo@am__quote@
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index bfb98da2..2d852338 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2007 Douglas Gilbert.
+ * Copyright (c) 1999-2008 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,10 +61,6 @@
#define ATA_PT_16_CMDLEN 16
#define FORMAT_UNIT_CMD 0x4
#define FORMAT_UNIT_CMDLEN 6
-#define GET_CONFIG_CMD 0x46
-#define GET_CONFIG_CMD_LEN 10
-#define GET_PERFORMANCE_CMD 0xac
-#define GET_PERFORMANCE_CMD_LEN 12
#define PERSISTENT_RESERVE_IN_CMD 0x5e
#define PERSISTENT_RESERVE_IN_CMDLEN 10
#define PERSISTENT_RESERVE_OUT_CMD 0x5f
@@ -81,8 +77,6 @@
#define SEND_DIAGNOSTIC_CMDLEN 6
#define SERVICE_ACTION_IN_12_CMD 0xab
#define SERVICE_ACTION_IN_12_CMDLEN 12
-#define SET_CD_SPEED_CMD 0xbb
-#define SET_CD_SPEED_CMDLEN 12
#define READ_LONG10_CMD 0x3e
#define READ_LONG10_CMDLEN 10
#define WRITE_LONG10_CMD 0x3f
@@ -166,71 +160,6 @@ sg_ll_report_tgt_prt_grp(int sg_fd, void * resp, int mx_resp_len, int noisy,
return ret;
}
-/* Invokes a SCSI SET CD SPEED command (MMC).
- * Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> command not supported,
- * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
- * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
- * -1 -> other failure */
-int
-sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed,
- int drv_write_speed, int noisy, int verbose)
-{
- int res, ret, k, sense_cat;
- unsigned char scsCmdBlk[SET_CD_SPEED_CMDLEN] = {SET_CD_SPEED_CMD, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
- unsigned char sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
-
- if (NULL == sg_warnings_strm)
- sg_warnings_strm = stderr;
- scsCmdBlk[1] |= (rot_control & 0x3);
- scsCmdBlk[2] = (drv_read_speed >> 8) & 0xff;
- scsCmdBlk[3] = drv_read_speed & 0xff;
- scsCmdBlk[4] = (drv_write_speed >> 8) & 0xff;
- scsCmdBlk[5] = drv_write_speed & 0xff;
-
- if (verbose) {
- fprintf(sg_warnings_strm, " set cd speed cdb: ");
- for (k = 0; k < SET_CD_SPEED_CMDLEN; ++k)
- fprintf(sg_warnings_strm, "%02x ", scsCmdBlk[k]);
- fprintf(sg_warnings_strm, "\n");
- }
- ptvp = construct_scsi_pt_obj();
- if (NULL == ptvp) {
- fprintf(sg_warnings_strm, "set cd speed: out of memory\n");
- return -1;
- }
- set_scsi_pt_cdb(ptvp, scsCmdBlk, sizeof(scsCmdBlk));
- set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "set cd speed", res, 0,
- sense_b, noisy, verbose, &sense_cat);
- if (-1 == ret)
- ;
- else if (-2 == ret) {
- switch (sense_cat) {
- case SG_LIB_CAT_NOT_READY:
- case SG_LIB_CAT_UNIT_ATTENTION:
- case SG_LIB_CAT_INVALID_OP:
- case SG_LIB_CAT_ILLEGAL_REQ:
- case SG_LIB_CAT_ABORTED_COMMAND:
- ret = sense_cat;
- break;
- case SG_LIB_CAT_RECOVERED:
- case SG_LIB_CAT_NO_SENSE:
- ret = 0;
- break;
- default:
- ret = -1;
- break;
- }
- } else
- ret = 0;
-
- destruct_scsi_pt_obj(ptvp);
- return ret;
-}
-
/* Invokes a SCSI SET TARGET PORT GROUPS command. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Set Target Port Groups not supported,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
@@ -883,193 +812,6 @@ sg_ll_reassign_blocks(int sg_fd, int longlba, int longlist, void * paramp,
return ret;
}
-/* Invokes a SCSI GET CONFIGURATION command (MMC-3,4,5).
- * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
- * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
- * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
-int
-sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
- int mx_resp_len, int noisy, int verbose)
-{
- int res, k, ret, sense_cat;
- unsigned char gcCmdBlk[GET_CONFIG_CMD_LEN] = {GET_CONFIG_CMD, 0, 0, 0,
- 0, 0, 0, 0, 0, 0};
- unsigned char sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
-
- if (NULL == sg_warnings_strm)
- sg_warnings_strm = stderr;
- if ((rt < 0) || (rt > 3)) {
- fprintf(sg_warnings_strm, "Bad rt value: %d\n", rt);
- return -1;
- }
- gcCmdBlk[1] = (rt & 0x3);
- if ((starting < 0) || (starting > 0xffff)) {
- fprintf(sg_warnings_strm, "Bad starting field number: 0x%x\n",
- starting);
- return -1;
- }
- gcCmdBlk[2] = (unsigned char)((starting >> 8) & 0xff);
- gcCmdBlk[3] = (unsigned char)(starting & 0xff);
- if ((mx_resp_len < 0) || (mx_resp_len > 0xffff)) {
- fprintf(sg_warnings_strm, "Bad mx_resp_len: 0x%x\n", starting);
- return -1;
- }
- gcCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff);
- gcCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff);
-
- if (verbose) {
- fprintf(sg_warnings_strm, " Get Configuration cdb: ");
- for (k = 0; k < GET_CONFIG_CMD_LEN; ++k)
- fprintf(sg_warnings_strm, "%02x ", gcCmdBlk[k]);
- fprintf(sg_warnings_strm, "\n");
- }
-
- ptvp = construct_scsi_pt_obj();
- if (NULL == ptvp) {
- fprintf(sg_warnings_strm, "get configuration: out of memory\n");
- return -1;
- }
- set_scsi_pt_cdb(ptvp, gcCmdBlk, sizeof(gcCmdBlk));
- set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
- set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "get configuration", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
- if (-1 == ret)
- ;
- else if (-2 == ret) {
- switch (sense_cat) {
- case SG_LIB_CAT_INVALID_OP:
- case SG_LIB_CAT_ILLEGAL_REQ:
- case SG_LIB_CAT_UNIT_ATTENTION:
- case SG_LIB_CAT_ABORTED_COMMAND:
- ret = sense_cat;
- break;
- case SG_LIB_CAT_RECOVERED:
- case SG_LIB_CAT_NO_SENSE:
- ret = 0;
- break;
- default:
- ret = -1;
- break;
- }
- } else {
- if ((verbose > 2) && (ret > 3)) {
- unsigned char * ucp;
- int len;
-
- ucp = (unsigned char *)resp;
- len = (ucp[0] << 24) + (ucp[1] << 16) + (ucp[2] << 8) + ucp[3] +
- 4;
- if (len < 0)
- len = 0;
- len = (ret < len) ? ret : len;
- fprintf(sg_warnings_strm, " get configuration: response%s\n",
- (len > 256 ? ", first 256 bytes" : ""));
- dStrHex((const char *)resp, (len > 256 ? 256 : len), -1);
- }
- ret = 0;
- }
- destruct_scsi_pt_obj(ptvp);
- return ret;
-}
-
-/* Invokes a SCSI GET PERFORMANCE command (MMC-3...6).
- * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
- * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
- * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
-int
-sg_ll_get_performance(int sg_fd, int data_type, unsigned long starting_lba,
- int max_num_desc, int ttype, void * resp,
- int mx_resp_len, int noisy, int verbose)
-{
- int res, k, ret, sense_cat;
- unsigned char gpCmdBlk[GET_PERFORMANCE_CMD_LEN] = {GET_PERFORMANCE_CMD, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- unsigned char sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
-
- if (NULL == sg_warnings_strm)
- sg_warnings_strm = stderr;
- if ((data_type < 0) || (data_type > 0x1f)) {
- fprintf(sg_warnings_strm, "Bad data_type value: %d\n", data_type);
- return -1;
- }
- gpCmdBlk[1] = (data_type & 0x1f);
- gpCmdBlk[2] = (unsigned char)((starting_lba >> 24) & 0xff);
- gpCmdBlk[3] = (unsigned char)((starting_lba >> 16) & 0xff);
- gpCmdBlk[4] = (unsigned char)((starting_lba >> 8) & 0xff);
- gpCmdBlk[3] = (unsigned char)(starting_lba & 0xff);
- if ((max_num_desc < 0) || (max_num_desc > 0xffff)) {
- fprintf(sg_warnings_strm, "Bad max_num_desc: 0x%x\n", max_num_desc);
- return -1;
- }
- gpCmdBlk[8] = (unsigned char)((max_num_desc >> 8) & 0xff);
- gpCmdBlk[9] = (unsigned char)(max_num_desc & 0xff);
- if ((ttype < 0) || (ttype > 0xff)) {
- fprintf(sg_warnings_strm, "Bad type: 0x%x\n", ttype);
- return -1;
- }
- gpCmdBlk[10] = (unsigned char)ttype;
-
- if (verbose) {
- fprintf(sg_warnings_strm, " Get Performance cdb: ");
- for (k = 0; k < GET_PERFORMANCE_CMD_LEN; ++k)
- fprintf(sg_warnings_strm, "%02x ", gpCmdBlk[k]);
- fprintf(sg_warnings_strm, "\n");
- }
-
- ptvp = construct_scsi_pt_obj();
- if (NULL == ptvp) {
- fprintf(sg_warnings_strm, "get performance: out of memory\n");
- return -1;
- }
- set_scsi_pt_cdb(ptvp, gpCmdBlk, sizeof(gpCmdBlk));
- set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
- set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "get performance", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
- if (-1 == ret)
- ;
- else if (-2 == ret) {
- switch (sense_cat) {
- case SG_LIB_CAT_INVALID_OP:
- case SG_LIB_CAT_ILLEGAL_REQ:
- case SG_LIB_CAT_UNIT_ATTENTION:
- case SG_LIB_CAT_ABORTED_COMMAND:
- ret = sense_cat;
- break;
- case SG_LIB_CAT_RECOVERED:
- case SG_LIB_CAT_NO_SENSE:
- ret = 0;
- break;
- default:
- ret = -1;
- break;
- }
- } else {
- if ((verbose > 2) && (ret > 3)) {
- unsigned char * ucp;
- int len;
-
- ucp = (unsigned char *)resp;
- len = (ucp[0] << 24) + (ucp[1] << 16) + (ucp[2] << 8) + ucp[3] +
- 4;
- if (len < 0)
- len = 0;
- len = (ret < len) ? ret : len;
- fprintf(sg_warnings_strm, " get performance:: response%s\n",
- (len > 256 ? ", first 256 bytes" : ""));
- dStrHex((const char *)resp, (len > 256 ? 256 : len), -1);
- }
- ret = 0;
- }
- destruct_scsi_pt_obj(ptvp);
- return ret;
-}
-
/* Invokes a SCSI PERSISTENT RESERVE IN command (SPC). Returns 0
* when successful, SG_LIB_CAT_INVALID_OP if command not supported,
* SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
diff --git a/lib/sg_cmds_mmc.c b/lib/sg_cmds_mmc.c
new file mode 100644
index 00000000..b5840118
--- /dev/null
+++ b/lib/sg_cmds_mmc.c
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2008 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>
+
+#include "sg_lib.h"
+#include "sg_cmds_basic.h"
+#include "sg_cmds_mmc.h"
+#include "sg_pt.h"
+
+
+
+#define SENSE_BUFF_LEN 32 /* Arbitrary, could be larger */
+
+#define DEF_PT_TIMEOUT 60 /* 60 seconds */
+
+#define GET_CONFIG_CMD 0x46
+#define GET_CONFIG_CMD_LEN 10
+#define GET_PERFORMANCE_CMD 0xac
+#define GET_PERFORMANCE_CMD_LEN 12
+#define SET_CD_SPEED_CMD 0xbb
+#define SET_CD_SPEED_CMDLEN 12
+
+
+/* Invokes a SCSI SET CD SPEED command (MMC).
+ * Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> command not supported,
+ * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
+ * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
+ * -1 -> other failure */
+int
+sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed,
+ int drv_write_speed, int noisy, int verbose)
+{
+ int res, ret, k, sense_cat;
+ unsigned char scsCmdBlk[SET_CD_SPEED_CMDLEN] = {SET_CD_SPEED_CMD, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
+ unsigned char sense_b[SENSE_BUFF_LEN];
+ struct sg_pt_base * ptvp;
+
+ if (NULL == sg_warnings_strm)
+ sg_warnings_strm = stderr;
+ scsCmdBlk[1] |= (rot_control & 0x3);
+ scsCmdBlk[2] = (drv_read_speed >> 8) & 0xff;
+ scsCmdBlk[3] = drv_read_speed & 0xff;
+ scsCmdBlk[4] = (drv_write_speed >> 8) & 0xff;
+ scsCmdBlk[5] = drv_write_speed & 0xff;
+
+ if (verbose) {
+ fprintf(sg_warnings_strm, " set cd speed cdb: ");
+ for (k = 0; k < SET_CD_SPEED_CMDLEN; ++k)
+ fprintf(sg_warnings_strm, "%02x ", scsCmdBlk[k]);
+ fprintf(sg_warnings_strm, "\n");
+ }
+ ptvp = construct_scsi_pt_obj();
+ if (NULL == ptvp) {
+ fprintf(sg_warnings_strm, "set cd speed: out of memory\n");
+ return -1;
+ }
+ set_scsi_pt_cdb(ptvp, scsCmdBlk, sizeof(scsCmdBlk));
+ set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ ret = sg_cmds_process_resp(ptvp, "set cd speed", res, 0,
+ sense_b, noisy, verbose, &sense_cat);
+ if (-1 == ret)
+ ;
+ else if (-2 == ret) {
+ switch (sense_cat) {
+ case SG_LIB_CAT_NOT_READY:
+ case SG_LIB_CAT_UNIT_ATTENTION:
+ case SG_LIB_CAT_INVALID_OP:
+ case SG_LIB_CAT_ILLEGAL_REQ:
+ case SG_LIB_CAT_ABORTED_COMMAND:
+ ret = sense_cat;
+ break;
+ case SG_LIB_CAT_RECOVERED:
+ case SG_LIB_CAT_NO_SENSE:
+ ret = 0;
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+ } else
+ ret = 0;
+
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
+
+/* Invokes a SCSI GET CONFIGURATION command (MMC-3,4,5).
+ * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
+ * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
+ * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
+int
+sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
+ int mx_resp_len, int noisy, int verbose)
+{
+ int res, k, ret, sense_cat;
+ unsigned char gcCmdBlk[GET_CONFIG_CMD_LEN] = {GET_CONFIG_CMD, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0};
+ unsigned char sense_b[SENSE_BUFF_LEN];
+ struct sg_pt_base * ptvp;
+
+ if (NULL == sg_warnings_strm)
+ sg_warnings_strm = stderr;
+ if ((rt < 0) || (rt > 3)) {
+ fprintf(sg_warnings_strm, "Bad rt value: %d\n", rt);
+ return -1;
+ }
+ gcCmdBlk[1] = (rt & 0x3);
+ if ((starting < 0) || (starting > 0xffff)) {
+ fprintf(sg_warnings_strm, "Bad starting field number: 0x%x\n",
+ starting);
+ return -1;
+ }
+ gcCmdBlk[2] = (unsigned char)((starting >> 8) & 0xff);
+ gcCmdBlk[3] = (unsigned char)(starting & 0xff);
+ if ((mx_resp_len < 0) || (mx_resp_len > 0xffff)) {
+ fprintf(sg_warnings_strm, "Bad mx_resp_len: 0x%x\n", starting);
+ return -1;
+ }
+ gcCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff);
+ gcCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff);
+
+ if (verbose) {
+ fprintf(sg_warnings_strm, " Get Configuration cdb: ");
+ for (k = 0; k < GET_CONFIG_CMD_LEN; ++k)
+ fprintf(sg_warnings_strm, "%02x ", gcCmdBlk[k]);
+ fprintf(sg_warnings_strm, "\n");
+ }
+
+ ptvp = construct_scsi_pt_obj();
+ if (NULL == ptvp) {
+ fprintf(sg_warnings_strm, "get configuration: out of memory\n");
+ return -1;
+ }
+ set_scsi_pt_cdb(ptvp, gcCmdBlk, sizeof(gcCmdBlk));
+ set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
+ set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ ret = sg_cmds_process_resp(ptvp, "get configuration", res, mx_resp_len,
+ sense_b, noisy, verbose, &sense_cat);
+ if (-1 == ret)
+ ;
+ else if (-2 == ret) {
+ switch (sense_cat) {
+ case SG_LIB_CAT_INVALID_OP:
+ case SG_LIB_CAT_ILLEGAL_REQ:
+ case SG_LIB_CAT_UNIT_ATTENTION:
+ case SG_LIB_CAT_ABORTED_COMMAND:
+ ret = sense_cat;
+ break;
+ case SG_LIB_CAT_RECOVERED:
+ case SG_LIB_CAT_NO_SENSE:
+ ret = 0;
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+ } else {
+ if ((verbose > 2) && (ret > 3)) {
+ unsigned char * ucp;
+ int len;
+
+ ucp = (unsigned char *)resp;
+ len = (ucp[0] << 24) + (ucp[1] << 16) + (ucp[2] << 8) + ucp[3] +
+ 4;
+ if (len < 0)
+ len = 0;
+ len = (ret < len) ? ret : len;
+ fprintf(sg_warnings_strm, " get configuration: response%s\n",
+ (len > 256 ? ", first 256 bytes" : ""));
+ dStrHex((const char *)resp, (len > 256 ? 256 : len), -1);
+ }
+ ret = 0;
+ }
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
+
+/* Invokes a SCSI GET PERFORMANCE command (MMC-3...6).
+ * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not
+ * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
+ * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
+int
+sg_ll_get_performance(int sg_fd, int data_type, unsigned long starting_lba,
+ int max_num_desc, int ttype, void * resp,
+ int mx_resp_len, int noisy, int verbose)
+{
+ int res, k, ret, sense_cat;
+ unsigned char gpCmdBlk[GET_PERFORMANCE_CMD_LEN] = {GET_PERFORMANCE_CMD, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ unsigned char sense_b[SENSE_BUFF_LEN];
+ struct sg_pt_base * ptvp;
+
+ if (NULL == sg_warnings_strm)
+ sg_warnings_strm = stderr;
+ if ((data_type < 0) || (data_type > 0x1f)) {
+ fprintf(sg_warnings_strm, "Bad data_type value: %d\n", data_type);
+ return -1;
+ }
+ gpCmdBlk[1] = (data_type & 0x1f);
+ gpCmdBlk[2] = (unsigned char)((starting_lba >> 24) & 0xff);
+ gpCmdBlk[3] = (unsigned char)((starting_lba >> 16) & 0xff);
+ gpCmdBlk[4] = (unsigned char)((starting_lba >> 8) & 0xff);
+ gpCmdBlk[3] = (unsigned char)(starting_lba & 0xff);
+ if ((max_num_desc < 0) || (max_num_desc > 0xffff)) {
+ fprintf(sg_warnings_strm, "Bad max_num_desc: 0x%x\n", max_num_desc);
+ return -1;
+ }
+ gpCmdBlk[8] = (unsigned char)((max_num_desc >> 8) & 0xff);
+ gpCmdBlk[9] = (unsigned char)(max_num_desc & 0xff);
+ if ((ttype < 0) || (ttype > 0xff)) {
+ fprintf(sg_warnings_strm, "Bad type: 0x%x\n", ttype);
+ return -1;
+ }
+ gpCmdBlk[10] = (unsigned char)ttype;
+
+ if (verbose) {
+ fprintf(sg_warnings_strm, " Get Performance cdb: ");
+ for (k = 0; k < GET_PERFORMANCE_CMD_LEN; ++k)
+ fprintf(sg_warnings_strm, "%02x ", gpCmdBlk[k]);
+ fprintf(sg_warnings_strm, "\n");
+ }
+
+ ptvp = construct_scsi_pt_obj();
+ if (NULL == ptvp) {
+ fprintf(sg_warnings_strm, "get performance: out of memory\n");
+ return -1;
+ }
+ set_scsi_pt_cdb(ptvp, gpCmdBlk, sizeof(gpCmdBlk));
+ set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
+ set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ ret = sg_cmds_process_resp(ptvp, "get performance", res, mx_resp_len,
+ sense_b, noisy, verbose, &sense_cat);
+ if (-1 == ret)
+ ;
+ else if (-2 == ret) {
+ switch (sense_cat) {
+ case SG_LIB_CAT_INVALID_OP:
+ case SG_LIB_CAT_ILLEGAL_REQ:
+ case SG_LIB_CAT_UNIT_ATTENTION:
+ case SG_LIB_CAT_ABORTED_COMMAND:
+ ret = sense_cat;
+ break;
+ case SG_LIB_CAT_RECOVERED:
+ case SG_LIB_CAT_NO_SENSE:
+ ret = 0;
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+ } else {
+ if ((verbose > 2) && (ret > 3)) {
+ unsigned char * ucp;
+ int len;
+
+ ucp = (unsigned char *)resp;
+ len = (ucp[0] << 24) + (ucp[1] << 16) + (ucp[2] << 8) + ucp[3] +
+ 4;
+ if (len < 0)
+ len = 0;
+ len = (ret < len) ? ret : len;
+ fprintf(sg_warnings_strm, " get performance:: response%s\n",
+ (len > 256 ? ", first 256 bytes" : ""));
+ dStrHex((const char *)resp, (len > 256 ? 256 : len), -1);
+ }
+ ret = 0;
+ }
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 110a6ac4..0f61ed00 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -189,9 +189,9 @@ sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff)
for (k = 0; sg_lib_asc_ascq_range[k].text; ++k) {
ei2p = &sg_lib_asc_ascq_range[k];
- if ((ei2p->code1 == asc) &&
- (ascq >= ei2p->code2_min) &&
- (ascq <= ei2p->code2_max)) {
+ if ((ei2p->asc == asc) &&
+ (ascq >= ei2p->ascq_min) &&
+ (ascq <= ei2p->ascq_max)) {
found = 1;
num = snprintf(buff, buff_len, "Additional sense: ");
rlen = buff_len - num;
@@ -204,8 +204,8 @@ sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff)
for (k = 0; sg_lib_asc_ascq[k].text; ++k) {
eip = &sg_lib_asc_ascq[k];
- if (eip->code1 == asc &&
- eip->code2 == ascq) {
+ if (eip->asc == asc &&
+ eip->ascq == ascq) {
found = 1;
snprintf(buff, buff_len, "Additional sense: %s", eip->text);
}
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index b97b0da4..d9fac5cf 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -29,62 +29,63 @@
#include <stdlib.h>
+#include "sg_lib.h"
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "1.40 20080115"; /* spc-4 rev 12 */
+const char * sg_lib_version_str = "1.41 20080218"; /* spc-4 rev 12 */
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0, 0, "Test Unit Ready"},
{0x1, 0, "Rezero Unit"},
- {0x1, 1, "Rewind"},
+ {0x1, PDT_TAPE, "Rewind"},
{0x3, 0, "Request Sense"},
{0x4, 0, "Format Unit"},
- {0x4, 1, "Format medium"},
- {0x4, 2, "Format"},
+ {0x4, PDT_TAPE, "Format medium"},
+ {0x4, PDT_PRINTER, "Format"},
{0x5, 0, "Read Block Limits"},
{0x7, 0, "Reassign Blocks"},
- {0x7, 8, "Initialize element status"},
+ {0x7, PDT_MCHANGER, "Initialize element status"},
{0x8, 0, "Read(6)"},
- {0x8, 3, "Receive"},
+ {0x8, PDT_PROCESSOR, "Receive"},
{0xa, 0, "Write(6)"},
- {0xa, 2, "Print"},
- {0xa, 3, "Send"},
+ {0xa, PDT_PRINTER, "Print"},
+ {0xa, PDT_PROCESSOR, "Send"},
{0xb, 0, "Seek(6)"},
- {0xb, 1, "Set capacity"},
- {0xb, 2, "Slew and print"},
+ {0xb, PDT_TAPE, "Set capacity"},
+ {0xb, PDT_PRINTER, "Slew and print"},
{0xf, 0, "Read reverse(6)"},
{0x10, 0, "Write filemarks(6)"},
- {0x10, 2, "Synchronize buffer"},
+ {0x10, PDT_PRINTER, "Synchronize buffer"},
{0x11, 0, "Space(6)"},
{0x12, 0, "Inquiry"},
{0x13, 0, "Verify(6)"}, /* SSC */
{0x14, 0, "Recover buffered data"},
{0x15, 0, "Mode select(6)"},
{0x16, 0, "Reserve(6)"}, /* obsolete in SPC-4 r11 */
- {0x16, 8, "Reserve element(6)"},
+ {0x16, PDT_MCHANGER, "Reserve element(6)"},
{0x17, 0, "Release(6)"}, /* obsolete in SPC-4 r11 */
- {0x17, 8, "Release element(6)"},
+ {0x17, PDT_MCHANGER, "Release element(6)"},
{0x18, 0, "Copy"}, /* obsolete in SPC-4 r11 */
{0x19, 0, "Erase(6)"},
{0x1a, 0, "Mode sense(6)"},
{0x1b, 0, "Start stop unit"},
- {0x1b, 1, "Load unload"},
- {0x1b, 0x12, "Load unload"},
- {0x1b, 2, "Stop print"},
+ {0x1b, PDT_TAPE, "Load unload"},
+ {0x1b, PDT_ADC, "Load unload"},
+ {0x1b, PDT_PRINTER, "Stop print"},
{0x1c, 0, "Receive diagnostic results"},
{0x1d, 0, "Send diagnostic"},
{0x1e, 0, "Prevent allow medium removal"},
{0x23, 0, "Read Format capacities"},
{0x24, 0, "Set window"},
{0x25, 0, "Read capacity(10)"},
- {0x25, 0xf, "Read card capacity"},
+ {0x25, PDT_OCRW, "Read card capacity"},
{0x28, 0, "Read(10)"},
{0x29, 0, "Read generation"},
{0x2a, 0, "Write(10)"},
{0x2b, 0, "Seek(10)"},
- {0x2b, 1, "Locate(10)"},
- {0x2b, 8, "Position to element"},
+ {0x2b, PDT_TAPE, "Locate(10)"},
+ {0x2b, PDT_MCHANGER, "Position to element"},
{0x2c, 0, "Erase(10)"},
{0x2d, 0, "Read updated block"},
{0x2e, 0, "Write and verify(10)"},
@@ -94,11 +95,11 @@ struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0x32, 0, "Search data low(10)"},
{0x33, 0, "Set limits(10)"},
{0x34, 0, "Pre-fetch(10)"},
- {0x34, 1, "Read position"},
+ {0x34, PDT_TAPE, "Read position"},
{0x35, 0, "Synchronize cache(10)"},
{0x36, 0, "Lock unlock cache(10)"},
{0x37, 0, "Read defect data(10)"},
- {0x37, 8, "Initialize element status with range"},
+ {0x37, PDT_MCHANGER, "Initialize element status with range"},
{0x38, 0, "Medium scan"},
{0x39, 0, "Compare"}, /* obsolete in SPC-4 r11 */
{0x3a, 0, "Copy and verify"}, /* obsolete in SPC-4 r11 */
@@ -122,16 +123,16 @@ struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0x4e, 0, "Stop play/scan"},
{0x50, 0, "Xdwrite(10)"},
{0x51, 0, "Xpwrite(10)"},
- {0x51, 5, "Read disk information"},
+ {0x51, PDT_MMC, "Read disk information"},
{0x52, 0, "Xdread(10)"},
- {0x52, 5, "Read track information"},
+ {0x52, PDT_MMC, "Read track information"},
{0x53, 0, "Reserve track"},
{0x54, 0, "Send OPC information"},
{0x55, 0, "Mode select(10)"},
{0x56, 0, "Reserve(10)"}, /* obsolete in SPC-4 r11 */
- {0x56, 8, "Reserve element(10)"},
+ {0x56, PDT_MCHANGER, "Reserve element(10)"},
{0x57, 0, "Release(10)"}, /* obsolete in SPC-4 r11 */
- {0x57, 8, "Release element(10)"},
+ {0x57, PDT_MCHANGER, "Release element(10)"},
{0x58, 0, "Repair track"},
{0x5a, 0, "Mode sense(10)"},
{0x5b, 0, "Close track/session"},
@@ -139,11 +140,11 @@ struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0x5d, 0, "Send cue sheet"},
{0x5e, 0, "Persistent reserve in"},
{0x5f, 0, "Persistent reserve out"},
- {0x7e, 0, "Extended cdb"}, /* added in SPC-4 r12 */
+ {0x7e, 0, "Extended cdb (XCBD)"}, /* added in SPC-4 r12 */
{0x80, 0, "Xdwrite extended(16)"},
- {0x80, 1, "Write filemarks(16)"},
+ {0x80, PDT_TAPE, "Write filemarks(16)"},
{0x81, 0, "Rebuild(16)"},
- {0x81, 1, "Read reverse(16)"},
+ {0x81, PDT_TAPE, "Read reverse(16)"},
{0x82, 0, "Regenerate(16)"},
{0x83, 0, "Extended copy"},
{0x84, 0, "Receive copy results"},
@@ -159,60 +160,60 @@ struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0x8f, 0, "Verify(16)"},
{0x90, 0, "Pre-fetch(16)"},
{0x91, 0, "Synchronize cache(16)"},
- {0x91, 1, "Space(16)"},
+ {0x91, PDT_TAPE, "Space(16)"},
{0x92, 0, "Lock unlock cache(16)"},
- {0x92, 1, "Locate(16)"},
+ {0x92, PDT_TAPE, "Locate(16)"},
{0x93, 0, "Write same(16)"},
- {0x93, 1, "Erase(16)"},
+ {0x93, PDT_TAPE, "Erase(16)"},
{0x9e, 0, "Service action in(16)"},
{0x9f, 0, "Service action out(16)"},
{0xa0, 0, "Report luns"},
{0xa1, 0, "ATA command pass through(12)"},
- {0xa1, 5, "Blank"},
+ {0xa1, PDT_MMC, "Blank"},
{0xa2, 0, "Security protocol in"},
{0xa3, 0, "Maintenance in"},
- {0xa3, 5, "Send key"},
+ {0xa3, PDT_MMC, "Send key"},
{0xa4, 0, "Maintenance out"},
- {0xa4, 5, "Report key"},
+ {0xa4, PDT_MMC, "Report key"},
{0xa5, 0, "Move medium"},
- {0xa5, 5, "Play audio(12)"},
+ {0xa5, PDT_MMC, "Play audio(12)"},
{0xa6, 0, "Exchange medium"},
- {0xa6, 5, "Load/unload medium"},
+ {0xa6, PDT_MMC, "Load/unload medium"},
{0xa7, 0, "Move medium attached"},
- {0xa7, 5, "Set read ahead"},
+ {0xa7, PDT_MMC, "Set read ahead"},
{0xa8, 0, "Read(12)"},
{0xa9, 0, "Service action out(12)"},
{0xaa, 0, "Write(12)"},
{0xab, 0, "Service action in(12)"},
{0xac, 0, "erase(12)"},
- {0xac, 5, "Get performance"},
- {0xad, 5, "Read DVD/BD structure"},
+ {0xac, PDT_MMC, "Get performance"},
+ {0xad, PDT_MMC, "Read DVD/BD structure"},
{0xae, 0, "Write and verify(12)"},
{0xaf, 0, "Verify(12)"},
{0xb0, 0, "Search data high(12)"},
{0xb1, 0, "Search data equal(12)"},
- {0xb1, 8, "Open/close import/export element"},
+ {0xb1, PDT_MCHANGER, "Open/close import/export element"},
{0xb2, 0, "Search data low(12)"},
{0xb3, 0, "Set limits(12)"},
{0xb4, 0, "Read element status attached"},
{0xb5, 0, "Security protocol out"},
- {0xb5, 8, "Request volume element address"},
+ {0xb5, PDT_MCHANGER, "Request volume element address"},
{0xb6, 0, "Send volume tag"},
- {0xb6, 5, "Set streaming"},
+ {0xb6, PDT_MMC, "Set streaming"},
{0xb7, 0, "Read defect data(12)"},
{0xb8, 0, "Read element status"},
{0xb9, 0, "Read CD msf"},
{0xba, 0, "Redundancy group in"},
- {0xba, 5, "Scan"},
+ {0xba, PDT_MMC, "Scan"},
{0xbb, 0, "Redundancy group out"},
- {0xbb, 5, "Set CD speed"},
+ {0xbb, PDT_MMC, "Set CD speed"},
{0xbc, 0, "Spare in"},
{0xbd, 0, "Spare out"},
- {0xbd, 5, "Mechanism status"},
+ {0xbd, PDT_MMC, "Mechanism status"},
{0xbe, 0, "Volume set in"},
- {0xbe, 5, "Read CD"},
+ {0xbe, PDT_MMC, "Read CD"},
{0xbf, 0, "Volume set out"},
- {0xbf, 5, "Send DVD/BD structure"},
+ {0xbf, PDT_MMC, "Send DVD/BD structure"},
{0xffff, 0, NULL},
};
@@ -258,7 +259,7 @@ struct sg_lib_value_name_t sg_lib_serv_in16_arr[] = {
struct sg_lib_value_name_t sg_lib_serv_out16_arr[] = {
{0x11, 0, "Write long(16)"},
- {0x1f, 0x12, "Notify data transfer device(16)"},
+ {0x1f, PDT_ADC, "Notify data transfer device(16)"},
{0xffff, 0, NULL},
};
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 7e425112..6d547a95 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Feb 17 2008 - dgilbert at interlog dot com
+* Mon Feb 18 2008 - dgilbert at interlog dot com
- sg_get_config sync with mmc6r01, add sg_sat_phy_event
* sg3_utils-1.26
diff --git a/src/sg_get_config.c b/src/sg_get_config.c
index 6298792b..c4a395ca 100644
--- a/src/sg_get_config.c
+++ b/src/sg_get_config.c
@@ -40,7 +40,7 @@
#endif
#include "sg_lib.h"
#include "sg_cmds_basic.h"
-#include "sg_cmds_extra.h"
+#include "sg_cmds_mmc.h"
/* A utility program for the Linux OS SCSI subsystem.
*
@@ -49,7 +49,7 @@
*/
-static char * version_str = "0.32 20080114"; /* mmc6r01 */
+static char * version_str = "0.33 20080218"; /* mmc6r01 */
#define MX_ALLOC_LEN 8192
#define NAME_BUFF_SZ 64
diff --git a/src/sg_inq.c b/src/sg_inq.c
index c19bb682..47fce922 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.72 20080204"; /* spc-4 rev 12 */
+static char * version_str = "0.73 20080218"; /* spc-4 rev 12 */
#define VPD_SUPPORTED_VPDS 0x0
@@ -646,10 +646,10 @@ static struct vpd_name vpd_name_arr[] = {
{VPD_ATA_INFO, 0, "ATA information"},
{VPD_BLOCK_LIMITS, 0, "Block limits (sbc2)"},
{VPD_BLOCK_DEV_CHARS, 0, "Block device characteristics (sbc3)"},
- {0xb0, 0x1, "Sequential access device capabilities (ssc3)"},
- {0xb2, 0x1, "TapeAlert supported flags (ssc3)"},
- {0xb0, 0x11, "OSD information (osd)"},
- {0xb1, 0x11, "Security token (osd)"},
+ {0xb0, PDT_TAPE, "Sequential access device capabilities (ssc3)"},
+ {0xb2, PDT_TAPE, "TapeAlert supported flags (ssc3)"},
+ {0xb0, PDT_OSD, "OSD information (osd)"},
+ {0xb1, PDT_OSD, "Security token (osd)"},
{0xc0, 0, "vendor: Firmware numbers (seagate); Unit path report (EMC)"},
{0xc1, 0, "vendor: Date code (seagate)"},
{0xc2, 0, "vendor: Jumper settings (seagate); Software version (RDAC)"},
@@ -1340,7 +1340,7 @@ decode_b0_vpd(unsigned char * buff, int len, int do_hex, int pdt)
return;
}
switch (pdt) {
- case 0: case 4: case 7:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL:
if (len < 16) {
fprintf(stderr, "Block limits VPD page length too "
"short=%d\n", len);
@@ -1361,10 +1361,10 @@ decode_b0_vpd(unsigned char * buff, int len, int do_hex, int pdt)
"blocks\n", u);
}
break;
- case 1: case 8:
+ case PDT_TAPE: case PDT_MCHANGER:
printf(" WORM=%d\n", !!(buff[4] & 0x1));
break;
- case 0x11:
+ case PDT_OSD:
default:
printf(" Unable to decode pdt=0x%x, in hex:\n", pdt);
dStrHex((const char *)buff, len, 0);
@@ -1382,7 +1382,7 @@ decode_b1_vpd(unsigned char * buff, int len, int do_hex, int pdt)
return;
}
switch (pdt) {
- case 0: case 4: case 7:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL:
if (len < 64) {
fprintf(stderr, "Block device characteristics VPD page length "
"too short=%d\n", len);
@@ -1398,7 +1398,7 @@ decode_b1_vpd(unsigned char * buff, int len, int do_hex, int pdt)
else
printf(" Nominal rotation rate: %d rpm\n", u);
break;
- case 1: case 8: case 0x12:
+ case PDT_TAPE: case PDT_MCHANGER: case PDT_ADC:
printf(" Manufacturer-assigned serial number: %.*s\n",
len - 4, buff + 4);
break;
@@ -2227,14 +2227,14 @@ decode_vpd(int sg_fd, const struct opts_t * optsp)
pdt = rsp_buff[0] & 0x1f;
if (! optsp->do_raw) {
switch (pdt) {
- case 0: case 4: case 7:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL:
printf("VPD INQUIRY: Block limits page (SBC)\n");
break;
- case 1: case 8:
+ case PDT_TAPE: case PDT_MCHANGER:
printf("VPD INQUIRY: Sequential access device "
"capabilities (SSC)\n");
break;
- case 0x11:
+ case PDT_OSD:
printf("VPD INQUIRY: OSD information (OSD)\n");
break;
default:
@@ -2271,18 +2271,18 @@ decode_vpd(int sg_fd, const struct opts_t * optsp)
pdt = rsp_buff[0] & 0x1f;
if (! optsp->do_raw) {
switch (pdt) {
- case 0: case 4: case 7:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL:
printf("VPD INQUIRY: Block device characteristcis page "
"(SBC)\n");
break;
- case 1: case 8:
+ case PDT_TAPE: case PDT_MCHANGER:
printf("Manufactured assigned serial number VPD page "
"(SSC):\n");
break;
- case 0x11:
+ case PDT_OSD:
printf("Security token VPD page (OSD):\n");
break;
- case 0x12:
+ case PDT_ADC:
printf("Manufactured assigned serial number VPD page "
"(ADC):\n");
break;
diff --git a/src/sg_logs.c b/src/sg_logs.c
index f1fc7fa1..1159be13 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -25,7 +25,7 @@
*/
-static char * version_str = "0.79 20080122"; /* SPC-4 revision 12 */
+static char * version_str = "0.80 20080218"; /* SPC-4 revision 12 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -679,7 +679,7 @@ show_page_name(int pg_code, int subpg_code,
done = 1;
switch (inq_dat->peripheral_type) {
- case 0: case 4: case 7: case 0xe:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
{
switch (pg_code) {
@@ -707,7 +707,7 @@ show_page_name(int pg_code, int subpg_code,
}
}
break;
- case 1: case 2:
+ case PDT_TAPE: case PDT_PRINTER:
/* tape (streaming) and printer (obsolete) devices */
{
switch (pg_code) {
@@ -741,7 +741,7 @@ show_page_name(int pg_code, int subpg_code,
}
}
break;
- case 8:
+ case PDT_MCHANGER:
/* medium changer type devices */
{
switch (pg_code) {
@@ -763,7 +763,7 @@ show_page_name(int pg_code, int subpg_code,
}
}
break;
- case 0x12: /* Automation Device interface (ADC) */
+ case PDT_ADC: /* Automation Device interface (ADC) */
{
switch (pg_code) {
case 0x11:
@@ -2938,7 +2938,7 @@ show_ascii_page(unsigned char * resp, int len,
case 0x8:
{
switch (inq_dat->peripheral_type) {
- case 0: case 4: case 7: case 0xe:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
show_format_status_page(resp, len, optsp->do_pcb);
break;
@@ -2954,7 +2954,7 @@ show_ascii_page(unsigned char * resp, int len,
case 0xc:
{
switch (inq_dat->peripheral_type) {
- case 1: case 2:
+ case PDT_TAPE: case PDT_PRINTER:
/* tape and (printer) type devices */
show_sequential_access_page(resp, len, optsp->do_pcb,
optsp->do_verbose);
@@ -2977,11 +2977,11 @@ show_ascii_page(unsigned char * resp, int len,
case 0x14:
{
switch (inq_dat->peripheral_type) {
- case 1: case 0x12:
+ case PDT_TAPE: case PDT_ADC:
/* tape and adc type devices */
show_device_stats_page(resp, len, optsp->do_pcb);
break;
- case 8: /* smc-3 */
+ case PDT_MCHANGER: /* smc-3 */
show_media_stats_page(resp, len, optsp->do_pcb);
break;
default:
@@ -2993,12 +2993,12 @@ show_ascii_page(unsigned char * resp, int len,
case 0x15:
{
switch (inq_dat->peripheral_type) {
- case 0: case 4: case 7: case 0xe:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
show_background_scan_results_page(resp, len, optsp->do_pcb,
optsp->do_verbose);
break;
- case 8: /* smc-3 */
+ case PDT_MCHANGER: /* smc-3 */
show_element_stats_page(resp, len, optsp->do_pcb);
break;
default:
@@ -3010,7 +3010,7 @@ show_ascii_page(unsigned char * resp, int len,
case 0x16:
{
switch (inq_dat->peripheral_type) {
- case 8: /* smc-3 */
+ case PDT_MCHANGER: /* smc-3 */
show_mchanger_diag_data_page(resp, len, optsp->do_pcb);
break;
default:
@@ -3021,7 +3021,7 @@ show_ascii_page(unsigned char * resp, int len,
case 0x17:
{
switch (inq_dat->peripheral_type) {
- case 0: case 4: case 7: case 0xe:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
show_non_volatile_cache_page(resp, len, optsp->do_pcb);
break;
@@ -3040,7 +3040,7 @@ show_ascii_page(unsigned char * resp, int len,
case TAPE_ALERT_LPAGE:
{
switch (inq_dat->peripheral_type) {
- case 1: /* ssc only */
+ case PDT_TAPE: /* ssc only */
show_tape_alert_ssc_page(resp, len, optsp->do_pcb, optsp);
break;
default:
@@ -3055,7 +3055,7 @@ show_ascii_page(unsigned char * resp, int len,
case 0x37:
{
switch (inq_dat->peripheral_type) {
- case 0: case 4: case 7: case 0xe:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
show_seagate_cache_page(resp, len, optsp->do_pcb);
break;
@@ -3068,7 +3068,7 @@ show_ascii_page(unsigned char * resp, int len,
case 0x3e:
{
switch (inq_dat->peripheral_type) {
- case 0: case 4: case 7: case 0xe:
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
show_seagate_factory_page(resp, len, optsp->do_pcb);
break;
diff --git a/src/sg_modes.c b/src/sg_modes.c
index 514701b6..4ca03ab2 100644
--- a/src/sg_modes.c
+++ b/src/sg_modes.c
@@ -26,7 +26,7 @@
*/
-static char * version_str = "1.28 20080115";
+static char * version_str = "1.29 20080218";
#define DEF_ALLOC_LEN (1024 * 4)
#define DEF_6_ALLOC_LEN 252
@@ -592,31 +592,31 @@ mode_page_cs_table(int scsi_ptype, int * size)
case -1: /* common list */
*size = sizeof(pc_desc_common) / sizeof(pc_desc_common[0]);
return &pc_desc_common[0];
- case 0: /* disk (direct access) type devices */
- case 4:
- case 7:
+ case PDT_DISK: /* disk (direct access) type devices */
+ case PDT_WO:
+ case PDT_OPTICAL:
*size = sizeof(pc_desc_disk) / sizeof(pc_desc_disk[0]);
return &pc_desc_disk[0];
- case 1: /* tape devices */
- case 2:
+ case PDT_TAPE: /* tape devices */
+ case PDT_PRINTER:
*size = sizeof(pc_desc_tape) / sizeof(pc_desc_tape[0]);
return &pc_desc_tape[0];
- case 5: /* cd/dvd devices */
+ case PDT_MMC: /* cd/dvd/bd devices */
*size = sizeof(pc_desc_cddvd) / sizeof(pc_desc_cddvd[0]);
return &pc_desc_cddvd[0];
- case 8: /* medium changer devices */
+ case PDT_MCHANGER: /* medium changer devices */
*size = sizeof(pc_desc_smc) / sizeof(pc_desc_smc[0]);
return &pc_desc_smc[0];
- case 0xc: /* storage array devices */
+ case PDT_SAC: /* storage array devices */
*size = sizeof(pc_desc_scc) / sizeof(pc_desc_scc[0]);
return &pc_desc_scc[0];
- case 0xd: /* enclosure services devices */
+ case PDT_SES: /* enclosure services devices */
*size = sizeof(pc_desc_ses) / sizeof(pc_desc_ses[0]);
return &pc_desc_ses[0];
- case 0xe: /* simplified direct access device */
+ case PDT_RBC: /* simplified direct access device */
*size = sizeof(pc_desc_rbc) / sizeof(pc_desc_rbc[0]);
return &pc_desc_rbc[0];
- case 0x12: /* automation device/interface */
+ case PDT_ADC: /* automation device/interface */
*size = sizeof(pc_desc_adt) / sizeof(pc_desc_adt[0]);
return &pc_desc_adt[0];
}