sg_inq: add --only option, further sanity checks on --inhex so CDROM std inq not confused with VPD page 0x80; sgp_dd: use pthread_kill(); various configure.ac and Makefile.am cleanups

git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@742 6180dd3e-e324-4e3e-922d-17de1ae2f315
diff --git a/BSD_LICENSE b/BSD_LICENSE
index 75de7f1..fe73146 100644
--- a/BSD_LICENSE
+++ b/BSD_LICENSE
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999-2017 Douglas Gilbert.
+ * Copyright (c) 1999-2018 Douglas Gilbert.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/CREDITS b/CREDITS
index f59ad04..beefb4c 100644
--- a/CREDITS
+++ b/CREDITS
@@ -8,6 +8,8 @@
 
 Bart Van Assche <bart dot vanassche at sandisk dot com>
         harden (improve) code in rescan-scsi-bus.sh [20160224]
+        configure.ac and Makefile.am cleanup plus sgp_dd code
+        to replace pthread_cancel with pthread_kill [20180102]
 
 Brian Bunker <Brian dot Bunker at netapp dot com> contributed
         sg_read_block_limits and the target reset addition to sg_reset
@@ -55,6 +57,7 @@
         rescan-scsi-bus.sh patches to Kurt Garloff's v1.57 [20130715]
         55-scsi-sg3_id.rules + 58-scsi-sg3_symlink.rules [20140527]
         sg_sat_read_gplog [20141107]
+        sg_inq --only option plus --inhex fixes [20180102]
 
 Hayashi Naoyuki <titan at culzean dot org>
         port to Tru64 [20060127]
@@ -138,4 +141,4 @@
 
 
 Douglas Gilbert
-28th February 2016
+2nd January 2018
diff --git a/ChangeLog b/ChangeLog
index 13ada9a..ae73c86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@
 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 [20171231] [svn: r741]
+Changelog for sg3_utils-1.43 [20180102] [svn: r742]
   - 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
@@ -46,7 +46,11 @@
     - fixup enumeration in power condition transition
       log page (from H. Reinecke, Suse)
   - sg_inq: fix potential unbounded loop in --export
+    - add --only to stop standard inquiry decoding also
+      doing a serial number vpd page (0x80) fetch
     - update version descriptor list to 20170114
+    - add further checks so CDROM standard inquiry response
+      doesn't trick --inhex into thinking it's VPD pg 0x80
     - decode NVMe Identify controller/nsid
   - sg_inq+sg_vpd: update Extended inquiry data vpd
     page (spc5r09)
@@ -65,8 +69,9 @@
   - sg_turs+sg_requests: make both accept '--num=NUM'
     and '--number=NUM' for mutual compatibility
   - sg_zone: fix debug cdb naming
-  - sgp_dd: if SG_LIB_ANDROID defined invoke
-    pthread_kill() rather than pthread_cancel() [Linux]
+  - sgp_dd: pthread_cancel() has issues in C++ (and
+    the Android multi-threaded library doesn't supply it)
+    so use pthread_kill() in its place [Linux only]
   - sg_opcode: add '--enumerate' and '--pdt=' options
     - support CDLP (command duration limit page)
     - check resid and trim response if necessary
@@ -137,6 +142,7 @@
     decision made at runtime
   - automake: add AM_PROG_AR to configure.ac
     - upgrade to version 1.15
+    - various configure.ac and Makefile.am cleanups
     - 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
diff --git a/Makefile.in b/Makefile.in
index 07ba399..0c13063 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -261,6 +261,7 @@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -307,8 +308,6 @@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
diff --git a/config.h.in b/config.h.in
index b33212f..6050d85 100644
--- a/config.h.in
+++ b/config.h.in
@@ -36,10 +36,10 @@
 /* Define to 1 if you have the `posix_memalign' function. */
 #undef HAVE_POSIX_MEMALIGN
 
-/* Found pthread_cancel */
+/* Define to 1 if you have the `pthread_cancel' function. */
 #undef HAVE_PTHREAD_CANCEL
 
-/* Found pthread_kill */
+/* Define to 1 if you have the `pthread_kill' function. */
 #undef HAVE_PTHREAD_KILL
 
 /* Define to 1 if you have the <stdint.h> header file. */
@@ -105,7 +105,7 @@
 /* sg3_utils on FreeBSD */
 #undef SG_LIB_FREEBSD
 
-/* assume sg3_utils on linux */
+/* sg3_utils on linux */
 #undef SG_LIB_LINUX
 
 /* also MinGW environment */
diff --git a/configure b/configure
index 79815dd..1ddb0cd 100755
--- a/configure
+++ b/configure
@@ -649,9 +649,8 @@
 OS_LINUX_TRUE
 OS_FREEBSD_FALSE
 OS_FREEBSD_TRUE
-os_libs
-os_cflags
 GETOPT_O_FILES
+PTHREAD_LIB
 CPP
 LT_SYS_LIBRARY_PATH
 OTOOL64
@@ -661,8 +660,6 @@
 DSYMUTIL
 MANIFEST_TOOL
 RANLIB
-ac_ct_AR
-AR
 DLLTOOL
 OBJDUMP
 LN_S
@@ -683,6 +680,8 @@
 build_cpu
 build
 LIBTOOL
+ac_ct_AR
+AR
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
 CCDEPMODE
@@ -3932,6 +3931,180 @@
 # AC_PROG_CXX
 
 
+# AM_PROG_AR is supported and needed since automake v1.12+
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar lib "link -lib"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$AR" && break
+  done
+fi
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar lib "link -lib"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_AR" && break
+done
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+fi
+
+: ${AR=ar}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5
+$as_echo_n "checking the archiver ($AR) interface... " >&6; }
+if ${am_cv_ar_interface+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+   am_cv_ar_interface=ar
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int some_variable = 0;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'
+      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
+  (eval $am_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+      if test "$ac_status" -eq 0; then
+        am_cv_ar_interface=ar
+      else
+        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5'
+        { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
+  (eval $am_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        if test "$ac_status" -eq 0; then
+          am_cv_ar_interface=lib
+        else
+          am_cv_ar_interface=unknown
+        fi
+      fi
+      rm -f conftest.lib libconftest.a
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
+$as_echo "$am_cv_ar_interface" >&6; }
+
+case $am_cv_ar_interface in
+ar)
+  ;;
+lib)
+  # Microsoft lib, so override with the ar-lib wrapper script.
+  # FIXME: It is wrong to rewrite AR.
+  # But if we don't then we get into trouble of one sort or another.
+  # A longer-term fix would be to have automake use am__AR in this case,
+  # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
+  # similar.
+  AR="$am_aux_dir/ar-lib $AR"
+  ;;
+unknown)
+  as_fn_error $? "could not determine $AR interface" "$LINENO" 5
+  ;;
+esac
+
+
 # Adding libtools to the build seems to bring in C++ environment
 case `pwd` in
   *\ * | *\	*)
@@ -5503,7 +5676,6 @@
 
 
 
-
 if test -n "$ac_tool_prefix"; then
   for ac_prog in ar
   do
@@ -12015,179 +12187,6 @@
 
 
 
