aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BSD_LICENSE51
-rw-r--r--ChangeLog4
-rw-r--r--README39
-rw-r--r--debian/copyright47
-rw-r--r--examples/Makefile2
-rw-r--r--examples/README4
-rw-r--r--examples/sg__sat_phy_event.c10
-rw-r--r--include/sg_pr2serr.h12
-rw-r--r--lib/BSD_LICENSE51
-rw-r--r--lib/sg_cmds_basic2.c14
-rw-r--r--lib/sg_cmds_extra.c95
-rw-r--r--lib/sg_cmds_mmc.c12
-rw-r--r--lib/sg_pt_linux.c2
-rw-r--r--lib/sg_pt_linux_nvme.c6
-rw-r--r--src/BSD_LICENSE24
-rw-r--r--src/sg_opcodes.c4
-rw-r--r--src/sg_read_buffer.c13
-rw-r--r--src/sg_read_long.c2
-rw-r--r--src/sg_sanitize.c2
-rw-r--r--src/sg_sat_phy_event.c4
-rw-r--r--src/sg_timestamp.c5
-rw-r--r--src/sg_write_same.c2
-rw-r--r--src/sg_write_x.c4
-rw-r--r--testing/Makefile16
-rw-r--r--testing/Makefile.cplus2
-rw-r--r--testing/README7
-rw-r--r--testing/sg_chk_asc.c11
-rw-r--r--testing/sg_sense_test.c4
-rw-r--r--testing/tst_sg_lib.c64
29 files changed, 287 insertions, 226 deletions
diff --git a/BSD_LICENSE b/BSD_LICENSE
index fe731462..7f1906bb 100644
--- a/BSD_LICENSE
+++ b/BSD_LICENSE
@@ -1,27 +1,24 @@
-/*
- * Copyright (c) 1999-2018 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.
- */
+
+Copyright (c) 1999-2018, 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+
diff --git a/ChangeLog b/ChangeLog
index 817f545e..a83d0029 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.43 [20180119] [svn: r745]
+Changelog for sg3_utils-1.43 [20180119] [svn: r746]
- sg_bg_ctl: new Background control command (sbc4r08)
- sg_write_x: where x can be normal, atomic, orwrite,
same, scattered, or stream writes with 16 or 32 byte
@@ -157,6 +157,8 @@ Changelog for sg3_utils-1.43 [20180119] [svn: r745]
- add SG_LIB_ANDROID build 'define'. If defined then
SG_LIB_LINUX is also defined, so test for Android
before Linux if need to differentiate
+ - update BSD license from 3 to 2 clause aka FreeBSD
+ license (without reference to FreeBSD project)
Changelog for sg3_utils-1.42 [20160217] [svn: r663]
- sg_timestamp: new, to report or set timestamp
diff --git a/README b/README
index 312fca00..ae886e9b 100644
--- a/README
+++ b/README
@@ -35,6 +35,20 @@ other Operating Systems. A new utility called ddpt (in a package of the same
name) is more generic while still allowing a copy to be done in terms of
SCSI READ and WRITE commands. ddpt has been ported to other OSes.
+License
+=======
+All utilities and libraries have either a "2 clause" BSD license or are
+"GPL-2ed". The "2 clause" BSD license is taken from the FreeBSD project but
+drops the last paragraph that directly refers to the "FreeBSD project".
+That BSD license was updated from the "3 clause" to the newer "2 clause"
+version on 20180119. To save space various source code files refer to a
+file called "BSD_LICENSE" in the main, src and lib directories. The author's
+intention is that users may incorporate all or part of the code in their work
+as they please. Attribution is encouraged. Please check the code as other
+contributors (apart from the author) may also have copyright notices. For a
+list of contributors see the CREDITS file.
+
+
Description
===========
A web site supporting the sg3_utils package can be found at
@@ -85,12 +99,6 @@ Postscript and pdf renderings are also in that directory. Older documentation
for the sg version 3 driver can be found at:
http://sg.danny.cz/sg/p/scsi_generic_v3.txt .
-All utilities are either "GPL"-ed or have a FreeBSD license. The author's
-intention is that users may incorporate all or part of the code in their work
-as they please. Attribution is encouraged. Please check the code as other
-contributors (apart from the author) may also have copyright notices. For a
-list of contributors see the CREDITS file.
-
To save the repetition of common code (e.g. SCSI error processing) and
reduce the size of the executable files, a shared library called
libsgutils<num>.so (its Linux name) is created during the build process.
@@ -151,16 +159,27 @@ Darwin is not supported because the Apple folks do not want to give their
users a pass-through SCSI interface. The author has read about creative
hackers using a VM containing a real OS to circumvent the Apple restriction.
-C standard is C99
+C standard is C11
==================
The C code in this package is written for portability rather than speed.
-It assumes a level of C99 compliance and favours POSIX system and library
-calls over OS specific calls.
+It assumes a level of C99 compliance (the C standard prior to C11) and
+favours POSIX system and library calls over OS specific calls.
The C code is written in a C++ friendly way and is checked from time to
time that it compiles clean with C++. To accommodate C++ certain C99
constructs such as designated initializers cannot be used.
+The author has not seriously attempted to build this code on MSVC (aka
+Visual Studio). There are a few roadblocks (that may be overcome in the
+future) that include MSVC being basically a C++ compiler, not a C/C++
+compiler. For some reason MSVC only claims C89 compliance (i.e. the first
+C standard from 1989). MSVC 2013 and 2015 are moving closer to C99
+compliance and may be sufficient to compile this package. Another problem
+is the assumption of te availability of basic Unix system calls such as
+open(). Nearly 20 years ago Microsoft indicated (promised ?) that it
+would move in the direction of POSIX compliance, but very little ever
+happened. "Talk is cheap, there should be a tax on it."
+
Building
========
This package is designed to be built with the usual:
@@ -476,4 +495,4 @@ See http://sg.danny.cz/sg/tools.html
Douglas Gilbert
-9th December 2017
+19th January 2018
diff --git a/debian/copyright b/debian/copyright
index 10ebeaf3..7f1906bb 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,33 +1,24 @@
-This package was debianized by Eric Schwartz <emschwar@debian.org> on
-Wed, 14 Nov 2001 17:05:56 -0700.
-It was downloaded from <URL:http://sg.danny.cz/sg/>
+Copyright (c) 1999-2018, Douglas Gilbert
+All rights reserved.
-Upstream Authors: Douglas Gilbert <dgilbert at interlog dot com>,
- Bruce Allen <ballen at gravity dot phys dot uwm dot edu>,
- Peter Allworth <linsol at zeta dot org dot au>,
- James Bottomley <jejb at parisc-linux dot org>,
- Lars Marowsky-Bree <lmb at suse dot de>,
- Kurt Garloff <garloff at suse dot de>,
- Grant Grundler <grundler at parisc-linux dot org>,
- Christophe Varoqui <christophe dot varoqui at free dot fr>,
- Michael Weller <eowmob at exp-math dot uni-essen dot de>,
- Eric Youngdale <eric at andante dot org>,
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
-Copyright:
+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.
-This software is copyright(c) 1994-2009 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.
-
-Many parts of this package are covered by the BSD license.
-These include central error processing code and common command
-code found in the lib subdirectory. Most newer utilities also
-use the BSD license. The author's intention is that this code can
-be used freely by others. On Debian systems and those derived from
-Debian, the complete text of the BSD License can be found in
-/usr/share/common-licenses/BSD.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
diff --git a/examples/Makefile b/examples/Makefile
index 1501850f..73df9bc2 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -36,7 +36,7 @@ CFLAGS = -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
LDFLAGS =
LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_io_linux.o
-LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o
+LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_common.o ../lib/sg_pt_linux.o ../lib/sg_pt_linux_nvme.o
all: $(EXECS)
diff --git a/examples/README b/examples/README
index 0b86426c..7a5ae285 100644
--- a/examples/README
+++ b/examples/README
@@ -4,7 +4,7 @@ needs to be executed in the parent directory followed by changing
directory to the lib directory and calling 'make' there.
Another way is to do a top level 'make' after the ./configure which
will make the libraries followed by all the utilities in the src/
-directory.
+directory. To make them in FreeBSD use 'make -f Makefile.freebsd' .
There is an brief explanation of each example in the README file in
the main (i.e. this directory's parent) directory. There are also
@@ -14,4 +14,4 @@ Some files that were previously in this directory have been moved to
the 'testing' directory.
Douglas Gilbert
-4th November 2017
+19th January 2018
diff --git a/examples/sg__sat_phy_event.c b/examples/sg__sat_phy_event.c
index e2dd2d01..fab33393 100644
--- a/examples/sg__sat_phy_event.c
+++ b/examples/sg__sat_phy_event.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2016 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@
#define EBUFF_SZ 256
-static const char * version_str = "1.01 20160528";
+static const char * version_str = "1.02 20180119";
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
@@ -135,7 +135,7 @@ static const char * find_phy_desc(int id)
return NULL;
}
-static void dStrRaw(const char* str, int len)
+static void dStrRaw(const uint8_t * str, int len)
{
int k;
@@ -304,12 +304,12 @@ int main(int argc, char * argv[])
if (ok) { /* output result if it is available */
if (raw > 0)
- dStrRaw((const char *)inBuff, 512);
+ dStrRaw(inBuff, 512);
else {
if (verbose && hex)
fprintf(stderr, "Response to READ LOG EXT (page=11h):\n");
if (1 == hex)
- dStrHex((const char *)inBuff, 512, 0);
+ hex2stdout(inBuff, 512, 0);
else if (hex > 1)
dWordHex((const unsigned short *)inBuff, 256, 0,
sg_is_big_endian());
diff --git a/include/sg_pr2serr.h b/include/sg_pr2serr.h
index 71db2ec5..4419087e 100644
--- a/include/sg_pr2serr.h
+++ b/include/sg_pr2serr.h
@@ -2,7 +2,7 @@
#define SG_PR2SERR_H
/*
- * Copyright (c) 2004-2016 Douglas Gilbert.
+ * Copyright (c) 2004-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -10,6 +10,11 @@
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
#if defined(__GNUC__) || defined(__clang__)
int pr2serr(const char * fmt, ...)
__attribute__ ((format (printf, 1, 2)));
@@ -17,4 +22,9 @@ int pr2serr(const char * fmt, ...)
int pr2serr(const char * fmt, ...);
#endif
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/lib/BSD_LICENSE b/lib/BSD_LICENSE
index fe731462..7f1906bb 100644
--- a/lib/BSD_LICENSE
+++ b/lib/BSD_LICENSE
@@ -1,27 +1,24 @@
-/*
- * Copyright (c) 1999-2018 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.
- */
+
+Copyright (c) 1999-2018, 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+
diff --git a/lib/sg_cmds_basic2.c b/lib/sg_cmds_basic2.c
index cf7b1240..9a0f283c 100644
--- a/lib/sg_cmds_basic2.c
+++ b/lib/sg_cmds_basic2.c
@@ -313,10 +313,11 @@ sg_ll_mode_sense6(int sg_fd, bool dbd, int pc, int pg_code, int sub_pg_code,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -412,10 +413,11 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -464,7 +466,7 @@ sg_ll_mode_select6(int sg_fd, bool pf, bool sp, void * paramp, int param_len,
}
if (verbose > 1) {
pr2ws(" %s parameter list\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
@@ -521,7 +523,7 @@ sg_ll_mode_select10(int sg_fd, bool pf, bool sp, void * paramp, int param_len,
}
if (verbose > 1) {
pr2ws(" %s parameter list\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 9b3a3eff..d94c5bc4 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -175,10 +175,11 @@ sg_ll_get_lba_status16(int sg_fd, uint64_t start_llba, uint8_t rt,
pr2ws(" %s: response\n", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -250,10 +251,11 @@ sg_ll_get_lba_status32(int sg_fd, uint64_t start_llba, uint32_t scan_len,
pr2ws(" %s: response\n", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -319,10 +321,11 @@ sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -353,7 +356,7 @@ sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, bool noisy,
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
@@ -434,10 +437,11 @@ sg_ll_report_referrals(int sg_fd, uint64_t start_llba, bool one_seg,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -486,7 +490,7 @@ sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
if (verbose > 1) {
if (paramp && param_len) {
pr2ws(" %s parameter list:\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
pr2ws(" %s timeout: %d seconds\n", cdb_name_s, tmout);
}
@@ -589,10 +593,11 @@ sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -656,10 +661,11 @@ sg_ll_read_defect10(int sg_fd, bool req_plist, bool req_glist, int dl_format,
pr2ws(" %s: response\n", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -715,10 +721,11 @@ sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -777,10 +784,11 @@ sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -813,7 +821,7 @@ sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
@@ -905,7 +913,7 @@ sg_ll_format_unit_v2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
if (verbose > 1) {
if (param_len > 0) {
pr2ws(" %s parameter list:\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
pr2ws(" %s timeout: %d seconds\n", cdb_name_s, tmout);
}
@@ -963,7 +971,7 @@ sg_ll_reassign_blocks(int sg_fd, bool longlba, bool longlist, void * paramp,
}
if (verbose > 1) {
pr2ws(" %s parameter list\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
@@ -1043,10 +1051,11 @@ sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -1082,7 +1091,7 @@ sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope,
pr2ws("\n");
if (verbose > 1) {
pr2ws(" %s parameters:\n", cdb_name_s);
- hex2stderr(paramp, param_len, 0);
+ hex2stderr((const uint8_t *)paramp, param_len, 0);
}
}
@@ -1207,10 +1216,11 @@ sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -1296,10 +1306,11 @@ sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -1500,7 +1511,7 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk,
k = data_out_len > 4104 ? 4104 : data_out_len;
pr2ws(" data_out buffer%s\n",
(data_out_len > 4104 ? ", first 4104 bytes" : ""));
- hex2stderr(data_out, k, verbose < 5);
+ hex2stderr((const uint8_t *)data_out, k, verbose < 5);
}
}
if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
@@ -1578,7 +1589,7 @@ sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba,
k = data_out_len > 4104 ? 4104 : data_out_len;
pr2ws(" data_out buffer%s\n",
(data_out_len > 4104 ? ", first 4104 bytes" : ""));
- hex2stderr(data_out, k, verbose < 5);
+ hex2stderr((const uint8_t *)data_out, k, verbose < 5);
}
}
if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
@@ -1847,10 +1858,11 @@ sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -1885,10 +1897,11 @@ sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
pr2ws(" %s parameter list", cdb_name_s);
if (2 == verbose) {
pr2ws("%s:\n", (param_len > 256 ? ", first 256 bytes" : ""));
- hex2stderr(paramp, (param_len > 256 ? 256 : param_len), -1);
+ hex2stderr((const uint8_t *)paramp,
+ (param_len > 256 ? 256 : param_len), -1);
} else {
pr2ws(":\n");
- hex2stderr(paramp, param_len, 0);
+ hex2stderr((const uint8_t *)paramp, param_len, 0);
}
}
}
@@ -1960,7 +1973,8 @@ sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
if ((verbose > 1) && paramp && param_len) {
pr2ws(" Write buffer parameter list%s:\n",
((param_len > 256) ? " (first 256 bytes)" : ""));
- hex2stderr(paramp, ((param_len > 256) ? 256 : param_len), -1);
+ hex2stderr((const uint8_t *)paramp,
+ ((param_len > 256) ? 256 : param_len), -1);
}
}
if (timeout_secs <= 0)
@@ -2031,7 +2045,7 @@ sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
@@ -2106,10 +2120,11 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, ret, 0);
+ hex2stderr((const uint8_t *)resp, ret, 0);
}
}
ret = 0;
@@ -2202,7 +2217,7 @@ sg_ll_extended_copy(int sg_fd, void * paramp, int param_len, bool noisy,
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", opcode_name);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
@@ -2279,7 +2294,7 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", cname);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
diff --git a/lib/sg_cmds_mmc.c b/lib/sg_cmds_mmc.c
index b9bd9ff7..0e003b82 100644
--- a/lib/sg_cmds_mmc.c
+++ b/lib/sg_cmds_mmc.c
@@ -202,10 +202,11 @@ sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
pr2ws(" %s: response:\n", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (len > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (len > 256 ? 256 : len), -1);
+ hex2stderr((const uint8_t *)resp, (len > 256 ? 256 : len),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, len, 0);
+ hex2stderr((const uint8_t *)resp, len, 0);
}
}
ret = 0;
@@ -293,10 +294,11 @@ sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba,
pr2ws(" %s: response", cdb_name_s);
if (3 == verbose) {
pr2ws("%s:\n", (len > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (len > 256 ? 256 : len), -1);
+ hex2stderr((const uint8_t *)resp, (len > 256 ? 256 : len),
+ -1);
} else {
pr2ws(":\n");
- hex2stderr(resp, len, 0);
+ hex2stderr((const uint8_t *)resp, len, 0);
}
}
ret = 0;
@@ -330,7 +332,7 @@ sg_ll_set_streaming(int sg_fd, int type, void * paramp, int param_len,
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", cdb_name_s);
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index d3a91199..4b433054 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -5,7 +5,7 @@
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_linux version 1.35 20180115 */
+/* sg_pt_linux version 1.36 20180119 */
#include <stdio.h>
diff --git a/lib/sg_pt_linux_nvme.c b/lib/sg_pt_linux_nvme.c
index 1b4fa735..95d5300f 100644
--- a/lib/sg_pt_linux_nvme.c
+++ b/lib/sg_pt_linux_nvme.c
@@ -305,7 +305,7 @@ do_nvme_admin_cmd(struct sg_pt_linux_scsi * ptp,
ptp->os_err = 0;
if (vb > 2) {
pr2ws("NVMe command:\n");
- hex2stderr(cmdp, cmd_len, 1);
+ hex2stderr((const uint8_t *)cmdp, cmd_len, 1);
if ((vb > 3) && (! is_read) && dp) {
uint32_t len = sg_get_unaligned_le32(up + SG_NVME_PT_DATA_LEN);
@@ -317,7 +317,7 @@ do_nvme_admin_cmd(struct sg_pt_linux_scsi * ptp,
pr2ws("\nData-out buffer (first 512 of %u bytes):\n", n);
n = 512;
}
- hex2stderr(dp, n, 0);
+ hex2stderr((const uint8_t *)dp, n, 0);
}
}
}
@@ -372,7 +372,7 @@ do_nvme_admin_cmd(struct sg_pt_linux_scsi * ptp,
pr2ws("\nData-in buffer (first 1024 of %u bytes):\n", n);
n = 1024;
}
- hex2stderr(dp, n, 0);
+ hex2stderr((const uint8_t *)dp, n, 0);
}
}
return 0;
diff --git a/src/BSD_LICENSE b/src/BSD_LICENSE
new file mode 100644
index 00000000..7f1906bb
--- /dev/null
+++ b/src/BSD_LICENSE
@@ -0,0 +1,24 @@
+
+Copyright (c) 1999-2018, 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.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+
diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c
index a594870c..140fa9ee 100644
--- a/src/sg_opcodes.c
+++ b/src/sg_opcodes.c
@@ -236,7 +236,7 @@ do_rsoc(int sg_fd, bool rctd, int rep_opts, int rq_opcode, int rq_servact,
*act_resp_lenp = ret;
if ((verbose > 2) && (ret > 0)) {
pr2serr("%s response:\n", rsoc_s);
- hex2stderr(resp, ret, 1);
+ hex2stderr((const uint8_t *)resp, ret, 1);
}
ret = 0;
}
@@ -298,7 +298,7 @@ do_rstmf(int sg_fd, bool repd, void * resp, int mx_resp_len,
*act_resp_lenp = ret;
if ((verbose > 2) && (ret > 0)) {
pr2serr("%s response:\n", rstmf_s);
- hex2stderr(resp, ret, 1);
+ hex2stderr((const uint8_t *)resp, ret, 1);
}
ret = 0;
}
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index cd16f954..f9561219 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -24,9 +24,7 @@
#include "sg_lib.h"
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-#ifdef SG_LIB_WIN32
-#include "sg_pt.h" /* needed for scsi_pt_win32_direct() */
-#endif
+#include "sg_pt.h"
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
@@ -196,7 +194,7 @@ sg_ll_read_buffer_10(int sg_fd, int rb_mode, int rb_mode_sp, int rb_id,
if ((verbose > 2) && (ret > 0)) {
pr2serr(" Read buffer(10): response%s\n",
(ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret), -1);
}
ret = 0;
}
@@ -260,7 +258,7 @@ sg_ll_read_buffer_16(int sg_fd, int rb_mode, int rb_mode_sp, int rb_id,
if ((verbose > 2) && (ret > 0)) {
pr2serr(" Read buffer(16): response%s\n",
(ret > 256 ? ", first 256 bytes" : ""));
- hex2stderr(resp, (ret > 256 ? 256 : ret), -1);
+ hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret), -1);
}
ret = 0;
}
@@ -484,7 +482,7 @@ main(int argc, char * argv[])
if (do_raw)
dStrRaw(resp, rb_len);
else if (do_hex || (rb_len < 4))
- hex2stdout(resp, rb_len, ((do_hex > 1) ? 0 : 1));
+ hex2stdout((const uint8_t *)resp, rb_len, ((do_hex > 1) ? 0 : 1));
else {
switch (rb_mode) {
case MODE_DESCRIPTOR:
@@ -499,7 +497,8 @@ main(int argc, char * argv[])
printf("Echo buffer capacity: %d (0x%x)\n", k, k);
break;
default:
- hex2stdout(resp, rb_len, (verbose > 1 ? 0 : 1));
+ hex2stdout((const uint8_t *)resp, rb_len,
+ (verbose > 1 ? 0 : 1));
break;
}
}
diff --git a/src/sg_read_long.c b/src/sg_read_long.c
index 86dcd659..9c0e65fd 100644
--- a/src/sg_read_long.c
+++ b/src/sg_read_long.c
@@ -242,7 +242,7 @@ main(int argc, char * argv[])
goto err_out;
if ('\0' == out_fname[0])
- hex2stdout(rawp, xfer_len, 0);
+ hex2stdout((const uint8_t *)rawp, xfer_len, 0);
else {
got_stdout = (0 == strcmp(out_fname, "-"));
if (got_stdout)
diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c
index a346887d..bd4efca9 100644
--- a/src/sg_sanitize.c
+++ b/src/sg_sanitize.c
@@ -212,7 +212,7 @@ do_sanitize(int sg_fd, const struct opts_t * op, const void * param_lstp,
if (op->verbose > 2) {
if (param_lst_len > 0) {
pr2serr(" Parameter list contents:\n");
- hex2stderr(param_lstp, param_lst_len, 1);
+ hex2stderr((const uint8_t *)param_lstp, param_lst_len, 1);
}
pr2serr(" Sanitize command timeout: %d seconds\n", timeout);
}
diff --git a/src/sg_sat_phy_event.c b/src/sg_sat_phy_event.c
index d18f2e5d..e39833f3 100644
--- a/src/sg_sat_phy_event.c
+++ b/src/sg_sat_phy_event.c
@@ -347,9 +347,9 @@ do_read_log_ext(int sg_fd, int log_addr, bool page_in_log, int feature,
if (ok) { /* output result if ok and --hex or --raw given */
if (do_raw)
- dStrRaw(resp, mx_resp_len);
+ dStrRaw((const uint8_t *)resp, mx_resp_len);
else if (1 == do_hex)
- hex2stdout(resp, mx_resp_len, 0);
+ hex2stdout((const uint8_t *)resp, mx_resp_len, 0);
else if (do_hex > 1)
dWordHex((const unsigned short *)resp, mx_resp_len / 2, 0,
sg_is_big_endian());
diff --git a/src/sg_timestamp.c b/src/sg_timestamp.c
index aa6dea6a..f50aa7a4 100644
--- a/src/sg_timestamp.c
+++ b/src/sg_timestamp.c
@@ -168,7 +168,8 @@ sg_ll_rep_timestamp(int sg_fd, void * resp, int mx_resp_len, int * residp,
*residp = k;
if ((verbose > 2) && ((mx_resp_len - k) > 0)) {
pr2serr("Parameter data returned:\n");
- hex2stderr(resp, mx_resp_len - k, ((verbose > 3) ? -1 : 1));
+ hex2stderr((const uint8_t *)resp, mx_resp_len - k,
+ ((verbose > 3) ? -1 : 1));
}
destruct_scsi_pt_obj(ptvp);
return ret;
@@ -196,7 +197,7 @@ sg_ll_set_timestamp(int sg_fd, void * paramp, int param_len, bool noisy,
pr2serr("\n");
if ((verbose > 1) && paramp && param_len) {
pr2serr(" set timestamp parameter list:\n");
- hex2stderr(paramp, param_len, -1);
+ hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
diff --git a/src/sg_write_same.c b/src/sg_write_same.c
index 73bd4d9d..67507d6c 100644
--- a/src/sg_write_same.c
+++ b/src/sg_write_same.c
@@ -253,7 +253,7 @@ do_write_same(int sg_fd, const struct opts_t * op, const void * dataoutp,
}
if ((op->verbose > 3) && (op->xfer_len > 0)) {
pr2serr(" Data-out buffer contents:\n");
- hex2stderr(dataoutp, op->xfer_len, 1);
+ hex2stderr((const uint8_t *)dataoutp, op->xfer_len, 1);
}
ptvp = construct_scsi_pt_obj();
if (NULL == ptvp) {
diff --git a/src/sg_write_x.c b/src/sg_write_x.c
index 4c99a2c0..cf931925 100644
--- a/src/sg_write_x.c
+++ b/src/sg_write_x.c
@@ -1265,12 +1265,12 @@ do_write_x(int sg_fd, const void * dataoutp, int dout_len,
if ((dout_len > 1024) && (vb < 7)) {
pr2serr(" Data-out buffer contents (first 1024 of %u "
"bytes):\n", dout_len);
- hex2stdout(dataoutp, 1024, 1);
+ hex2stdout((const uint8_t *)dataoutp, 1024, 1);
pr2serr(" Above: dout's first 1024 of %u bytes [%s]\n",
dout_len, op->cdb_name);
} else {
pr2serr(" Data-out buffer contents (length=%u):\n", dout_len);
- hex2stderr(dataoutp, (int)dout_len, 1);
+ hex2stderr((const uint8_t *)dataoutp, (int)dout_len, 1);
}
}
if (op->dry_run) {
diff --git a/testing/Makefile b/testing/Makefile
index 9471292a..9b7f6a83 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -27,22 +27,22 @@ MAN_PREF = man8
LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
# For C++/clang testing
-# ## CC = gcc
-# ## CC = g++
-# ## CC = clang
-# ## CC = clang++
+## CC = gcc
+CC = g++
+## CC = clang
+## CC = clang++
-CFLAGS = -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
+##CFLAGS = -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
# CFLAGS = -g -O2 -Wall -iquote ../include -D_REENTRANT -DSG_KERNEL_INCLUDES $(LARGE_FILE_FLAGS)
# CFLAGS = -g -O2 -Wall -pedantic -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
# CFLAGS = -Wall -W -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -pedantic -std=c11 --analyze
-# CFLAGS = -Wall -W -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -pedantic -std=c++14
+CFLAGS = -Wall -W -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -pedantic -std=c++14 -fPIC
LDFLAGS =
LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_io_linux.o
-LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o \
- ../lib/sg_pt_common.o ../lib/sg_cmds_basic.o ../lib/sg_pt_linux_nvme.o
+LIBFILESNEW = ../lib/sg_pt_linux_nvme.o ../lib/sg_lib.o ../lib/sg_lib_data.o \
+ ../lib/sg_pt_linux.o ../lib/sg_pt_common.o ../lib/sg_cmds_basic.o
all: $(EXECS)
diff --git a/testing/Makefile.cplus b/testing/Makefile.cplus
index b884b291..31af2ff5 100644
--- a/testing/Makefile.cplus
+++ b/testing/Makefile.cplus
@@ -29,7 +29,7 @@ CPPFLAGS = -std=c++11 -pthread -g -O2 -W -Wall -iquote ../include -D_REENTRANT $
LDFLAGS = -std=c++11 -pthread
LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_io_linux.o
-LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o
+LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o ../lib/sg_pt_common.o ../lib/sg_pt_linux_nvme.o
all: $(EXECS)
diff --git a/testing/README b/testing/README
index 5b6a9790..7ae56f63 100644
--- a/testing/README
+++ b/testing/README
@@ -4,7 +4,7 @@ needs to be executed in the parent directory followed by changing
directory to the lib directory and calling 'make' there.
Another way is to do a top level 'make' after the ./configure which
will make the libraries followed by all the utilities in the src/
-directory.
+directory. To make them in FreeBSD use 'make -f Makefile.freebsd' .
There is an brief explanation of each example in the README file in
the main (i.e. this directory's parent) directory. There are also
@@ -22,7 +22,8 @@ to get more information.
Those files with the extension "cpp" are C++ examples that use facilities
in C++11. They can be built by calling 'make -f Makefile.cplus'. A
-gcc/g++ compiler of 4.7.3 vintage or later will be required.
+gcc/g++ compiler of 4.7.3 vintage or later (or a recent clang compiler)
+will be required.
Douglas Gilbert
-4th November 2017
+19th January 2018
diff --git a/testing/sg_chk_asc.c b/testing/sg_chk_asc.c
index cb30075d..ef37729f 100644
--- a/testing/sg_chk_asc.c
+++ b/testing/sg_chk_asc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2015 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -25,7 +25,7 @@
* http://www.t10.org/lists/asc-num.txt
*/
-static char * version_str = "1.05 20150105";
+static const char * version_str = "1.06 20180119";
#define MAX_LINE_LEN 1024
@@ -59,7 +59,8 @@ static void usage()
int main(int argc, char * argv[])
{
- int k, j, res, c, num, len, asc, ascq;
+ int k, j, res, c, num, len;
+ unsigned int asc, ascq;
FILE * fp;
int offset = 24;
int verbose = 0;
@@ -138,7 +139,7 @@ int main(int argc, char * argv[])
continue;
num = sscanf(line, "%xh/%xh", &asc, &ascq);
if (1 == num)
- ascq = -1;
+ ascq = 999;
if (num < 1) {
if (verbose)
fprintf(stderr, "Badly formed line number %d (num=%d)\n",
@@ -169,7 +170,7 @@ printf("\"%s\",\n", b);
b[j] = toupper(b[j]);
bb[0] = '\0';
- if (ascq >= 0) {
+ if (ascq < 999) {
cp = sg_get_asc_ascq_str(asc, ascq, sizeof(bb) - 1, bb);
if (NULL == cp) {
fprintf(stderr, "no entry for %x,%x : %s\n", asc, ascq, b);
diff --git a/testing/sg_sense_test.c b/testing/sg_sense_test.c
index 4ada185b..683fc9b0 100644
--- a/testing/sg_sense_test.c
+++ b/testing/sg_sense_test.c
@@ -13,7 +13,7 @@
/* This is a simple program that tests the sense data descriptor format
printout function in sg_lib.c
-* Copyright (C) 2004-2016 D. Gilbert
+* Copyright (C) 2004-2018 D. Gilbert
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -25,7 +25,7 @@
#define ME "sg_sense_test: "
-static char * version_str = "2.00 20160128";
+static const char * version_str = "2.01 20180119";
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
diff --git a/testing/tst_sg_lib.c b/testing/tst_sg_lib.c
index 13be7ff8..90741ff7 100644
--- a/testing/tst_sg_lib.c
+++ b/testing/tst_sg_lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Douglas Gilbert.
+ * Copyright (c) 2013-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -25,15 +25,15 @@
*
*/
-static char * version_str = "1.04 20160503";
+static const char * version_str = "1.05 20180119";
#define MAX_LINE_LEN 1024
static struct option long_options[] = {
- {"dstrhex", no_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
+ {"hex2", no_argument, 0, 'H'},
{"leadin", required_argument, 0, 'l'},
{"printf", no_argument, 0, 'p'},
{"sense", no_argument, 0, 's'},
@@ -58,7 +58,7 @@ static const unsigned char desc_sense_data1[] = {
0xa, 0x6, 0x2, 0x1, 0x2, 0x0, 0x32, 0x01,
/* incorrect length indicator (ILI) */
0x5, 0x2, 0x0, 0x20,
- /* user data degment referral */
+ /* user data segment referral */
0xb, 26, 0x1, 0x0,
0,0,0,1, 0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,
0x1,0x2,0x3,0x4,0x55,0x6,0x7,0x8,
@@ -136,12 +136,12 @@ static void
usage()
{
fprintf(stderr,
- "Usage: tst_sg_lib [--dstrhex] [--help] [--leadin=STR] "
+ "Usage: tst_sg_lib [--help] [--hex2] [--leadin=STR] "
"[--printf]\n"
" [--sense] [--unaligned] [--verbose] "
"[--version]\n"
- " where: --dstrhex|-d test dStrHex* variants\n"
- " --help|-h print out usage message\n"
+ " where; --help|-h print out usage message\n"
+ " --hex2|-H test hex2* variants\n"
" --leadin=STR|-l STR every line output by --sense "
"should\n"
" be prefixed by STR\n"
@@ -180,7 +180,7 @@ int
main(int argc, char * argv[])
{
int k, c, n, len;
- int do_dstrhex = 0;
+ int do_hex2 = 0;
int do_printf = 0;
int do_sense = 0;
int do_unaligned = 0;
@@ -193,19 +193,19 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "dhl:psuvV", long_options,
+ c = getopt_long(argc, argv, "hHl:psuvV", long_options,
&option_index);
if (c == -1)
break;
switch (c) {
- case 'd':
- ++do_dstrhex;
- break;
case 'h':
case '?':
usage();
return 0;
+ case 'H':
+ ++do_hex2;
+ break;
case 'l':
leadin = optarg;
break;
@@ -360,21 +360,21 @@ main(int argc, char * argv[])
if (strlen(b) > 0)
printf("Resulting string: %s\n", b);
}
- if (do_dstrhex) {
- char b[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58};
+ if (do_hex2) {
+ uint8_t b[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58};
++did_something;
for (k = 0; k < 18; ++k) {
printf("k=%d:\n", k);
- dStrHex(b, k, 0);
- dStrHexStr(b, k, "dSHS_0: ", 0, sizeof(bb), bb);
+ hex2stdout(b, k, 0);
+ hex2str(b, k, "h2str0: ", 0, sizeof(bb), bb);
printf("%s", bb);
- dStrHex(b, k, 1);
- dStrHexStr(b, k, "dSHS_1: ", 1, sizeof(bb), bb);
+ hex2stdout(b, k, 1);
+ hex2str(b, k, "h2str1: ", 1, sizeof(bb), bb);
printf("%s", bb);
- dStrHex(b, k, -1);
+ hex2stdout(b, k, -1);
printf("\n");
}
}
@@ -397,64 +397,64 @@ main(int argc, char * argv[])
printf("u16=0x%" PRIx16 "\n", u16);
sg_put_unaligned_le16(u16, u8);
printf(" le16:\n");
- dStrHex((const char *)u8, verbose ? 10 : 2, -1);
+ hex2stdout(u8, verbose ? 10 : 2, -1);
u16r = sg_get_unaligned_le16(u8);
printf(" u16r=0x%" PRIx16 "\n", u16r);
sg_put_unaligned_be16(u16, u8);
printf(" be16:\n");
- dStrHex((const char *)u8, verbose ? 10 : 2, -1);
+ hex2stdout(u8, verbose ? 10 : 2, -1);
u16r = sg_get_unaligned_be16(u8);
printf(" u16r=0x%" PRIx16 "\n\n", u16r);
printf("u24=0x%" PRIx32 "\n", u24);
sg_put_unaligned_le24(u24, u8);
printf(" le24:\n");
- dStrHex((const char *)u8, verbose ? 10 : 3, -1);
+ hex2stdout(u8, verbose ? 10 : 3, -1);
u24r = sg_get_unaligned_le24(u8);
printf(" u24r=0x%" PRIx32 "\n", u24r);
sg_put_unaligned_be24(u24, u8);
printf(" be24:\n");
- dStrHex((const char *)u8, verbose ? 10 : 3, -1);
+ hex2stdout(u8, verbose ? 10 : 3, -1);
u24r = sg_get_unaligned_be24(u8);
printf(" u24r=0x%" PRIx32 "\n\n", u24r);
printf("u32=0x%" PRIx32 "\n", u32);
sg_put_unaligned_le32(u32, u8);
printf(" le32:\n");
- dStrHex((const char *)u8, verbose ? 10 : 4, -1);
+ hex2stdout(u8, verbose ? 10 : 4, -1);
u32r = sg_get_unaligned_le32(u8);
printf(" u32r=0x%" PRIx32 "\n", u32r);
sg_put_unaligned_be32(u32, u8);
printf(" be32:\n");
- dStrHex((const char *)u8, verbose ? 10 : 4, -1);
+ hex2stdout(u8, verbose ? 10 : 4, -1);
u32r = sg_get_unaligned_be32(u8);
printf(" u32r=0x%" PRIx32 "\n\n", u32r);
printf("u48=0x%" PRIx64 "\n", u48);
sg_put_unaligned_le48(u48, u8);
printf(" le48:\n");
- dStrHex((const char *)u8, verbose ? 10 : 6, -1);
+ hex2stdout(u8, verbose ? 10 : 6, -1);
u48r = sg_get_unaligned_le48(u8);
printf(" u48r=0x%" PRIx64 "\n", u48r);
sg_put_unaligned_be48(u48, u8);
printf(" be48:\n");
- dStrHex((const char *)u8, verbose ? 10 : 6, -1);
+ hex2stdout(u8, verbose ? 10 : 6, -1);
u48r = sg_get_unaligned_be48(u8);
printf(" u48r=0x%" PRIx64 "\n\n", u48r);
printf("u64=0x%" PRIx64 "\n", u64);
sg_put_unaligned_le64(u64, u8);
printf(" le64:\n");
- dStrHex((const char *)u8, verbose ? 10 : 8, -1);
+ hex2stdout(u8, verbose ? 10 : 8, -1);
u64r = sg_get_unaligned_le64(u8);
printf(" u64r=0x%" PRIx64 "\n", u64r);
sg_put_unaligned_be64(u64, u8);
printf(" be64:\n");
- dStrHex((const char *)u8, verbose ? 10 : 8, -1);
+ hex2stdout(u8, verbose ? 10 : 8, -1);
u64r = sg_get_unaligned_be64(u8);
printf(" u64r=0x%" PRIx64 "\n\n", u64r);
printf(" be[8]:\n");
- dStrHex((const char *)u8, verbose ? 10 : 8, -1);
+ hex2stdout(u8, verbose ? 10 : 8, -1);
u64r = sg_get_unaligned_be(8, u8);
printf(" u64r[8]=0x%" PRIx64 "\n\n", u64r);
printf(" le[8]:\n");