aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-05-02 22:02:05 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-05-02 22:02:05 +0000
commita59b767b38f08c0dafc011a58e8791aa06d4feb0 (patch)
tree8be0500cec5edb562779bc41f0ef7ad46b8c86fc
parentf65566c3934a9e22335dee20401cc1cc50865d56 (diff)
downloadsg3_utils-a59b767b38f08c0dafc011a58e8791aa06d4feb0.tar.gz
sg_lib: add sg_ll_inquiry_pt(), sg_ll_test_unit_ready_progress_pt(), sg_ll_request_sense_pt(), sg_ll_send_diag_pt(), sg_ll_receive_diag_pt(); sg_timestamp: add --elapsed, --hex and --no-timestamp options; sg_ses: check for NVMe enclosure bits
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@769 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog11
-rw-r--r--Makefile.in12
-rw-r--r--aclocal.m450
-rwxr-xr-xar-lib2
-rwxr-xr-xconfig.guess584
-rwxr-xr-xconfig.sub258
-rw-r--r--debian/changelog2
-rwxr-xr-xdepcomp6
-rw-r--r--doc/Makefile.in4
-rw-r--r--doc/sg3_utils.82
-rw-r--r--doc/sg_timestamp.839
-rw-r--r--doc/sg_write_x.86
-rw-r--r--include/Makefile.in4
-rw-r--r--include/sg_cmds_basic.h29
-rw-r--r--include/sg_cmds_extra.h18
-rw-r--r--include/sg_lib.h2
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/Makefile.in5
-rw-r--r--lib/sg_cmds_basic.c168
-rw-r--r--lib/sg_cmds_extra.c83
-rw-r--r--lib/sg_pt_win32.c12
-rw-r--r--scripts/Makefile.in4
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/Makefile.in5
-rw-r--r--src/sg_compare_and_write.c26
-rw-r--r--src/sg_copy_results.c13
-rw-r--r--src/sg_dd.c4
-rw-r--r--src/sg_get_lba_status.c34
-rw-r--r--src/sg_inq.c3
-rw-r--r--src/sg_logs.c46
-rw-r--r--src/sg_luns.c12
-rw-r--r--src/sg_modes.c2
-rw-r--r--src/sg_opcodes.c45
-rw-r--r--src/sg_raw.c6
-rw-r--r--src/sg_read.c4
-rw-r--r--src/sg_read_attr.c14
-rw-r--r--src/sg_read_long.c5
-rw-r--r--src/sg_referrals.c17
-rw-r--r--src/sg_rep_zones.c15
-rw-r--r--src/sg_sanitize.c2
-rw-r--r--src/sg_ses.c244
-rw-r--r--src/sg_stream_ctl.c18
-rw-r--r--src/sg_test_rwbuf.c24
-rw-r--r--src/sg_timestamp.c165
-rw-r--r--src/sg_vpd.c3
-rw-r--r--src/sg_write_long.c18
-rw-r--r--src/sg_write_same.c15
-rw-r--r--src/sg_write_verify.c17
-rw-r--r--src/sg_write_x.c22
-rw-r--r--src/sginfo.c2
-rw-r--r--src/sgm_dd.c28
-rw-r--r--src/sgp_dd.c104
53 files changed, 1329 insertions, 893 deletions
diff --git a/ChangeLog b/ChangeLog
index 749de3f9..9a8cd47e 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 [20180414] [svn: r768]
+Changelog for sg3_utils-1.43 [20180502] [svn: r769]
- sg_write_x: where x can be normal, atomic, or(write),
same, scattered, or stream writes with 16 or 32 byte
cdbs (sbc4r04 for atomic, sbc4r11 for scattered)
@@ -26,6 +26,8 @@ Changelog for sg3_utils-1.43 [20180414] [svn: r768]
- --data=@FN with --status now decodes dpage(s) in FN
- add 'offset_temp' and 'rqst_override' to temperature
sensor element type
+ - add 'hw_reset' and 'sw_reset' to enclosure services
+ controller electronics element type (18-047r0)
- interpret '--join --page=aes' to only display join
rows that have a corresponding AES dpage element
- support NVMe attached enclosure via NVME-MI Send and
@@ -111,6 +113,8 @@ Changelog for sg3_utils-1.43 [20180414] [svn: r768]
large contiguous segments of a disk/ssd
- add --dry-run and --force options
- sg_wr_mode: add --rtd option for RTD bit
+ - sg_timestamp: add '--no-timestamp' option
+ - add --elapsed and --hex options
- manpages and usage messages: corrections from
Gris Ge via github
- group_number: is 6 bit field allowing 0 to 63,
@@ -118,7 +122,7 @@ Changelog for sg3_utils-1.43 [20180414] [svn: r768]
- convert many two valued 'int's to bool
- sg_lib: add SSC maintenance in/out sa names
- enhance exit status, add SG_LIB_OS_BASE_ERR (50)
- - add sg_ll_inquiry_v2()
+ - add sg_ll_inquiry_v2() and sg_ll_inquiry_pt()
- add sg_ll_log_sense_v2()
- add sg_ll_mode_sense10_v2()
- add sg_ll_mode_select6_v2() and
@@ -129,6 +133,9 @@ Changelog for sg3_utils-1.43 [20180414] [svn: r768]
- add sg_ll_get_lba_status16()
- add sg_ll_get_lba_status32()
- add sg_ll_format_unit_v2()
+ - add sg_ll_test_unit_ready_progress_pt()
+ - add sg_ll_request_sense_pt()
+ - add sg_ll_send_diag_pt(), sg_ll_receive_diag_pt()
- add sg_get_sfs_name() for spc5r11 (Feature sets)
- add sg_decode_transportid_str()
- add sg_msense_calc_length()
diff --git a/Makefile.in b/Makefile.in
index bf367a65..fb215b22 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -562,7 +562,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
@@ -588,7 +588,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
- shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
@@ -606,7 +606,7 @@ dist dist-all:
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
- GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
@@ -616,7 +616,7 @@ distcheck: dist
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
- GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
diff --git a/aclocal.m4 b/aclocal.m4
index dc407d89..087efba5 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.15 -*- Autoconf -*-
+# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9067,7 +9067,7 @@ m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9082,7 +9082,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.15], [],
+m4_if([$1], [1.15.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -9098,12 +9098,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.15])dnl
+[AM_AUTOMAKE_VERSION([1.15.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9165,7 +9165,7 @@ AC_SUBST([AR])dnl
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9217,7 +9217,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
# AM_CONDITIONAL -*- Autoconf -*-
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9248,7 +9248,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9439,7 +9439,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9515,7 +9515,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9712,7 +9712,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9733,7 +9733,7 @@ if test x"${install_sh+set}" != xset; then
fi
AC_SUBST([install_sh])])
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9755,7 +9755,7 @@ AC_SUBST([am__leading_dot])])
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9790,7 +9790,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
# Check to see how 'make' treats includes. -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9840,7 +9840,7 @@ rm -f confinc confmf
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9881,7 +9881,7 @@ fi
# Obsolete and "removed" macros, that must however still report explicit
# error messages when used, to smooth transition.
#
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9908,7 +9908,7 @@ AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
# Helper functions for option handling. -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9937,7 +9937,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9984,7 +9984,7 @@ AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -10003,7 +10003,7 @@ AC_DEFUN([AM_RUN_LOG],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -10084,7 +10084,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -10144,7 +10144,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -10172,7 +10172,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -10191,7 +10191,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
diff --git a/ar-lib b/ar-lib
index 463b9ec0..05094d34 100755
--- a/ar-lib
+++ b/ar-lib
@@ -4,7 +4,7 @@
me=ar-lib
scriptversion=2012-03-01.08; # UTC
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2017 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# This program is free software; you can redistribute it and/or modify
diff --git a/config.guess b/config.guess
index 2e9ad7fe..f50dcdb6 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2016 Free Software Foundation, Inc.
+# Copyright 1992-2018 Free Software Foundation, Inc.
-timestamp='2016-10-02'
+timestamp='2018-02-24'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2016-10-02'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -27,7 +27,7 @@ timestamp='2016-10-02'
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
#
# Please send patches to <config-patches@gnu.org>.
@@ -39,7 +39,7 @@ Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
-Operation modes:
+Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
@@ -50,7 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2016 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -107,9 +107,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
+ ,,) echo "int x;" > "$dummy.c" ;
for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
@@ -132,14 +132,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-case "${UNAME_SYSTEM}" in
+case "$UNAME_SYSTEM" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
- eval $set_cc_for_build
- cat <<-EOF > $dummy.c
+ eval "$set_cc_for_build"
+ cat <<-EOF > "$dummy.c"
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
@@ -149,13 +149,20 @@ Linux|GNU|GNU/*)
LIBC=gnu
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+ # If ldd exists, use it to detect musl libc.
+ if command -v ldd >/dev/null && \
+ ldd --version 2>&1 | grep -q ^musl
+ then
+ LIBC=musl
+ fi
;;
esac
# Note: order is significant - the case branches are not exclusive.
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
@@ -169,30 +176,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
- /sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || \
+ "/sbin/$sysctl" 2>/dev/null || \
+ "/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
+ case "$UNAME_MACHINE_ARCH" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
- arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
- endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
- machine=${arch}${endian}-unknown
+ arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+ endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
+ machine="${arch}${endian}"-unknown
;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently (or will in the future) and ABI.
- case "${UNAME_MACHINE_ARCH}" in
+ case "$UNAME_MACHINE_ARCH" in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
@@ -208,10 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;;
esac
# Determine ABI tags.
- case "${UNAME_MACHINE_ARCH}" in
+ case "$UNAME_MACHINE_ARCH" in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
- abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
;;
esac
# The OS release
@@ -219,46 +226,55 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
+ case "$UNAME_VERSION" in
Debian*)
release='-gnu'
;;
*)
- release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}${abi}"
+ echo "$machine-${os}${release}${abi}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+ echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
exit ;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE}
+ echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
+ exit ;;
+ *:MidnightBSD:*:*)
+ echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
exit ;;
*:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
exit ;;
*:SolidBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
exit ;;
macppc:MirBSD:*:*)
- echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
exit ;;
*:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
exit ;;
*:Sortix:*:*)
- echo ${UNAME_MACHINE}-unknown-sortix
+ echo "$UNAME_MACHINE"-unknown-sortix
exit ;;
+ *:Redox:*:*)
+ echo "$UNAME_MACHINE"-unknown-redox
+ exit ;;
+ mips:OSF1:*.*)
+ echo mips-dec-osf1
+ exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
@@ -310,28 +326,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
exit $exitcode ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
+ echo "$UNAME_MACHINE"-unknown-amigaos
exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
+ echo "$UNAME_MACHINE"-unknown-morphos
exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
@@ -343,7 +350,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
+ echo arm-acorn-riscix"$UNAME_RELEASE"
exit ;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
@@ -370,19 +377,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
s390x:SunOS:*:*)
- echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
exit ;;
sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
- echo i386-pc-auroraux${UNAME_RELEASE}
+ echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
@@ -395,13 +402,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
SUN_ARCH=x86_64
fi
fi
- echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
@@ -410,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
exit ;;
sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
+ echo m68k-sun-sunos"$UNAME_RELEASE"
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3
+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
+ echo m68k-sun-sunos"$UNAME_RELEASE"
;;
sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
+ echo sparc-sun-sunos"$UNAME_RELEASE"
;;
esac
exit ;;
aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
+ echo sparc-auspex-sunos"$UNAME_RELEASE"
exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
@@ -439,44 +446,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
+ echo m68k-atari-mint"$UNAME_RELEASE"
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
+ echo m68k-atari-mint"$UNAME_RELEASE"
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
+ echo m68k-atari-mint"$UNAME_RELEASE"
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
+ echo m68k-milan-mint"$UNAME_RELEASE"
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
+ echo m68k-hades-mint"$UNAME_RELEASE"
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
+ echo m68k-unknown-mint"$UNAME_RELEASE"
exit ;;
m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
+ echo m68k-apple-machten"$UNAME_RELEASE"
exit ;;
powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
+ echo powerpc-apple-machten"$UNAME_RELEASE"
exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit ;;
RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
+ echo mips-dec-ultrix"$UNAME_RELEASE"
exit ;;
VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
+ echo vax-dec-ultrix"$UNAME_RELEASE"
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
+ echo clipper-intergraph-clix"$UNAME_RELEASE"
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
@@ -485,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
+ dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
{ echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
+ echo mips-mips-riscos"$UNAME_RELEASE"
exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
@@ -527,17 +534,17 @@ EOF
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
+ if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
+ [ "$TARGET_BINARY_INTERFACE"x = x ]
then
- echo m88k-dg-dgux${UNAME_RELEASE}
+ echo m88k-dg-dgux"$UNAME_RELEASE"
else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ echo m88k-dg-dguxbcs"$UNAME_RELEASE"
fi
else
- echo i586-dg-dgux${UNAME_RELEASE}
+ echo i586-dg-dgux"$UNAME_RELEASE"
fi
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
@@ -554,7 +561,7 @@ EOF
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
@@ -566,14 +573,14 @@ EOF
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
main()
@@ -584,7 +591,7 @@ EOF
exit(0);
}
EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
then
echo "$SYSTEM_NAME"
else
@@ -598,7 +605,7 @@ EOF
exit ;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@@ -607,18 +614,18 @@ EOF
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
echo romp-ibm-bsd4.4
exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to
exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
@@ -633,28 +640,28 @@ EOF
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
+ HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+ case "$UNAME_MACHINE" in
+ 9000/31?) HP_ARCH=m68000 ;;
+ 9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
+ case "$sc_cpu_version" in
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
+ case "$sc_kernel_bits" in
32) HP_ARCH=hppa2.0n ;;
64) HP_ARCH=hppa2.0w ;;
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
+ if [ "$HP_ARCH" = "" ]; then
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
#include <stdlib.h>
@@ -687,13 +694,13 @@ EOF
exit (0);
}
EOF
- (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
- if [ ${HP_ARCH} = hppa2.0w ]
+ if [ "$HP_ARCH" = hppa2.0w ]
then
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
@@ -712,15 +719,15 @@ EOF
HP_ARCH=hppa64
fi
fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
exit ;;
ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
+ HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux"$HPUX_REV"
exit ;;
3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#include <unistd.h>
int
main ()
@@ -745,11 +752,11 @@ EOF
exit (0);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
echo hppa1.1-hp-bsd
exit ;;
9000/8??:4.3bsd:*:*)
@@ -758,7 +765,7 @@ EOF
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
echo hppa1.1-hp-osf
exit ;;
hp8??:OSF1:*:*)
@@ -766,9 +773,9 @@ EOF
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
+ echo "$UNAME_MACHINE"-unknown-osf1mk
else
- echo ${UNAME_MACHINE}-unknown-osf1
+ echo "$UNAME_MACHINE"-unknown-osf1
fi
exit ;;
parisc*:Lites*:*:*)
@@ -793,127 +800,109 @@ EOF
echo c4-convex-bsd
exit ;;
CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
*:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
exit ;;
sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
+ echo sparc-unknown-bsdi"$UNAME_RELEASE"
exit ;;
*:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
exit ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
- case ${UNAME_PROCESSOR} in
+ case "$UNAME_PROCESSOR" in
amd64)
- echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
- *)
- echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ UNAME_PROCESSOR=x86_64 ;;
+ i386)
+ UNAME_PROCESSOR=i586 ;;
esac
+ echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
exit ;;
i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
+ echo "$UNAME_MACHINE"-pc-cygwin
exit ;;
*:MINGW64*:*)
- echo ${UNAME_MACHINE}-pc-mingw64
+ echo "$UNAME_MACHINE"-pc-mingw64
exit ;;
*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
+ echo "$UNAME_MACHINE"-pc-mingw32
exit ;;
*:MSYS*:*)
- echo ${UNAME_MACHINE}-pc-msys
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
+ echo "$UNAME_MACHINE"-pc-msys
exit ;;
i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
+ echo "$UNAME_MACHINE"-pc-pw32
exit ;;
*:Interix*:*)
- case ${UNAME_MACHINE} in
+ case "$UNAME_MACHINE" in
x86)
- echo i586-pc-interix${UNAME_RELEASE}
+ echo i586-pc-interix"$UNAME_RELEASE"
exit ;;
authenticamd | genuineintel | EM64T)
- echo x86_64-unknown-interix${UNAME_RELEASE}
+ echo x86_64-unknown-interix"$UNAME_RELEASE"
exit ;;
IA64)
- echo ia64-unknown-interix${UNAME_RELEASE}
+ echo ia64-unknown-interix"$UNAME_RELEASE"
exit ;;
esac ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- 8664:Windows_NT:*)
- echo x86_64-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
+ echo "$UNAME_MACHINE"-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
*:GNU:*:*)
# the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+ echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
exit ;;
i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
+ echo "$UNAME_MACHINE"-pc-minix
exit ;;
aarch64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -927,63 +916,63 @@ EOF
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arm*:Linux:*:*)
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
else
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
cris:Linux:*:*)
- echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
exit ;;
crisv32:Linux:*:*)
- echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
exit ;;
e2k:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
frv:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
hexagon:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
i*86:Linux:*:*)
- echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
exit ;;
ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
k1om:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
@@ -997,70 +986,74 @@ EOF
#endif
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
+ test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
;;
mips64el:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
openrisc*:Linux:*:*)
- echo or1k-unknown-linux-${LIBC}
+ echo or1k-unknown-linux-"$LIBC"
exit ;;
or32:Linux:*:* | or1k*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
padre:Linux:*:*)
- echo sparc-unknown-linux-${LIBC}
+ echo sparc-unknown-linux-"$LIBC"
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-${LIBC}
+ echo hppa64-unknown-linux-"$LIBC"
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
- PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
- *) echo hppa-unknown-linux-${LIBC} ;;
+ PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
+ PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
+ *) echo hppa-unknown-linux-"$LIBC" ;;
esac
exit ;;
ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-${LIBC}
+ echo powerpc64-unknown-linux-"$LIBC"
exit ;;
ppc:Linux:*:*)
- echo powerpc-unknown-linux-${LIBC}
+ echo powerpc-unknown-linux-"$LIBC"
exit ;;
ppc64le:Linux:*:*)
- echo powerpc64le-unknown-linux-${LIBC}
+ echo powerpc64le-unknown-linux-"$LIBC"
exit ;;
ppcle:Linux:*:*)
- echo powerpcle-unknown-linux-${LIBC}
+ echo powerpcle-unknown-linux-"$LIBC"
exit ;;
riscv32:Linux:*:* | riscv64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+ echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
exit ;;
sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
tile*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
vax:Linux:*:*)
- echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+ echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
exit ;;
x86_64:Linux:*:*)
- echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+ if objdump -f /bin/sh | grep -q elf32-x86-64; then
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32
+ else
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
+ fi
exit ;;
xtensa*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1074,34 +1067,34 @@ EOF
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
exit ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
+ echo "$UNAME_MACHINE"-pc-os2-emx
exit ;;
i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
+ echo "$UNAME_MACHINE"-unknown-stop
exit ;;
i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
+ echo "$UNAME_MACHINE"-unknown-atheos
exit ;;
i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
+ echo "$UNAME_MACHINE"-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
+ echo i386-unknown-lynxos"$UNAME_RELEASE"
exit ;;
i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ echo "$UNAME_MACHINE"-pc-msdosdjgpp
exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ i*86:*:4.*:*)
+ UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
fi
exit ;;
i*86:*:5:[678]*)
@@ -1111,12 +1104,12 @@ EOF
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1126,9 +1119,9 @@ EOF
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
else
- echo ${UNAME_MACHINE}-pc-sysv32
+ echo "$UNAME_MACHINE"-pc-sysv32
fi
exit ;;
pc:*:*:*)
@@ -1148,9 +1141,9 @@ EOF
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4
fi
exit ;;
mini*:CTIX:SYS*5:*)
@@ -1170,9 +1163,9 @@ EOF
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
@@ -1181,28 +1174,28 @@ EOF
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
+ echo m68k-unknown-lynxos"$UNAME_RELEASE"
exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit ;;
TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
+ echo sparc-unknown-lynxos"$UNAME_RELEASE"
exit ;;
rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ echo rs6000-unknown-lynxos"$UNAME_RELEASE"
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ echo powerpc-unknown-lynxos"$UNAME_RELEASE"
exit ;;
SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
+ echo mips-dde-sysv"$UNAME_RELEASE"
exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
@@ -1213,7 +1206,7 @@ EOF
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
+ echo "$UNAME_MACHINE"-sni-sysv4
else
echo ns32k-sni-sysv
fi
@@ -1233,23 +1226,23 @@ EOF
exit ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
+ echo "$UNAME_MACHINE"-stratus-vos
exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit ;;
mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
+ echo m68k-apple-aux"$UNAME_RELEASE"
exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
+ echo mips-nec-sysv"$UNAME_RELEASE"
else
- echo mips-unknown-sysv${UNAME_RELEASE}
+ echo mips-unknown-sysv"$UNAME_RELEASE"
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
@@ -1268,49 +1261,56 @@ EOF
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
+ echo sx4-nec-superux"$UNAME_RELEASE"
exit ;;
SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
+ echo sx5-nec-superux"$UNAME_RELEASE"
exit ;;
SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
+ echo sx6-nec-superux"$UNAME_RELEASE"
exit ;;
SX-7:SUPER-UX:*:*)
- echo sx7-nec-superux${UNAME_RELEASE}
+ echo sx7-nec-superux"$UNAME_RELEASE"
exit ;;
SX-8:SUPER-UX:*:*)
- echo sx8-nec-superux${UNAME_RELEASE}
+ echo sx8-nec-superux"$UNAME_RELEASE"
exit ;;
SX-8R:SUPER-UX:*:*)
- echo sx8r-nec-superux${UNAME_RELEASE}
+ echo sx8r-nec-superux"$UNAME_RELEASE"
exit ;;
SX-ACE:SUPER-UX:*:*)
- echo sxace-nec-superux${UNAME_RELEASE}
+ echo sxace-nec-superux"$UNAME_RELEASE"
exit ;;
Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ echo powerpc-apple-rhapsody"$UNAME_RELEASE"
exit ;;
*:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
- if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+ if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_64BIT_ARCH >/dev/null
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_PPC >/dev/null
+ then
+ UNAME_PROCESSOR=powerpc
+ fi
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# Avoid executing cc on OS X 10.9, as it ships with a stub
@@ -1321,7 +1321,7 @@ EOF
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
fi
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
@@ -1329,19 +1329,25 @@ EOF
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
- NEO-?:NONSTOP_KERNEL:*:*)
- echo neo-tandem-nsk${UNAME_RELEASE}
+ NEO-*:NONSTOP_KERNEL:*:*)
+ echo neo-tandem-nsk"$UNAME_RELEASE"
exit ;;
NSE-*:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
+ echo nse-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ NSR-*:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk"$UNAME_RELEASE"
+ exit ;;
+ NSV-*:NONSTOP_KERNEL:*:*)
+ echo nsv-tandem-nsk"$UNAME_RELEASE"
exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
+ NSX-*:NONSTOP_KERNEL:*:*)
+ echo nsx-tandem-nsk"$UNAME_RELEASE"
exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
@@ -1350,7 +1356,7 @@ EOF
echo bs2000-siemens-sysv
exit ;;
DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
@@ -1361,7 +1367,7 @@ EOF
else
UNAME_MACHINE="$cputype"
fi
- echo ${UNAME_MACHINE}-unknown-plan9
+ echo "$UNAME_MACHINE"-unknown-plan9
exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
@@ -1382,14 +1388,14 @@ EOF
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
+ echo mips-sei-seiux"$UNAME_RELEASE"
exit ;;
*:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
+ case "$UNAME_MACHINE" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
V*) echo vax-dec-vms ; exit ;;
@@ -1398,32 +1404,44 @@ EOF
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'`
+ echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
exit ;;
i*86:rdos:*:*)
- echo ${UNAME_MACHINE}-pc-rdos
+ echo "$UNAME_MACHINE"-pc-rdos
exit ;;
i*86:AROS:*:*)
- echo ${UNAME_MACHINE}-pc-aros
+ echo "$UNAME_MACHINE"-pc-aros
exit ;;
x86_64:VMkernel:*:*)
- echo ${UNAME_MACHINE}-unknown-esx
+ echo "$UNAME_MACHINE"-unknown-esx
exit ;;
amd64:Isilon\ OneFS:*:*)
echo x86_64-unknown-onefs
exit ;;
esac
+echo "$0: unable to guess system type" >&2
+
+case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+ mips:Linux | mips64:Linux)
+ # If we got here on MIPS GNU/Linux, output extra information.
+ cat >&2 <<EOF
+
+NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
+the system type. Please install a C compiler and try again.
+EOF
+ ;;
+esac
+
cat >&2 <<EOF
-$0: unable to guess system type
This script (version $timestamp), has failed to recognize the
-operating system you are using. If your script is old, overwrite
-config.guess and config.sub with the latest versions from:
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
- http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+ https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
and
- http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+ https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
If $0 has already been updated, send the following data and any
information you think might be pertinent to config-patches@gnu.org to
@@ -1446,16 +1464,16 @@ hostinfo = `(hostinfo) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
+UNAME_MACHINE = "$UNAME_MACHINE"
+UNAME_RELEASE = "$UNAME_RELEASE"
+UNAME_SYSTEM = "$UNAME_SYSTEM"
+UNAME_VERSION = "$UNAME_VERSION"
EOF
exit 1
# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'write-file-functions 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
diff --git a/config.sub b/config.sub
index dd2ca93c..1d8e98bc 100755
--- a/config.sub
+++ b/config.sub
@@ -1,8 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2016 Free Software Foundation, Inc.
+# Copyright 1992-2018 Free Software Foundation, Inc.
-timestamp='2016-11-04'
+timestamp='2018-02-22'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2016-11-04'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2016-11-04'
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
@@ -57,7 +57,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
-Operation modes:
+Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
@@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2016 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -94,7 +94,7 @@ while test $# -gt 0 ; do
*local*)
# First pass through any local machine types.
- echo $1
+ echo "$1"
exit ;;
* )
@@ -112,7 +112,7 @@ esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
@@ -120,16 +120,16 @@ case $maybe_os in
kopensolaris*-gnu* | cloudabi*-eabi* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+ basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
+ basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
+ if [ "$basic_machine" != "$1" ]
+ then os=`echo "$1" | sed 's/.*-/-/'`
else os=; fi
;;
esac
@@ -178,44 +178,44 @@ case $os in
;;
-sco6)
os=-sco5v6
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
@@ -227,10 +227,7 @@ case $os in
os=-lynxos
;;
-ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
;;
-psos*)
os=-psos
@@ -263,7 +260,7 @@ case $basic_machine in
| fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
- | i370 | i860 | i960 | ia64 \
+ | i370 | i860 | i960 | ia16 | ia64 \
| ip2k | iq2000 \
| k1om \
| le32 | le64 \
@@ -299,7 +296,7 @@ case $basic_machine in
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 | or1k | or1knd | or32 \
- | pdp10 | pdp11 | pj | pjl \
+ | pdp10 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pru \
| pyramid \
@@ -315,7 +312,7 @@ case $basic_machine in
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| visium \
- | we32k \
+ | wasm32 \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
@@ -336,7 +333,7 @@ case $basic_machine in
basic_machine=$basic_machine-unknown
os=-none
;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
;;
ms1)
basic_machine=mt-unknown
@@ -365,7 +362,7 @@ case $basic_machine in
;;
# Object if more than one company name word.
*-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
@@ -388,7 +385,7 @@ case $basic_machine in
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
- | i*86-* | i860-* | i960-* | ia64-* \
+ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
| ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
@@ -446,6 +443,7 @@ case $basic_machine in
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| visium-* \
+ | wasm32-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@@ -459,7 +457,7 @@ case $basic_machine in
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
- basic_machine=i386-unknown
+ basic_machine=i386-pc
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
@@ -493,7 +491,7 @@ case $basic_machine in
basic_machine=x86_64-pc
;;
amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
@@ -538,7 +536,7 @@ case $basic_machine in
os=-linux
;;
blackfin-*)
- basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
@@ -546,13 +544,13 @@ case $basic_machine in
os=-cnk
;;
c54x-*)
- basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
c55x-*)
- basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
c6x-*)
- basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
c90)
basic_machine=c90-cray
@@ -641,7 +639,7 @@ case $basic_machine in
basic_machine=rs6000-bull
os=-bosx
;;
- dpx2* | dpx2*-bull)
+ dpx2*)
basic_machine=m68k-bull
os=-sysv3
;;
@@ -650,7 +648,7 @@ case $basic_machine in
os=$os"spe"
;;
e500v[12]-*)
- basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=$os"spe"
;;
ebmon29k)
@@ -742,9 +740,6 @@ case $basic_machine in
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
- hppa-next)
- os=-nextstep3
- ;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
@@ -757,26 +752,26 @@ case $basic_machine in
basic_machine=i370-ibm
;;
i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
- i386-vsta | vsta)
+ vsta)
basic_machine=i386-unknown
os=-vsta
;;
@@ -795,19 +790,16 @@ case $basic_machine in
os=-sysv
;;
leon-*|leon[3-9]-*)
- basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+ basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
- basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=-linux
;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
@@ -839,10 +831,10 @@ case $basic_machine in
os=-mint
;;
mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
;;
mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
@@ -861,7 +853,7 @@ case $basic_machine in
os=-msdos
;;
ms1-*)
- basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i686-pc
@@ -903,7 +895,7 @@ case $basic_machine in
basic_machine=v70-nec
os=-sysv
;;
- next | m*-next )
+ next | m*-next)
basic_machine=m68k-next
case $os in
-nextstep* )
@@ -948,6 +940,12 @@ case $basic_machine in
nsr-tandem)
basic_machine=nsr-tandem
;;
+ nsv-tandem)
+ basic_machine=nsv-tandem
+ ;;
+ nsx-tandem)
+ basic_machine=nsx-tandem
+ ;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
@@ -980,7 +978,7 @@ case $basic_machine in
os=-linux
;;
parisc-*)
- basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
@@ -996,7 +994,7 @@ case $basic_machine in
basic_machine=i386-pc
;;
pc98-*)
- basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
@@ -1011,16 +1009,16 @@ case $basic_machine in
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
@@ -1030,23 +1028,23 @@ case $basic_machine in
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-* | ppcbe-*)
- basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
@@ -1100,17 +1098,10 @@ case $basic_machine in
sequent)
basic_machine=i386-sequent
;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
sh5el)
basic_machine=sh5le-unknown
;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
+ simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
@@ -1129,7 +1120,7 @@ case $basic_machine in
os=-sysv4
;;
strongarm-* | thumb-*)
- basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
sun2)
basic_machine=m68000-sun
@@ -1251,6 +1242,9 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
+ x64)
+ basic_machine=x86_64-pc
+ ;;
xbox)
basic_machine=i686-pc
os=-mingw32
@@ -1259,20 +1253,12 @@ case $basic_machine in
basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
- basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+ basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- z80-*-coff)
- basic_machine=z80-unknown
- os=-sim
- ;;
none)
basic_machine=none-none
os=-none
@@ -1301,10 +1287,6 @@ case $basic_machine in
vax)
basic_machine=vax-dec
;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
pdp11)
basic_machine=pdp11-dec
;;
@@ -1314,9 +1296,6 @@ case $basic_machine in
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
- sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
- basic_machine=sparc-sun
- ;;
cydra)
basic_machine=cydra-cydrome
;;
@@ -1336,7 +1315,7 @@ case $basic_machine in
# Make sure to match an already-canonicalized machine name.
;;
*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
exit 1
;;
esac
@@ -1344,10 +1323,10 @@ esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
;;
*-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
;;
*)
;;
@@ -1358,8 +1337,8 @@ esac
if [ x"$os" != x"" ]
then
case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
+ # First match some system type aliases that might get confused
+ # with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
@@ -1370,18 +1349,19 @@ case $os in
-solaris)
os=-solaris2
;;
- -svr4*)
- os=-sysv4
- ;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
- # First accept the basic system types.
+ # es1800 is here to avoid being matched by es* (a different OS)
+ -es1800*)
+ os=-ose
+ ;;
+ # Now accept the basic system types.
# The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
+ # Each alternative MUST end in a * to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
@@ -1391,25 +1371,26 @@ case $os in
| -aos* | -aros* | -cloudabi* | -sortix* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \
| -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* | -cegcc* \
+ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -morphos* | -superux* | -rtmk* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
- | -onefs* | -tirtos* | -phoenix* | -fuchsia*)
+ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
+ | -midnightbsd*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1426,12 +1407,12 @@ case $os in
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ -sim | -xray | -os68k* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
+ os=`echo "$os" | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
@@ -1440,10 +1421,10 @@ case $os in
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
@@ -1454,12 +1435,6 @@ case $os in
-wince*)
os=-wince
;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
-utek*)
os=-bsd
;;
@@ -1484,7 +1459,7 @@ case $os in
-nova*)
os=-rtmk-nova
;;
- -ns2 )
+ -ns2)
os=-nextstep2
;;
-nsk*)
@@ -1506,7 +1481,7 @@ case $os in
-oss*)
os=-sysv3
;;
- -svr4)
+ -svr4*)
os=-sysv4
;;
-svr3)
@@ -1521,24 +1496,28 @@ case $os in
-ose*)
os=-ose
;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
- -aros*)
- os=-aros
- ;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
+ -pikeos*)
+ # Until real need of OS specific support for
+ # particular features comes up, bare metal
+ # configurations are quite functional.
+ case $basic_machine in
+ arm*)
+ os=-eabi
+ ;;
+ *)
+ os=-elf
+ ;;
+ esac
+ ;;
-nacl*)
;;
-ios)
@@ -1548,7 +1527,7 @@ case $os in
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
exit 1
;;
esac
@@ -1638,12 +1617,12 @@ case $basic_machine in
sparc-* | *-sun)
os=-sunos4.1.1
;;
+ pru-*)
+ os=-elf
+ ;;
*-be)
os=-beos
;;
- *-haiku)
- os=-haiku
- ;;
*-ibm)
os=-aix
;;
@@ -1683,7 +1662,7 @@ case $basic_machine in
m88k-omron*)
os=-luna
;;
- *-next )
+ *-next)
os=-nextstep
;;
*-sequent)
@@ -1698,9 +1677,6 @@ case $basic_machine in
i370-*)
os=-mvs
;;
- *-next)
- os=-nextstep3
- ;;
*-gould)
os=-sysv
;;
@@ -1810,15 +1786,15 @@ case $basic_machine in
vendor=stratus
;;
esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
;;
esac
-echo $basic_machine$os
+echo "$basic_machine$os"
exit
# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'write-file-functions 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
diff --git a/debian/changelog b/debian/changelog
index f806633d..0518c943 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.43-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Thu, 05 Apr 2018 01:00:00 -0400
+ -- Douglas Gilbert <dgilbert@interlog.com> Tue, 01 May 2018 13:00:00 -0400
sg3-utils (1.42-0.1) unstable; urgency=low
diff --git a/depcomp b/depcomp
index fc98710e..b39f98f9 100755
--- a/depcomp
+++ b/depcomp
@@ -1,9 +1,9 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# 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
@@ -786,6 +786,6 @@ exit 0
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 514ab45a..30976089 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index 0d0b339a..f1c0f4e7 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -1,4 +1,4 @@
-.TH SG3_UTILS "8" "April 2018" "sg3_utils\-1.43" SG3_UTILS
+.TH SG3_UTILS "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg3_utils \- a package of utilities for sending SCSI commands
.SH SYNOPSIS
diff --git a/doc/sg_timestamp.8 b/doc/sg_timestamp.8
index c63588ad..36fa55f7 100644
--- a/doc/sg_timestamp.8
+++ b/doc/sg_timestamp.8
@@ -1,9 +1,10 @@
-.TH SG_TIMESTAMP "8" "December 2015" "sg3_utils\-1.42" SG3_UTILS
+.TH SG_TIMESTAMP "8" "April 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_timestamp \- report or set timestamp on SCSI device
.SH SYNOPSIS
.B sg_timestamp
-[\fI\-\-help\fR] [\fI\-\-milliseconds=MS\fR] [\fI\-\-origin\fR]
+[\fI\-\-elapsed\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
+[\fI\-\-milliseconds=MS\fR] [\fI\-\-no\-timestamp\fR] [\fI\-\-origin\fR]
[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-seconds=SEC\fR] [\fI\-\-srep\fR]
[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
@@ -26,18 +27,46 @@ timestamps and more humanly readable forms. See the EXAMPLES section below.
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
.TP
+\fB\-e\fR, \fB\-\-elapsed\fR
+assume the timestamp in the REPORT TIMESTAMP is an elapsed time from an
+event such as a power cycle or hard reset and format the output as '<n>
+days hh:mm:ss.xxx' where hh is hours (00 to 23 inclusive); mm is
+minutes (00 to 59 inclusive); ss is seconds (00 to 59 inclusive) and xxx
+is milliseconds (000 to 999 inclusive). If the number of days is 0
+then '0 days' is not output unless this option is given two or more times.
+.TP
\fB\-h\fR, \fB\-\-help\fR
output the usage message then exit.
.TP
+\fB\-H\fR, \fB\-\-hex\fR
+output the response to REPORT TIMESTAMP in ASCII hexadecimal on stderr. The
+response is not decoded.
+.TP
\fB\-m\fR, \fB\-\-milliseconds\fR=\fIMS\fR
where \fIMS\fR is the number of milliseconds since 1970\-01\-01 00:00:00 UTC
to set in the \fIDEVICE\fR with the SCSI SET TIMESTAMP command.
.TP
+\fB\-N\fR, \fB\-\-no\-timestamp\fR
+when REPORT TIMESTAMP is called this option suppress the output of the
+timestamp value (in either seconds or milliseconds). This may be useful
+in uncluttering the output when trying to decode the timestamp origin (see
+the \fI\-\-origin\fR option).
+.TP
\fB\-o\fR, \fB\-\-origin\fR
the REPORT TIMESTAMP returned parameter data contains a "timestamp origin"
field. When this option is given, that field is decoded and printed out
before the timestamp value is output. The default action (i.e. when the
option is not given) is not to print out this decoded field.
+.br
+T10 defines this field as "the most recent event that initialized the
+returned device clock". The value 0 indicates a power up of hard reset
+initialized the clock; 2 indicates a SET TIMESTAMP initialized the
+clock while 3 indicates some other method initialized the clock.
+.br
+When used once a descriptive string is output (in a line before the
+timestamp value). When used twice the value of the TIMESTAMP ORIGIN
+field is output (in decimal, a value between 0 and 7 inclusive). When
+used thrice a line of the form 'TIMESTAMP_ORIGIN=<value>' is output.
.TP
\fB\-r\fR, \fB\-\-raw\fR
output the SCSI REPORT TIMESTAMP response (i.e. the data\-out buffer) in
@@ -84,7 +113,7 @@ readable form the following could be used:
.br
1448993950
.br
- # date \-\-date="@1448993950"
+ # date \-\-date=@1448993950
.br
Tue Dec 1 13:19:10 EST 2015
.br
@@ -96,7 +125,7 @@ The latter two date commands show different forms of the same date (i.e.
1448993950 seconds since 1970\-01\-01 00:00:00 UTC). The sg_timestamp and
date commands can be combined using backquotes:
.PP
- # date \-R \-\-date="@`sg_timestamp \-S /dev/sdc`"
+ # date \-R \-\-date=@`sg_timestamp \-S /dev/sdc`
.br
Wed, 16 Dec 2015 20:12:59 \-0500
.PP
@@ -118,7 +147,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2015 Douglas Gilbert
+Copyright \(co 2015\-2018 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_write_x.8 b/doc/sg_write_x.8
index 866344ca..5d776709 100644
--- a/doc/sg_write_x.8
+++ b/doc/sg_write_x.8
@@ -1,4 +1,4 @@
-.TH SG_WRITE_X "8" "February 2018" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_WRITE_X "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_write_x \- SCSI WRITE normal/ATOMIC/SAME/SCATTERED/STREAM, ORWRITE commands
.SH SYNOPSIS
@@ -135,7 +135,9 @@ descriptor as a terminator of the scatter list.
.PP
The current reference for these commands is draft SBC\-4 (T10/BSR INCITS
506) revision 15 dated 9 November 2017. All six SCSI commands are described
-in that document.
+in that document. WRITE ATOMIC was added in SBC\-4 revision 3; WRITE STREAM
+was added in SBC\-4 revision 7; WRITE SCATTERED was added in SBC\-4
+revision 11 while the others are in the SBC\-3 standard.
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
The options are arranged in alphabetical order based on the long
diff --git a/include/Makefile.in b/include/Makefile.in
index f12229b1..d6029bf3 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
diff --git a/include/sg_cmds_basic.h b/include/sg_cmds_basic.h
index 90863255..9848c13e 100644
--- a/include/sg_cmds_basic.h
+++ b/include/sg_cmds_basic.h
@@ -28,6 +28,13 @@
extern "C" {
#endif
+/* Functions with the "_pt" suffix take a pointer to an object (derived from)
+ * sg_pt_base rather than an open file descriptor as their first argument.
+ * That object is assumed to be constructed and have a device file descriptor
+ * associated with it. Caller is responsible for lifetime of ptp. */
+
+struct sg_pt_base;
+
/* Invokes a SCSI INQUIRY command and yields the response
* Returns 0 when successful, SG_LIB_CAT_INVALID_OP -> not supported,
@@ -47,10 +54,14 @@ int sg_ll_inquiry(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp,
* written where residp points. A residual value of 0 implies mx_resp_len
* bytes have be written where resp points. If the residual value equals
* mx_resp_len then no bytes have been written. */
-int
-sg_ll_inquiry_v2(int sg_fd, bool evpd, int pg_op, void * resp,
- int mx_resp_len, int timeout_secs, int * residp,
- bool noisy, int verbose);
+int sg_ll_inquiry_v2(int sg_fd, bool evpd, int pg_op, void * resp,
+ int mx_resp_len, int timeout_secs, int * residp,
+ bool noisy, int verbose);
+
+/* Similar to sg_ll_inquiry_v2(). See note above about "_pt" suffix. */
+int sg_ll_inquiry_pt(struct sg_pt_base * ptp, bool evpd, int pg_op,
+ void * resp, int mx_resp_len, int timeout_secs,
+ int * residp, bool noisy, int verbose);
/* Invokes a SCSI LOG SELECT command. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Log Select not supported,
@@ -165,6 +176,10 @@ int sg_ll_report_luns(int sg_fd, int select_report, void * resp,
int sg_ll_request_sense(int sg_fd, bool desc, void * resp, int mx_resp_len,
bool noisy, int verbose);
+/* Similar to sg_ll_request_sense(). See note above about "_pt" suffix. */
+int sg_ll_request_sense_pt(struct sg_pt_base * ptp, bool desc, void * resp,
+ int mx_resp_len, bool noisy, int verbose);
+
/* Invokes a SCSI START STOP UNIT command (SBC + MMC).
* Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Start stop unit not supported,
@@ -205,6 +220,11 @@ int sg_ll_test_unit_ready(int sg_fd, int pack_id, bool noisy, int verbose);
int sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress,
bool noisy, int verbose);
+/* Similar to sg_ll_test_unit_ready_progress(). See note above about "_pt"
+ * suffix. */
+int sg_ll_test_unit_ready_progress_pt(struct sg_pt_base * ptp, int pack_id,
+ int * progress, bool noisy, int verbose);
+
struct sg_simple_inquiry_resp {
uint8_t peripheral_qualifier;
@@ -288,7 +308,6 @@ const char * sg_cmds_version();
#define SG_NO_DATA_IN 0
-struct sg_pt_base;
/* This is a helper function used by sg_cmds_* implementations after the
* call to the pass-through. pt_res is returned from do_scsi_pt(). If valid
diff --git a/include/sg_cmds_extra.h b/include/sg_cmds_extra.h
index d7b82320..974d17c1 100644
--- a/include/sg_cmds_extra.h
+++ b/include/sg_cmds_extra.h
@@ -22,6 +22,15 @@ extern "C" {
* commands (e.g. FORMAT UNIT and the Third Party copy commands) can take
* a lot longer than the default timeout. */
+/* Functions with the "_pt" suffix ^^^ take a pointer to an object (derived
+ * from) sg_pt_base rather than an open file descriptor as their first
+ * argument. That object is assumed to be constructed and have a device file
+ * descriptor * associated with it. Caller is responsible for lifetime of
+ * ptp.
+ * ^^^ apart from sg_ll_ata_pt() as 'pass-through' is part of its name. */
+
+struct sg_pt_base;
+
/* Invokes a ATA PASS-THROUGH (12, 16 or 32) SCSI command (SAT). This is
* selected by the cdb_len argument that can take values of 12, 16 or 32
@@ -180,6 +189,10 @@ int sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
int mx_resp_len, int timeout_secs, int * residp,
bool noisy, int verbose);
+int sg_ll_receive_diag_pt(struct sg_pt_base * ptp, bool pcv, int pg_code,
+ void * resp, int mx_resp_len, int timeout_secs,
+ int * residp, bool noisy, int verbose);
+
/* Invokes a SCSI REPORT IDENTIFYING INFORMATION command. This command was
* called REPORT DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Report identifying information not supported,
@@ -225,6 +238,11 @@ int sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
bool devofl_bit, bool unitofl_bit, int long_duration,
void * paramp, int param_len, bool noisy, int verbose);
+int sg_ll_send_diag_pt(struct sg_pt_base * ptp, int st_code, bool pf_bit,
+ bool st_bit, bool devofl_bit, bool unitofl_bit,
+ int long_duration, void * paramp, int param_len,
+ bool noisy, int verbose);
+
/* Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was
* called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Set identifying information not supported,
diff --git a/include/sg_lib.h b/include/sg_lib.h
index a66532b3..7ea24b3f 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -459,10 +459,10 @@ int sg_err_category_sense(const uint8_t * sense_buffer, int sb_len);
#define SG_LIB_CAT_MEDIUM_HARD_WITH_INFO 18 /* medium or hardware error */
/* sense key plus 'info' field: */
/* [sk,asc,ascq: 0x3/0x4,*,*] */
+#define SG_LIB_CAT_TIMEOUT 33 /* SCSI command timeout */
#define SG_LIB_CAT_PROTECTION_WITH_INFO 41 /* aborted command sense key, */
/* protection plus 'info' field: */
/* [sk,asc,ascq: 0xb,0x10,*] */
-#define SG_LIB_CAT_TIMEOUT 33
/* Yield string associated with sense category. Returns 'buff' (or pointer
* to "Bad sense category" if 'buff' is NULL). If sense_cat unknown then
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 2acb18da..c70f47d2 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -35,7 +35,7 @@ libsgutils2_la_SOURCES += sg_pt_osf1.c
endif
# For C++/clang testing
-## CC = gcc
+## CC = gcc-8
## CC = g++
## CC = clang
## CC = clang++
@@ -49,6 +49,7 @@ 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
+# AM_CFLAGS = -Wall -W -pedantic -std=c++1z
lib_LTLIBRARIES = libsgutils2.la
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 4d772e2a..4a8d7678 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -359,6 +359,7 @@ 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
+# AM_CFLAGS = -Wall -W -pedantic -std=c++1z
lib_LTLIBRARIES = libsgutils2.la
libsgutils2_la_LDFLAGS = -version-info 2:0:0 -no-undefined
libsgutils2_la_LIBADD = @GETOPT_O_FILES@
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index a31d1834..53014180 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
+#include <errno.h>
#include <string.h>
#include <unistd.h>
@@ -36,7 +37,7 @@
#endif
-static const char * const version_str = "1.85 20180302";
+static const char * const version_str = "1.86 20180501";
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
@@ -333,18 +334,19 @@ create_pt_obj(const char * cname)
static const char * const inquiry_s = "inquiry";
+
+
/* Returns 0 on success, while positive values are SG_LIB_CAT_* errors
* (e.g. SG_LIB_CAT_MALFORMED). If OS error, returns negated errno or -1. */
static int
-sg_ll_inquiry_com(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp,
- int mx_resp_len, int timeout_secs, int * residp,
- bool noisy, int verbose)
+sg_ll_inquiry_com(struct sg_pt_base * ptvp, bool cmddt, bool evpd, int pg_op,
+ void * resp, int mx_resp_len, int timeout_secs,
+ int * residp, bool noisy, int verbose)
{
int res, ret, k, sense_cat, resid;
uint8_t inq_cdb[INQUIRY_CMDLEN] = {INQUIRY_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
uint8_t * up;
- struct sg_pt_base * ptvp;
if (cmddt)
inq_cdb[1] |= 0x2;
@@ -367,17 +369,10 @@ sg_ll_inquiry_com(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp,
}
if (timeout_secs <= 0)
timeout_secs = DEF_PT_TIMEOUT;
- ptvp = construct_scsi_pt_obj();
- if (NULL == ptvp) {
- pr2ws("%s: out of memory\n", __func__);
- if (residp)
- *residp = 0;
- return -1;
- }
set_scsi_pt_cdb(ptvp, inq_cdb, sizeof(inq_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, timeout_secs, verbose);
+ res = do_scsi_pt(ptvp, -1, timeout_secs, verbose);
ret = sg_cmds_process_resp(ptvp, inquiry_s, res, mx_resp_len, sense_b,
noisy, verbose, &sense_cat);
resid = get_scsi_pt_resid(ptvp);
@@ -401,7 +396,6 @@ sg_ll_inquiry_com(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp,
ret = SG_LIB_CAT_MALFORMED;
} else
ret = 0;
- destruct_scsi_pt_obj(ptvp);
if (resid > 0) {
if (resid > mx_resp_len) {
@@ -422,8 +416,57 @@ int
sg_ll_inquiry(int sg_fd, bool cmddt, bool evpd, int pg_op, void * resp,
int mx_resp_len, bool noisy, int verbose)
{
- return sg_ll_inquiry_com(sg_fd, cmddt, evpd, pg_op, resp, mx_resp_len,
- 0 /* timeout_sec */, NULL, noisy, verbose);
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_inquiry_com(ptvp, cmddt, evpd, pg_op, resp, mx_resp_len,
+ 0 /* timeout_sec */, NULL, noisy, verbose);
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
+
+/* Invokes a SCSI INQUIRY command and yields the response. Returns 0 when
+ * successful, various SG_LIB_CAT_* positive values or -1 -> other errors.
+ * The CMDDT field is obsolete in the INQUIRY cdb (since spc3r16 in 2003) so
+ * an argument to set it has been removed (use the REPORT SUPPORTED OPERATION
+ * CODES command instead). Adds the ability to set the command abort timeout
+ * and the ability to report the residual count. If timeout_secs is zero
+ * or less the default command abort timeout (60 seconds) is used.
+ * If residp is non-NULL then the residual value is written where residp
+ * points. A residual value of 0 implies mx_resp_len bytes have be written
+ * where resp points. If the residual value equals mx_resp_len then no
+ * bytes have been written. */
+int
+sg_ll_inquiry_v2(int sg_fd, bool evpd, int pg_op, void * resp,
+ int mx_resp_len, int timeout_secs, int * residp,
+ bool noisy, int verbose)
+{
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_inquiry_com(ptvp, false, evpd, pg_op, resp, mx_resp_len,
+ timeout_secs, residp, noisy, verbose);
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
+
+/* Similar to _v2 but takes a pointer to an object (derived from) sg_pt_base.
+ * That object is assumed to be constructed and have a device file descriptor
+ * associated with it. Caller is responsible for lifetime of ptp. */
+int
+sg_ll_inquiry_pt(struct sg_pt_base * ptvp, bool evpd, int pg_op, void * resp,
+ int mx_resp_len, int timeout_secs, int * residp, bool noisy,
+ int verbose)
+{
+ return sg_ll_inquiry_com(ptvp, false, evpd, pg_op, resp, mx_resp_len,
+ timeout_secs, residp, noisy, verbose);
+
}
/* Yields most of first 36 bytes of a standard INQUIRY (evpd==0) response.
@@ -434,15 +477,21 @@ sg_simple_inquiry(int sg_fd, struct sg_simple_inquiry_resp * inq_data,
bool noisy, int verbose)
{
int ret;
- uint8_t inq_resp[SAFE_STD_INQ_RESP_LEN];
+ uint8_t * inq_resp = NULL;
+ uint8_t * free_irp = NULL;
if (inq_data) {
memset(inq_data, 0, sizeof(* inq_data));
inq_data->peripheral_qualifier = 0x3;
inq_data->peripheral_type = 0x1f;
}
- ret = sg_ll_inquiry_com(sg_fd, false, false, 0, inq_resp,
- sizeof(inq_resp), 0, NULL, noisy, verbose);
+ inq_resp = sg_memalign(SAFE_STD_INQ_RESP_LEN, 0, &free_irp, verbose > 4);
+ if (NULL == inq_resp) {
+ pr2ws("%s: out of memory\n", __func__);
+ return sg_convert_errno(ENOMEM);
+ }
+ ret = sg_ll_inquiry_v2(sg_fd, false, 0, inq_resp, SAFE_STD_INQ_RESP_LEN,
+ 0, NULL, noisy, verbose);
if (inq_data && (0 == ret)) {
inq_data->peripheral_qualifier = (inq_resp[0] >> 5) & 0x7;
@@ -457,29 +506,11 @@ sg_simple_inquiry(int sg_fd, struct sg_simple_inquiry_resp * inq_data,
memcpy(inq_data->product, inq_resp + 16, 16);
memcpy(inq_data->revision, inq_resp + 32, 4);
}
+ if (free_irp)
+ free(free_irp);
return ret;
}
-/* Invokes a SCSI INQUIRY command and yields the response. Returns 0 when
- * successful, various SG_LIB_CAT_* positive values or -1 -> other errors.
- * The CMDDT field is obsolete in the INQUIRY cdb (since spc3r16 in 2003) so
- * an argument to set it has been removed (use the REPORT SUPPORTED OPERATION
- * CODES command instead). Adds the ability to set the command abort timeout
- * and the ability to report the residual count. If timeout_secs is zero
- * or less the default command abort timeout (60 seconds) is used.
- * If residp is non-NULL then the residual value is written where residp
- * points. A residual value of 0 implies mx_resp_len bytes have be written
- * where resp points. If the residual value equals mx_resp_len then no
- * bytes have been written. */
-int
-sg_ll_inquiry_v2(int sg_fd, bool evpd, int pg_op, void * resp,
- int mx_resp_len, int timeout_secs, int * residp,
- bool noisy, int verbose)
-{
- return sg_ll_inquiry_com(sg_fd, false, evpd, pg_op, resp, mx_resp_len,
- timeout_secs, residp, noisy, verbose);
-}
-
/* Invokes a SCSI TEST UNIT READY command.
* 'pack_id' is just for diagnostics, safe to set to 0.
* Looks for progress indicator if 'progress' non-NULL;
@@ -487,14 +518,13 @@ sg_ll_inquiry_v2(int sg_fd, bool evpd, int pg_op, void * resp,
* Returns 0 when successful, various SG_LIB_CAT_* positive values or
* -1 -> other errors */
int
-sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress,
- bool noisy, int verbose)
+sg_ll_test_unit_ready_progress_pt(struct sg_pt_base * ptvp, int pack_id,
+ int * progress, bool noisy, int verbose)
{
static const char * const tur_s = "test unit ready";
int res, ret, k, sense_cat;
uint8_t tur_cdb[TUR_CMDLEN] = {TUR_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
if (verbose) {
pr2ws(" %s cdb: ", tur_s);
@@ -503,12 +533,10 @@ sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress,
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(tur_s))))
- return -1;
set_scsi_pt_cdb(ptvp, tur_cdb, sizeof(tur_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_packet_id(ptvp, pack_id);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
ret = sg_cmds_process_resp(ptvp, tur_s, res, SG_NO_DATA_IN, sense_b,
noisy, verbose, &sense_cat);
if (-1 == ret)
@@ -531,7 +559,21 @@ sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress,
}
} else
ret = 0;
+ return ret;
+}
+int
+sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress,
+ bool noisy, int verbose)
+{
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_test_unit_ready_progress_pt(ptvp, pack_id, progress, noisy,
+ verbose);
destruct_scsi_pt_obj(ptvp);
return ret;
}
@@ -543,22 +585,29 @@ sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress,
int
sg_ll_test_unit_ready(int sg_fd, int pack_id, bool noisy, int verbose)
{
- return sg_ll_test_unit_ready_progress(sg_fd, pack_id, NULL, noisy,
- verbose);
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_test_unit_ready_progress_pt(ptvp, pack_id, NULL, noisy,
+ verbose);
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
}
/* Invokes a SCSI REQUEST SENSE command. Returns 0 when successful, various
* SG_LIB_CAT_* positive values or -1 -> other errors */
int
-sg_ll_request_sense(int sg_fd, bool desc, void * resp, int mx_resp_len,
- bool noisy, int verbose)
+sg_ll_request_sense_pt(struct sg_pt_base * ptvp, bool desc, void * resp,
+ int mx_resp_len, bool noisy, int verbose)
{
static const char * const rq_s = "request sense";
int k, ret, res, sense_cat;
uint8_t rs_cdb[REQUEST_SENSE_CMDLEN] =
{REQUEST_SENSE_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
if (desc)
rs_cdb[1] |= 0x1;
@@ -574,12 +623,10 @@ sg_ll_request_sense(int sg_fd, bool desc, void * resp, int mx_resp_len,
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(rq_s))))
- return -1;
set_scsi_pt_cdb(ptvp, rs_cdb, sizeof(rs_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
ret = sg_cmds_process_resp(ptvp, rq_s, res, mx_resp_len, sense_b, noisy,
verbose, &sense_cat);
if (-1 == ret)
@@ -603,6 +650,21 @@ sg_ll_request_sense(int sg_fd, bool desc, void * resp, int mx_resp_len,
} else
ret = 0;
}
+ return ret;
+}
+
+int
+sg_ll_request_sense(int sg_fd, bool desc, void * resp, int mx_resp_len,
+ bool noisy, int verbose)
+{
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_request_sense_pt(ptvp, desc, resp, mx_resp_len, noisy,
+ verbose);
destruct_scsi_pt_obj(ptvp);
return ret;
}
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 6db51f36..579dc464 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <errno.h>
#include <unistd.h>
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
@@ -462,16 +463,16 @@ sg_ll_report_referrals(int sg_fd, uint64_t start_llba, bool one_seg,
* value is taken as the timeout value in seconds. Return of 0 -> success,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
-sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
- bool devofl_bit, bool unitofl_bit, int long_duration,
- void * paramp, int param_len, bool noisy, int verbose)
+sg_ll_send_diag_pt(struct sg_pt_base * ptvp, int st_code, bool pf_bit,
+ bool st_bit, bool devofl_bit, bool unitofl_bit,
+ int long_duration, void * paramp, int param_len,
+ bool noisy, int verbose)
{
static const char * const cdb_name_s = "Send diagnostic";
int k, res, ret, sense_cat, tmout;
uint8_t senddiag_cdb[SEND_DIAGNOSTIC_CMDLEN] =
{SEND_DIAGNOSTIC_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
senddiag_cdb[1] = (uint8_t)(st_code << 5);
if (pf_bit)
@@ -502,12 +503,10 @@ sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
- return -1;
set_scsi_pt_cdb(ptvp, senddiag_cdb, sizeof(senddiag_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, tmout, verbose);
+ res = do_scsi_pt(ptvp, -1, tmout, verbose);
ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
noisy, verbose, &sense_cat);
if (-1 == ret)
@@ -525,31 +524,37 @@ sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
} else
ret = 0;
- destruct_scsi_pt_obj(ptvp);
return ret;
}
-/* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success,
- * various SG_LIB_CAT_* positive values or -1 -> other errors */
int
-sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
- int mx_resp_len, bool noisy, int verbose)
+sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
+ bool devofl_bit, bool unitofl_bit, int long_duration,
+ void * paramp, int param_len, bool noisy, int verbose)
{
- return sg_ll_receive_diag_v2(sg_fd, pcv, pg_code, resp, mx_resp_len, 0,
- NULL, noisy, verbose);
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_send_diag_pt(ptvp, st_code, pf_bit, st_bit, devofl_bit,
+ unitofl_bit, long_duration, paramp, param_len,
+ noisy, verbose);
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
}
/* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
-sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
- int mx_resp_len, int timeout_secs, int * residp,
- bool noisy, int verbose)
+sg_ll_receive_diag_pt(struct sg_pt_base * ptvp, bool pcv, int pg_code,
+ void * resp, int mx_resp_len, int timeout_secs,
+ int * residp, bool noisy, int verbose)
{
int resid = 0;
int k, res, ret, sense_cat;
static const char * const cdb_name_s = "Receive diagnostic results";
- struct sg_pt_base * ptvp;
uint8_t rcvdiag_cdb[RECEIVE_DIAGNOSTICS_CMDLEN] =
{RECEIVE_DIAGNOSTICS_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -568,15 +573,10 @@ sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
if (timeout_secs <= 0)
timeout_secs = DEF_PT_TIMEOUT;
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s)))) {
- if (residp)
- *residp = 0;
- return -1;
- }
set_scsi_pt_cdb(ptvp, rcvdiag_cdb, sizeof(rcvdiag_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, timeout_secs, verbose);
+ res = do_scsi_pt(ptvp, -1, timeout_secs, verbose);
ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
noisy, verbose, &sense_cat);
resid = get_scsi_pt_resid(ptvp);
@@ -608,6 +608,41 @@ sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
}
ret = 0;
}
+ return ret;
+}
+
+
+/* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success,
+ * various SG_LIB_CAT_* positive values or -1 -> other errors */
+int
+sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
+ int mx_resp_len, bool noisy, int verbose)
+{
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_receive_diag_pt(ptvp, pcv, pg_code, resp, mx_resp_len, 0,
+ NULL, noisy, verbose);
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
+
+int
+sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
+ int mx_resp_len, int timeout_secs, int * residp,
+ bool noisy, int verbose)
+{
+ int ret;
+ struct sg_pt_base * ptvp;
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp)
+ return sg_convert_errno(ENOMEM);
+ ret = sg_ll_receive_diag_pt(ptvp, pcv, pg_code, resp, mx_resp_len,
+ timeout_secs, residp, noisy, verbose);
destruct_scsi_pt_obj(ptvp);
return ret;
}
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index bdb2808e..1fbb6d2f 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -5,7 +5,7 @@
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_win32 version 1.24 20180309 */
+/* sg_pt_win32 version 1.25 20180427 */
#include <stdio.h>
#include <stdlib.h>
@@ -1536,7 +1536,7 @@ nvme_identify(struct sg_pt_win32_scsi * psp, struct sg_pt_handle * shp,
sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA) + n;
buffer = sg_memalign(bufferLength, pg_sz, &free_buffer, false);
if (buffer == NULL) {
- res = SG_LIB_OS_BASE_ERR + ENOMEM;
+ res = sg_convert_errno(ENOMEM);
if (vb > 1)
pr2ws("%s: unable to allocate memory\n", __func__);
psp->os_err = res;
@@ -1626,7 +1626,7 @@ nvme_get_features(struct sg_pt_win32_scsi * psp, struct sg_pt_handle * shp,
sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA) + n;
buffer = sg_memalign(bufferLength, pg_sz, &free_buffer, false);
if (buffer == NULL) {
- res = SG_LIB_OS_BASE_ERR + ENOMEM;
+ res = sg_convert_errno(ENOMEM);
if (vb > 1)
pr2ws("%s: unable to allocate memory\n", __func__);
psp->os_err = res;
@@ -1705,7 +1705,7 @@ nvme_get_log_page(struct sg_pt_win32_scsi * psp, struct sg_pt_handle * shp,
sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA) + n;
buffer = sg_memalign(bufferLength, pg_sz, &free_buffer, false);
if (buffer == NULL) {
- res = SG_LIB_OS_BASE_ERR + ENOMEM;
+ res = sg_convert_errno(ENOMEM);
if (vb > 1)
pr2ws("%s: unable to allocate memory\n", __func__);
psp->os_err = res;
@@ -1787,7 +1787,7 @@ nvme_real_pt(struct sg_pt_win32_scsi * psp, struct sg_pt_handle * shp,
sizeof(NVME_ERROR_INFO_LOG) + n;
buffer = sg_memalign(bufferLength, pg_sz, &free_buffer, false);
if (buffer == NULL) {
- res = SG_LIB_OS_BASE_ERR + ENOMEM;
+ res = sg_convert_errno(ENOMEM);
if (vb > 1)
pr2ws("%s: unable to allocate memory\n", __func__);
psp->os_err = res;
@@ -2014,7 +2014,7 @@ do_nvme_admin_cmd(struct sg_pt_win32_scsi * psp, struct sg_pt_handle * shp,
pthru = (NVME_PASS_THROUGH_IOCTL *)sg_memalign(alloc_len, pg_sz,
&free_pthru, false);
if (NULL == pthru) {
- res = SG_LIB_OS_BASE_ERR + ENOMEM;
+ res = sg_convert_errno(ENOMEM);
if (vb > 1)
pr2ws("%s: unable to allocate memory\n", __func__);
psp->os_err = res;
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 00f2d6f1..b78ef28b 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 599bed14..32ba4170 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Thu Apr 05 2018 - dgilbert at interlog dot com
+* Tue May 01 2018 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.43
diff --git a/src/Makefile.am b/src/Makefile.am
index 2407435f..18985656 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,7 +35,7 @@ endif
# For C++/clang testing
-## CC = gcc
+## CC = gcc-8
## CC = g++
## CC = clang
## CC = clang++
@@ -49,6 +49,7 @@ 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
+# AM_CFLAGS = -Wall -W -pedantic -std=c++1z
sg_bg_ctl_LDADD = ../lib/libsgutils2.la
diff --git a/src/Makefile.in b/src/Makefile.in
index 999c0f4b..dc56ca9c 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -579,6 +579,7 @@ 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
+# AM_CFLAGS = -Wall -W -pedantic -std=c++1z
sg_bg_ctl_LDADD = ../lib/libsgutils2.la
sg_compare_and_write_LDADD = ../lib/libsgutils2.la
sg_copy_results_LDADD = ../lib/libsgutils2.la
diff --git a/src/sg_compare_and_write.c b/src/sg_compare_and_write.c
index 1ede6e88..e4dbc5ae 100644
--- a/src/sg_compare_and_write.c
+++ b/src/sg_compare_and_write.c
@@ -54,7 +54,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.22 20180219";
+static const char * version_str = "1.22 20180428";
#define DEF_BLOCK_SIZE 512
#define DEF_NUM_BLOCKS (1)
@@ -457,11 +457,12 @@ int
main(int argc, char * argv[])
{
bool ifn_stdin;
- int res, half_xlen;
+ int res, half_xlen, vb;
int infd = -1;
int wfd = -1;
int devfd = -1;
uint8_t * wrkBuff = NULL;
+ uint8_t * free_wrkBuff = NULL;
struct opts_t * op;
struct opts_t opts;
@@ -473,7 +474,8 @@ main(int argc, char * argv[])
goto out;
}
- if (op->verbose) {
+ vb = op->verbose;
+ if (vb) {
pr2serr("Running COMPARE AND WRITE command with the "
"following options:\n in=%s ", op->ifn);
if (op->wfn_given)
@@ -501,16 +503,17 @@ main(int argc, char * argv[])
}
}
- devfd = open_dev(op->device_name, op->verbose);
+ devfd = open_dev(op->device_name, vb);
if (devfd < 0) {
res = -devfd;
goto out;
}
- wrkBuff = (uint8_t *)malloc(op->xfer_len);
- if (0 == wrkBuff) {
+ wrkBuff = (uint8_t *)sg_memalign(op->xfer_len, 0, &free_wrkBuff,
+ vb > 3);
+ if (NULL == wrkBuff) {
pr2serr("Not enough user memory\n");
- res = SG_LIB_CAT_OTHER;
+ res = sg_convert_errno(ENOMEM);
goto out;
}
@@ -547,7 +550,7 @@ main(int argc, char * argv[])
}
res = sg_ll_compare_and_write(devfd, wrkBuff, op->numblocks, op->lba,
op->xfer_len, op->flags, ! op->quiet,
- op->verbose);
+ vb);
out:
if (0 != res) {
@@ -559,15 +562,14 @@ out:
case SG_LIB_FILE_ERROR:
break; /* already reported */
default:
- sg_get_category_sense_str(res, sizeof(b), b,
- op->verbose);
+ sg_get_category_sense_str(res, sizeof(b), b, vb);
pr2serr(ME "SCSI COMPARE AND WRITE: %s\n", b);
break;
}
}
- if (wrkBuff)
- free(wrkBuff);
+ if (free_wrkBuff)
+ free(free_wrkBuff);
if ((infd >= 0) && (! ifn_stdin))
close(infd);
if (wfd >= 0)
diff --git a/src/sg_copy_results.c b/src/sg_copy_results.c
index 97cd5388..514a33b9 100644
--- a/src/sg_copy_results.c
+++ b/src/sg_copy_results.c
@@ -38,7 +38,7 @@
and the optional list identifier passed as the list_id argument.
*/
-static const char * version_str = "1.19 20180326";
+static const char * version_str = "1.20 20180428";
#define MAX_XFER_LEN 10000
@@ -314,6 +314,7 @@ main(int argc, char * argv[])
uint32_t list_id = 0;
const char * cp;
uint8_t * cpResultBuff = NULL;
+ uint8_t * free_cprb = NULL;
const char * device_name = NULL;
char file_name[256];
@@ -401,11 +402,12 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
- if (NULL == (cpResultBuff = (uint8_t *)malloc(xfer_len))) {
+ cpResultBuff = (uint8_t *)sg_memalign(xfer_len, 0, &free_cprb,
+ verbose > 3);
+ if (NULL == cpResultBuff) {
pr2serr(ME "out of memory\n");
- return SG_LIB_FILE_ERROR;
+ return sg_convert_errno(ENOMEM);
}
- memset(cpResultBuff, 0x00, xfer_len);
sg_fd = sg_cmds_open_device(device_name, o_readonly, verbose);
if (sg_fd < 0) {
@@ -453,7 +455,8 @@ main(int argc, char * argv[])
}
finish:
- free(cpResultBuff);
+ if (free_cprb)
+ free(free_cprb);
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
pr2serr(ME "close error: %s\n", safe_strerror(-res));
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 6abc50f4..af168fc6 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -62,7 +62,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "5.97 20180219";
+static const char * version_str = "5.98 20180502";
#define ME "sg_dd: "
@@ -71,7 +71,7 @@ static const char * version_str = "5.97 20180219";
#define STR_SZ 1024
#define INOUTF_SZ 512
-#define EBUFF_SZ 512
+#define EBUFF_SZ 768
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c
index 29e95115..7db694e4 100644
--- a/src/sg_get_lba_status.c
+++ b/src/sg_get_lba_status.c
@@ -32,7 +32,7 @@
* device.
*/
-static const char * version_str = "1.14 20180311";
+static const char * version_str = "1.15 20180425";
#ifndef UINT32_MAX
#define UINT32_MAX ((uint32_t)-1)
@@ -42,7 +42,6 @@ static const char * version_str = "1.14 20180311";
#define DEF_GLBAS_BUFF_LEN 24
static uint8_t glbasBuff[DEF_GLBAS_BUFF_LEN];
-static uint8_t * glbasBuffp = glbasBuff;
static struct option long_options[] = {
@@ -149,26 +148,28 @@ decode_lba_status_desc(const uint8_t * bp, uint64_t * slbap,
int
main(int argc, char * argv[])
{
+ bool do_16 = false;
+ bool do_32 = false;
+ bool do_raw = false;
+ bool o_readonly = false;
int sg_fd, k, j, res, c, rlen, num_descs, completion_cond;
int do_brief = 0;
int do_hex = 0;
- int64_t ll;
- uint64_t lba = 0;
+ int ret = 0;
+ int maxlen = DEF_GLBAS_BUFF_LEN;
+ int rt = 0;
+ int verbose = 0;
+ uint8_t add_status = 0; /* keep gcc quiet */
uint64_t d_lba = 0;
uint32_t d_blocks = 0;
uint32_t element_id = 0;
uint32_t scan_len = 0;
- int maxlen = DEF_GLBAS_BUFF_LEN;
- int rt = 0;
- int verbose = 0;
- bool do_16 = false;
- bool do_32 = false;
- bool do_raw = false;
- bool o_readonly = false;
+ int64_t ll;
+ uint64_t lba = 0;
const char * device_name = NULL;
const uint8_t * bp;
- int ret = 0;
- uint8_t add_status = 0; /* keep gcc quiet */
+ uint8_t * glbasBuffp = glbasBuff;
+ uint8_t * free_glbasBuffp = NULL;
while (1) {
int option_index = 0;
@@ -271,7 +272,8 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
if (maxlen > DEF_GLBAS_BUFF_LEN) {
- glbasBuffp = (uint8_t *)calloc(maxlen, 1);
+ glbasBuffp = (uint8_t *)sg_memalign(maxlen, 0, &free_glbasBuffp,
+ verbose > 3);
if (NULL == glbasBuffp) {
pr2serr("unable to allocate %d bytes on heap\n", maxlen);
return SG_LIB_SYNTAX_ERROR;
@@ -477,7 +479,7 @@ the_end:
ret = SG_LIB_FILE_ERROR;
}
free_buff:
- if (glbasBuffp && (glbasBuffp != glbasBuff))
- free(glbasBuffp);
+ if (free_glbasBuffp)
+ free(free_glbasBuffp);
return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
}
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 57f234db..85dab11a 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#define __STDC_FORMAT_MACROS 1
@@ -48,7 +49,7 @@
#include "sg_pt_nvme.h"
#endif
-static const char * version_str = "1.92 20180405"; /* SPC-5 rev 19 */
+static const char * version_str = "1.93 20180425"; /* SPC-5 rev 19 */
/* INQUIRY notes:
* It is recommended that the initial allocation length given to a
diff --git a/src/sg_logs.c b/src/sg_logs.c
index c8086115..283a1831 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -34,7 +34,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.63 20180325"; /* spc5r19 + sbc4r11 */
+static const char * version_str = "1.65 20180501"; /* spc5r19 + sbc4r11 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -3042,17 +3042,22 @@ show_app_client_page(const uint8_t * resp, int len, const struct opts_t * op)
static bool
show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
{
- int k, num, extra, pc;
+ int k, num, param_len, pc;
const uint8_t * bp;
const char * cp;
char str[PCB_STR_LEN];
char b[256];
char bb[32];
- bool full, decoded, has_header;
+ bool full, decoded;
+ bool has_header = false;
bool is_smstr = op->lep ? (MVP_SMSTR & op->lep->flags) :
(VP_SMSTR == op->vend_prod_num);
full = ! op->do_temperature;
+ if ('\0' != t10_vendor_str[0]) {
+ if (0 != strcmp(vp_arr[VP_SMSTR].t10_vendorp, t10_vendor_str))
+ is_smstr = false; /* Inquiry vendor string says not SmrtStor */
+ }
num = len - 4;
bp = &resp[0] + 4;
if (num < 4) {
@@ -3063,54 +3068,63 @@ show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
if (full)
printf("Informational Exceptions page [0x2f]\n");
}
- for (k = num, has_header = false; k > 0; k -= extra, bp += extra) {
+ for (k = num; k > 0; k -= param_len, bp += param_len) {
if (k < 3) {
printf("short Informational Exceptions page\n");
return false;
}
- extra = bp[3] + 4;
+ param_len = bp[3] + 4;
pc = sg_get_unaligned_be16(bp + 0);
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw(bp, extra);
+ dStrRaw(bp, param_len);
break;
} else if (op->do_hex) {
- hex2stdout(bp, extra, ((1 == op->do_hex) ? 1 : -1));
+ hex2stdout(bp, param_len, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
decoded = true;
cp = NULL;
+
switch (pc) {
case 0x0:
- if (extra > 5) {
+ if (param_len > 5) {
if (full) {
printf(" IE asc = 0x%x, ascq = 0x%x", bp[4], bp[5]);
if (bp[4] || bp[5])
if(sg_get_asc_ascq_str(bp[4], bp[5], sizeof(b), b))
printf("\n [%s]", b);
}
- if (extra > 6) {
+ if (param_len > 6) {
if (bp[6] < 0xff)
printf("\n Current temperature = %d C", bp[6]);
else
printf("\n Current temperature = <not available>");
- if (extra > 7) {
+ if (param_len > 7) {
if (bp[7] < 0xff)
printf("\n Threshold temperature = %d C "
"[common extension]", bp[7]);
else
printf("\n Threshold temperature = <not "
"available>");
- }
+ if ((param_len > 8) && (bp[8] >= bp[6])) {
+ if (bp[8] < 0xff)
+ printf("\n Maximum temperature = %d C "
+ "[(since new), extension]", bp[8]);
+ else
+ printf("\n Maximum temperature = <not "
+ "available>");
+ }
+ }
}
decoded = true;
}
break;
default:
- if (! is_smstr) {
+ if ((! is_smstr) || (param_len < 24)) {
decoded = false;
break;
}
@@ -3170,8 +3184,8 @@ show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
break;
}
break;
- }
- if (cp && (extra >= 24)) {
+ } /* end of switch statement */
+ if (cp && (param_len >= 24)) {
if (! has_header) {
has_header = true;
printf(" Has|Ever %% to worst %% Current "
@@ -3188,14 +3202,14 @@ show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
/* decoded = true; */
} else if ((! decoded) && full) {
printf(" parameter code = 0x%x, contents in hex:\n", pc);
- hex2stdout(bp, extra, 1);
+ hex2stdout(bp, param_len, 1);
}
printf("\n");
if (op->do_pcb)
printf(" <%s>\n", get_pcb_str(bp[2], str, sizeof(str)));
if (op->filter_given)
break;
- }
+ } /* end of for loop */
return true;
}
diff --git a/src/sg_luns.c b/src/sg_luns.c
index 20502ef5..cacb37c6 100644
--- a/src/sg_luns.c
+++ b/src/sg_luns.c
@@ -31,7 +31,7 @@
* and decodes the response.
*/
-static const char * version_str = "1.38 20180329";
+static const char * version_str = "1.39 20180425";
#define MAX_RLUNS_BUFF_LEN (1024 * 1024)
#define DEF_RLUNS_BUFF_LEN (1024 * 8)
@@ -380,6 +380,7 @@ main(int argc, char * argv[])
const char * device_name = NULL;
const char * cp;
uint8_t * reportLunsBuff = NULL;
+ uint8_t * free_reportLunsBuff = NULL;
uint8_t lun_arr[8];
struct sg_simple_inquiry_resp sir;
@@ -593,9 +594,10 @@ main(int argc, char * argv[])
if (0 == maxlen)
maxlen = DEF_RLUNS_BUFF_LEN;
- reportLunsBuff = (uint8_t *)calloc(1, maxlen);
+ reportLunsBuff = (uint8_t *)sg_memalign(maxlen, 0, &free_reportLunsBuff,
+ verbose > 3);
if (NULL == reportLunsBuff) {
- pr2serr("unable to malloc %d bytes\n", maxlen);
+ pr2serr("unable to sg_memalign %d bytes\n", maxlen);
return SG_LIB_CAT_OTHER;
}
trunc = false;
@@ -669,8 +671,8 @@ main(int argc, char * argv[])
}
the_end:
- if (reportLunsBuff)
- free(reportLunsBuff);
+ if (free_reportLunsBuff)
+ free(free_reportLunsBuff);
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
pr2serr("close error: %s\n", safe_strerror(-res));
diff --git a/src/sg_modes.c b/src/sg_modes.c
index 0a839526..e680a153 100644
--- a/src/sg_modes.c
+++ b/src/sg_modes.c
@@ -550,7 +550,7 @@ static struct page_code_desc pc_desc_disk[] = {
{0xa, 0x5, "IO advice hints grouping"}, /* added sbc4r06 */
{0xa, 0x6, "Background operation control"}, /* added sbc4r07 */
{0xa, 0xf1, "Parallel ATA control (SAT)"},
- {0xa, 0xf2, "Reserved (SATA control) (SAT)"},
+/* {0xa, 0xf2, "Reserved (SATA control) (SAT)"}, // proposed + dropped ?? */
{0xb, 0x0, "Medium types supported (obsolete)"},
{0xc, 0x0, "Notch and partition (obsolete)"},
{0xd, 0x0, "Power condition (obsolete, moved to 0x1a)"},
diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c
index 8164dfb5..4e7f73d5 100644
--- a/src/sg_opcodes.c
+++ b/src/sg_opcodes.c
@@ -17,6 +17,7 @@
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
+#include <errno.h>
#include <getopt.h>
#ifdef HAVE_CONFIG_H
@@ -30,7 +31,7 @@
#include "sg_pt.h"
-static const char * version_str = "0.58 20180403"; /* spc5r14 */
+static const char * version_str = "0.59 20180428"; /* spc5r14 */
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
@@ -45,7 +46,7 @@ static const char * version_str = "0.58 20180403"; /* spc5r14 */
#define NAME_BUFF_SZ 128
-#define SEAGATE_READ_UDS_DATA_CMD 0xf7 /* may start reporting vendor cmds */
+#define SEAGATE_READ_UDS_DATA_CMD 0xf7 /* may start reporting vendor cmds */
static int peri_dtype = -1; /* ugly but not easy to pass to alpha compare */
@@ -907,12 +908,13 @@ list_one(uint8_t * rsoc_buff, int cd_len, int rep_opts,
int
main(int argc, char * argv[])
{
- int sg_fd, cd_len, res, len, act_len, rq_len;
+ int sg_fd, cd_len, res, len, act_len, rq_len, vb;
int rep_opts = 0;
const char * cp;
struct opts_t * op;
const char * op_name;
- uint8_t rsoc_buff[MX_ALLOC_LEN];
+ uint8_t * rsoc_buff = NULL;
+ uint8_t * free_rsoc_buff = NULL;
char buff[48];
char b[80];
struct sg_simple_inquiry_resp inq_resp;
@@ -936,6 +938,7 @@ main(int argc, char * argv[])
pr2serr("Version string: %s\n", version_str);
return 0;
}
+ vb = op->verbose;
if ((NULL == op->device_name) && (! op->do_enumerate)) {
pr2serr("No DEVICE argument given\n");
@@ -976,7 +979,7 @@ main(int argc, char * argv[])
if (peri_dtype < 0)
peri_dtype = 0;
printf("SCSI command:");
- if (op->verbose)
+ if (vb)
printf(" [opcode=0x%x, sa=0x%x, pdt=0x%x]\n", op->opcode,
op->servact, peri_dtype);
else
@@ -990,18 +993,25 @@ main(int argc, char * argv[])
op_name = op->do_taskman ? "Report supported task management functions" :
"Report supported operation codes";
+ rsoc_buff = (uint8_t *)sg_memalign(MX_ALLOC_LEN, 0, &free_rsoc_buff,
+ vb > 3);
+ if (NULL == rsoc_buff) {
+ pr2serr("Unable to allocate memory\n");
+ return sg_convert_errno(ENOMEM);
+ }
+
if (op->opcode < 0) {
- if ((sg_fd = scsi_pt_open_device(op->device_name, 1 /* RO */,
- op->verbose)) < 0) {
+ /* Try to open read-only */
+ if ((sg_fd = scsi_pt_open_device(op->device_name, 1, vb)) < 0) {
pr2serr("sg_opcodes: error opening file (ro): %s: %s\n",
op->device_name, safe_strerror(-sg_fd));
- return SG_LIB_FILE_ERROR;
+ goto open_rw;
}
if (op->no_inquiry && (peri_dtype < 0))
pr2serr("--no-inquiry ignored because --pdt= not given\n");
if (op->no_inquiry && (peri_dtype >= 0))
;
- else if (0 == sg_simple_inquiry(sg_fd, &inq_resp, true, op->verbose)) {
+ else if (0 == sg_simple_inquiry(sg_fd, &inq_resp, true, vb)) {
peri_dtype = inq_resp.peripheral_type;
if (! (op->do_raw || op->no_inquiry)) {
printf(" %.8s %.16s %.4s\n", inq_resp.vendor,
@@ -1024,26 +1034,25 @@ main(int argc, char * argv[])
}
}
- if ((sg_fd = scsi_pt_open_device(op->device_name, 0 /* RW */,
- op->verbose)) < 0) {
+open_rw:
+ if ((sg_fd = scsi_pt_open_device(op->device_name, 0 /* RW */, vb)) < 0) {
pr2serr("sg_opcodes: error opening file (rw): %s: %s\n",
op->device_name, safe_strerror(-sg_fd));
return SG_LIB_FILE_ERROR;
}
if (op->opcode >= 0)
rep_opts = ((op->servact >= 0) ? 2 : 1);
- memset(rsoc_buff, 0, sizeof(rsoc_buff));
if (op->do_taskman) {
rq_len = (op->do_repd ? 16 : 4);
- res = do_rstmf(sg_fd, op->do_repd, rsoc_buff,
- rq_len, &act_len, true, op->verbose);
+ res = do_rstmf(sg_fd, op->do_repd, rsoc_buff, rq_len, &act_len, true,
+ vb);
} else {
- rq_len = sizeof(rsoc_buff);
+ rq_len = MX_ALLOC_LEN;
res = do_rsoc(sg_fd, op->do_rctd, rep_opts, op->opcode, op->servact,
- rsoc_buff, rq_len, &act_len, true, op->verbose);
+ rsoc_buff, rq_len, &act_len, true, vb);
}
if (res) {
- sg_get_category_sense_str(res, sizeof(b), b, op->verbose);
+ sg_get_category_sense_str(res, sizeof(b), b, vb);
pr2serr("%s: %s\n", op_name, b);
goto err_out;
}
@@ -1133,6 +1142,8 @@ main(int argc, char * argv[])
res = 0;
err_out:
+ if (free_rsoc_buff)
+ free(free_rsoc_buff);
scsi_pt_close_device(sg_fd);
return res;
}
diff --git a/src/sg_raw.c b/src/sg_raw.c
index 9dee2852..d480e6d0 100644
--- a/src/sg_raw.c
+++ b/src/sg_raw.c
@@ -37,7 +37,7 @@
#include "sg_pr2serr.h"
#include "sg_unaligned.h"
-#define SG_RAW_VERSION "0.4.24 (2018-03-02)"
+#define SG_RAW_VERSION "0.4.25 (2018-04-25)"
#define DEFAULT_TIMEOUT 20
#define MIN_SCSI_CDBSZ 6
@@ -576,7 +576,7 @@ fetch_dataout(struct opts_t * op, uint8_t ** free_buf, int * errp)
pr2serr("sg_memalign: failed to get %d bytes of memory\n",
op->dataout_len);
if (errp)
- *errp = SG_LIB_OS_BASE_ERR + ENOMEM;
+ *errp = sg_convert_errno(ENOMEM);
goto bail;
}
@@ -728,7 +728,7 @@ main(int argc, char *argv[])
if (dinp == NULL) {
pr2serr("sg_memalign: failed to get %d bytes of memory\n",
din_len);
- ret = SG_LIB_OS_BASE_ERR + ENOMEM;
+ ret = sg_convert_errno(ENOMEM);
goto done;
}
if (op->verbose > 2)
diff --git a/src/sg_read.c b/src/sg_read.c
index 9d9038cd..9326b180 100644
--- a/src/sg_read.c
+++ b/src/sg_read.c
@@ -53,7 +53,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "1.30 20180219";
+static const char * version_str = "1.31 20180502";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -368,7 +368,7 @@ static int sg_bread(int sg_fd, uint8_t * buff, int blocks,
#define STR_SZ 1024
#define INF_SZ 512
-#define EBUFF_SZ 512
+#define EBUFF_SZ 768
int main(int argc, char * argv[])
diff --git a/src/sg_read_attr.c b/src/sg_read_attr.c
index c8673e61..ff10af92 100644
--- a/src/sg_read_attr.c
+++ b/src/sg_read_attr.c
@@ -12,6 +12,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#define __STDC_FORMAT_MACROS 1
@@ -36,7 +37,7 @@
* and decodes the response. Based on spc5r08.pdf
*/
-static const char * version_str = "1.08 20180219";
+static const char * version_str = "1.09 20180425";
#define MAX_RATTR_BUFF_LEN (1024 * 1024)
#define DEF_RATTR_BUFF_LEN (1024 * 8)
@@ -912,6 +913,7 @@ main(int argc, char * argv[])
const char * device_name = NULL;
const char * fname = NULL;
uint8_t * rabp = NULL;
+ uint8_t * free_rabp = NULL;
struct opts_t opts;
struct opts_t * op;
char b[80];
@@ -1052,10 +1054,10 @@ main(int argc, char * argv[])
if (0 == op->maxlen)
op->maxlen = DEF_RATTR_BUFF_LEN;
- rabp = (uint8_t *)calloc(1, op->maxlen);
+ rabp = (uint8_t *)sg_memalign(op->maxlen, 0, &free_rabp, op->verbose > 3);
if (NULL == rabp) {
- pr2serr("unable to calloc %d bytes\n", op->maxlen);
- return SG_LIB_CAT_OTHER;
+ pr2serr("unable to sg_memalign %d bytes\n", op->maxlen);
+ return sg_convert_errno(ENOMEM);
}
if (NULL == device_name) {
@@ -1142,7 +1144,7 @@ close_then_end:
ret = SG_LIB_FILE_ERROR;
}
clean_up:
- if (rabp)
- free(rabp);
+ if (free_rabp)
+ free(free_rabp);
return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
}
diff --git a/src/sg_read_long.c b/src/sg_read_long.c
index e214e5f6..1c278801 100644
--- a/src/sg_read_long.c
+++ b/src/sg_read_long.c
@@ -33,13 +33,13 @@
#include "sg_cmds_extra.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.24 20180219";
+static const char * version_str = "1.26 20180502";
#define MAX_XFER_LEN 10000
#define ME "sg_read_long: "
-#define EBUFF_SZ 256
+#define EBUFF_SZ 512
static struct option long_options[] = {
@@ -53,6 +53,7 @@ static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"xfer_len", required_argument, 0, 'x'},
+ {"xfer-len", required_argument, 0, 'x'},
{0, 0, 0, 0},
};
diff --git a/src/sg_referrals.c b/src/sg_referrals.c
index 96e1368e..83ab89e7 100644
--- a/src/sg_referrals.c
+++ b/src/sg_referrals.c
@@ -12,6 +12,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <getopt.h>
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
@@ -34,7 +35,7 @@
* SCSI device.
*/
-static const char * version_str = "1.10 20180219"; /* sbc4r10 */
+static const char * version_str = "1.11 20180425"; /* sbc4r10 */
#define MAX_REFER_BUFF_LEN (1024 * 1024)
#define DEF_REFER_BUFF_LEN 256
@@ -48,7 +49,6 @@ static const char * version_str = "1.10 20180219"; /* sbc4r10 */
#define TPGS_STATE_TRANSITIONING 0xf
static uint8_t referralBuff[DEF_REFER_BUFF_LEN];
-static uint8_t * referralBuffp = referralBuff;
static const char *decode_tpgs_state(const int st)
{
@@ -86,6 +86,7 @@ static struct option long_options[] = {
{"lba", required_argument, 0, 'l'},
{"maxlen", required_argument, 0, 'm'},
{"one-segment", no_argument, 0, 's'},
+ {"one_segment", no_argument, 0, 's'},
{"raw", no_argument, 0, 'r'},
{"readonly", no_argument, 0, 'R'},
{"verbose", no_argument, 0, 'v'},
@@ -182,6 +183,8 @@ main(int argc, char * argv[])
uint64_t lba = 0;
const char * device_name = NULL;
const uint8_t * bp;
+ uint8_t * referralBuffp = referralBuff;
+ uint8_t * free_referralBuffp = NULL;
while (1) {
int option_index = 0;
@@ -255,10 +258,12 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
if (maxlen > DEF_REFER_BUFF_LEN) {
- referralBuffp = (uint8_t *)calloc(maxlen, 1);
+ referralBuffp = (uint8_t *)sg_memalign(maxlen, 0,
+ &free_referralBuffp,
+ verbose > 3);
if (NULL == referralBuffp) {
pr2serr("unable to allocate %d bytes on heap\n", maxlen);
- return SG_LIB_SYNTAX_ERROR;
+ return sg_convert_errno(ENOMEM);
}
}
if (do_raw) {
@@ -343,7 +348,7 @@ the_end:
ret = SG_LIB_FILE_ERROR;
}
free_buff:
- if (referralBuffp && (referralBuffp != referralBuff))
- free(referralBuffp);
+ if (free_referralBuffp)
+ free(free_referralBuffp);
return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
}
diff --git a/src/sg_rep_zones.c b/src/sg_rep_zones.c
index 2e8ef942..ce4078ad 100644
--- a/src/sg_rep_zones.c
+++ b/src/sg_rep_zones.c
@@ -12,6 +12,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#define __STDC_FORMAT_MACROS 1
@@ -35,7 +36,7 @@
* and decodes the response. Based on zbc-r02.pdf
*/
-static const char * version_str = "1.15 20180219";
+static const char * version_str = "1.16 20180425";
#define MAX_RZONES_BUFF_LEN (1024 * 1024)
#define DEF_RZONES_BUFF_LEN (1024 * 8)
@@ -287,6 +288,7 @@ main(int argc, char * argv[])
int64_t ll;
const char * device_name = NULL;
uint8_t * reportZonesBuff = NULL;
+ uint8_t * free_rzbp = NULL;
uint8_t * bp;
char b[80];
@@ -390,10 +392,11 @@ main(int argc, char * argv[])
if (0 == maxlen)
maxlen = DEF_RZONES_BUFF_LEN;
- reportZonesBuff = (uint8_t *)calloc(1, maxlen);
+ reportZonesBuff = (uint8_t *)sg_memalign(maxlen, 0, &free_rzbp,
+ verbose > 3);
if (NULL == reportZonesBuff) {
- pr2serr("unable to malloc %d bytes\n", maxlen);
- return SG_LIB_CAT_OTHER;
+ pr2serr("unable to sg_memalign %d bytes\n", maxlen);
+ return sg_convert_errno(ENOMEM);
}
res = sg_ll_report_zones(sg_fd, st_lba, do_partial, reporting_opt,
@@ -467,8 +470,8 @@ main(int argc, char * argv[])
}
the_end:
- if (reportZonesBuff)
- free(reportZonesBuff);
+ if (free_rzbp)
+ free(free_rzbp);
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
pr2serr("close error: %s\n", safe_strerror(-res));
diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c
index e67a634c..38e5030b 100644
--- a/src/sg_sanitize.c
+++ b/src/sg_sanitize.c
@@ -661,7 +661,7 @@ main(int argc, char * argv[])
if (! got_stdin)
close(infd);
}
- wBuff[0] = op->count & 0x1f;;
+ wBuff[0] = op->count & 0x1f;
if (op->test)
wBuff[0] |= ((op->test & 0x3) << 5);
if (op->invert)
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 41eea275..15d76295 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -28,9 +28,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
#include "sg_unaligned.h"
-#ifdef SG_LIB_WIN32
-#include "sg_pt.h" /* needed for scsi_pt_win32_direct() */
-#endif
+#include "sg_pt.h"
#include "sg_pr2serr.h"
/*
@@ -38,10 +36,11 @@
* commands tailored for SES (enclosure) devices.
*/
-static const char * version_str = "2.35 20180305"; /* ses4r02 */
+static const char * version_str = "2.37 20180502"; /* ses4r02 */
#define MX_ALLOC_LEN ((64 * 1024) - 4) /* max allowable for big enclosures */
#define MX_ELEM_HDR 1024
+#define REQUEST_SENSE_RESP_SZ 252
#define DATA_IN_OFF 4
#define MIN_DATA_IN_SZ 8192 /* use max(MIN_DATA_IN_SZ, op->maxlen) for
* the size of data_arr */
@@ -499,6 +498,7 @@ static struct element_type_t element_type_by_code =
/* Many control element names below have "RQST" in front in drafts.
These are for the Enclosure Control/Status diagnostic page */
static struct acronym2tuple ecs_a2t_arr[] = {
+ /* acron element_type start_byte start_bit num_bits */
{"ac_fail", UI_POWER_SUPPLY_ETC, 2, 4, 1, NULL},
{"ac_hi", UI_POWER_SUPPLY_ETC, 2, 6, 1, NULL},
{"ac_lo", UI_POWER_SUPPLY_ETC, 2, 7, 1, NULL},
@@ -557,7 +557,8 @@ static struct acronym2tuple ecs_a2t_arr[] = {
{"fault", ARRAY_DEV_ETC, 3, 5, 1, NULL},
{"hotspare", ARRAY_DEV_ETC, 1, 5, 1, NULL},
{"hotswap", COOLING_ETC, 3, 7, 1, NULL},
- {"hotswap", ENC_SCELECTR_ETC, 3, 7, 1, NULL},
+ {"hotswap", ENC_SCELECTR_ETC, 3, 7, 1, NULL}, /* status only */
+ {"hw_reset", ENC_SCELECTR_ETC, 1, 2, 1, "hardware reset"}, /* 18-047r0 */
{"ident", DEVICE_ETC, 2, 1, 1, "flash LED"},
{"ident", ARRAY_DEV_ETC, 2, 1, 1, "flash LED"},
{"ident", POWER_SUPPLY_ETC, 1, 7, 1, "flash LED"},
@@ -652,7 +653,7 @@ static struct acronym2tuple ecs_a2t_arr[] = {
{"remove", DEVICE_ETC, 2, 2, 1, NULL},
{"remove", ARRAY_DEV_ETC, 2, 2, 1, NULL},
{"remind", AUD_ALARM_ETC, 3, 4, 1, NULL},
- {"report", ENC_SCELECTR_ETC, 2, 0, 1, NULL},
+ {"report", ENC_SCELECTR_ETC, 2, 0, 1, NULL}, /* status only */
{"report", SCC_CELECTR_ETC, 2, 0, 1, NULL},
{"report", SCSI_IPORT_ETC, 2, 0, 1, NULL},
{"report", SCSI_TPORT_ETC, 2, 0, 1, NULL},
@@ -661,7 +662,7 @@ static struct acronym2tuple ecs_a2t_arr[] = {
{"rqst_override", TEMPERATURE_ETC, 3, 7, 1, "Request(ed) override"},
{"rrabort", ARRAY_DEV_ETC, 1, 0, 1, "rebuild/remap abort"},
{"rsvddevice", ARRAY_DEV_ETC, 1, 6, 1, "reserved device"},
- {"select_element", ENC_SCELECTR_ETC, 2, 0, 1, NULL},
+ {"select_element", ENC_SCELECTR_ETC, 2, 0, 1, NULL}, /* control */
{"short_stat", SIMPLE_SUBENC_ETC, 3, 7, 8, "short enclosure status"},
{"size", NV_CACHE_ETC, 2, 7, 16, NULL},
{"speed_act", COOLING_ETC, 1, 2, 11, "actual speed (rpm / 10)"},
@@ -669,6 +670,7 @@ static struct acronym2tuple ecs_a2t_arr[] = {
"0: leave; 1: lowest... 7: highest"},
{"size_mult", NV_CACHE_ETC, 1, 1, 2, NULL},
{"swap", -1, 0, 4, 1, NULL}, /* Reset swap */
+ {"sw_reset", ENC_SCELECTR_ETC, 1, 3, 1, "software reset"},/* 18-047r0 */
{"temp", TEMPERATURE_ETC, 2, 7, 8, "(Requested) temperature"},
{"unlock", DOOR_ETC, 3, 0, 1, NULL},
{"undertemp_fail", TEMPERATURE_ETC, 3, 1, 1, "Undertemperature failure"},
@@ -738,6 +740,7 @@ static struct option long_options[] = {
{"data", required_argument, 0, 'd'},
{"descriptor", required_argument, 0, 'D'},
{"dev-slot-num", required_argument, 0, 'x'},
+ {"dev_slot_num", required_argument, 0, 'x'},
{"dsn", required_argument, 0, 'x'},
{"eiioe", required_argument, 0, 'E'},
{"enumerate", no_argument, 0, 'e'},
@@ -747,6 +750,7 @@ static struct option long_options[] = {
{"hex", no_argument, 0, 'H'},
{"index", required_argument, 0, 'I'},
{"inner-hex", no_argument, 0, 'i'},
+ {"inner_hex", no_argument, 0, 'i'},
{"join", no_argument, 0, 'j'},
{"list", no_argument, 0, 'l'},
{"nickid", required_argument, 0, 'N'},
@@ -758,6 +762,7 @@ static struct option long_options[] = {
{"raw", no_argument, 0, 'r'},
{"readonly", no_argument, 0, 'R'},
{"sas-addr", required_argument, 0, 'A'},
+ {"sas_addr", required_argument, 0, 'A'},
{"set", required_argument, 0, 'S'},
{"status", no_argument, 0, 's'},
{"verbose", no_argument, 0, 'v'},
@@ -1508,7 +1513,7 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
}
if ((! (op->do_data && op->do_status)) && (NULL == op->dev_name)) {
- pr2serr("missing DEVICE name!\n");
+ pr2serr("missing DEVICE name!\n\n");
goto err_help;
}
return 0;
@@ -1636,12 +1641,12 @@ match_last_ind_indiv(int index, const struct opts_t * op)
/* Return of 0 -> success, SG_LIB_CAT_* positive values or -1 -> other
* failures */
static int
-do_senddiag(int sg_fd, void * outgoing_pg, int outgoing_len, bool noisy,
- int verbose)
+do_senddiag(struct sg_pt_base * ptvp, void * outgoing_pg, int outgoing_len,
+ bool noisy, int verbose)
{
const bool pf_bit = true;
+ int page_num, ret;
const char * cp;
- int page_num;
if (outgoing_pg && (verbose > 2)) {
page_num = ((const char *)outgoing_pg)[0];
@@ -1652,10 +1657,12 @@ do_senddiag(int sg_fd, void * outgoing_pg, int outgoing_len, bool noisy,
pr2serr(" Send diagnostic command page number: 0x%x\n",
page_num);
}
- return sg_ll_send_diag(sg_fd, 0 /* sf_code */, pf_bit, false /* sf_bit */,
- false /* devofl_bit */, false /* unitofl_bit */,
- 0 /* long_duration */, outgoing_pg, outgoing_len,
- noisy, verbose);
+ ret = sg_ll_send_diag_pt(ptvp, 0 /* sf_code */, pf_bit,
+ false /* sf_bit */, false /* devofl_bit */,
+ false /* unitofl_bit */, 0 /* long_duration */,
+ outgoing_pg, outgoing_len, noisy, verbose);
+ clear_scsi_pt_obj(ptvp);
+ return ret;
}
/* Fetch diagnostic page name (status and/or control). Returns NULL if not
@@ -1826,7 +1833,7 @@ find_join_row_cnst(const struct th_es_t * tesp, int index,
/* Return of 0 -> success, SG_LIB_CAT_* positive values or -2 if response
* had bad format, -1 -> other failures */
static int
-do_rec_diag(int sg_fd, int page_code, uint8_t * rsp_buff,
+do_rec_diag(struct sg_pt_base * ptvp, int page_code, uint8_t * rsp_buff,
int rsp_buff_size, struct opts_t * op, int * rsp_lenp)
{
int k, d_len, rsp_len, res;
@@ -1889,9 +1896,10 @@ do_rec_diag(int sg_fd, int page_code, uint8_t * rsp_buff,
}
if (vb > 1)
pr2serr(" %s command for %s\n", rdr, cp);
- res = sg_ll_receive_diag_v2(sg_fd, true /* pcv */, page_code, rsp_buff,
+ res = sg_ll_receive_diag_pt(ptvp, true /* pcv */, page_code, rsp_buff,
rsp_buff_size, 0 /* default timeout */,
&resid, ! op->quiet, vb);
+ clear_scsi_pt_obj(ptvp);
decode:
if (0 == res) {
rsp_len = sg_get_unaligned_be16(rsp_buff + 2) + 4;
@@ -2045,7 +2053,8 @@ truncated:
* Returns total number of type descriptor headers written to 'tdhp' or -1
* if there is a problem */
static int
-build_type_desc_hdr_arr(int fd, struct type_desc_hdr_t * tdhp, int max_elems,
+build_type_desc_hdr_arr(struct sg_pt_base * ptvp,
+ struct type_desc_hdr_t * tdhp, int max_elems,
uint32_t * generationp,
struct enclosure_info * primary_ip,
struct opts_t * op)
@@ -2065,7 +2074,7 @@ build_type_desc_hdr_arr(int fd, struct type_desc_hdr_t * tdhp, int max_elems,
ret = -1;
goto the_end;
}
- res = do_rec_diag(fd, CONFIGURATION_DPC, config_dp_resp, op->maxlen,
+ res = do_rec_diag(ptvp, CONFIGURATION_DPC, config_dp_resp, op->maxlen,
op, &resp_len);
if (res) {
pr2serr("%s: couldn't read config page, res=%d\n", __func__, res);
@@ -4063,8 +4072,8 @@ err_with_fp:
}
static int
-process_status_dpage(int sg_fd, int page_code, uint8_t * resp, int resp_len,
- struct opts_t * op)
+process_status_dpage(struct sg_pt_base * ptvp, int page_code, uint8_t * resp,
+ int resp_len, struct opts_t * op)
{
int j, num_ths;
int ret = 0;
@@ -4112,7 +4121,7 @@ process_status_dpage(int sg_fd, int page_code, uint8_t * resp, int resp_len,
configuration_sdg(resp, resp_len);
break;
case ENC_STATUS_DPC:
- num_ths = build_type_desc_hdr_arr(sg_fd, type_desc_hdr_arr,
+ num_ths = build_type_desc_hdr_arr(ptvp, type_desc_hdr_arr,
MX_ELEM_HDR, &ref_gen_code,
&primary_info, op);
if (num_ths < 0) {
@@ -4130,7 +4139,7 @@ process_status_dpage(int sg_fd, int page_code, uint8_t * resp, int resp_len,
enc_status_dp(tesp, ref_gen_code, resp, resp_len, op);
break;
case ARRAY_STATUS_DPC:
- num_ths = build_type_desc_hdr_arr(sg_fd, type_desc_hdr_arr,
+ num_ths = build_type_desc_hdr_arr(ptvp, type_desc_hdr_arr,
MX_ELEM_HDR, &ref_gen_code,
&primary_info, op);
if (num_ths < 0) {
@@ -4164,7 +4173,7 @@ process_status_dpage(int sg_fd, int page_code, uint8_t * resp, int resp_len,
printf(" <empty>\n");
break;
case THRESHOLD_DPC:
- num_ths = build_type_desc_hdr_arr(sg_fd, type_desc_hdr_arr,
+ num_ths = build_type_desc_hdr_arr(ptvp, type_desc_hdr_arr,
MX_ELEM_HDR, &ref_gen_code,
&primary_info, op);
if (num_ths < 0) {
@@ -4182,7 +4191,7 @@ process_status_dpage(int sg_fd, int page_code, uint8_t * resp, int resp_len,
threshold_sdg(tesp, ref_gen_code, resp, resp_len, op);
break;
case ELEM_DESC_DPC:
- num_ths = build_type_desc_hdr_arr(sg_fd, type_desc_hdr_arr,
+ num_ths = build_type_desc_hdr_arr(ptvp, type_desc_hdr_arr,
MX_ELEM_HDR, &ref_gen_code,
&primary_info, op);
if (num_ths < 0) {
@@ -4209,7 +4218,7 @@ process_status_dpage(int sg_fd, int page_code, uint8_t * resp, int resp_len,
resp[1] & 1, (resp[1] >> 1) & 0xff);
break;
case ADD_ELEM_STATUS_DPC:
- num_ths = build_type_desc_hdr_arr(sg_fd, type_desc_hdr_arr,
+ num_ths = build_type_desc_hdr_arr(ptvp, type_desc_hdr_arr,
MX_ELEM_HDR, &ref_gen_code,
&primary_info, op);
if (num_ths < 0) {
@@ -4255,7 +4264,7 @@ fini:
/* Display "status" page or pages (if op->page_code==0xff) . data-in from
* SES device or user provided (with --data= option). Return 0 for success */
static int
-process_status_page_s(int sg_fd, struct opts_t * op)
+process_status_page_s(struct sg_pt_base * ptvp, struct opts_t * op)
{
int page_code, ret, resp_len;
uint8_t * resp = NULL;
@@ -4276,10 +4285,10 @@ process_status_page_s(int sg_fd, struct opts_t * op)
const int s_arr_sz = sizeof(supp_dpg_arr);
memset(supp_dpg_arr, 0, s_arr_sz);
- ret = do_rec_diag(sg_fd, SUPPORTED_DPC, resp, op->maxlen, op,
+ ret = do_rec_diag(ptvp, SUPPORTED_DPC, resp, op->maxlen, op,
&resp_len);
if (ret) /* SUPPORTED_DPC failed so try SUPPORTED_SES_DPC */
- ret = do_rec_diag(sg_fd, SUPPORTED_SES_DPC, resp, op->maxlen, op,
+ ret = do_rec_diag(ptvp, SUPPORTED_SES_DPC, resp, op->maxlen, op,
&resp_len);
if (ret)
goto fini;
@@ -4301,17 +4310,17 @@ process_status_page_s(int sg_fd, struct opts_t * op)
}
for (k = 0; k < n; ++k) {
page_code = supp_dpg_arr[k];
- ret = do_rec_diag(sg_fd, page_code, resp, op->maxlen, op,
+ ret = do_rec_diag(ptvp, page_code, resp, op->maxlen, op,
&resp_len);
if (ret)
goto fini;
- ret = process_status_dpage(sg_fd, page_code, resp, resp_len, op);
+ ret = process_status_dpage(ptvp, page_code, resp, resp_len, op);
}
} else { /* asking for a specific page code */
- ret = do_rec_diag(sg_fd, page_code, resp, op->maxlen, op, &resp_len);
+ ret = do_rec_diag(ptvp, page_code, resp, op->maxlen, op, &resp_len);
if (ret)
goto fini;
- ret = process_status_dpage(sg_fd, page_code, resp, resp_len, op);
+ ret = process_status_dpage(ptvp, page_code, resp, resp_len, op);
}
fini:
@@ -4785,7 +4794,7 @@ join_juggle_aes(struct th_es_t * tesp, uint8_t * es_bp, const uint8_t * ed_bp,
* stderr when op->verbose > 3. Returns 0 for success, any other return value
* is an error. */
static int
-join_work(int sg_fd, struct opts_t * op, bool display)
+join_work(struct sg_pt_base * ptvp, struct opts_t * op, bool display)
{
bool broken_ei;
int j, res, num_ths, mlen;
@@ -4802,7 +4811,7 @@ join_work(int sg_fd, struct opts_t * op, bool display)
struct th_es_t tes;
memset(&primary_info, 0, sizeof(primary_info));
- num_ths = build_type_desc_hdr_arr(sg_fd, type_desc_hdr_arr, MX_ELEM_HDR,
+ num_ths = build_type_desc_hdr_arr(ptvp, type_desc_hdr_arr, MX_ELEM_HDR,
&ref_gen_code, &primary_info, op);
if (num_ths < 0)
return num_ths;
@@ -4819,7 +4828,7 @@ join_work(int sg_fd, struct opts_t * op, bool display)
mlen = enc_stat_rsp_sz;
if (mlen > op->maxlen)
mlen = op->maxlen;
- res = do_rec_diag(sg_fd, ENC_STATUS_DPC, enc_stat_rsp, mlen, op,
+ res = do_rec_diag(ptvp, ENC_STATUS_DPC, enc_stat_rsp, mlen, op,
&enc_stat_rsp_len);
if (res)
return res;
@@ -4838,7 +4847,7 @@ join_work(int sg_fd, struct opts_t * op, bool display)
mlen = elem_desc_rsp_sz;
if (mlen > op->maxlen)
mlen = op->maxlen;
- res = do_rec_diag(sg_fd, ELEM_DESC_DPC, elem_desc_rsp, mlen, op,
+ res = do_rec_diag(ptvp, ELEM_DESC_DPC, elem_desc_rsp, mlen, op,
&elem_desc_rsp_len);
if (0 == res) {
if (elem_desc_rsp_len < 8) {
@@ -4866,7 +4875,7 @@ join_work(int sg_fd, struct opts_t * op, bool display)
mlen = add_elem_rsp_sz;
if (mlen > op->maxlen)
mlen = op->maxlen;
- res = do_rec_diag(sg_fd, ADD_ELEM_STATUS_DPC, add_elem_rsp, mlen, op,
+ res = do_rec_diag(ptvp, ADD_ELEM_STATUS_DPC, add_elem_rsp, mlen, op,
&add_elem_rsp_len);
if (0 == res) {
if (add_elem_rsp_len < 8) {
@@ -4904,7 +4913,7 @@ join_work(int sg_fd, struct opts_t * op, bool display)
mlen = threshold_rsp_sz;
if (mlen > op->maxlen)
mlen = op->maxlen;
- res = do_rec_diag(sg_fd, THRESHOLD_DPC, threshold_rsp, mlen, op,
+ res = do_rec_diag(ptvp, THRESHOLD_DPC, threshold_rsp, mlen, op,
&threshold_rsp_len);
if (0 == res) {
if (threshold_rsp_len < 8) {
@@ -5013,7 +5022,7 @@ is_acronym_in_additional(const struct tuple_acronym_val * tavp)
* Do clear/get/set (cgs) on Enclosure Control/Status page. Return 0 for ok
* -2 for acronym not found, else -1 . */
static int
-cgs_enc_ctl_stat(int sg_fd, struct join_row_t * jrp,
+cgs_enc_ctl_stat(struct sg_pt_base * ptvp, struct join_row_t * jrp,
const struct tuple_acronym_val * tavp,
const struct opts_t * op, bool last)
{
@@ -5074,7 +5083,7 @@ cgs_enc_ctl_stat(int sg_fd, struct join_row_t * jrp,
enc_stat_rsp[1] = op->byte1;
len = sg_get_unaligned_be16(enc_stat_rsp + 2) + 4;
if (last) {
- ret = do_senddiag(sg_fd, enc_stat_rsp, len, ! op->quiet,
+ ret = do_senddiag(ptvp, enc_stat_rsp, len, ! op->quiet,
op->verbose);
if (ret) {
pr2serr("couldn't send Enclosure Control page\n");
@@ -5089,7 +5098,7 @@ cgs_enc_ctl_stat(int sg_fd, struct join_row_t * jrp,
* Do clear/get/set (cgs) on Threshold In/Out page. Return 0 for ok,
* -2 for acronym not found, else -1 . */
static int
-cgs_threshold(int sg_fd, const struct join_row_t * jrp,
+cgs_threshold(struct sg_pt_base * ptvp, const struct join_row_t * jrp,
const struct tuple_acronym_val * tavp,
const struct opts_t * op, bool last)
{
@@ -5132,7 +5141,7 @@ cgs_threshold(int sg_fd, const struct join_row_t * jrp,
threshold_rsp[1] = op->byte1;
len = sg_get_unaligned_be16(threshold_rsp + 2) + 4;
if (last) {
- ret = do_senddiag(sg_fd, threshold_rsp, len, ! op->quiet,
+ ret = do_senddiag(ptvp, threshold_rsp, len, ! op->quiet,
op->verbose);
if (ret) {
pr2serr("couldn't send Threshold Out page\n");
@@ -5194,7 +5203,7 @@ cgs_additional_el(const struct join_row_t * jrp,
/* Do --clear, --get or --set .
* Returns 0 for success, any other return value is an error. */
static int
-ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
+ses_cgs(struct sg_pt_base * ptvp, const struct tuple_acronym_val * tavp,
struct opts_t * op, bool last)
{
int ret, k, j, desc_len, dn_len;
@@ -5203,7 +5212,7 @@ ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
const uint8_t * ed_bp;
char b[64];
- if ((sg_fd < 0) && (GET_OPT != tavp->cgs_sel)) {
+ if ((NULL == ptvp) && (GET_OPT != tavp->cgs_sel)) {
pr2serr("%s: --clear= and --set= only supported when DEVICE is "
"given\n", __func__);
return SG_LIB_SYNTAX_ERROR;
@@ -5240,7 +5249,7 @@ ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
return -1;
}
if (false == join_done) {
- ret = join_work(sg_fd, op, false);
+ ret = join_work(ptvp, op, false);
if (ret)
return ret;
}
@@ -5278,9 +5287,9 @@ ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
continue;
}
if (ENC_CONTROL_DPC == op->page_code)
- ret = cgs_enc_ctl_stat(sg_fd, jrp, tavp, op, last);
+ ret = cgs_enc_ctl_stat(ptvp, jrp, tavp, op, last);
else if (THRESHOLD_DPC == op->page_code)
- ret = cgs_threshold(sg_fd, jrp, tavp, op, last);
+ ret = cgs_threshold(ptvp, jrp, tavp, op, last);
else if (ADD_ELEM_STATUS_DPC == op->page_code)
ret = cgs_additional_el(jrp, tavp, op);
else {
@@ -5322,20 +5331,20 @@ inconsistent:
* the generation code. Returns 0 for success, any other return value is
* an error. */
static int
-ses_set_nickname(int sg_fd, struct opts_t * op)
+ses_set_nickname(struct sg_pt_base * ptvp, struct opts_t * op)
{
int res, len;
int resp_len = 0;
uint8_t b[64];
const int control_plen = 0x24;
- if (sg_fd < 0) {
+ if (NULL == ptvp) {
pr2serr("%s: ignored when no device name\n", __func__);
return 0;
}
memset(b, 0, sizeof(b));
/* Only after the generation code, offset 4 for 4 bytes */
- res = do_rec_diag(sg_fd, SUBENC_NICKNAME_DPC, b, 8, op, &resp_len);
+ res = do_rec_diag(ptvp, SUBENC_NICKNAME_DPC, b, 8, op, &resp_len);
if (res) {
pr2serr("%s: Subenclosure nickname status page, res=%d\n", __func__,
res);
@@ -5360,7 +5369,7 @@ ses_set_nickname(int sg_fd, struct opts_t * op)
if (len > 32)
len = 32;
memcpy(b + 8, op->nickname_str, len);
- return do_senddiag(sg_fd, b, control_plen + 4, ! op->quiet,
+ return do_senddiag(ptvp, b, control_plen + 4, ! op->quiet,
op->verbose);
}
@@ -5466,7 +5475,7 @@ int
main(int argc, char * argv[])
{
bool have_cgs = false;
- int k, d_len, res, vb;
+ int k, d_len, res, resid, vb;
int sg_fd = -1;
int pd_type = 0;
int ret = 0;
@@ -5479,10 +5488,10 @@ main(int argc, char * argv[])
uint8_t * free_elem_desc_rsp = NULL;
uint8_t * free_add_elem_rsp = NULL;
uint8_t * free_threshold_rsp = NULL;
+ struct sg_pt_base * ptvp = NULL;
struct tuple_acronym_val tav_arr[CGS_CL_ARR_MAX_SZ];
- struct sg_simple_inquiry_resp inq_resp;
char buff[128];
- char b[80];
+ char b[128];
op = &opts;
memset(op, 0, sizeof(*op));
@@ -5610,46 +5619,131 @@ main(int argc, char * argv[])
if (sg_fd < 0) {
pr2serr("open error: %s: %s\n", op->dev_name,
safe_strerror(-sg_fd));
- ret = SG_LIB_FILE_ERROR;
+ ret = sg_convert_errno(-sg_fd);
+ goto err_out;
+ }
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, vb);
+ if (NULL == ptvp) {
+ pr2serr("construct pt_base failed, probably out of memory\n");
+ ret = sg_convert_errno(ENOMEM);
goto err_out;
}
if (! (op->do_raw || have_cgs || (op->do_hex > 2))) {
- if ((ret = sg_simple_inquiry(sg_fd, &inq_resp, ! op->quiet, vb))) {
+ if ((ret = sg_ll_inquiry_pt(ptvp, false, 0, enc_stat_rsp, 36,
+ 0, &resid, ! op->quiet, vb))) {
pr2serr("%s doesn't respond to a SCSI INQUIRY\n",
op->dev_name);
goto err_out;
} else {
- printf(" %.8s %.16s %.4s\n", inq_resp.vendor,
- inq_resp.product, inq_resp.revision);
- pd_type = inq_resp.peripheral_type;
+ if (resid > 0)
+ pr2serr("Short INQUIRY response, not looking good\n");
+ printf(" %.8s %.16s %.4s\n", enc_stat_rsp + 8,
+ enc_stat_rsp + 16, enc_stat_rsp + 32);
+ pd_type = 0x1f & enc_stat_rsp[0];
cp = sg_get_pdt_str(pd_type, sizeof(buff), buff);
if (0xd == pd_type) {
if (vb)
printf(" enclosure services device\n");
- } else if (0x40 & inq_resp.byte_6)
+ } else if (0x40 & enc_stat_rsp[6])
printf(" %s device has EncServ bit set\n", cp);
- else
- printf(" %s device (not an enclosure)\n", cp);
+ else {
+ if (0 != memcmp("NVMe", enc_stat_rsp + 8, 4))
+ printf(" %s device (not an enclosure)\n", cp);
+ }
}
+ clear_scsi_pt_obj(ptvp);
+ /* finished using enc_stat_rsp so clear back to zero */
+ memset(enc_stat_rsp, 0, enc_stat_rsp_sz);
}
} else if (op->do_control) {
pr2serr("Cannot do SCSI Send diagnostic command without a DEVICE\n");
return SG_LIB_SYNTAX_ERROR;
}
+#if (HAVE_NVME && (! IGNORE_NVME))
+ if (ptvp && pt_device_is_nvme(ptvp) && (enc_stat_rsp_sz > 4095)) {
+ /* Fetch VPD 0xde (vendor specific: sg3_utils) for Identify ctl */
+ ret = sg_ll_inquiry_pt(ptvp, true, 0xde, enc_stat_rsp, 4096, 0,
+ &resid, ! op->quiet, vb);
+ if (ret) {
+ if (vb)
+ pr2serr("Fetch VPD page 0xde (NVMe Identify ctl) failed, "
+ "continue\n");
+ } else if (resid > 0) {
+ if (vb)
+ pr2serr("VPD page 0xde (NVMe Identify ctl) less than 4096 "
+ "bytes, continue\n");
+ } else {
+ uint8_t nvmsr;
+ uint16_t oacs;
+
+ nvmsr = enc_stat_rsp[253];
+ oacs = sg_get_unaligned_le16(enc_stat_rsp + 256);
+ if (vb > 3)
+ pr2serr("NVMe Identify ctl response: nvmsr=%u, oacs=0x%x\n",
+ nvmsr, oacs);
+ if (! ((0x2 & nvmsr) && (0x40 & oacs))) {
+ pr2serr(">>> Warning: A NVMe enclosure needs both the "
+ "enclosure bit and support for\n");
+ pr2serr(">>> MI Send+Receive commands bit set; current "
+ "state: %s, %s\n", (0x2 & nvmsr) ? "set" : "clear",
+ (0x40 & oacs) ? "set" : "clear");
+ }
+ }
+ clear_scsi_pt_obj(ptvp);
+ memset(enc_stat_rsp, 0, 4096);
+ }
+#endif
+
+ if (ptvp) {
+ ret = sg_ll_request_sense_pt(ptvp, false, enc_stat_rsp,
+ REQUEST_SENSE_RESP_SZ, ! op->quiet, vb);
+ if (0 == ret) {
+ int sense_len = REQUEST_SENSE_RESP_SZ - get_scsi_pt_resid(ptvp);
+ struct sg_scsi_sense_hdr ssh;
+
+ if ((sense_len > 7) && sg_scsi_normalize_sense(enc_stat_rsp,
+ sense_len, &ssh)) {
+ const char * aa_str = sg_get_asc_ascq_str(ssh.asc, ssh.ascq,
+ sizeof(b), b);
+
+ /* Ignore the possibility that multiple UAs queued up */
+ if (SPC_SK_UNIT_ATTENTION == ssh.sense_key)
+ pr2serr("Unit attention detected: %s\n ... continue\n",
+ aa_str);
+ else {
+ if (vb) {
+ pr2serr("Request Sense near startup detected "
+ "something:\n");
+ pr2serr(" Sense key: %s, additional: %s\n ... "
+ "continue\n",
+ sg_get_sense_key_str(ssh.sense_key,
+ sizeof(buff), buff), aa_str);
+ }
+ }
+ }
+ } else {
+ if (vb)
+ pr2serr("Request sense failed (res=%d), most likely "
+ " problems ahead\n", ret);
+ }
+ clear_scsi_pt_obj(ptvp);
+ memset(enc_stat_rsp, 0, REQUEST_SENSE_RESP_SZ);
+ }
+
if (op->nickname_str)
- ret = ses_set_nickname(sg_fd, op);
+ ret = ses_set_nickname(ptvp, op);
else if (have_cgs) {
for (k = 0, tavp = tav_arr, cgs_clp = op->cgs_cl_arr;
k < op->num_cgs; ++k, ++tavp, ++cgs_clp) {
- ret = ses_cgs(sg_fd, tavp, op, cgs_clp->last_cs);
+ ret = ses_cgs(ptvp, tavp, op, cgs_clp->last_cs);
if (ret)
break;
}
} else if (op->do_join)
- ret = join_work(sg_fd, op, true);
+ ret = join_work(ptvp, op, true);
else if (op->do_status)
- ret = process_status_page_s(sg_fd, op);
+ ret = process_status_page_s(ptvp, op);
else { /* control page requested */
op->data_arr[0] = op->page_code;
op->data_arr[1] = op->byte1;
@@ -5659,7 +5753,7 @@ main(int argc, char * argv[])
case ENC_CONTROL_DPC: /* Enclosure Control diagnostic page [0x2] */
printf("Sending Enclosure Control [0x%x] page, with page "
"length=%d bytes\n", op->page_code, op->arr_len);
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send Enclosure Control page\n");
goto err_out;
@@ -5668,7 +5762,7 @@ main(int argc, char * argv[])
case STRING_DPC: /* String Out diagnostic page [0x4] */
printf("Sending String Out [0x%x] page, with page length=%d "
"bytes\n", op->page_code, op->arr_len);
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send String Out page\n");
goto err_out;
@@ -5677,7 +5771,7 @@ main(int argc, char * argv[])
case THRESHOLD_DPC: /* Threshold Out diagnostic page [0x5] */
printf("Sending Threshold Out [0x%x] page, with page length=%d "
"bytes\n", op->page_code, op->arr_len);
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send Threshold Out page\n");
goto err_out;
@@ -5686,7 +5780,7 @@ main(int argc, char * argv[])
case ARRAY_CONTROL_DPC: /* Array control diagnostic page [0x6] */
printf("Sending Array Control [0x%x] page, with page "
"length=%d bytes\n", op->page_code, op->arr_len);
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send Array Control page\n");
goto err_out;
@@ -5695,7 +5789,7 @@ main(int argc, char * argv[])
case SUBENC_STRING_DPC: /* Subenclosure String Out page [0xc] */
printf("Sending Subenclosure String Out [0x%x] page, with page "
"length=%d bytes\n", op->page_code, op->arr_len);
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send Subenclosure String Out page\n");
goto err_out;
@@ -5706,7 +5800,7 @@ main(int argc, char * argv[])
"page length=%d bytes\n", op->page_code, d_len);
printf(" Perhaps it would be better to use the sg_ses_microcode "
"utility\n");
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send Download Microcode Control page\n");
goto err_out;
@@ -5715,7 +5809,7 @@ main(int argc, char * argv[])
case SUBENC_NICKNAME_DPC: /* Subenclosure Nickname Control [0xf] */
printf("Sending Subenclosure Nickname Control [0x%x] page, with "
"page length=%d bytes\n", op->page_code, d_len);
- ret = do_senddiag(sg_fd, op->data_arr, d_len, ! op->quiet, vb);
+ ret = do_senddiag(ptvp, op->data_arr, d_len, ! op->quiet, vb);
if (ret) {
pr2serr("couldn't send Subenclosure Nickname Control page\n");
goto err_out;
@@ -5754,6 +5848,8 @@ err_out:
ret = SG_LIB_FILE_ERROR;
}
early_out:
+ if (ptvp)
+ destruct_scsi_pt_obj(ptvp);
if ((0 == vb) && (! op->quiet)) {
if (! sg_if_can2stderr("sg_ses failed: ", ret))
pr2serr("Some error occurred, try again with '-v' or '-vv' for "
diff --git a/src/sg_stream_ctl.c b/src/sg_stream_ctl.c
index e278e4a2..f2372ed7 100644
--- a/src/sg_stream_ctl.c
+++ b/src/sg_stream_ctl.c
@@ -33,7 +33,7 @@
* to the given SCSI device. Based on sbc4r15.pdf .
*/
-static const char * version_str = "1.02 20180219";
+static const char * version_str = "1.03 20180427";
#define STREAM_CONTROL_SA 0x14
#define GET_STREAM_STATUS_SA 0x16
@@ -166,7 +166,10 @@ sg_ll_get_stream_status(int sg_fd, uint16_t s_str_id, uint8_t * resp,
}
/* Invokes a SCSI STREAM CONTROL command (SBC-4). Return of 0 -> success,
- * various SG_LIB_CAT_* positive values or -1 -> other errors */
+ * various SG_LIB_CAT_* positive values or -1 -> other errors.
+ * N.B. The is a device modifying command that is SERVICE ACTION IN(16)
+ * command since it has data-in buffer that for open returns the
+ * ASSIGNED_STR_ID field . */
static int
sg_ll_stream_control(int sg_fd, uint32_t str_ctl, uint16_t str_id,
uint8_t * resp, uint32_t alloc_len, int * residp,
@@ -202,12 +205,9 @@ sg_ll_stream_control(int sg_fd, uint32_t str_ctl, uint16_t str_id,
res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
ret = sg_cmds_process_resp(ptvp, cmd_name, res, alloc_len, sense_b,
noisy, verbose, &sense_cat);
- if (-1 == ret) {
- int os_err = get_scsi_pt_os_err(ptvp);
-
- if ((os_err > 0) && (os_err < 47))
- ret = SG_LIB_OS_BASE_ERR + os_err;
- } else if (-2 == ret) {
+ if (-1 == ret)
+ ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
+ else if (-2 == ret) {
switch (sense_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
@@ -378,7 +378,7 @@ main(int argc, char * argv[])
arr = sg_memalign(pg_sz, pg_sz, &free_arr, verbose > 3);
if (NULL == arr) {
pr2serr("Unable to allocate space for response\n");
- return SG_LIB_OS_BASE_ERR + ENOMEM;
+ return sg_convert_errno(ENOMEM);
}
resid = 0;
diff --git a/src/sg_test_rwbuf.c b/src/sg_test_rwbuf.c
index 7bd5d962..c680ae4b 100644
--- a/src/sg_test_rwbuf.c
+++ b/src/sg_test_rwbuf.c
@@ -29,6 +29,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -44,7 +45,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "1.15 20180219";
+static const char * version_str = "1.16 20180428";
#define BPI (signed)(sizeof(int))
@@ -64,6 +65,7 @@ static int base = 0x12345678;
static int buf_capacity = 0;
static int buf_granul = 255;
static uint8_t *cmpbuf = NULL;
+static uint8_t *free_cmpbuf = NULL;
/* Options */
@@ -229,7 +231,9 @@ int read_buffer (int sg_fd, unsigned ssize)
int res, k;
uint8_t rb_cdb[] = {READ_BUFFER, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int bufSize = ssize + addread;
- uint8_t * rbBuff = (uint8_t *)malloc(bufSize);
+ uint8_t * free_rbBuff = NULL;
+ uint8_t * rbBuff = (uint8_t *)sg_memalign(bufSize, 0, &free_rbBuff,
+ false);
uint8_t sense_buffer[32];
struct sg_io_hdr io_hdr;
@@ -280,7 +284,8 @@ int read_buffer (int sg_fd, unsigned ssize)
}
res = do_checksum((int*)rbBuff, ssize, false);
- free(rbBuff);
+ if (free_rbBuff)
+ free(free_rbBuff);
return res;
}
@@ -288,7 +293,9 @@ int write_buffer (int sg_fd, unsigned ssize)
{
uint8_t wb_cdb[] = {WRITE_BUFFER, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int bufSize = ssize + addwrite;
- uint8_t * wbBuff = (uint8_t *)malloc(bufSize);
+ uint8_t * free_wbBuff = NULL;
+ uint8_t * wbBuff = (uint8_t *)sg_memalign(bufSize, 0, &free_wbBuff,
+ false);
uint8_t sense_buffer[32];
struct sg_io_hdr io_hdr;
int k, res;
@@ -340,7 +347,8 @@ int write_buffer (int sg_fd, unsigned ssize)
free(wbBuff);
return res;
}
- free(wbBuff);
+ if (free_wbBuff)
+ free(free_wbBuff);
return res;
}
@@ -511,7 +519,7 @@ int main (int argc, char * argv[])
goto err_out;
}
- cmpbuf = (uint8_t *)malloc(size);
+ cmpbuf = (uint8_t *)sg_memalign(size, 0, &free_cmpbuf, false);
for (k = 0; k < times; ++k) {
ret = write_buffer (sg_fd, size);
if (ret) {
@@ -526,8 +534,8 @@ int main (int argc, char * argv[])
}
err_out:
- if (cmpbuf)
- free(cmpbuf);
+ if (free_cmpbuf)
+ free(free_cmpbuf);
res = close(sg_fd);
if (res < 0) {
perror(ME "close error");
diff --git a/src/sg_timestamp.c b/src/sg_timestamp.c
index 17105976..976bca56 100644
--- a/src/sg_timestamp.c
+++ b/src/sg_timestamp.c
@@ -35,7 +35,7 @@
* to the given SCSI device. Based on spc5r07.pdf .
*/
-static const char * version_str = "1.07 20180219";
+static const char * version_str = "1.08 20180502";
#define REP_TIMESTAMP_CMDLEN 12
#define SET_TIMESTAMP_CMDLEN 12
@@ -53,8 +53,12 @@ uint8_t d_buff[256];
static struct option long_options[] = {
+ {"elapsed", no_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
+ {"hex", no_argument, 0, 'H'},
{"milliseconds", required_argument, 0, 'm'},
+ {"no_timestamp", no_argument, 0, 'N'},
+ {"no-timestamp", no_argument, 0, 'N'},
{"origin", no_argument, 0, 'o'},
{"raw", no_argument, 0, 'r'},
{"readonly", no_argument, 0, 'R'},
@@ -79,20 +83,38 @@ static const char * ts_origin_arr[] = {
static void
-usage()
+usage(int num)
{
+ if (num > 1)
+ goto page2;
+
pr2serr("Usage: "
- "sg_timestamp [--help] [--milliseconds=MS] [--origin] [--raw]\n"
- " [--readonly] [--seconds=SEC] [--srep] "
- "[--verbose]\n"
- " [--version] DEVICE\n");
+ "sg_timestamp [--elapsed] [--help] [--hex] [--milliseconds=MS]\n"
+ " [--no-timestamp] [--origin] [--raw] "
+ "[--readonly]\n"
+ " [--seconds=SEC] [--srep] [--verbose] "
+ "[--version]\n"
+ " DEVICE\n"
+ );
pr2serr(" where:\n"
- " --help|-h print out usage message\n"
+ " --elapsed|-e show time as '<n> days hh.mm.ss.xxx' "
+ "where\n"
+ " '.xxx' is the remainder milliseconds. "
+ "Don't show\n"
+ " '<n> days' if <n> is 0 (unless '-e' "
+ "given twice)\n"
+ " --help|-h print out usage message, use twice for "
+ "examples\n"
+ " --hex|-H output response in ASCII hexadecimal\n"
" --milliseconds=MS|-m MS set timestamp to MS "
"milliseconds since\n"
" 1970-01-01 00:00:00 UTC\n"
+ " --no-timestamp|-N suppress output of timestamp\n"
" --origin|-o show Report timestamp origin "
"(def: don't)\n"
+ " used twice outputs value of field\n"
+ " 0: power up or hard reset; 2: SET "
+ "TIMESTAMP\n"
" --raw|-r output Report timestamp response to "
"stdout in\n"
" binary\n"
@@ -106,17 +128,62 @@ usage()
" milliseconds)\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
- "Performs a SCSI REPORT TIMESTAMP or SET TIMESTAMP command. "
+ );
+ pr2serr("Performs a SCSI REPORT TIMESTAMP or SET TIMESTAMP command. "
"The timestamp\nis SET if either the --milliseconds=MS or "
"--seconds=SEC option is given,\notherwise the existing "
- "timestamp is reported. The DEVICE stores the\ntimestamp as "
- "the number of milliseconds since power up (or reset) or\n"
- "since 1970-01-01 00:00:00 UTC which also happens to be the "
- "time 'epoch'\nof Unix machines. The 'date +%%s' command in "
+ "timestamp is reported in milliseconds. The\nDEVICE stores "
+ "the timestamp as the number of milliseconds since power up\n"
+ "(or reset) or since 1970-01-01 00:00:00 UTC which also "
+ "happens to\nbe the time 'epoch'of Unix machines.\n\n"
+ "Use '-hh' (the '-h' option twice) for examples.\n"
+#if 0
+ "The 'date +%%s' command in "
"Unix returns the number of\nseconds since the epoch. To "
"convert a reported timestamp (in seconds since\nthe epoch) "
"to a more readable form use "
- "'date --date='@<secs_since_epoch>' .\n");
+ "'date --date=@<secs_since_epoch>' .\n"
+#endif
+ );
+ return;
+page2:
+ pr2serr("sg_timestamp examples:\n"
+ "It is possible that the target device containing a SCSI "
+ "Logical Unit (LU)\nhas a battery (or supercapacitor) to "
+ "keep its RTC (real time clock)\nticking during a power "
+ "outage. More likely it doesn't and its RTC is\ncleared to "
+ "zero after a power cycle or hard reset.\n\n"
+ "Either way REPORT TIMESTAMP returns a 48 bit counter value "
+ "whose unit is\na millisecond. A heuristic to determine if a "
+ "date or elapsed time is\nbeing returned is to choose a date "
+ "like 1 January 2000 which is 30 years\nafter the Unix epoch "
+ "(946,684,800,000 milliseconds) and values less than\nthat are "
+ "elapsed times and greater are timestamps. Observing the "
+ "TIMESTAMP\nORIGIN field of REPORT TIMESTAMP is a better "
+ "method:\n\n"
+ );
+ pr2serr(" $ sg_timestamp -o -N /dev/sg1\n"
+ "Device clock initialized to zero at power on or by hard "
+ "reset\n"
+ " $ sg_timestamp -oo -N /dev/sg1\n"
+ "0\n\n"
+ " $ sg_timestamp /dev/sg1\n"
+ "3984499\n"
+ " $ sg_timestamp --elapsed /dev/sg1\n"
+ "01:06:28.802\n\n"
+ "The last output indicates an elapsed time of 1 hour, 6 minutes "
+ "and 28.802\nseconds. Next set the clock to the current time:\n\n"
+ " $ sg_timestamp --seconds=`date +%%s` /dev/sg1\n\n"
+ " $ sg_timestamp -o -N /dev/sg1\n"
+ "Device clock initialized by SET TIMESTAMP command\n\n"
+ "Now show that as an elapsed time:\n\n"
+ " $ sg_timestamp -e /dev/sg1\n"
+ "17652 days 20:53:22.545\n\n"
+ "That is over 48 years worth of days. Lets try again as a "
+ "data-time\nstamp in UTC:\n\n"
+ " $ date -u -R --date=@`sg_timestamp -S /dev/sg1`\n"
+ "Tue, 01 May 2018 20:56:38 +0000\n"
+ );
}
/* Invokes a SCSI REPORT TIMESTAMP command. Return of 0 -> success,
@@ -244,12 +311,16 @@ dStrRaw(const uint8_t * str, int len)
int
main(int argc, char * argv[])
{
- bool do_origin = false;
bool do_srep = false;
bool do_raw = false;
+ bool no_timestamp = false;
bool readonly = false;
bool secs_given = false;
int sg_fd, res, c;
+ int elapsed = 0;
+ int do_origin = 0;
+ int do_help = 0;
+ int do_hex = 0;
int do_set = 0;
int ret = 0;
int verbose = 0;
@@ -262,16 +333,22 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "hm:orRs:SvV", long_options,
+ c = getopt_long(argc, argv, "ehHm:NorRs:SvV", long_options,
&option_index);
if (c == -1)
break;
switch (c) {
+ case 'e':
+ ++elapsed;
+ break;
case 'h':
case '?':
- usage();
- return 0;
+ ++do_help;
+ break;
+ case 'H':
+ ++do_hex;
+ break;
case 'm':
ll = sg_get_llnum(optarg);
if (-1 == ll) {
@@ -281,8 +358,11 @@ main(int argc, char * argv[])
msecs = (uint64_t)ll;
++do_set;
break;
+ case 'N':
+ no_timestamp = true;
+ break;
case 'o':
- do_origin = true;
+ ++do_origin;
break;
case 'r':
do_raw = true;
@@ -311,7 +391,7 @@ main(int argc, char * argv[])
return 0;
default:
pr2serr("unrecognised option code 0x%x ??\n", c);
- usage();
+ usage(1);
return SG_LIB_SYNTAX_ERROR;
}
}
@@ -323,21 +403,25 @@ main(int argc, char * argv[])
if (optind < argc) {
for (; optind < argc; ++optind)
pr2serr("Unexpected extra argument: %s\n", argv[optind]);
- usage();
+ usage(1);
return SG_LIB_SYNTAX_ERROR;
}
}
+ if (do_help) {
+ usage(do_help);
+ return 0;
+ }
if (do_set > 1) {
pr2serr("either --milliseconds=MS or --seconds=SEC may be given, "
"not both\n");
- usage();
+ usage(1);
return SG_LIB_SYNTAX_ERROR;
}
if (NULL == device_name) {
- pr2serr("missing device name!\n");
- usage();
+ pr2serr("missing device name!\n\n");
+ usage(1);
return SG_LIB_SYNTAX_ERROR;
}
@@ -359,17 +443,42 @@ main(int argc, char * argv[])
if (0 == res) {
if (do_raw)
dStrRaw(d_buff, 12);
+ else if (do_hex)
+ hex2stderr(d_buff, 12, 1);
else {
int len = sg_get_unaligned_be16(d_buff + 0);
+
if (len < 8)
pr2serr("timestamp parameter data length too short, "
"expect >= 10, got %d\n", len + 2);
else {
- if (do_origin)
- printf("Device clock %s\n",
- ts_origin_arr[0x7 & d_buff[2]]);
- msecs = sg_get_unaligned_be48(d_buff + 4);
- printf("%" PRIu64 "\n", do_srep ? (msecs / 1000) : msecs);
+ if (do_origin) {
+ if (1 == do_origin)
+ printf("Device clock %s\n",
+ ts_origin_arr[0x7 & d_buff[2]]);
+ else if (2 == do_origin)
+ printf("%d\n", 0x7 & d_buff[2]);
+ else
+ printf("TIMESTAMP_ORIGIN=%d\n", 0x7 & d_buff[2]);
+ }
+ if (! no_timestamp) {
+ msecs = sg_get_unaligned_be48(d_buff + 4);
+ if (elapsed) {
+ int days = (int)(msecs / 1000 / 60 / 60 / 24);
+ int hours = (int)(msecs / 1000 / 60 / 60 % 24);
+ int mins = (int)(msecs / 1000 / 60 % 60);
+ int secs_in_min =(int)( msecs / 1000 % 60);
+ int rem_msecs = (int)(msecs % 1000);
+
+ if ((elapsed > 1) || (days > 0))
+ printf("%d day%s ", days,
+ ((1 == days) ? "" : "s"));
+ printf("%02d:%02d:%02d.%03d\n", hours, mins,
+ secs_in_min, rem_msecs);
+ } else
+ printf("%" PRIu64 "\n", do_srep ?
+ (msecs / 1000) : msecs);
+ }
}
}
}
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index 1aad48df..2e2d7081 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -856,6 +856,9 @@ decode_mode_policy_vpd(uint8_t * buff, int len, int do_hex)
printf(", subpage code: 0x%x\n", bp[1]);
else
printf("\n");
+ if ((0 == k) && (0x3f == (0x3f & bp[0])) && (0xff == bp[1]))
+ printf(" therefore the policy applies to all modes pages "
+ "and subpages\n");
printf(" MLUS=%d, Policy: %s\n", !!(bp[2] & 0x80),
mode_page_policy_arr[bp[2] & 0x3]);
}
diff --git a/src/sg_write_long.c b/src/sg_write_long.c
index 8b01c1a7..b6f9e694 100644
--- a/src/sg_write_long.c
+++ b/src/sg_write_long.c
@@ -35,20 +35,21 @@
#include "sg_cmds_extra.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.16 20180219";
+static const char * version_str = "1.17 20180502";
-#define MAX_XFER_LEN 10000
+#define MAX_XFER_LEN (15 * 1024)
/* #define SG_DEBUG */
#define ME "sg_write_long: "
-#define EBUFF_SZ 256
+#define EBUFF_SZ 512
static struct option long_options[] = {
{"16", no_argument, 0, 'S'},
{"cor_dis", no_argument, 0, 'c'},
+ {"cor-dis", no_argument, 0, 'c'},
{"help", no_argument, 0, 'h'},
{"in", required_argument, 0, 'i'},
{"lba", required_argument, 0, 'l'},
@@ -56,7 +57,9 @@ static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"wr_uncor", no_argument, 0, 'w'},
+ {"wr-uncor", no_argument, 0, 'w'},
{"xfer_len", required_argument, 0, 'x'},
+ {"xfer-len", required_argument, 0, 'x'},
{0, 0, 0, 0},
};
@@ -111,6 +114,7 @@ main(int argc, char * argv[])
const char * device_name = NULL;
uint8_t * writeLongBuff = NULL;
void * rawp = NULL;
+ uint8_t * free_rawp = NULL;
const char * ten_or;
char file_name[256];
char b[80];
@@ -209,9 +213,9 @@ main(int argc, char * argv[])
pr2serr(">>> warning: when '--wr_uncor' given '-in=' is "
"ignored\n");
} else {
- if (NULL == (rawp = malloc(MAX_XFER_LEN))) {
+ if (NULL == (rawp = sg_memalign(MAX_XFER_LEN, 0, &free_rawp, false))) {
pr2serr(ME "out of memory\n");
- ret = SG_LIB_FILE_ERROR;
+ ret = sg_convert_errno(ENOMEM);
goto err_out;
}
writeLongBuff = (uint8_t *)rawp;
@@ -279,8 +283,8 @@ main(int argc, char * argv[])
}
err_out:
- if (rawp)
- free(rawp);
+ if (free_rawp)
+ free(free_rawp);
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
pr2serr("close error: %s\n", safe_strerror(-res));
diff --git a/src/sg_write_same.c b/src/sg_write_same.c
index d2176395..2d6d241a 100644
--- a/src/sg_write_same.c
+++ b/src/sg_write_same.c
@@ -31,7 +31,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.21 20180219";
+static const char * version_str = "1.22 20180425";
#define ME "sg_write_same: "
@@ -317,6 +317,7 @@ main(int argc, char * argv[])
const char * device_name = NULL;
struct opts_t * op;
uint8_t * wBuff = NULL;
+ uint8_t * free_wBuff = NULL;
char ebuff[EBUFF_SZ];
char b[80];
uint8_t resp_buff[RCAP16_RESP_LEN];
@@ -550,11 +551,11 @@ main(int argc, char * argv[])
ret = SG_LIB_SYNTAX_ERROR;
goto err_out;
}
- wBuff = (uint8_t*)calloc(op->xfer_len, 1);
+ wBuff = (uint8_t *)sg_memalign(op->xfer_len, 0, &free_wBuff, vb > 3);
if (NULL == wBuff) {
- pr2serr("unable to allocate %d bytes of memory with calloc()\n",
- op->xfer_len);
- ret = SG_LIB_SYNTAX_ERROR;
+ pr2serr("unable to allocate %d bytes of memory with "
+ "sg_memalign()\n", op->xfer_len);
+ ret = sg_convert_errno(ENOMEM);
goto err_out;
}
if (op->ifilename[0]) {
@@ -610,8 +611,8 @@ main(int argc, char * argv[])
}
err_out:
- if (wBuff)
- free(wBuff);
+ if (free_wBuff)
+ free(free_wBuff);
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
pr2serr("close error: %s\n", safe_strerror(-res));
diff --git a/src/sg_write_verify.c b/src/sg_write_verify.c
index 00adb6e0..aae62257 100644
--- a/src/sg_write_verify.c
+++ b/src/sg_write_verify.c
@@ -288,7 +288,8 @@ main(int argc, char * argv[])
uint64_t llba = 0;
int64_t ll;
uint8_t * wvb = NULL;
- void * wrkBuff = NULL;
+ uint8_t * wrkBuff = NULL;
+ uint8_t * free_wrkBuff = NULL;
const char * device_name = NULL;
const char * ifnp;
char cmd_name[32];
@@ -497,9 +498,10 @@ main(int argc, char * argv[])
} else if (verbose)
pr2serr("Using file size of %d bytes\n", ilen);
}
- if (NULL == (wrkBuff = malloc(ilen))) {
+ if (NULL == (wrkBuff = (uint8_t *)sg_memalign(ilen, 0,
+ &free_wrkBuff, verbose > 3))) {
pr2serr(ME "out of memory\n");
- ret = SG_LIB_CAT_OTHER;
+ ret = sg_convert_errno(ENOMEM);
goto err_out;
}
wvb = (uint8_t *)wrkBuff;
@@ -523,9 +525,10 @@ main(int argc, char * argv[])
num_lb, 512, 512 * num_lb);
ilen = 512 * num_lb;
}
- if (NULL == (wrkBuff = malloc(ilen))) {
+ if (NULL == (wrkBuff = (uint8_t *)sg_memalign(ilen, 0,
+ &free_wrkBuff, verbose > 3))) {
pr2serr(ME "out of memory\n");
- ret = SG_LIB_CAT_OTHER;
+ ret = sg_convert_errno(ENOMEM);
goto err_out;
}
wvb = (uint8_t *)wrkBuff;
@@ -576,8 +579,8 @@ err_out:
if (repeat)
pr2serr("%d [0x%x] logical blocks written, in total\n", tnum_lb_wr,
tnum_lb_wr);
- if (wrkBuff)
- free(wrkBuff);
+ if (free_wrkBuff)
+ free(free_wrkBuff);
if ((ifd >= 0) && (STDIN_FILENO != ifd))
close(ifd);
res = sg_cmds_close_device(sg_fd);
diff --git a/src/sg_write_x.c b/src/sg_write_x.c
index 71f4d556..3311ad0d 100644
--- a/src/sg_write_x.c
+++ b/src/sg_write_x.c
@@ -36,16 +36,16 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.15 20180329";
+static const char * version_str = "1.16 20180425";
/* Protection Information refers to 8 bytes of extra information usually
* associated with each logical block and is often abbreviated to PI while
* its fields: reference-tag (4 bytes), application-tag (2 bytes) and
* tag-mask (2 bytes) are often abbreviated to RT, AT and TM respectively.
* And the LBA Range Descriptor associated with the WRITE SCATTERED command
- * is abbreviated to RD. A degenerate RD is one where both the LBA and length
- * components are zero; they are not illegal according to T10 but are a
- * little tricky to handle when scanning and little extra information
+ * is abbreviated to RD. A degenerate RD is one where length components,
+ ( and perhaps the LBA, are zero; it is not illegal according to T10 but are
+ * a little tricky to handle when scanning and little extra information
* is provided. */
#define ORWRITE16_OP 0x8b
@@ -1841,7 +1841,7 @@ process_scattered(int sg_fd, int infd, uint32_t if_len, uint32_t if_rlen,
if (NULL == up) {
pr2serr("unable to allocate aligned memory for "
"scatterlist+data\n");
- return SG_LIB_OS_BASE_ERR + ENOMEM;
+ return sg_convert_errno(ENOMEM);
}
ret = bin_read(infd, up, ((if_len < d) ? if_len : d), "IF c1");
if (ret)
@@ -1908,7 +1908,7 @@ process_scattered(int sg_fd, int infd, uint32_t if_len, uint32_t if_rlen,
if (NULL == u2p) {
pr2serr("unable to allocate memory for final "
"scatterlist+data\n");
- ret = SG_LIB_OS_BASE_ERR + ENOMEM;
+ ret = sg_convert_errno(ENOMEM);
goto finii;
}
memcpy(u2p, up, d);
@@ -1943,7 +1943,7 @@ process_scattered(int sg_fd, int infd, uint32_t if_len, uint32_t if_rlen,
if (NULL == up) {
pr2serr("unable to allocate aligned memory for "
"scatterlist+data\n");
- return SG_LIB_OS_BASE_ERR + ENOMEM;
+ return sg_convert_errno(ENOMEM);
}
num_lbard = 0;
sum_num = 0;
@@ -2032,7 +2032,7 @@ process_scattered(int sg_fd, int infd, uint32_t if_len, uint32_t if_rlen,
if (NULL == up) {
pr2serr("unable to allocate aligned memory for "
"scatterlist+data\n");
- ret = SG_LIB_OS_BASE_ERR + ENOMEM;
+ ret = sg_convert_errno(ENOMEM);
goto finii;
}
ret = bin_read(sfr_fd, up, sf_len, "SF");
@@ -2054,7 +2054,7 @@ process_scattered(int sg_fd, int infd, uint32_t if_len, uint32_t if_rlen,
if (NULL == u2p) {
pr2serr("unable to allocate memory for final "
"scatterlist+data\n");
- ret = SG_LIB_OS_BASE_ERR + ENOMEM;
+ ret = sg_convert_errno(ENOMEM);
goto finii;
}
memcpy(u2p, up, dd);
@@ -2096,7 +2096,7 @@ process_scattered(int sg_fd, int infd, uint32_t if_len, uint32_t if_rlen,
if (NULL == up) {
pr2serr("unable to allocate aligned memory for "
"scatterlist+data\n");
- ret = SG_LIB_OS_BASE_ERR + ENOMEM;
+ ret = sg_convert_errno(ENOMEM);
goto finii;
}
for (n = lbard_sz, k = 0; k < (int)addr_arr_len; ++k,
@@ -2562,7 +2562,7 @@ main(int argc, char * argv[])
up = sg_memalign(do_len, 0, &free_up, false);
if (NULL == up) {
pr2serr("unable to allocate %u bytes of memory\n", do_len);
- ret = SG_LIB_OS_BASE_ERR + ENOMEM;
+ ret = sg_convert_errno(ENOMEM);
goto err_out;
}
ret = bin_read(infd, up, ((if_len < do_len) ? if_len : do_len),
diff --git a/src/sginfo.c b/src/sginfo.c
index b466e8f1..6569140a 100644
--- a/src/sginfo.c
+++ b/src/sginfo.c
@@ -374,7 +374,7 @@ struct scsi_cmnd_io
#define SENSE_BUFF_LEN 64
#define CMD_TIMEOUT 60000 /* 60,000 milliseconds (60 seconds) */
-#define EBUFF_SZ 256
+#define EBUFF_SZ 512
#define GENERAL_ERROR 1
diff --git a/src/sgm_dd.c b/src/sgm_dd.c
index 0e2f6483..90729f0a 100644
--- a/src/sgm_dd.c
+++ b/src/sgm_dd.c
@@ -66,7 +66,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "1.51 20171209";
+static const char * version_str = "1.53 20180502";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -680,7 +680,7 @@ process_flags(const char * arg, struct flags_t * fp)
#define STR_SZ 1024
#define INOUTF_SZ 512
-#define EBUFF_SZ 512
+#define EBUFF_SZ 768
int
@@ -1187,24 +1187,18 @@ main(int argc, char * argv[])
if (wrkMmap) {
wrkPos = wrkMmap;
} else {
- if ((FT_RAW == in_type) || (FT_RAW == out_type)) {
- wrkBuff = (uint8_t *)malloc(blk_sz * bpt + psz);
- if (NULL == wrkBuff) {
- pr2serr("Not enough user memory for raw\n");
- return SG_LIB_FILE_ERROR;
- }
+ wrkPos = (uint8_t *)sg_memalign(blk_sz * bpt, 0, &wrkBuff,
+ verbose > 3);
+ if (NULL == wrkPos) {
+ pr2serr("Not enough user memory\n");
+ return sg_convert_errno(ENOMEM);
+ }
+#if 0 /* keep copy of hack below, just in case ... */
/* perhaps use posix_memalign() instead */
+ wrkBuff = (uint8_t *)malloc(blk_sz * bpt + psz);
wrkPos = (uint8_t *)(((sg_uintptr_t)wrkBuff + psz - 1) &
(~(psz - 1)));
- }
- else {
- wrkBuff = (uint8_t *)malloc(blk_sz * bpt);
- if (NULL == wrkBuff) {
- pr2serr("Not enough user memory\n");
- return SG_LIB_FILE_ERROR;
- }
- wrkPos = wrkBuff;
- }
+#endif
}
blocks_per = bpt;
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index df5e12f2..de9697ea 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -60,7 +60,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "5.62 20180219";
+static const char * version_str = "5.63 20180502";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -68,7 +68,6 @@ static const char * version_str = "5.62 20180219";
#define DEF_SCSI_CDBSZ 10
#define MAX_SCSI_CDBSZ 16
-#define ME "sgp_dd: "
/* #define SG_DEBUG */
@@ -97,7 +96,7 @@ static const char * version_str = "5.62 20180219";
#define DEV_NULL_MINOR_NUM 3
-#define EBUFF_SZ 512
+#define EBUFF_SZ 768
struct flags_t {
bool append;
@@ -190,6 +189,8 @@ static int64_t dd_count = -1;
static int num_threads = DEF_NUM_THREADS;
static int exit_status = 0;
+static const char * my_name = "sgp_dd: ";
+
static void
calc_duration_throughput(int contin)
@@ -482,7 +483,7 @@ sig_listen_thread(void * v_clp)
if (shutting_down)
break;
if (SIGINT == sig_number) {
- pr2serr(ME "interrupted by SIGINT\n");
+ pr2serr("%sinterrupted by SIGINT\n", my_name);
guarded_stop_both(clp);
pthread_cond_broadcast(&clp->out_sync_cv);
}
@@ -740,18 +741,18 @@ sg_build_scsi_cdb(uint8_t * cdbp, int cdb_sz, unsigned int blocks,
sg_put_unaligned_be24(0x1fffff & start_block, cdbp + 1);
cdbp[4] = (256 == blocks) ? 0 : (uint8_t)blocks;
if (blocks > 256) {
- pr2serr(ME "for 6 byte commands, maximum number of blocks is "
- "256\n");
+ pr2serr("%sfor 6 byte commands, maximum number of blocks is "
+ "256\n", my_name);
return 1;
}
if ((start_block + blocks - 1) & (~0x1fffff)) {
- pr2serr(ME "for 6 byte commands, can't address blocks beyond "
- "%d\n", 0x1fffff);
+ pr2serr("%sfor 6 byte commands, can't address blocks beyond "
+ "%d\n", my_name, 0x1fffff);
return 1;
}
if (dpo || fua) {
- pr2serr(ME "for 6 byte commands, neither dpo nor fua bits "
- "supported\n");
+ pr2serr("%sfor 6 byte commands, neither dpo nor fua bits "
+ "supported\n", my_name);
return 1;
}
break;
@@ -762,8 +763,8 @@ sg_build_scsi_cdb(uint8_t * cdbp, int cdb_sz, unsigned int blocks,
sg_put_unaligned_be32((uint32_t)start_block, cdbp + 2);
sg_put_unaligned_be16((uint16_t)blocks, cdbp + 7);
if (blocks & (~0xffff)) {
- pr2serr(ME "for 10 byte commands, maximum number of blocks is "
- "%d\n", 0xffff);
+ pr2serr("%sfor 10 byte commands, maximum number of blocks is "
+ "%d\n", my_name, 0xffff);
return 1;
}
break;
@@ -782,8 +783,8 @@ sg_build_scsi_cdb(uint8_t * cdbp, int cdb_sz, unsigned int blocks,
sg_put_unaligned_be32((uint32_t)blocks, cdbp + 10);
break;
default:
- pr2serr(ME "expected cdb size of 6, 10, 12, or 16 but got %d\n",
- cdb_sz);
+ pr2serr("%sexpected cdb size of 6, 10, 12, or 16 but got %d\n",
+ my_name, cdb_sz);
return 1;
}
return 0;
@@ -801,7 +802,8 @@ sg_in_operation(Rq_coll * clp, Rq_elem * rep)
if (1 == res)
err_exit(ENOMEM, "sg starting in command");
else if (res < 0) {
- pr2serr(ME "inputting to sg failed, blk=%" PRId64 "\n", rep->blk);
+ pr2serr("%sinputting to sg failed, blk=%" PRId64 "\n", my_name,
+ rep->blk);
status = pthread_mutex_unlock(&clp->in_mutex);
if (0 != status) err_exit(status, "unlock in_mutex");
guarded_stop_both(clp);
@@ -876,8 +878,8 @@ sg_out_operation(Rq_coll * clp, Rq_elem * rep)
if (1 == res)
err_exit(ENOMEM, "sg starting out command");
else if (res < 0) {
- pr2serr(ME "outputting from sg failed, blk=%" PRId64 "\n",
- rep->blk);
+ pr2serr("%soutputting from sg failed, blk=%" PRId64 "\n",
+ my_name, rep->blk);
status = pthread_mutex_unlock(&clp->out_mutex);
if (0 != status) err_exit(status, "unlock out_mutex");
guarded_stop_both(clp);
@@ -950,8 +952,8 @@ sg_start_io(Rq_elem * rep)
if (sg_build_scsi_cdb(rep->cmd, cdbsz, rep->num_blks, rep->blk,
rep->wr, fua, dpo)) {
- pr2serr(ME "bad cdb build, start_blk=%" PRId64 ", blocks=%d\n",
- rep->blk, rep->num_blks);
+ pr2serr("%sbad cdb build, start_blk=%" PRId64 ", blocks=%d\n",
+ my_name, rep->blk, rep->num_blks);
return -1;
}
memset(hp, 0, sizeof(struct sg_io_hdr));
@@ -1068,17 +1070,17 @@ sg_prepare(int fd, int bs, int bpt)
res = ioctl(fd, SG_GET_VERSION_NUM, &t);
if ((res < 0) || (t < 30000)) {
- pr2serr(ME "sg driver prior to 3.x.y\n");
+ pr2serr("%ssg driver prior to 3.x.y\n", my_name);
return 1;
}
t = bs * bpt;
res = ioctl(fd, SG_SET_RESERVED_SIZE, &t);
if (res < 0)
- perror(ME "SG_SET_RESERVED_SIZE error");
+ perror("sgp_dd: SG_SET_RESERVED_SIZE error");
t = 1;
res = ioctl(fd, SG_SET_FORCE_PACK_ID, &t);
if (res < 0)
- perror(ME "SG_SET_FORCE_PACK_ID error");
+ perror("sgp_dd: SG_SET_FORCE_PACK_ID error");
return 0;
}
@@ -1185,14 +1187,14 @@ main(int argc, char * argv[])
if (0 == strcmp(key,"bpt")) {
rcoll.bpt = sg_get_num(buf);
if (-1 == rcoll.bpt) {
- pr2serr(ME "bad argument to 'bpt='\n");
+ pr2serr("%sbad argument to 'bpt='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
bpt_given = 1;
} else if (0 == strcmp(key,"bs")) {
rcoll.bs = sg_get_num(buf);
if (-1 == rcoll.bs) {
- pr2serr(ME "bad argument to 'bs='\n");
+ pr2serr("%sbad argument to 'bs='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (0 == strcmp(key,"cdbsz")) {
@@ -1206,7 +1208,7 @@ main(int argc, char * argv[])
if (0 != strcmp("-1", buf)) {
dd_count = sg_get_llnum(buf);
if (-1LL == dd_count) {
- pr2serr(ME "bad argument to 'count='\n");
+ pr2serr("%sbad argument to 'count='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} /* treat 'count=-1' as calculate count (same as not given) */
@@ -1225,7 +1227,7 @@ main(int argc, char * argv[])
} else if (0 == strcmp(key,"ibs")) {
ibs = sg_get_num(buf);
if (-1 == ibs) {
- pr2serr(ME "bad argument to 'ibs='\n");
+ pr2serr("%sbad argument to 'ibs='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (strcmp(key,"if") == 0) {
@@ -1236,13 +1238,13 @@ main(int argc, char * argv[])
strncpy(inf, buf, INOUTF_SZ);
} else if (0 == strcmp(key, "iflag")) {
if (process_flags(buf, &rcoll.in_flags)) {
- pr2serr(ME "bad argument to 'iflag='\n");
+ pr2serr("%sbad argument to 'iflag='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (0 == strcmp(key,"obs")) {
obs = sg_get_num(buf);
if (-1 == obs) {
- pr2serr(ME "bad argument to 'obs='\n");
+ pr2serr("%sbad argument to 'obs='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (strcmp(key,"of") == 0) {
@@ -1253,19 +1255,19 @@ main(int argc, char * argv[])
strncpy(outf, buf, INOUTF_SZ);
} else if (0 == strcmp(key, "oflag")) {
if (process_flags(buf, &rcoll.out_flags)) {
- pr2serr(ME "bad argument to 'oflag='\n");
+ pr2serr("%sbad argument to 'oflag='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (0 == strcmp(key,"seek")) {
seek = sg_get_llnum(buf);
if (-1LL == seek) {
- pr2serr(ME "bad argument to 'seek='\n");
+ pr2serr("%sbad argument to 'seek='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (0 == strcmp(key,"skip")) {
skip = sg_get_llnum(buf);
if (-1LL == skip) {
- pr2serr(ME "bad argument to 'skip='\n");
+ pr2serr("%sbad argument to 'skip='\n", my_name);
return SG_LIB_SYNTAX_ERROR;
}
} else if (0 == strcmp(key,"sync"))
@@ -1281,7 +1283,7 @@ main(int argc, char * argv[])
return 0;
} else if ((0 == strncmp(key, "--vers", 6)) ||
(0 == strcmp(key, "-V"))) {
- pr2serr(ME ": %s\n", version_str);
+ pr2serr("%s%s\n", my_name, version_str);
return 0;
}
else {
@@ -1322,8 +1324,8 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
if (rcoll.debug)
- pr2serr(ME "if=%s skip=%" PRId64 " of=%s seek=%" PRId64 " count=%"
- PRId64 "\n", inf, skip, outf, seek, dd_count);
+ pr2serr("%sif=%s skip=%" PRId64 " of=%s seek=%" PRId64 " count=%"
+ PRId64 "\n", my_name, inf, skip, outf, seek, dd_count);
install_handler(SIGINT, interrupt_handler);
install_handler(SIGQUIT, interrupt_handler);
@@ -1336,10 +1338,10 @@ main(int argc, char * argv[])
rcoll.in_type = dd_filetype(inf);
if (FT_ERROR == rcoll.in_type) {
- pr2serr(ME "unable to access %s\n", inf);
+ pr2serr("%sunable to access %s\n", my_name, inf);
return SG_LIB_FILE_ERROR;
} else if (FT_ST == rcoll.in_type) {
- pr2serr(ME "unable to use scsi tape device %s\n", inf);
+ pr2serr("%sunable to use scsi tape device %s\n", my_name, inf);
return SG_LIB_FILE_ERROR;
} else if (FT_SG == rcoll.in_type) {
flags = O_RDWR;
@@ -1351,8 +1353,8 @@ main(int argc, char * argv[])
flags |= O_SYNC;
if ((rcoll.infd = open(inf, flags)) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "could not open %s for sg reading", inf);
+ snprintf(ebuff, EBUFF_SZ, "%scould not open %s for sg "
+ "reading", my_name, inf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}
@@ -1369,8 +1371,8 @@ main(int argc, char * argv[])
flags |= O_SYNC;
if ((rcoll.infd = open(inf, flags)) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "could not open %s for reading", inf);
+ snprintf(ebuff, EBUFF_SZ, "%scould not open %s for reading",
+ my_name, inf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}
@@ -1379,8 +1381,8 @@ main(int argc, char * argv[])
offset *= rcoll.bs; /* could exceed 32 here! */
if (lseek64(rcoll.infd, offset, SEEK_SET) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "couldn't skip to required position on %s", inf);
+ snprintf(ebuff, EBUFF_SZ, "%scouldn't skip to required "
+ "position on %s", my_name, inf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}
@@ -1391,7 +1393,7 @@ main(int argc, char * argv[])
rcoll.out_type = dd_filetype(outf);
if (FT_ST == rcoll.out_type) {
- pr2serr(ME "unable to use scsi tape device %s\n", outf);
+ pr2serr("%sunable to use scsi tape device %s\n", my_name, outf);
return SG_LIB_FILE_ERROR;
}
else if (FT_SG == rcoll.out_type) {
@@ -1404,8 +1406,8 @@ main(int argc, char * argv[])
flags |= O_SYNC;
if ((rcoll.outfd = open(outf, flags)) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "could not open %s for sg writing", outf);
+ snprintf(ebuff, EBUFF_SZ, "%scould not open %s for sg "
+ "writing", my_name, outf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}
@@ -1428,16 +1430,16 @@ main(int argc, char * argv[])
flags |= O_APPEND;
if ((rcoll.outfd = open(outf, flags, 0666)) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "could not open %s for writing", outf);
+ snprintf(ebuff, EBUFF_SZ, "%scould not open %s for "
+ "writing", my_name, outf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}
}
else { /* raw output file */
if ((rcoll.outfd = open(outf, O_WRONLY)) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "could not open %s for raw writing", outf);
+ snprintf(ebuff, EBUFF_SZ, "%scould not open %s for raw "
+ "writing", my_name, outf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}
@@ -1447,8 +1449,8 @@ main(int argc, char * argv[])
offset *= rcoll.bs; /* could exceed 32 bits here! */
if (lseek64(rcoll.outfd, offset, SEEK_SET) < 0) {
- snprintf(ebuff, EBUFF_SZ,
- ME "couldn't seek to required position on %s", outf);
+ snprintf(ebuff, EBUFF_SZ, "%scouldn't seek to required "
+ "position on %s", my_name, outf);
perror(ebuff);
return SG_LIB_FILE_ERROR;
}