-# AM_PROG_AR is supported and needed since automake v1.12+
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in ar lib "link -lib"
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    test -n "$AR" && break
-  done
-fi
-if test -z "$AR"; then
-  ac_ct_AR=$AR
-  for ac_prog in ar lib "link -lib"
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_AR"; then
-  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_AR="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ac_ct_AR" && break
-done
-
-  if test "x$ac_ct_AR" = x; then
-    AR="false"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    AR=$ac_ct_AR
-  fi
-fi
-
-: ${AR=ar}
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5
-$as_echo_n "checking the archiver ($AR) interface... " >&6; }
-if ${am_cv_ar_interface+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-   am_cv_ar_interface=ar
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-int some_variable = 0;
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'
-      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
-  (eval $am_ar_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
-        am_cv_ar_interface=ar
-      else
-        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5'
-        { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
-  (eval $am_ar_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-        if test "$ac_status" -eq 0; then
-          am_cv_ar_interface=lib
-        else
-          am_cv_ar_interface=unknown
-        fi
-      fi
-      rm -f conftest.lib libconftest.a
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
-$as_echo "$am_cv_ar_interface" >&6; }
-
-case $am_cv_ar_interface in
-ar)
-  ;;
-lib)
-  # Microsoft lib, so override with the ar-lib wrapper script.
-  # FIXME: It is wrong to rewrite AR.
-  # But if we don't then we get into trouble of one sort or another.
-  # A longer-term fix would be to have automake use am__AR in this case,
-  # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
-  # similar.
-  AR="$am_aux_dir/ar-lib $AR"
-  ;;
-unknown)
-  as_fn_error $? "could not determine $AR interface" "$LINENO" 5
-  ;;
-esac
-
-
 # check for headers
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
@@ -12360,9 +12359,10 @@
 fi
 done
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_cancel" >&5
-$as_echo_n "checking for library containing pthread_cancel... " >&6; }
-if ${ac_cv_search_pthread_cancel+:} false; then :
+SAVED_LIBS=$LIBS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5
+$as_echo_n "checking for library containing pthread_create... " >&6; }
+if ${ac_cv_search_pthread_create+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -12375,11 +12375,11 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char pthread_cancel ();
+char pthread_create ();
 int
 main ()
 {
-return pthread_cancel ();
+return pthread_create ();
   ;
   return 0;
 }
@@ -12392,89 +12392,47 @@
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
   if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_pthread_cancel=$ac_res
+  ac_cv_search_pthread_create=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if ${ac_cv_search_pthread_cancel+:} false; then :
+  if ${ac_cv_search_pthread_create+:} false; then :
   break
 fi
 done
-if ${ac_cv_search_pthread_cancel+:} false; then :
+if ${ac_cv_search_pthread_create+:} false; then :
 
 else
-  ac_cv_search_pthread_cancel=no
+  ac_cv_search_pthread_create=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_cancel" >&5
-$as_echo "$ac_cv_search_pthread_cancel" >&6; }
-ac_res=$ac_cv_search_pthread_cancel
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5
+$as_echo "$ac_cv_search_pthread_create" >&6; }
+ac_res=$ac_cv_search_pthread_create
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-$as_echo "#define HAVE_PTHREAD_CANCEL 1" >>confdefs.h
-
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_kill" >&5
-$as_echo_n "checking for library containing pthread_kill... " >&6; }
-if ${ac_cv_search_pthread_kill+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_kill ();
-int
-main ()
-{
-return pthread_kill ();
-  ;
-  return 0;
-}
+# AC_SEARCH_LIBS adds libraries at the start of $LIBS so remove $SAVED_LIBS
+# from the end of $LIBS.
+pthread_lib=${LIBS%${SAVED_LIBS}}
+for ac_func in pthread_cancel pthread_kill
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
-for ac_lib in '' pthread; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_pthread_kill=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_pthread_kill+:} false; then :
-  break
+
 fi
 done
-if ${ac_cv_search_pthread_kill+:} false; then :
 
-else
-  ac_cv_search_pthread_kill=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_kill" >&5
-$as_echo "$ac_cv_search_pthread_kill" >&6; }
-ac_res=$ac_cv_search_pthread_kill
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-$as_echo "#define HAVE_PTHREAD_KILL 1" >>confdefs.h
-
-fi
+LIBS=$SAVED_LIBS
+PTHREAD_LIB=$pthread_lib
 
 
 
@@ -12486,89 +12444,41 @@
 _ACEOF
 
 
+check_for_linux_nvme_headers() {
+	for ac_header in linux/nvme_ioctl.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
+if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LINUX_NVME_IOCTL_H 1
+_ACEOF
+
+$as_echo "#define HAVE_NVME 1" >>confdefs.h
+
+fi
+
+done
+
+	for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H
+		     # include <linux/types.h>
+		     #endif
+
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+}
+
 case "${host}" in
-        *-*-linux-gnu*)
-
-cat >>confdefs.h <<_ACEOF
-#define SG_LIB_LINUX 1
-_ACEOF
-
-                os_cflags=''
-
-                os_libs=''
-
-		for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-		for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
- ;;
-        *-*-linux*)
-
-cat >>confdefs.h <<_ACEOF
-#define SG_LIB_LINUX 1
-_ACEOF
-
-                os_cflags=''
-
-                os_libs=''
-
-		for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-		for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
- ;;
 	*-*-android*)
 
 cat >>confdefs.h <<_ACEOF
@@ -12580,41 +12490,7 @@
 #define SG_LIB_LINUX 1
 _ACEOF
 
-                os_cflags=''
-
-                os_libs=''
-
-		for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-		for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
- ;;
+		check_for_linux_nvme_headers;;
         *-*-freebsd*|*-*-kfreebsd*-gnu*)
 
 cat >>confdefs.h <<_ACEOF
@@ -12624,40 +12500,26 @@
 
 $as_echo "#define HAVE_NVME 1" >>confdefs.h
 
-                os_cflags=''
-
-                os_libs='-lcam'
-;;
+                LIBS="$LIBS -lcam";;
         *-*-solaris*)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_SOLARIS 1
 _ACEOF
-
-                os_cflags=''
-
-                os_libs=''
 ;;
         *-*-osf*)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_OSF1 1
 _ACEOF
-
-                os_cflags=''
-
-                os_libs=''
- ;;
+;;
         *-*-cygwin*)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_WIN32 1
 _ACEOF
 
-                os_cflags='-Wno-char-subscripts'
-
-                os_libs=''
- ;;
+                CFLAGS="$CFLAGS -Wno-char-subscripts";;
         *-*-mingw*)
 
 cat >>confdefs.h <<_ACEOF
@@ -12668,52 +12530,14 @@
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_MINGW 1
 _ACEOF
-
-                os_cflags=''
-
-                os_libs=''
- ;;
-        *)
+;;
+        *-*-linux-gnu* | *-*-linux* | *)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_LINUX 1
 _ACEOF
 
-                os_cflags=''
-
-                os_libs=''
-
-		for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-		for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
- ;;
+                check_for_linux_nvme_headers;;
 esac
 
 # Define platform-specific symbol.
diff --git a/configure.ac b/configure.ac
index 1cce0b2..b1d1f4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,12 +7,12 @@
 AC_PROG_CC
 # AC_PROG_CXX
 AC_PROG_INSTALL
