aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--Makefile.in1
-rwxr-xr-xconfigure17
-rw-r--r--configure.ac8
-rw-r--r--doc/Makefile.in1
-rw-r--r--doc/sg3_utils.82
-rw-r--r--include/Makefile.in1
-rw-r--r--lib/Makefile.in1
-rw-r--r--lib/sg_pt_win32.c79
-rw-r--r--scripts/Makefile.in1
-rw-r--r--src/Makefile.am6
-rw-r--r--src/Makefile.in7
12 files changed, 88 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index d5129a1d..20f7d1e7 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.40 [20140829] [svn: r603]
+Changelog for sg3_utils-1.40 [20140801] [svn: r604]
- sg_write_verify: new utility for WRITE AND VERIFY
- sg_senddiag: add --maxlen= option
- sg_copy_results: correct response length calculations
diff --git a/Makefile.in b/Makefile.in
index 29b2ad1f..15121c50 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -296,6 +296,7 @@ localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+os_cflags = @os_cflags@
os_libs = @os_libs@
pdfdir = @pdfdir@
prefix = @prefix@
diff --git a/configure b/configure
index ef27c433..bd8ee263 100755
--- a/configure
+++ b/configure
@@ -648,6 +648,7 @@ OS_LINUX_TRUE
OS_FREEBSD_FALSE
OS_FREEBSD_TRUE
os_libs
+os_cflags
GETOPT_O_FILES
CPP
OTOOL64
@@ -11615,6 +11616,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_LINUX 1
_ACEOF
+ os_cflags=''
+
os_libs=''
;;
*-*-linux*)
@@ -11623,6 +11626,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_LINUX 1
_ACEOF
+ os_cflags=''
+
os_libs=''
;;
*-*-freebsd*|*-*-kfreebsd*-gnu*)
@@ -11631,6 +11636,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_FREEBSD 1
_ACEOF
+ os_cflags=''
+
os_libs='-lcam'
;;
*-*-solaris*)
@@ -11639,6 +11646,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_SOLARIS 1
_ACEOF
+ os_cflags=''
+
os_libs=''
;;
*-*-osf*)
@@ -11647,6 +11656,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_OSF1 1
_ACEOF
+ os_cflags=''
+
os_libs=''
;;
*-*-cygwin*)
@@ -11655,6 +11666,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_WIN32 1
_ACEOF
+ os_cflags='-Wno-char-subscripts'
+
os_libs=''
;;
*-*-mingw*)
@@ -11668,6 +11681,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_MINGW 1
_ACEOF
+ os_cflags=''
+
os_libs=''
;;
*)
@@ -11676,6 +11691,8 @@ cat >>confdefs.h <<_ACEOF
#define SG_LIB_LINUX 1
_ACEOF
+ os_cflags=''
+
os_libs=''
;;
esac
diff --git a/configure.ac b/configure.ac
index d0ee2517..def549ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,28 +36,36 @@ AC_DEFINE_UNQUOTED(SG_LIB_BUILD_HOST, "${host}", [sg3_utils Build Host])
case "${host}" in
*-*-linux-gnu*)
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['']) ;;
*-*-linux*)
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['']) ;;
*-*-freebsd*|*-*-kfreebsd*-gnu*)
AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sg3_utils on FreeBSD])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['-lcam']);;
*-*-solaris*)
AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sg3_utils on Solaris])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['']);;
*-*-osf*)
AC_DEFINE_UNQUOTED(SG_LIB_OSF1, 1, [sg3_utils on Tru64 UNIX])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['']) ;;
*-*-cygwin*)
AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
+ AC_SUBST([os_cflags], ['-Wno-char-subscripts'])
AC_SUBST([os_libs], ['']) ;;
*-*-mingw*)
AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['']) ;;
*)
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [assume sg3_utils on linux])
+ AC_SUBST([os_cflags], [''])
AC_SUBST([os_libs], ['']) ;;
esac
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 19cd7067..f4df4c2a 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -243,6 +243,7 @@ localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+os_cflags = @os_cflags@
os_libs = @os_libs@
pdfdir = @pdfdir@
prefix = @prefix@
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index 26cd7a95..f3edb750 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -1,4 +1,4 @@
-.TH SG3_UTILS "8" "August 2014" "sg3_utils\-1.40" SG3_UTILS
+.TH SG3_UTILS "8" "September 2014" "sg3_utils\-1.40" SG3_UTILS
.SH NAME
sg3_utils \- a package of utilities for sending SCSI commands
.SH SYNOPSIS
diff --git a/include/Makefile.in b/include/Makefile.in
index bbe399c7..54a4c3b0 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -271,6 +271,7 @@ localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+os_cflags = @os_cflags@
os_libs = @os_libs@
pdfdir = @pdfdir@
prefix = @prefix@
diff --git a/lib/Makefile.in b/lib/Makefile.in
index d9d9beaa..5531c12c 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -316,6 +316,7 @@ localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+os_cflags = @os_cflags@
os_libs = @os_libs@
pdfdir = @pdfdir@
prefix = @prefix@
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index 6bb3912b..a55e029d 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2006-2012 Douglas Gilbert.
+ * Copyright (c) 2006-2014 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.
*/
-/* sg_pt_win32 version 1.14 20121026 */
+/* sg_pt_win32 version 1.15 20140901 */
#include <stdio.h>
#include <stdlib.h>
@@ -24,9 +24,9 @@
#endif
#ifndef O_EXCL
-// #define O_EXCL 0x80 // cygwin ??
-// #define O_EXCL 0x80 // Linux
-#define O_EXCL 0x400 // mingw
+// #define O_EXCL 0x80 // cygwin ??
+// #define O_EXCL 0x80 // Linux
+#define O_EXCL 0x400 // mingw
#warning "O_EXCL not defined"
#endif
@@ -64,9 +64,10 @@ struct sg_pt_handle {
int bus;
int target;
int lun;
+ int verbose; /* tunnel verbose through to scsi_pt_close_device */
};
-struct sg_pt_handle handle_arr[MAX_OPEN_SIMULT];
+static struct sg_pt_handle handle_arr[MAX_OPEN_SIMULT];
struct sg_pt_win32_scsi {
unsigned char * dxferp;
@@ -201,6 +202,7 @@ scsi_pt_open_flags(const char * device_name, int flags, int verbose)
shp->bus = bus;
shp->target = target;
shp->lun = lun;
+ shp->verbose = verbose;
memset(shp->adapter, 0, sizeof(shp->adapter));
strncpy(shp->adapter, "\\\\.\\", 4);
if (got_pd_name)
@@ -216,8 +218,8 @@ scsi_pt_open_flags(const char * device_name, int flags, int verbose)
share_mode, NULL, OPEN_EXISTING, 0, NULL);
if (shp->fh == INVALID_HANDLE_VALUE) {
if (verbose)
- fprintf(sg_warnings_strm, "Windows CreateFile error=%ld\n",
- GetLastError());
+ fprintf(sg_warnings_strm, "Windows CreateFile error=%u\n",
+ (unsigned int)GetLastError());
shp->in_use = 0;
return -ENODEV;
}
@@ -225,7 +227,11 @@ scsi_pt_open_flags(const char * device_name, int flags, int verbose)
}
-/* Returns 0 if successful. If error in Unix returns negated errno. */
+/* Returns 0 if successful. If device_id seems wild returns -ENODEV,
+ * other errors return 0. If CloseHandle() fails and verbose > 0 then
+ * outputs warning with value from GetLastError(). The verbose value
+ * defaults to zero and is potentially set from the most recent call
+ * to scsi_pt_open_device() or do_scsi_pt(). */
int
scsi_pt_close_device(int device_fd)
{
@@ -237,12 +243,15 @@ scsi_pt_close_device(int device_fd)
if ((index < 0) || (index >= WIN32_FDOFFSET))
return -ENODEV;
shp = handle_arr + index;
- CloseHandle(shp->fh);
+ if ((! CloseHandle(shp->fh)) && shp->verbose)
+ fprintf(sg_warnings_strm, "Windows CloseHandle error=%u\n",
+ (unsigned int)GetLastError());
shp->bus = 0;
shp->target = 0;
shp->lun = 0;
memset(shp->adapter, 0, sizeof(shp->adapter));
shp->in_use = 0;
+ shp->verbose = 0;
return 0;
}
@@ -435,7 +444,7 @@ set_scsi_pt_flags(struct sg_pt_base * objp, int flags)
/* Executes SCSI command (or at least forwards it to lower layers)
* using direct interface. Clears os_err field prior to active call (whose
* result may set it again). */
-int
+static int
do_scsi_pt_direct(struct sg_pt_base * vp, int device_fd, int time_secs,
int verbose)
{
@@ -443,7 +452,7 @@ do_scsi_pt_direct(struct sg_pt_base * vp, int device_fd, int time_secs,
struct sg_pt_win32_scsi * psp = vp->implp;
struct sg_pt_handle * shp;
BOOL status;
- ULONG returned;
+ DWORD returned;
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
@@ -473,6 +482,7 @@ do_scsi_pt_direct(struct sg_pt_base * vp, int device_fd, int time_secs,
psp->os_err = ENODEV;
return -psp->os_err;
}
+ shp->verbose = verbose;
psp->swb_d.spt.Length = sizeof (SCSI_PASS_THROUGH_DIRECT);
psp->swb_d.spt.PathId = shp->bus;
psp->swb_d.spt.TargetId = shp->target;
@@ -486,13 +496,14 @@ do_scsi_pt_direct(struct sg_pt_base * vp, int device_fd, int time_secs,
(int)psp->swb_d.spt.ScsiStatus, (int)psp->swb_d.spt.PathId,
(int)psp->swb_d.spt.TargetId, (int)psp->swb_d.spt.Lun);
fprintf(stderr, " CdbLength=%d SenseInfoLength=%d DataIn=%d "
- "DataTransferLength=%lu\n",
+ "DataTransferLength=%u\n",
(int)psp->swb_d.spt.CdbLength,
(int)psp->swb_d.spt.SenseInfoLength,
(int)psp->swb_d.spt.DataIn,
- psp->swb_d.spt.DataTransferLength);
- fprintf(stderr, " TimeOutValue=%lu SenseInfoOffset=%lu\n",
- psp->swb_d.spt.TimeOutValue, psp->swb_d.spt.SenseInfoOffset);
+ (unsigned int)psp->swb_d.spt.DataTransferLength);
+ fprintf(stderr, " TimeOutValue=%u SenseInfoOffset=%u\n",
+ (unsigned int)psp->swb_d.spt.TimeOutValue,
+ (unsigned int)psp->swb_d.spt.SenseInfoOffset);
}
psp->swb_d.spt.DataBuffer = psp->dxferp;
status = DeviceIoControl(shp->fh, IOCTL_SCSI_PASS_THROUGH_DIRECT,
@@ -503,10 +514,13 @@ do_scsi_pt_direct(struct sg_pt_base * vp, int device_fd, int time_secs,
&returned,
NULL);
if (! status) {
- psp->transport_err = GetLastError();
+ unsigned int u;
+
+ u = (unsigned int)GetLastError();
if (verbose)
- fprintf(sg_warnings_strm, "Windows DeviceIoControl error=%d\n",
- psp->transport_err);
+ fprintf(sg_warnings_strm, "Windows DeviceIoControl error=%u\n",
+ u);
+ psp->transport_err = (int)u;
psp->os_err = EIO;
return 0; /* let app find transport error */
}
@@ -537,7 +551,7 @@ do_scsi_pt_indirect(struct sg_pt_base * vp, int device_fd, int time_secs,
struct sg_pt_win32_scsi * psp = vp->implp;
struct sg_pt_handle * shp;
BOOL status;
- ULONG returned;
+ DWORD returned;
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
@@ -568,6 +582,7 @@ do_scsi_pt_indirect(struct sg_pt_base * vp, int device_fd, int time_secs,
psp->os_err = ENODEV;
return -psp->os_err;
}
+ shp->verbose = verbose;
if (psp->dxfer_len > (int)sizeof(psp->swb_i.ucDataBuf)) {
int extra = psp->dxfer_len - (int)sizeof(psp->swb_i.ucDataBuf);
struct sg_pt_win32_scsi * epsp;
@@ -576,7 +591,7 @@ do_scsi_pt_indirect(struct sg_pt_base * vp, int device_fd, int time_secs,
fprintf(sg_warnings_strm, "spt_indirect: dxfer_len (%d) too "
"large for initial data\n buffer (%d bytes), try "
"enlarging\n", psp->dxfer_len,
- sizeof(psp->swb_i.ucDataBuf));
+ (int)sizeof(psp->swb_i.ucDataBuf));
epsp = (struct sg_pt_win32_scsi *)
calloc(sizeof(struct sg_pt_win32_scsi) + extra, 1);
if (NULL == epsp) {
@@ -605,15 +620,16 @@ do_scsi_pt_indirect(struct sg_pt_base * vp, int device_fd, int time_secs,
(int)psp->swb_i.spt.ScsiStatus, (int)psp->swb_i.spt.PathId,
(int)psp->swb_i.spt.TargetId, (int)psp->swb_i.spt.Lun);
fprintf(stderr, " CdbLength=%d SenseInfoLength=%d DataIn=%d "
- "DataTransferLength=%lu\n",
+ "DataTransferLength=%u\n",
(int)psp->swb_i.spt.CdbLength,
(int)psp->swb_i.spt.SenseInfoLength,
(int)psp->swb_i.spt.DataIn,
- psp->swb_i.spt.DataTransferLength);
- fprintf(stderr, " TimeOutValue=%lu DataBufferOffset=%lu "
- "SenseInfoOffset=%lu\n", psp->swb_i.spt.TimeOutValue,
- psp->swb_i.spt.DataBufferOffset,
- psp->swb_i.spt.SenseInfoOffset);
+ (unsigned int)psp->swb_i.spt.DataTransferLength);
+ fprintf(stderr, " TimeOutValue=%u DataBufferOffset=%u "
+ "SenseInfoOffset=%u\n",
+ (unsigned int)psp->swb_i.spt.TimeOutValue,
+ (unsigned int)psp->swb_i.spt.DataBufferOffset,
+ (unsigned int)psp->swb_i.spt.SenseInfoOffset);
}
if ((psp->dxfer_len > 0) &&
(SCSI_IOCTL_DATA_OUT == psp->swb_i.spt.DataIn))
@@ -626,10 +642,13 @@ do_scsi_pt_indirect(struct sg_pt_base * vp, int device_fd, int time_secs,
&returned,
NULL);
if (! status) {
- psp->transport_err = GetLastError();
+ unsigned int u;
+
+ u = (unsigned int)GetLastError();
if (verbose)
- fprintf(sg_warnings_strm, "Windows DeviceIoControl error=%d\n",
- psp->transport_err);
+ fprintf(sg_warnings_strm, "Windows DeviceIoControl error=%u\n",
+ u);
+ psp->transport_err = (int)u;
psp->os_err = EIO;
return 0; /* let app find transport error */
}
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index e16f9473..7500c850 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -242,6 +242,7 @@ localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+os_cflags = @os_cflags@
os_libs = @os_libs@
pdfdir = @pdfdir@
prefix = @prefix@
diff --git a/src/Makefile.am b/src/Makefile.am
index c5d2e8f8..77ed6c05 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -127,9 +127,9 @@ endif
## CC = clang++
# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
-AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W
-# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11
-# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c++11
+AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W @os_cflags@
+# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W @os_cflags@ -pedantic -std=c11
+# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W @os_cflags@ -pedantic -std=c++11
sg_dd_SOURCES = sg_dd.c
sg_dd_LDADD = ../lib/libsgutils2.la @os_libs@
diff --git a/src/Makefile.in b/src/Makefile.in
index 998914b9..fc579df0 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -752,6 +752,7 @@ localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+os_cflags = @os_cflags@
os_libs = @os_libs@
pdfdir = @pdfdir@
prefix = @prefix@
@@ -769,9 +770,9 @@ top_srcdir = @top_srcdir@
# For C++/clang testing
# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
-AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W
-# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11
-# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c++11
+AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W @os_cflags@
+# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W @os_cflags@ -pedantic -std=c11
+# AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W @os_cflags@ -pedantic -std=c++11
sg_dd_SOURCES = sg_dd.c
sg_dd_LDADD = ../lib/libsgutils2.la @os_libs@
sg_decode_sense_SOURCES = sg_decode_sense.c