-		
-# Adding libtools to the build seems to bring in C++ environment
-AC_PROG_LIBTOOL
 
 # AM_PROG_AR is supported and needed since automake v1.12+
 ifdef([AM_PROG_AR], [AM_PROG_AR], []) 
+		
+# Adding libtools to the build seems to bring in C++ environment
+AC_PROG_LIBTOOL
 
 # check for headers
 AC_HEADER_STDC
@@ -25,78 +25,51 @@
 AC_CHECK_FUNCS(posix_memalign)
 AC_CHECK_FUNCS(sysconf)
 AC_CHECK_FUNCS(lseek64)
-AC_SEARCH_LIBS([pthread_cancel], [pthread], [AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Found pthread_cancel])], [])
-AC_SEARCH_LIBS([pthread_kill], [pthread], [AC_DEFINE(HAVE_PTHREAD_KILL, 1, [Found pthread_kill])], [])
+SAVED_LIBS=$LIBS
+AC_SEARCH_LIBS([pthread_create], [pthread])
+# AC_SEARCH_LIBS adds libraries at the start of $LIBS so remove $SAVED_LIBS
+# from the end of $LIBS.
+pthread_lib=${LIBS%${SAVED_LIBS}}
+AC_CHECK_FUNCS([pthread_cancel pthread_kill])
+LIBS=$SAVED_LIBS
+AC_SUBST(PTHREAD_LIB, [$pthread_lib])
 AC_SUBST(GETOPT_O_FILES)
 
 AC_CANONICAL_HOST
 
 AC_DEFINE_UNQUOTED(SG_LIB_BUILD_HOST, "${host}", [sg3_utils Build Host])
 
+check_for_linux_nvme_headers() {
+	AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], [])
+	AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [],
+		     [[#ifdef HAVE_LINUX_TYPES_H
+		     # include <linux/types.h>
+		     #endif
+		     ]])
+}
+
 case "${host}" in
-        *-*-linux-gnu*)
-		AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
-                AC_SUBST([os_cflags], [''])
-                AC_SUBST([os_libs], [''])
-		AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], [])
-		AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [],
-		     [[#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-		     ]]) ;;
-        *-*-linux*)
-		AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
-                AC_SUBST([os_cflags], [''])
-                AC_SUBST([os_libs], [''])
-		AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], [])
-		AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [],
-		     [[#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-		     ]]) ;;
 	*-*-android*)
 		AC_DEFINE_UNQUOTED(SG_LIB_ANDROID, 1, [sg3_utils on android])
 		AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
-                AC_SUBST([os_cflags], [''])
-                AC_SUBST([os_libs], [''])
-		AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], [])
-		AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [],
-		     [[#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-		     ]]) ;;
+		check_for_linux_nvme_headers;;
         *-*-freebsd*|*-*-kfreebsd*-gnu*)
 		AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sg3_utils on FreeBSD])
-		AC_DEFINE(HAVE_NVME, 1, ['Found NVMe'])
-                AC_SUBST([os_cflags], [''])
-                AC_SUBST([os_libs], ['-lcam']);;
+		AC_DEFINE(HAVE_NVME, 1, [Found NVMe])
+                LIBS="$LIBS -lcam";;
         *-*-solaris*)
-		AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sg3_utils on Solaris])
-                AC_SUBST([os_cflags], [''])
-                AC_SUBST([os_libs], ['']);;
+		AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sg3_utils on Solaris]);;
         *-*-osf*)
-		AC_DEFINE_UNQUOTED(SG_LIB_OSF1, 1, [sg3_utils on Tru64 UNIX])
-                AC_SUBST([os_cflags], [''])
-                AC_SUBST([os_libs], ['']) ;;
+		AC_DEFINE_UNQUOTED(SG_LIB_OSF1, 1, [sg3_utils on Tru64 UNIX]);;
         *-*-cygwin*)
 		AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
-                AC_SUBST([os_cflags], ['-Wno-char-subscripts'])
-                AC_SUBST([os_libs], ['']) ;;
+                CFLAGS="$CFLAGS -Wno-char-subscripts";;
         *-*-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], [''])
-		AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], [])
-		AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [],
-		     [[#ifdef HAVE_LINUX_TYPES_H
-		     # include <linux/types.h>
-		     #endif
-		     ]]) ;;
+		AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment]);;
+        *-*-linux-gnu* | *-*-linux* | *)
+                AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
+                check_for_linux_nvme_headers;;
 esac
 
 # Define platform-specific symbol.
diff --git a/debian/changelog b/debian/changelog
index 3f94827..5393414 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@
 
   * New upstream version
 
- -- Douglas Gilbert <dgilbert@interlog.com>  Fri, 29 Dec 2017 10:00:00 -0500
+ -- Douglas Gilbert <dgilbert@interlog.com>  Tue, 02 Jan 2018 22:00:00 -0500
 
 sg3-utils (1.42-0.1) unstable; urgency=low
 
diff --git a/doc/Makefile.in b/doc/Makefile.in
index e71f9b0..0419857 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -219,6 +219,7 @@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -265,8 +266,6 @@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index 8472d58..93b4e1b 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -1,4 +1,4 @@
-.TH SG3_UTILS "8" "December 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG3_UTILS "8" "January 2018" "sg3_utils\-1.43" SG3_UTILS
 .SH NAME
 sg3_utils \- a package of utilities for sending SCSI commands
 .SH SYNOPSIS
@@ -571,7 +571,7 @@
 .SH "REPORTING BUGS"
 Report bugs to <dgilbert at interlog dot com>.
 .SH COPYRIGHT
-Copyright \(co 1999\-2017 Douglas Gilbert
+Copyright \(co 1999\-2018 Douglas Gilbert
 .br
 Some utilities are distributed under a GPL version 2 license while
 others, usually more recent ones, are under a FreeBSD license. The files
diff --git a/doc/sg_inq.8 b/doc/sg_inq.8
index ef8b77f..4217399 100644
--- a/doc/sg_inq.8
+++ b/doc/sg_inq.8
@@ -1,4 +1,4 @@
-.TH SG_INQ "8" "December 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_INQ "8" "January 2018" "sg3_utils\-1.43" SG3_UTILS
 .SH NAME
 sg_inq \- issue SCSI INQUIRY command and/or decode its response
 .SH SYNOPSIS
@@ -7,14 +7,15 @@
 [\fI\-\-descriptors\fR] [\fI\-\-export\fR] [\fI\-\-extended\fR]
 [\fI\-\-force\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-id\fR]
 [\fI\-\-inhex=FN\fR] [\fI\-\-len=LEN\fR]  [\fI\-\-long\fR]
-[\fI\-\-maxlen=LEN\fR] [\fI\-\-page=PG\fR] [\fI\-\-raw\fR] [\fI\-\-vendor\fR]
-[\fI\-\-verbose\fR] [\fI\-\-version\fR] [\fI\-\-vpd\fR] \fIDEVICE\fR
+[\fI\-\-maxlen=LEN\fR] [\fI\-\-only\fR] [\fI\-\-page=PG\fR] [\fI\-\-raw\fR]
+[\fI\-\-vendor\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] [\fI\-\-vpd\fR]
+\fIDEVICE\fR
 .PP
 .B sg_inq
 [\fI\-36\fR] [\fI\-a\fR] [\fI\-A\fR] [\fI\-b\fR] [\fI\-\-B=0|1\fR]
 [\fI\-c\fR] [\fI\-cl\fR] [\fI\-d\fR] [\fI\-e\fR] [\fI\-f\fR]
 [\fI\-h\fR] [\fI\-H\fR] [\fI\-i\fR] [\fI\-I=FN\fR] [\fI\-l=LEN\fR]
-[\fI\-L\fR] [\fI\-m\fR] [\fI\-M\fR] [\fI\-o=OPCODE_PG\fR] [\fI\-p=VPD_PG\fR]
+[\fI\-L\fR] [\fI\-m\fR] [\fI\-M\fR] [\fI\-o\fR] [\fI\-p=VPD_PG\fR]
 [\fI\-P\fR] [\fI\-r\fR] [\fI\-s\fR] [\fI\-u\fR] [\fI\-v\fR]
 [\fI\-V\fR] [\fI\-x\fR] [\fI\-36\fR] [\fI\-?\fR] \fIDEVICE\fR
 .SH DESCRIPTION
@@ -183,6 +184,17 @@
 \fB\-O\fR, \fB\-\-old\fR
 Switch to older style options. Please use as first option.
 .TP
+\fB\-o\fR, \fB\-\-only\fR
+Do not attempt to additionally retrieve the serial number VPD page (0x80) to
+enhance the output of a standard INQUIRY. So with this option given and no
+others, this utility will send a standard INQUIRY SCSI command and decode
+its response. No other SCSI commands will be sent to the \fIDEVICE\fR.
+Without this option an additional SCSI command is sent: a (non-standard)
+SCSI INQUIRY to fetch the Serial Number VPD page. However the Serial
+Number VPD page is not mandatory (while the Device Identification page is
+mandatory but a billion USB keys ignore that) and may cause nuisance error
+reports.
+.TP
 \fB\-p\fR, \fB\-\-page\fR=\fIPG\fR
 the \fIPG\fR argument can be either a number of an abbreviation for a VPD
 page. To enumerate the available abbreviations for VPD pages use '\-hh' or
@@ -320,7 +332,7 @@
 .TP
 \fB\-c\fR
 set the Command Support Data (CmdDt) bit (defaults to clear(0)). Used in
- conjunction with the \fI\-o=OPCODE_PG\fR option to specify the SCSI command
+ conjunction with the \fI\-p=VPD_PG\fR option to specify the SCSI command
 opcode to query. Equivalent to \fI\-\-cmddt\fR in the OPTIONS section.
 .TP
 \fB\-cl\fR
@@ -380,7 +392,10 @@
 \fB-N\fR, \fB\-\-new\fR
 Switch to the newer style options.
 .TP
-\fB\-o\fR=\fIOPCODE_PG\fR
+\fB\-o\fR
+equivalent to \fI\-\-only\fR in the OPTIONS section.
+.TP
+\fB\-p\fR=\fIVPD_PG\fR
 used in conjunction with the \fI\-e\fR or \fI\-c\fR option. If neither given
 then the \fI\-e\fR option assumed. When the \fI\-e\fR option is also
 given (or assumed) then the argument to this option is the VPD page number.
@@ -393,14 +408,6 @@
 facility to a separate command (see sg_opcodes(8)). Defaults to 0 so if
 \fI\-e\fR is given without this option then VPD page 0 is output.
 .TP
-\fB\-p\fR=\fIVPD_PG\fR
-same action as \fI\-o=OPCODE_PG\fR option described in the previous entry.
-Since the opcode value with the CmdDt is now obsolete, the main use of this
-option is to specify the VPD page number. The argument is interpreted as
-hexadecimal and is expected to be in the range 0 to ff inclusive.
-Defaults to 0 so if \fI\-e\fR is given without this option then VPD page 0
-is output.
-.TP
 \fB\-P\fR
 decodes the Unit Path Report VPD page [0xc0] which is EMC specific.
 Equivalent to '\-\-page=upr' in the OPTIONS section.
diff --git a/include/Makefile.in b/include/Makefile.in
index 6d40386..13d0935 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -239,6 +239,7 @@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -285,8 +286,6 @@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
diff --git a/lib/BSD_LICENSE b/lib/BSD_LICENSE
index 9b5c85e..fe73146 100644
--- a/lib/BSD_LICENSE
+++ b/lib/BSD_LICENSE
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999-2010 Douglas Gilbert.
+ * Copyright (c) 1999-2018 Douglas Gilbert.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 24d3c95..b8be482 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -40,7 +40,7 @@
 ## CC = clang
 ## CC = clang++
 
-# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
+# -std=<s> can be c99, c11, gnu11, etc. Default is gnu11 for C code
 # -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
 AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 AM_CFLAGS = -Wall -W
@@ -52,7 +52,7 @@
 
 libsgutils2_la_LDFLAGS = -version-info 2:0:0 -no-undefined
 
-libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@
+libsgutils2_la_LIBADD = @GETOPT_O_FILES@
 libsgutils2_la_DEPENDENCIES = @GETOPT_O_FILES@
 
 
diff --git a/lib/Makefile.in b/lib/Makefile.in
index a06aa38..36465e7 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -283,6 +283,7 @@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -329,8 +330,6 @@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
@@ -351,7 +350,7 @@
 
 # For C++/clang testing
 
-# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
+# -std=<s> can be c99, c11, gnu11, etc. Default is gnu11 for C code
 # -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
 AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 AM_CFLAGS = -Wall -W
@@ -360,7 +359,7 @@
 # AM_CFLAGS = -Wall -W -pedantic -std=c++14
 lib_LTLIBRARIES = libsgutils2.la
 libsgutils2_la_LDFLAGS = -version-info 2:0:0 -no-undefined
-libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@
+libsgutils2_la_LIBADD = @GETOPT_O_FILES@
 libsgutils2_la_DEPENDENCIES = @GETOPT_O_FILES@
 all: all-am
 
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 203a74b..034071d 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -208,6 +208,7 @@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -254,8 +255,6 @@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 7ba2b2b..7fe36de 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@
 %{_libdir}/*.la
 
 %changelog
-* Fri Dec 29 2017 - dgilbert at interlog dot com
+* Tue Jan 02 2018 - dgilbert at interlog dot com
 - track t10 changes
   * sg3_utils-1.43
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 4c3bb1c..7d76caf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,145 +39,141 @@
 ## CC = clang
 ## CC = clang++
 
-# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
+# -std=<s> can be c99, c11, gnu11, etc. Default is gnu11
 # -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
 AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-AM_CFLAGS = -Wall -W @os_cflags@
-# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11
-# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 --analyze
-# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c++14
+AM_CFLAGS = -Wall -W
+# AM_CFLAGS = -Wall -W -pedantic -std=c11
+# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
+# AM_CFLAGS = -Wall -W -pedantic -std=c++14
 
-sg_bg_ctl_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_bg_ctl_LDADD = ../lib/libsgutils2.la
 
-sg_compare_and_write_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_compare_and_write_LDADD = ../lib/libsgutils2.la
 
-sg_copy_results_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_copy_results_LDADD = ../lib/libsgutils2.la
 
-sg_dd_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_dd_LDADD = ../lib/libsgutils2.la
 
-sg_decode_sense_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_decode_sense_LDADD = ../lib/libsgutils2.la
 
-sg_emc_trespass_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_emc_trespass_LDADD = ../lib/libsgutils2.la
 
-sg_format_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_format_LDADD = ../lib/libsgutils2.la
 
-sg_get_config_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_get_config_LDADD = ../lib/libsgutils2.la
 
-sg_get_lba_status_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_get_lba_status_LDADD = ../lib/libsgutils2.la
 
-sg_ident_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_ident_LDADD = ../lib/libsgutils2.la
 
-sginfo_LDADD = ../lib/libsgutils2.la @os_libs@
+sginfo_LDADD = ../lib/libsgutils2.la
 
 sg_inq_SOURCES = sg_inq.c sg_inq_data.c
-sg_inq_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_inq_LDADD = ../lib/libsgutils2.la
 
-sg_logs_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_logs_LDADD = ../lib/libsgutils2.la
 
-sg_luns_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_luns_LDADD = ../lib/libsgutils2.la
 
-sg_map26_LDADD = @os_libs@
+sg_map_LDADD = ../lib/libsgutils2.la
 
-sg_map_LDADD = ../lib/libsgutils2.la @os_libs@
+sgm_dd_LDADD = ../lib/libsgutils2.la
 
-sgm_dd_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_modes_LDADD = ../lib/libsgutils2.la
 
-sg_modes_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_opcodes_LDADD = ../lib/libsgutils2.la
 
-sg_opcodes_LDADD = ../lib/libsgutils2.la @os_libs@
+sgp_dd_LDADD = ../lib/libsgutils2.la @PTHREAD_LIB@
 
-sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread
+sg_persist_LDADD = ../lib/libsgutils2.la
 
-sg_persist_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_prevent_LDADD = ../lib/libsgutils2.la
 
-sg_prevent_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_raw_LDADD = ../lib/libsgutils2.la
 
-sg_raw_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_rbuf_LDADD = ../lib/libsgutils2.la
 
-sg_rbuf_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_rdac_LDADD = ../lib/libsgutils2.la
 
-sg_rdac_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_read_LDADD = ../lib/libsgutils2.la
 
-sg_read_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_read_attr_LDADD = ../lib/libsgutils2.la
 
-sg_read_attr_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_readcap_LDADD = ../lib/libsgutils2.la
 
-sg_readcap_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_read_block_limits_LDADD = ../lib/libsgutils2.la
 
-sg_read_block_limits_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_read_buffer_LDADD = ../lib/libsgutils2.la
 
-sg_read_buffer_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_read_long_LDADD = ../lib/libsgutils2.la
 
-sg_read_long_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_reassign_LDADD = ../lib/libsgutils2.la
 
-sg_reassign_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_requests_LDADD = ../lib/libsgutils2.la
 
-sg_requests_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_referrals_LDADD = ../lib/libsgutils2.la
 
-sg_referrals_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_rep_zones_LDADD = ../lib/libsgutils2.la
 
-sg_rep_zones_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_reset_wp_LDADD = ../lib/libsgutils2.la
 
-sg_reset_LDADD = @os_libs@
+sg_rmsn_LDADD = ../lib/libsgutils2.la
 
-sg_reset_wp_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_rtpg_LDADD = ../lib/libsgutils2.la
 
-sg_rmsn_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_safte_LDADD = ../lib/libsgutils2.la
 
-sg_rtpg_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_sanitize_LDADD = ../lib/libsgutils2.la
 
-sg_safte_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_sat_identify_LDADD = ../lib/libsgutils2.la
 
-sg_sanitize_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_sat_phy_event_LDADD = ../lib/libsgutils2.la
 
-sg_sat_identify_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la
 
-sg_sat_phy_event_LDADD = ../lib/libsgutils2.la @os_libs@
-
-sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la @os_libs@
-
-sg_sat_set_features_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_sat_set_features_LDADD = ../lib/libsgutils2.la
 
 # sg_scan_SOURCES list is already set above in the platform-specific sections
-sg_scan_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_scan_LDADD = ../lib/libsgutils2.la
 
-sg_senddiag_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_senddiag_LDADD = ../lib/libsgutils2.la
 
-sg_ses_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_ses_LDADD = ../lib/libsgutils2.la
 
-sg_ses_microcode_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_ses_microcode_LDADD = ../lib/libsgutils2.la
 
-sg_start_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_start_LDADD = ../lib/libsgutils2.la
 
-sg_stpg_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_stpg_LDADD = ../lib/libsgutils2.la
 
-sg_sync_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_sync_LDADD = ../lib/libsgutils2.la
 
-sg_test_rwbuf_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_test_rwbuf_LDADD = ../lib/libsgutils2.la
 
-sg_timestamp_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_timestamp_LDADD = ../lib/libsgutils2.la
 
-sg_turs_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_turs_LDADD = ../lib/libsgutils2.la
 
-sg_unmap_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_unmap_LDADD = ../lib/libsgutils2.la
 
-sg_verify_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_verify_LDADD = ../lib/libsgutils2.la
 
 sg_vpd_SOURCES = sg_vpd.c sg_vpd_vendor.c
-sg_vpd_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_vpd_LDADD = ../lib/libsgutils2.la
 
-sg_wr_mode_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_wr_mode_LDADD = ../lib/libsgutils2.la
 
-sg_write_buffer_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_write_buffer_LDADD = ../lib/libsgutils2.la
 
-sg_write_long_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_write_long_LDADD = ../lib/libsgutils2.la
 
-sg_write_same_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_write_same_LDADD = ../lib/libsgutils2.la
 
-sg_write_verify_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_write_verify_LDADD = ../lib/libsgutils2.la
 
-sg_write_x_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_write_x_LDADD = ../lib/libsgutils2.la
 
-sg_xcopy_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_xcopy_LDADD = ../lib/libsgutils2.la
 
-sg_zone_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_zone_LDADD = ../lib/libsgutils2.la
diff --git a/src/Makefile.in b/src/Makefile.in
index 7b446b0..58b8139 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -188,7 +188,7 @@
 sg_map_DEPENDENCIES = ../lib/libsgutils2.la
 sg_map26_SOURCES = sg_map26.c
 sg_map26_OBJECTS = sg_map26.$(OBJEXT)
-sg_map26_DEPENDENCIES =
+sg_map26_LDADD = $(LDADD)
 sg_modes_SOURCES = sg_modes.c
 sg_modes_OBJECTS = sg_modes.$(OBJEXT)
 sg_modes_DEPENDENCIES = ../lib/libsgutils2.la
@@ -242,7 +242,7 @@
 sg_requests_DEPENDENCIES = ../lib/libsgutils2.la
 sg_reset_SOURCES = sg_reset.c
 sg_reset_OBJECTS = sg_reset.$(OBJEXT)
-sg_reset_DEPENDENCIES =
+sg_reset_LDADD = $(LDADD)
 sg_reset_wp_SOURCES = sg_reset_wp.c
 sg_reset_wp_OBJECTS = sg_reset_wp.$(OBJEXT)
 sg_reset_wp_DEPENDENCIES = ../lib/libsgutils2.la
@@ -499,6 +499,7 @@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -545,8 +546,6 @@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
@@ -564,83 +563,81 @@
 
 # For C++/clang testing
 
-# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
+# -std=<s> can be c99, c11, gnu11, etc. Default is gnu11
 # -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
 AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-AM_CFLAGS = -Wall -W @os_cflags@
-# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11
-# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 --analyze
-# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c++14
-sg_bg_ctl_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_compare_and_write_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_copy_results_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_dd_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_decode_sense_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_emc_trespass_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_format_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_get_config_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_get_lba_status_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_ident_LDADD = ../lib/libsgutils2.la @os_libs@
-sginfo_LDADD = ../lib/libsgutils2.la @os_libs@
+AM_CFLAGS = -Wall -W
+# AM_CFLAGS = -Wall -W -pedantic -std=c11
+# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
+# AM_CFLAGS = -Wall -W -pedantic -std=c++14
+sg_bg_ctl_LDADD = ../lib/libsgutils2.la
+sg_compare_and_write_LDADD = ../lib/libsgutils2.la
+sg_copy_results_LDADD = ../lib/libsgutils2.la
+sg_dd_LDADD = ../lib/libsgutils2.la
+sg_decode_sense_LDADD = ../lib/libsgutils2.la
+sg_emc_trespass_LDADD = ../lib/libsgutils2.la
+sg_format_LDADD = ../lib/libsgutils2.la
+sg_get_config_LDADD = ../lib/libsgutils2.la
+sg_get_lba_status_LDADD = ../lib/libsgutils2.la
+sg_ident_LDADD = ../lib/libsgutils2.la
+sginfo_LDADD = ../lib/libsgutils2.la
 sg_inq_SOURCES = sg_inq.c sg_inq_data.c
-sg_inq_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_logs_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_luns_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_map26_LDADD = @os_libs@
-sg_map_LDADD = ../lib/libsgutils2.la @os_libs@
-sgm_dd_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_modes_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_opcodes_LDADD = ../lib/libsgutils2.la @os_libs@
-sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread
-sg_persist_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_prevent_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_raw_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_rbuf_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_rdac_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_read_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_read_attr_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_readcap_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_read_block_limits_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_read_buffer_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_read_long_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_reassign_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_requests_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_referrals_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_rep_zones_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_reset_LDADD = @os_libs@
-sg_reset_wp_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_rmsn_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_rtpg_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_safte_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_sanitize_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_sat_identify_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_sat_phy_event_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_sat_set_features_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_inq_LDADD = ../lib/libsgutils2.la
+sg_logs_LDADD = ../lib/libsgutils2.la
+sg_luns_LDADD = ../lib/libsgutils2.la
+sg_map_LDADD = ../lib/libsgutils2.la
+sgm_dd_LDADD = ../lib/libsgutils2.la
+sg_modes_LDADD = ../lib/libsgutils2.la
+sg_opcodes_LDADD = ../lib/libsgutils2.la
+sgp_dd_LDADD = ../lib/libsgutils2.la @PTHREAD_LIB@
+sg_persist_LDADD = ../lib/libsgutils2.la
+sg_prevent_LDADD = ../lib/libsgutils2.la
+sg_raw_LDADD = ../lib/libsgutils2.la
+sg_rbuf_LDADD = ../lib/libsgutils2.la
+sg_rdac_LDADD = ../lib/libsgutils2.la
+sg_read_LDADD = ../lib/libsgutils2.la
+sg_read_attr_LDADD = ../lib/libsgutils2.la
+sg_readcap_LDADD = ../lib/libsgutils2.la
+sg_read_block_limits_LDADD = ../lib/libsgutils2.la
+sg_read_buffer_LDADD = ../lib/libsgutils2.la
+sg_read_long_LDADD = ../lib/libsgutils2.la
+sg_reassign_LDADD = ../lib/libsgutils2.la
+sg_requests_LDADD = ../lib/libsgutils2.la
+sg_referrals_LDADD = ../lib/libsgutils2.la
+sg_rep_zones_LDADD = ../lib/libsgutils2.la
+sg_reset_wp_LDADD = ../lib/libsgutils2.la
+sg_rmsn_LDADD = ../lib/libsgutils2.la
+sg_rtpg_LDADD = ../lib/libsgutils2.la
+sg_safte_LDADD = ../lib/libsgutils2.la
+sg_sanitize_LDADD = ../lib/libsgutils2.la
+sg_sat_identify_LDADD = ../lib/libsgutils2.la
+sg_sat_phy_event_LDADD = ../lib/libsgutils2.la
+sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la
+sg_sat_set_features_LDADD = ../lib/libsgutils2.la
 
 # sg_scan_SOURCES list is already set above in the platform-specific sections
-sg_scan_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_senddiag_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_ses_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_ses_microcode_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_start_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_stpg_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_sync_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_test_rwbuf_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_timestamp_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_turs_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_unmap_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_verify_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_scan_LDADD = ../lib/libsgutils2.la
+sg_senddiag_LDADD = ../lib/libsgutils2.la
+sg_ses_LDADD = ../lib/libsgutils2.la
+sg_ses_microcode_LDADD = ../lib/libsgutils2.la
+sg_start_LDADD = ../lib/libsgutils2.la
+sg_stpg_LDADD = ../lib/libsgutils2.la
+sg_sync_LDADD = ../lib/libsgutils2.la
+sg_test_rwbuf_LDADD = ../lib/libsgutils2.la
+sg_timestamp_LDADD = ../lib/libsgutils2.la
+sg_turs_LDADD = ../lib/libsgutils2.la
+sg_unmap_LDADD = ../lib/libsgutils2.la
+sg_verify_LDADD = ../lib/libsgutils2.la
 sg_vpd_SOURCES = sg_vpd.c sg_vpd_vendor.c
-sg_vpd_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_wr_mode_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_write_buffer_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_write_long_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_write_same_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_write_verify_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_write_x_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_xcopy_LDADD = ../lib/libsgutils2.la @os_libs@
-sg_zone_LDADD = ../lib/libsgutils2.la @os_libs@
+sg_vpd_LDADD = ../lib/libsgutils2.la
+sg_wr_mode_LDADD = ../lib/libsgutils2.la
+sg_write_buffer_LDADD = ../lib/libsgutils2.la
+sg_write_long_LDADD = ../lib/libsgutils2.la
+sg_write_same_LDADD = ../lib/libsgutils2.la
+sg_write_verify_LDADD = ../lib/libsgutils2.la
+sg_write_x_LDADD = ../lib/libsgutils2.la
+sg_xcopy_LDADD = ../lib/libsgutils2.la
+sg_zone_LDADD = ../lib/libsgutils2.la
 all: all-am
 
 .SUFFIXES:
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 423c0fb..3a4fae3 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -1,5 +1,5 @@
 /* A utility program originally written for the Linux OS SCSI subsystem.
-*  Copyright (C) 2000-2017 D. Gilbert
+*  Copyright (C) 2000-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)
@@ -46,7 +46,7 @@
 #include "sg_pt_nvme.h"
 #endif
 
-static const char * version_str = "1.80 20171229";    /* SPC-5 rev 17 */
+static const char * version_str = "1.81 20180102";    /* SPC-5 rev 17 */
 
 /* INQUIRY notes:
  * It is recommended that the initial allocation length given to a
@@ -223,6 +223,7 @@
         {"new", no_argument, 0, 'N'},
         {"old", no_argument, 0, 'O'},
 #endif
+        {"only", no_argument, 0, 'o'},
         {"page", required_argument, 0, 'p'},
         {"raw", no_argument, 0, 'r'},
         {"vendor", no_argument, 0, 's'},
@@ -241,6 +242,7 @@
     bool do_decode;
     bool do_vpd;
     bool p_given;
+    bool skip_vpd;  /* --only  after standard inq don't fetch VPD page 0x80 */
     int do_block;
     int do_cmddt;
     int do_help;
@@ -253,7 +255,6 @@
     int page_num;
     int page_pdt;
     int num_pages;
-    int num_opcodes;
     const char * page_arg;
     const char * device_name;
     const char * inhex_fn;
@@ -271,9 +272,10 @@
             "[--export]\n"
             "              [--extended] [--help] [--hex] [--id] [--inhex=FN] "
             "[--len=LEN]\n"
-            "              [--long] [--maxlen=LEN] [--page=PG] [--raw] "
-            "[--vendor]\n"
-            "              [--verbose] [--version] [--vpd] DEVICE\n"
+            "              [--long] [--maxlen=LEN] [--only] [--page=PG] "
+            "[--raw]\n"
+            "              [--vendor] [--verbose] [--version] [--vpd] "
+            "DEVICE\n"
             "  where:\n"
             "    --ata|-a        treat DEVICE as (directly attached) ATA "
             "device\n");
@@ -282,9 +284,9 @@
             "[--export]\n"
             "              [--extended] [--help] [--hex] [--id] [--inhex=FN] "
             "[--len=LEN]\n"
-            "              [--maxlen=LEN] [--page=PG] [--raw] [--verbose] "
-            "[--version]\n"
-            "              [--vpd] DEVICE\n"
+            "              [--long] [--maxlen=LEN] [--only] [--page=PG] "
+            "[--raw]\n"
+            "              [--verbose] [--version] [--vpd] DEVICE\n"
             "  where:\n");
 #endif
     pr2serr("    --block=0|1     0-> open(non-blocking); 1-> "
@@ -318,6 +320,9 @@
             "indicated)\n"
             "    --long|-L       supply extra information on NVMe devices\n"
             "    --maxlen=LEN|-m LEN    same as '--len='\n"
+            "    --old|-O        use old interface (use as first option)\n"
+            "    --only|-o       for std inquiry do not fetch serial number "
+            "vpd page\n"
             "    --page=PG|-p PG     Vital Product Data (VPD) page number "
             "or\n"
             "                        abbreviation (opcode number if "
@@ -327,7 +332,6 @@
             "inquiry\n"
             "    --verbose|-v    increase verbosity\n"
             "    --version|-V    print version string then exit\n"
-            "    --old|-O        use old interface (use as first option)\n"
             "    --vpd|-e        vital product data (set page with "
             "'--page=PG')\n\n"
             "Performs a SCSI INQUIRY command on DEVICE or decodes INQUIRY "
@@ -345,7 +349,7 @@
     pr2serr("Usage:  sg_inq [-a] [-A] [-b] [-B=0|1] [-c] [-cl] [-d] [-e] "
             "[-h]\n"
             "               [-H] [-i] [I=FN] [-l=LEN] [-L] [-m] [-M] "
-            "[-o=OPCODE_PG]\n"
+            "[-o]\n"
             "               [-p=VPD_PG] [-P] [-r] [-s] [-u] [-U] [-v] [-V] "
             "[-x]\n"
             "               [-36] [-?] DEVICE\n"
@@ -355,7 +359,7 @@
 #else
     pr2serr("Usage:  sg_inq [-a] [-b] [-B 0|1] [-c] [-cl] [-d] [-e] [-h] "
             "[-H]\n"
-            "               [-i] [-l=LEN] [-L] [-m] [-M] [-o=OPCODE_PG] "
+            "               [-i] [-l=LEN] [-L] [-m] [-M] [-o] "
             "[-p=VPD_PG]\n"
             "               [-P] [-r] [-s] [-u] [-v] [-V] [-x] [-36] "
             "[-?]\n"
@@ -382,7 +386,9 @@
             "    -m    decode management network addresses VPD page "
             "(0x85)\n"
             "    -M    decode mode page policy VPD page (0x87)\n"
-            "    -o=OPCODE_PG    opcode or page code in hex (def: 0)\n"
+            "    -N|--new   use new interface\n"
+            "    -o    for std inquiry only do that, not serial number vpd "
+            "page\n"
             "    -p=VPD_PG    vpd page code in hex (def: 0)\n"
             "    -P    decode Unit Path Report VPD page (0xc0) (EMC)\n"
             "    -r    output response in binary ('-rr': output for hdparm)\n"
@@ -392,7 +398,6 @@
             "    -V    output version string\n"
             "    -x    decode extended INQUIRY data VPD page (0x86)\n"
             "    -36   perform standard INQUIRY with a 36 byte response\n"
-            "    -N|--new   use new interface\n"
             "    -?    output this usage message\n\n"
             "If no options given then does a standard SCSI INQUIRY\n");
 }
@@ -429,19 +434,19 @@
 
 #ifdef SG_LIB_LINUX
 #ifdef SG_SCSI_STRINGS
-        c = getopt_long(argc, argv, "aB:cdeEfhHiI:l:Lm:NOp:rsuvVx",
+        c = getopt_long(argc, argv, "aB:cdeEfhHiI:l:Lm:NoOp:rsuvVx",
                         long_options, &option_index);
 #else
-        c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:p:rsuvVx", long_options,
-                        &option_index);
+        c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:op:rsuvVx",
+                        long_options, &option_index);
 #endif /* SG_SCSI_STRINGS */
 #else  /* SG_LIB_LINUX */
 #ifdef SG_SCSI_STRINGS
-        c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:NOp:rsuvVx",
+        c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:NoOp:rsuvVx",
                         long_options, &option_index);
 #else
-        c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:p:rsuvVx", long_options,
-                        &option_index);
+        c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:op:rsuvVx",
+                        long_options, &option_index);
 #endif /* SG_SCSI_STRINGS */
 #endif /* SG_LIB_LINUX */
         if (c == -1)
@@ -487,6 +492,9 @@
         case 'h':
             ++op->do_help;
             break;
+        case 'o':
+            op->skip_vpd = true;
+            break;
         case '?':
             if (! op->do_help)
                 ++op->do_help;
@@ -648,6 +656,9 @@
                 case 'N':
                     op->opt_new = true;
                     return 0;
+                case 'o':
+                    op->skip_vpd = true;
+                    break;
                 case 'O':
                     break;
                 case 'P':
@@ -711,9 +722,6 @@
                     return SG_LIB_SYNTAX_ERROR;
                 }
                 op->resp_len = n;
-            } else if (0 == strncmp("o=", cp, 2)) {
-                op->page_arg = cp + 2;
-                ++op->num_opcodes;
             } else if (0 == strncmp("p=", cp, 2)) {
                 op->page_arg = cp + 2;
                 op->p_given = true;
@@ -1208,29 +1216,31 @@
 }
 
 static bool
-vpd_page_is_supported(unsigned char * buff, int len, int pg)
+vpd_page_is_supported(unsigned char * vpd_pg0, int v0_len, int pg_num)
 {
-    int vpd, k, rlen;
-    bool supported = false;
+    int k, rlen;
 
-    if (len < 4)
+    if (v0_len < 4)
         return false;
 
-    rlen = buff[3] + 4;
-    if (rlen > len)
+    rlen = vpd_pg0[3] + 4;
+    if (rlen > v0_len)
         pr2serr("Supported VPD pages VPD page truncated, indicates %d, got "
-                "%d\n", rlen, len);
+                "%d\n", rlen, v0_len);
     else
-        len = rlen;
+        v0_len = rlen;
 
-    for (k = 0; k < len - 4; ++k) {
-        vpd = buff[4 + k];
-        if(vpd == pg) {
-            supported = true;
-            break;
-        }
+    for (k = 4; k < v0_len; ++k) {
+        if(vpd_pg0[k] == pg_num)
+            return true;
     }
-    return supported;
+    return false;
+}
+
+static bool
+vpd_page_not_supported(unsigned char * vpd_pg0, int v0_len, int pg_num)
+{
+    return ! vpd_page_is_supported(vpd_pg0, v0_len, pg_num);
 }
 
 /* ASCII Information VPD pages (page numbers: 0x1 to 0x7f) */
@@ -3151,6 +3161,16 @@
     int len, k, res, c;
     unsigned char b[DEF_ALLOC_LEN];
 
+    res = vpd_fetch_page_from_dev(sg_fd, b, VPD_SUPPORTED_VPDS,
+                                  -1,verbose, &len);
+    if (res) {
+        if (verbose > 2)
+            pr2serr("fetch_unit_serial_num: no supported VPDs page\n");
+        return SG_LIB_CAT_MALFORMED;
+    }
+    if (vpd_page_not_supported(b, len, VPD_UNIT_SERIAL_NUM))
+        return SG_LIB_CAT_ILLEGAL_REQ;
+
     memset(b, 0xff, 4); /* guard against empty response */
     res = vpd_fetch_page_from_dev(sg_fd, b, VPD_UNIT_SERIAL_NUM, -1, verbose,
                                   &len);
@@ -3226,7 +3246,7 @@
             act_len = rlen - resid;
         if (act_len < SAFE_STD_INQ_RESP_LEN)
             rsp_buff[act_len] = '\0';
-        if ((! op->do_export) && (0 == op->resp_len)) {
+        if ((! op->skip_vpd) && (! op->do_export) && (0 == op->resp_len)) {
             if (fetch_unit_serial_num(sg_fd, usn_buff, sizeof(usn_buff),
                                       op->do_verbose))
                 usn_buff[0] = '\0';
@@ -3459,7 +3479,7 @@
                                       vb, &len);
         if (res)
             goto out;
-        if (!vpd_page_is_supported(rp, len, pn)) {
+        if (vpd_page_not_supported(rp, len, pn)) {
             res = SG_LIB_CAT_ILLEGAL_REQ;
             goto out;
         }
@@ -4213,13 +4233,30 @@
                     pr2serr("Guessing from --inhex= this is a standard "
                             "INQUIRY\n");
             } else if (rsp_buff[2] <= 2) {
-                if (op->do_verbose)
-                    pr2serr("Guessing from --inhex this is VPD page 0x%x\n",
-                            rsp_buff[1]);
-                op->page_num = rsp_buff[1];
-                op->do_vpd = true;
-                if ((1 != op->do_hex) && (0 == op->do_raw))
-                    op->do_decode = true;
+                /*
+                 * Removable devices have the RMB bit set, which would
+                 * present itself as vpd page 0x80 output if we're not
+                 * careful
+                 *
+                 * Serial number must be right-aligned ASCII data in
+                 * bytes 5-7; standard INQUIRY will have flags here.
+                 */
+                if (rsp_buff[1] == 0x80 &&
+                    (rsp_buff[5] < 0x20 || rsp_buff[5] > 0x80 ||
+                     rsp_buff[6] < 0x20 || rsp_buff[6] > 0x80 ||
+                     rsp_buff[7] < 0x20 || rsp_buff[7] > 0x80)) {
+                    if (op->do_verbose)
+                        pr2serr("Guessing from --inhex= this is a "
+                                "standard INQUIRY\n");
+                } else {
+                    if (op->do_verbose)
+                        pr2serr("Guessing from --inhex= this is VPD "
+                                "page 0x%x\n", rsp_buff[1]);
+                    op->page_num = rsp_buff[1];
+                    op->do_vpd = true;
+                    if ((1 != op->do_hex) && (0 == op->do_raw))
+                        op->do_decode = true;
+                }
             } else {
                 if (op->do_verbose)
                     pr2serr("page number unclear from --inhex, hope it's a "
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 81ef6cf..bf1a5ce 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -1,5 +1,5 @@
 /* A utility program originally written for the Linux OS SCSI subsystem.
- *  Copyright (C) 2000-2017 D. Gilbert
+ *  Copyright (C) 2000-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)
@@ -32,7 +32,7 @@
 #include "sg_unaligned.h"
 #include "sg_pr2serr.h"
 
-static const char * version_str = "1.58 20171229";    /* spc5r17 + sbc4r11 */
+static const char * version_str = "1.59 20180102";    /* spc5r17 + sbc4r11 */
 
 #define MX_ALLOC_LEN (0xfffc)
 #define SHORT_RESP_LEN 128
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index bb515c8..ecc853e 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -1,7 +1,7 @@
 /* A utility program for copying files. Specialised for "files" that
  * represent devices that understand the SCSI command set.
  *
- * Copyright (C) 1999 - 2017 D. Gilbert and P. Allworth
+ * Copyright (C) 1999 - 2018 D. Gilbert and P. Allworth
  * 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)
@@ -60,7 +60,7 @@
 #include "sg_pr2serr.h"
 
 
-static const char * version_str = "5.59 20171222";
+static const char * version_str = "5.60 20180102";
 
 #define DEF_BLOCK_SIZE 512
 #define DEF_BLOCKS_PER_TRANSFER 128
@@ -181,6 +181,7 @@
 
 static pthread_mutex_t strerr_mut = PTHREAD_MUTEX_INITIALIZER;
 
+static bool shutting_down = false;
 static bool do_sync = false;
 static bool do_time = false;
 static Rq_coll rcoll;
@@ -478,6 +479,8 @@
 
     while (1) {
         sigwait(&signal_set, &sig_number);
+        if (shutting_down)
+            break;
         if (SIGINT == sig_number) {
             pr2serr(ME "interrupted by SIGINT\n");
             guarded_stop_both(clp);
@@ -1645,6 +1648,7 @@
         }
     }
 
+#if 0
 #if SG_LIB_ANDROID
     /* Android doesn't have pthread_cancel() so use pthread_kill() instead.
      * Also there is no need to link with -lpthread in Android */
@@ -1653,6 +1657,11 @@
     status = pthread_cancel(sig_listen_thread_id);
 #endif
     if (0 != status) err_exit(status, "pthread_cancel");
+#endif          /* 0 */
+
+    shutting_down = true;
+    status = pthread_kill(sig_listen_thread_id, SIGINT);
+    if (0 != status) err_exit(status, "pthread_kill");
     if (STDIN_FILENO != rcoll.infd)
         close(rcoll.infd);
     if ((STDOUT_FILENO != rcoll.outfd) && (FT_DEV_NULL != rcoll.out_type))