aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2019-08-29 00:15:08 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2019-08-29 00:15:08 +0000
commitb8a9d0f9070ee4a0f10c7d2e779655bffbfe1624 (patch)
tree45c9d8fe86fc79abccfe6d40f221da341d144f6f
parentabf4073cf5d973125dd384bc42f7338ec7e49c48 (diff)
downloadsg3_utils-b8a9d0f9070ee4a0f10c7d2e779655bffbfe1624.tar.gz
add sg_get_elem_status utility; inhex folder; some NVMe 1.4; some zbc realms
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@830 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--COVERAGE3
-rw-r--r--ChangeLog14
-rw-r--r--Makefile.in1
-rw-r--r--aclocal.m448
-rwxr-xr-xar-lib2
-rwxr-xr-xcompile2
-rwxr-xr-xconfig.guess130
-rwxr-xr-xconfig.sub2457
-rwxr-xr-xconfigure49
-rw-r--r--debian/changelog2
-rwxr-xr-xdepcomp2
-rw-r--r--doc/Makefile.am19
-rw-r--r--doc/Makefile.in23
-rw-r--r--doc/sg3_utils.826
-rw-r--r--doc/sg_get_elem_status.8100
-rw-r--r--doc/sg_get_lba_status.841
-rw-r--r--doc/sg_ses.827
-rw-r--r--include/Makefile.in1
-rw-r--r--include/sg_lib.h3
-rw-r--r--inhex/README50
-rw-r--r--inhex/get_elem_status.hex35
-rw-r--r--inhex/get_lba_status.hex14
-rw-r--r--inhex/ses_areca_all.hex186
-rw-r--r--inhex/vpd_consistuents.hex38
-rw-r--r--inhex/vpd_dev_id.hex5
-rw-r--r--inhex/vpd_lbpro.hex4
-rw-r--r--inhex/vpd_sfs.hex3
-rwxr-xr-xinstall-sh2
-rw-r--r--lib/Makefile.in1
-rw-r--r--lib/sg_lib.c78
-rw-r--r--lib/sg_lib_data.c17
-rwxr-xr-xltmain.sh246
-rwxr-xr-xmissing2
-rw-r--r--scripts/Makefile.in1
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/Makefile.am22
-rw-r--r--src/Makefile.in39
-rw-r--r--src/sg_get_elem_status.c587
-rw-r--r--src/sg_get_lba_status.c369
-rw-r--r--src/sg_inq.c24
-rw-r--r--src/sg_logs.c27
-rw-r--r--src/sg_ses.c78
-rw-r--r--testing/Makefile.cplus2
-rw-r--r--testing/sg_tst_async.cpp46
-rw-r--r--testing/sgh_dd.cpp4
-rw-r--r--testing/sgs_dd.c24
46 files changed, 3118 insertions, 1738 deletions
diff --git a/COVERAGE b/COVERAGE
index 84bd4d42..e78c20b0 100644
--- a/COVERAGE
+++ b/COVERAGE
@@ -21,6 +21,7 @@ COPY OPERATION ABORT ddptctl, ++
EXTENDED COPY(LID1) sg_xcopy, ddpt, ++
GET CONFIGURATION sg_get_config, ++
GET LBA STATUS sg_get_lba_status, ++
+GET PHYSICAL ELEMENT STATUS sg_get_elem_status, ++
GET STREAM STATUS sg_stream_ctl
INQUIRY sg_dd, sg_format, sg_inq, sginfo,
sg_logs, sg_map('-i'), sg_modes, sg_opcodes,
@@ -158,4 +159,4 @@ THIRD PARTY COPY IN (0x83).
Douglas Gilbert
-6th May 2018
+28th May 2019
diff --git a/ChangeLog b/ChangeLog
index f78cc7e3..a738c36c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,15 +2,19 @@ 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.45 [20190725] [svn: r829]
+Changelog for sg3_utils-1.45 [20190828] [svn: r830]
+ - sg_get_elem_status: new utility [sbc4r16]
- sg_ses: bug: --page= being overridden when --control
and --data= also given; fix
- document explicit Element type codes and example
- rename 'SAS SlimLine' to SlimSAS [ses4r02]
+ - add --inhex=FN, equivalent to --data=@FN, for
+ compatibility with other utilities
- sg_opcodes: expand MLU (spc5r20)
- sg_write_buffer: allow comma and period separated
lists when input from stdin
- sg_inq: update version descriptors to spc5r21
+ - add some NVMe 1.4 snippets to ctl identify
- sg_format: add --dcrt used twice (FOV=1 DCRT=0)
- sg_raw: fix --send bug when using stdin
- sg_vpd: 3pc VPD page add copy group descriptor
@@ -19,6 +23,7 @@ Changelog for sg3_utils-1.45 [20190725] [svn: r829]
- add --inhex=FN option
- sg_request: add --error option, replaces opcode
with 0xff (or skips call to pass-through)
+ - sg_get_lba_status: add --inhex=FN option
- sg_xcopy: add --fco (fast copy only) (spc5r20)
- implement --app=1 (append) on regular OFILE type
- sg_scan (win32): expand limits for big arrays
@@ -26,12 +31,19 @@ Changelog for sg3_utils-1.45 [20190725] [svn: r829]
T2A and T2B mpages (sbc4r17)
- sg_logs: placeholder for Command duration limits
statistics lpage (sbc4r17)
+ - zoned block device statistics log page: shorten
+ counter fields from 8 to 4 bytes (zbc2r02)
+ - zbc: preparatory work for Zoned domains and
+ realms; add new zbc service actions [19-032r3]
+ - inhex directory: new, contains ASCII hex files
+ that can be used with the '--inhex=' option
- sg_lib: add sg_t10_uuid_desig2str()
- sg_scsi_normalize_sense(): populate byte4,5,6
- tweak sg_pt interface to better handle bidi
- sg_cmds_process_resp(): two arguments removed
- add ${PACKAGE_VERSION} to '.so' name
- add sg_f2hex_arr()
+ - update some tables for NVMe 1.4
- sg_pt_freebsd: fixes for FreeBSD 12.0 release
- scripts: update 54-before-scsi-sg3_id.rules,
scsi-enable-target-scan.sh and
diff --git a/Makefile.in b/Makefile.in
index 173c41da..ddb80900 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -313,6 +313,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/aclocal.m4 b/aclocal.m4
index 21158447..a0e5edaa 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -744,7 +744,6 @@ _LT_CONFIG_SAVE_COMMANDS([
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.
@@ -2881,9 +2880,6 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
# before this can be enabled.
hardcode_into_libs=yes
- # Add ABI-specific directories to the system library path.
- sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
-
# Ideally, we could use ldconfig to report *all* directores which are
# searched for libraries, however this is still not possible. Aside from not
# being certain /sbin/ldconfig is available, command
@@ -2892,7 +2888,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
# appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -2904,6 +2900,18 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
dynamic_linker='GNU/Linux ld.so'
;;
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
netbsd*)
version_type=sunos
need_lib_prefix=no
@@ -3563,7 +3571,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
-netbsd*)
+netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
else
@@ -4069,7 +4077,8 @@ _LT_EOF
if AC_TRY_EVAL(ac_compile); then
# Now try to grab the symbols.
nlist=conftest.nm
- if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+ $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD
+ if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
@@ -4441,7 +4450,7 @@ m4_if([$1], [CXX], [
;;
esac
;;
- netbsd*)
+ netbsd* | netbsdelf*-gnu)
;;
*qnx* | *nto*)
# QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -4953,6 +4962,9 @@ m4_if([$1], [CXX], [
;;
esac
;;
+ linux* | k*bsd*-gnu | gnu*)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
*)
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
;;
@@ -5015,6 +5027,9 @@ dnl Note also adjust exclude_expsyms for C++ above.
openbsd* | bitrig*)
with_gnu_ld=no
;;
+ linux* | k*bsd*-gnu | gnu*)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
esac
_LT_TAGVAR(ld_shlibs, $1)=yes
@@ -5269,7 +5284,7 @@ _LT_EOF
fi
;;
- netbsd*)
+ netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc=
@@ -5790,6 +5805,7 @@ _LT_EOF
if test yes = "$lt_cv_irix_exported_symbol"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
fi
+ _LT_TAGVAR(link_all_deplibs, $1)=no
else
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
@@ -5811,7 +5827,7 @@ _LT_EOF
esac
;;
- netbsd*)
+ netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
else
@@ -6433,7 +6449,7 @@ if test yes != "$_lt_caught_CXX_error"; then
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
else
GXX=no
@@ -6808,7 +6824,7 @@ if test yes != "$_lt_caught_CXX_error"; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test yes = "$GXX"; then
@@ -6873,7 +6889,7 @@ if test yes != "$_lt_caught_CXX_error"; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test yes = "$GXX"; then
@@ -7212,7 +7228,7 @@ if test yes != "$_lt_caught_CXX_error"; then
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
else
# FIXME: insert proper C++ library support
@@ -7296,7 +7312,7 @@ if test yes != "$_lt_caught_CXX_error"; then
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
else
# g++ 2.7 appears to require '-G' NOT '-shared' on this
# platform.
@@ -7307,7 +7323,7 @@ if test yes != "$_lt_caught_CXX_error"; then
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
fi
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
diff --git a/ar-lib b/ar-lib
index ab457e5a..0baa4f60 100755
--- a/ar-lib
+++ b/ar-lib
@@ -1,4 +1,4 @@
-#!/usr/bin/sh
+#! /bin/sh
# Wrapper for Microsoft lib.exe
me=ar-lib
diff --git a/compile b/compile
index b89c278e..99e50524 100755
--- a/compile
+++ b/compile
@@ -1,4 +1,4 @@
-#!/usr/bin/sh
+#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2018-03-07.03; # UTC
diff --git a/config.guess b/config.guess
index b5d7a0f3..f50dcdb6 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
-#!/usr/bin/sh
+#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2018 Free Software Foundation, Inc.
-timestamp='2018-08-29'
+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
@@ -84,6 +84,8 @@ if test $# != 0; then
exit 1
fi
+trap 'exit 1' 1 2 15
+
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
@@ -94,39 +96,34 @@ fi
# Portable tmp directory creation inspired by the Autoconf team.
-tmp=
-# shellcheck disable=SC2172
-trap 'test -z "$tmp" || rm -fr "$tmp"' 1 2 13 15
-trap 'exitcode=$?; test -z "$tmp" || rm -fr "$tmp"; exit $exitcode' 0
-
-set_cc_for_build() {
- : "${TMPDIR=/tmp}"
- # shellcheck disable=SC2039
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
- dummy=$tmp/dummy
- case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
- ,,) echo "int x;" > "$dummy.c"
- for driver in cc gcc c89 c99 ; do
- if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$driver"
- break
- fi
- done
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
- esac
-}
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) 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
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
-if test -f /.attbin/uname ; then
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
@@ -141,7 +138,7 @@ Linux|GNU|GNU/*)
# We could probably try harder.
LIBC=gnu
- set_cc_for_build
+ eval "$set_cc_for_build"
cat <<-EOF > "$dummy.c"
#include <features.h>
#if defined(__UCLIBC__)
@@ -202,7 +199,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- set_cc_for_build
+ eval "$set_cc_for_build"
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
@@ -240,7 +237,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# 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.//'`
@@ -392,15 +389,20 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
- UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
- case `isainfo -b` in
- 32)
- echo i386-pc-solaris2"$UNAME_REL"
- ;;
- 64)
- echo x86_64-pc-solaris2"$UNAME_REL"
- ;;
- esac
+ 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.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH=x86_64
+ fi
+ fi
+ 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
@@ -480,7 +482,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo clipper-intergraph-clix"$UNAME_RELEASE"
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
- set_cc_for_build
+ eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
@@ -577,7 +579,7 @@ EOF
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- set_cc_for_build
+ eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
@@ -658,7 +660,7 @@ EOF
esac
fi
if [ "$HP_ARCH" = "" ]; then
- set_cc_for_build
+ eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
@@ -698,7 +700,7 @@ EOF
esac
if [ "$HP_ARCH" = hppa2.0w ]
then
- 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
@@ -724,7 +726,7 @@ EOF
echo ia64-hp-hpux"$HPUX_REV"
exit ;;
3050*:HI-UX:*:*)
- set_cc_for_build
+ eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#include <unistd.h>
int
@@ -838,17 +840,6 @@ EOF
*:BSD/OS:*:*)
echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
exit ;;
- arm:FreeBSD:*:*)
- UNAME_PROCESSOR=`uname -p`
- set_cc_for_build
- if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep -q __ARM_PCS_VFP
- then
- echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
- else
- echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
- fi
- exit ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
case "$UNAME_PROCESSOR" in
@@ -903,8 +894,8 @@ EOF
# 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"
exit ;;
- *:Minix:*:*)
- echo "$UNAME_MACHINE"-unknown-minix
+ i*86:Minix:*:*)
+ echo "$UNAME_MACHINE"-pc-minix
exit ;;
aarch64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@@ -931,7 +922,7 @@ EOF
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arm*:Linux:*:*)
- 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
@@ -980,7 +971,7 @@ EOF
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
- set_cc_for_build
+ eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef ${UNAME_MACHINE}
@@ -1055,7 +1046,11 @@ EOF
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"
@@ -1294,7 +1289,7 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- set_cc_for_build
+ eval "$set_cc_for_build"
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
@@ -1367,7 +1362,6 @@ EOF
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
- # shellcheck disable=SC2154
if test "$cputype" = 386; then
UNAME_MACHINE=i386
else
@@ -1479,7 +1473,7 @@ EOF
exit 1
# Local variables:
-# eval: (add-hook 'before-save-hook '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 be4dc6e5..1d8e98bc 100755
--- a/config.sub
+++ b/config.sub
@@ -1,8 +1,8 @@
-#!/usr/bin/sh
+#! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2018 Free Software Foundation, Inc.
-timestamp='2018-08-29'
+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
@@ -110,1159 +110,1223 @@ case $# in
exit 1;;
esac
-# Split fields of configuration type
-IFS="-" read -r field1 field2 field3 field4 <<EOF
-$1
-EOF
+# 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/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
+ kopensolaris*-gnu* | cloudabi*-eabi* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ 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/-[^-]*$//'`
+ if [ "$basic_machine" != "$1" ]
+ then os=`echo "$1" | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
-# Separate into logical components for further validation
-case $1 in
- *-*-*-*-*)
- echo Invalid configuration \`"$1"\': more than four components >&2
- exit 1
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
;;
- *-*-*-*)
- basic_machine=$field1-$field2
- os=$field3-$field4
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray | -microblaze*)
+ os=
+ basic_machine=$1
;;
- *-*-*)
- # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
- # parts
- maybe_os=$field2-$field3
- case $maybe_os in
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
- | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
- | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
- | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
- | storm-chaos* | os2-emx* | rtmk-nova*)
- basic_machine=$field1
- os=$maybe_os
- ;;
- android-linux)
- basic_machine=$field1-unknown
- os=linux-android
- ;;
- *)
- basic_machine=$field1-$field2
- os=$field3
- ;;
- esac
+ -bluegene*)
+ os=-cnk
;;
- *-*)
- # A lone config we happen to match not fitting any patern
- case $field1-$field2 in
- decstation-3100)
- basic_machine=mips-dec
- os=
- ;;
- *-*)
- # Second component is usually, but not always the OS
- case $field2 in
- # Prevent following clause from handling this valid os
- sun*os*)
- basic_machine=$field1
- os=$field2
- ;;
- # Manufacturers
- dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
- | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
- | unicom* | ibm* | next | hp | isi* | apollo | altos* \
- | convergent* | ncr* | news | 32* | 3600* | 3100* \
- | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
- | ultra | tti* | harris | dolphin | highlevel | gould \
- | cbm | ns | masscomp | apple | axis | knuth | cray \
- | microblaze* | sim | cisco \
- | oki | wec | wrs | winbond)
- basic_machine=$field1-$field2
- os=
- ;;
- *)
- basic_machine=$field1
- os=$field2
- ;;
- esac
- ;;
- esac
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
;;
- *)
- # Convert single-component short-hands not valid as part of
- # multi-component configurations.
- case $field1 in
- 386bsd)
- basic_machine=i386-pc
- os=bsd
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=udi
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=scout
- ;;
- alliant)
- basic_machine=fx80-alliant
- os=
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- os=
- ;;
- am29k)
- basic_machine=a29k-none
- os=bsd
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=sysv
- ;;
- amiga)
- basic_machine=m68k-unknown
- os=
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=bsd
- ;;
- aros)
- basic_machine=i386-pc
- os=aros
- ;;
- aux)
- basic_machine=m68k-apple
- os=aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=dynix
- ;;
- blackfin)
- basic_machine=bfin-unknown
- os=linux
- ;;
- cegcc)
- basic_machine=arm-unknown
- os=cegcc
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=bsd
- ;;
- cray)
- basic_machine=j90-cray
- os=unicos
- ;;
- crds | unos)
- basic_machine=m68k-crds
- os=
- ;;
- da30)
- basic_machine=m68k-da30
- os=
- ;;
- decstation | pmax | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- os=
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=sysv3
- ;;
- dicos)
- basic_machine=i686-pc
- os=dicos
- ;;
- djgpp)
- basic_machine=i586-pc
- os=msdosdjgpp
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=ebmon
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=ose
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=go32
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=sysv3
- ;;
- hp300)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=hpux
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=proelf
- ;;
- i386mach)
- basic_machine=i386-mach
- os=mach
- ;;
- vsta)
- basic_machine=i386-pc
- os=vsta
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=sysv
- ;;
- m68knommu)
- basic_machine=m68k-unknown
- os=linux
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=sysv
- ;;
- mingw64)
- basic_machine=x86_64-pc
- os=mingw64
- ;;
- mingw32)
- basic_machine=i686-pc
- os=mingw32
- ;;
- mingw32ce)
- basic_machine=arm-unknown
- os=mingw32ce
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=morphos
- ;;
- moxiebox)
- basic_machine=moxie-unknown
- os=moxiebox
- ;;
- msdos)
- basic_machine=i386-pc
- os=msdos
- ;;
- msys)
- basic_machine=i686-pc
- os=msys
- ;;
- mvs)
- basic_machine=i370-ibm
- os=mvs
- ;;
- nacl)
- basic_machine=le32-unknown
- os=nacl
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=sysv4
- ;;
- netbsd386)
- basic_machine=i386-pc
- os=netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=sysv
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=nonstopux
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=os68k
- ;;
- paragon)
- basic_machine=i860-intel
- os=osf
- ;;
- parisc)
- basic_machine=hppa-unknown
- os=linux
- ;;
- pw32)
- basic_machine=i586-unknown
- os=pw32
- ;;
- rdos | rdos64)
- basic_machine=x86_64-pc
- os=rdos
- ;;
- rdos32)
- basic_machine=i386-pc
- os=rdos
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=coff
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=udi
- ;;
- sei)
- basic_machine=mips-sei
- os=seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- os=
- ;;
- sps7)
- basic_machine=m68k-bull
- os=sysv2
- ;;
- st2000)
- basic_machine=m68k-tandem
- os=
- ;;
- stratus)
- basic_machine=i860-stratus
- os=sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- os=
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=sunos4
- ;;
- sun3)
- basic_machine=m68k-sun
- os=
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=sunos4
- ;;
- sun4)
- basic_machine=sparc-sun
- os=
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=solaris2
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- os=
- ;;
- sv1)
- basic_machine=sv1-cray
- os=unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=unicos
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=tops20
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=vms
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=vxworks
- ;;
- xbox)
- basic_machine=i686-pc
- os=mingw32
- ;;
- ymp)
- basic_machine=ymp-cray
- os=unicos
- ;;
- *)
- basic_machine=$1
- os=
- ;;
- esac
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ 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/'`
+ ;;
+ -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/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ 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/'`
+ ;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
;;
esac
-# Decode 1-component or ad-hoc basic machines
+# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
- # Here we handle the default manufacturer of certain CPU types. It is in
- # some cases the only manufacturer, in others, it is the most popular.
- w89k)
- cpu=hppa1.1
- vendor=winbond
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | aarch64 | aarch64_be \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arceb \
+ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+ | avr | avr32 \
+ | ba \
+ | be32 | be64 \
+ | bfin \
+ | c4x | c8051 | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | e2k | epiphany \
+ | fido | fr30 | frv | ft32 \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
+ | i370 | i860 | i960 | ia16 | ia64 \
+ | ip2k | iq2000 \
+ | k1om \
+ | le32 | le64 \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r6 | mipsisa32r6el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r6 | mipsisa64r6el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nios | nios2 | nios2eb | nios2el \
+ | ns16k | ns32k \
+ | open8 | or1k | or1knd | or32 \
+ | pdp10 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pru \
+ | pyramid \
+ | riscv32 | riscv64 \
+ | rl78 | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu \
+ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+ | ubicom32 \
+ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+ | visium \
+ | wasm32 \
+ | x86 | xc16x | xstormy16 | xtensa \
+ | z8k | z80)
+ basic_machine=$basic_machine-unknown
+ ;;
+ c54x)
+ basic_machine=tic54x-unknown
+ ;;
+ c55x)
+ basic_machine=tic55x-unknown
+ ;;
+ c6x)
+ basic_machine=tic6x-unknown
;;
- op50n)
- cpu=hppa1.1
- vendor=oki
+ leon|leon[3-9])
+ basic_machine=sparc-$basic_machine
;;
- op60c)
- cpu=hppa1.1
- vendor=oki
+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
+ basic_machine=$basic_machine-unknown
+ os=-none
;;
- ibm*)
- cpu=i370
- vendor=ibm
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
;;
- orion105)
- cpu=clipper
- vendor=highlevel
+ ms1)
+ basic_machine=mt-unknown
;;
- mac | mpw | mac-mpw)
- cpu=m68k
- vendor=apple
+
+ strongarm | thumb | xscale)
+ basic_machine=arm-unknown
;;
- pmac | pmac-mpw)
- cpu=powerpc
- vendor=apple
+ xgate)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ xscaleeb)
+ basic_machine=armeb-unknown
+ ;;
+
+ xscaleel)
+ basic_machine=armel-unknown
;;
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | aarch64-* | aarch64_be-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | ba-* \
+ | be32-* | be64-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
+ | c8051-* | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | e2k-* | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | hexagon-* \
+ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | k1om-* \
+ | le32-* | le64-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | microblaze-* | microblazeel-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64octeon-* | mips64octeonel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64r5900-* | mips64r5900el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa32r6-* | mipsisa32r6el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64r6-* | mipsisa64r6el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipsr5900-* | mipsr5900el-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nds32-* | nds32le-* | nds32be-* \
+ | nios-* | nios2-* | nios2eb-* | nios2el-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | open8-* \
+ | or1k*-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pru-* \
+ | pyramid-* \
+ | riscv32-* | riscv64-* \
+ | rl78-* | romp-* | rs6000-* | rx-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
+ | tahoe-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tile*-* \
+ | tron-* \
+ | ubicom32-* \
+ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+ | vax-* \
+ | visium-* \
+ | wasm32-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-* | z80-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
# 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-pc
+ os=-bsd
+ ;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- cpu=m68000
- vendor=att
+ basic_machine=m68000-att
;;
3b*)
- cpu=we32k
- vendor=att
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=-aros
+ ;;
+ asmjs)
+ basic_machine=asmjs-unknown
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ os=-linux
;;
bluegene*)
- cpu=powerpc
- vendor=ibm
- os=cnk
+ basic_machine=powerpc-ibm
+ os=-cnk
+ ;;
+ c54x-*)
+ basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ c55x-*)
+ basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ c6x-*)
+ basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=-cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16 | cr16-*)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
;;
decsystem10* | dec10*)
- cpu=pdp10
- vendor=dec
- os=tops10
+ basic_machine=pdp10-dec
+ os=-tops10
;;
decsystem20* | dec20*)
- cpu=pdp10
- vendor=dec
- os=tops20
+ basic_machine=pdp10-dec
+ os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
- cpu=m68k
- vendor=motorola
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=-dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
;;
dpx2*)
- cpu=m68k
- vendor=bull
- os=sysv3
+ basic_machine=m68k-bull
+ os=-sysv3
;;
- encore | umax | mmax)
- cpu=ns32k
- vendor=encore
+ e500v[12])
+ basic_machine=powerpc-unknown
+ os=$os"spe"
+ ;;
+ e500v[12]-*)
+ basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ os=$os"spe"
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
;;
elxsi)
- cpu=elxsi
- vendor=elxsi
- os=${os:-bsd}
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
;;
fx2800)
- cpu=i860
- vendor=alliant
+ basic_machine=i860-alliant
;;
genix)
- cpu=ns32k
- vendor=ns
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
;;
h3050r* | hiux*)
- cpu=hppa1.1
- vendor=hitachi
- os=hiuxwe2
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
- cpu=hppa1.0
- vendor=hp
+ basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
- cpu=m68000
- vendor=hp
+ basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
- cpu=m68k
- vendor=hp
+ basic_machine=m68k-hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
- cpu=hppa1.0
- vendor=hp
+ basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
- cpu=hppa1.1
- vendor=hp
+ basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
- cpu=hppa1.1
- vendor=hp
+ basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
- cpu=hppa1.1
- vendor=hp
+ basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
- cpu=hppa1.1
- vendor=hp
+ basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
- cpu=hppa1.0
- vendor=hp
+ basic_machine=hppa1.0-hp
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
;;
i*86v32)
- cpu=`echo "$1" | sed -e 's/86.*/86/'`
- vendor=pc
- os=sysv32
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
;;
i*86v4*)
- cpu=`echo "$1" | sed -e 's/86.*/86/'`
- vendor=pc
- os=sysv4
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
;;
i*86v)
- cpu=`echo "$1" | sed -e 's/86.*/86/'`
- vendor=pc
- os=sysv
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+ os=-sysv
;;
i*86sol2)
- cpu=`echo "$1" | sed -e 's/86.*/86/'`
- vendor=pc
- os=solaris2
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
;;
- j90 | j90-cray)
- cpu=j90
- vendor=cray
- os=${os:-unicos}
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ vsta)
+ basic_machine=i386-unknown
+ os=-vsta
;;
iris | iris4d)
- cpu=mips
- vendor=sgi
+ basic_machine=mips-sgi
case $os in
- irix*)
+ -irix*)
;;
*)
- os=irix4
+ os=-irix4
;;
esac
;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ leon-*|leon[3-9]-*)
+ basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ microblaze*)
+ basic_machine=microblaze-xilinx
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=-mingw64
+ ;;
+ mingw32)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
miniframe)
- cpu=m68000
- vendor=convergent
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ os=-moxiebox
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
+ ;;
+ msys)
+ basic_machine=i686-pc
+ os=-msys
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ nacl)
+ basic_machine=le32-unknown
+ os=-nacl
;;
- *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
- cpu=m68k
- vendor=atari
- os=mint
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
;;
news-3600 | risc-news)
- cpu=mips
- vendor=sony
- os=newsos
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
;;
next | m*-next)
- cpu=m68k
- vendor=next
+ basic_machine=m68k-next
case $os in
- nextstep* )
+ -nextstep* )
;;
- ns2*)
- os=nextstep2
+ -ns2*)
+ os=-nextstep2
;;
*)
- os=nextstep3
+ os=-nextstep3
;;
esac
;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
np1)
- cpu=np1
- vendor=gould
+ basic_machine=np1-gould
+ ;;
+ neo-tandem)
+ basic_machine=neo-tandem
+ ;;
+ nse-tandem)
+ basic_machine=nse-tandem
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ nsv-tandem)
+ basic_machine=nsv-tandem
+ ;;
+ nsx-tandem)
+ basic_machine=nsx-tandem
;;
op50n-* | op60c-*)
- cpu=hppa1.1
- vendor=oki
- os=proelf
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
;;
pa-hitachi)
- cpu=hppa1.1
- vendor=hitachi
- os=hiuxwe2
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ os=-linux
;;
pbd)
- cpu=sparc
- vendor=tti
+ basic_machine=sparc-tti
;;
pbb)
- cpu=m68k
- vendor=tti
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- pc532)
- cpu=ns32k
- vendor=pc532
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pn)
- cpu=pn
- vendor=gould
+ basic_machine=pn-gould
;;
- power)
- cpu=power
- vendor=ibm
+ power) basic_machine=power-ibm
;;
- ps2)
- cpu=i386
- vendor=ibm
+ ppc | ppcbe) basic_machine=powerpc-unknown
;;
- rm[46]00)
- cpu=mips
- vendor=siemens
+ ppc-* | ppcbe-*)
+ basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- rtpc | rtpc-*)
- cpu=romp
- vendor=ibm
+ ppcle | powerpclittle)
+ basic_machine=powerpcle-unknown
;;
- sde)
- cpu=mipsisa32
- vendor=sde
- os=${os:-elf}
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- simso-wrs)
- cpu=sparclite
- vendor=wrs
- os=vxworks
+ ppc64) basic_machine=powerpc64-unknown
;;
- tower | tower-32)
- cpu=m68k
- vendor=ncr
+ ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- vpp*|vx|vx-*)
- cpu=f301
- vendor=fujitsu
+ ppc64le | powerpc64little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- w65)
- cpu=w65
- vendor=wdc
+ ps2)
+ basic_machine=i386-ibm
;;
- w89k-*)
- cpu=hppa1.1
- vendor=winbond
- os=proelf
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
;;
- none)
- cpu=none
- vendor=none
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=-rdos
;;
- leon|leon[3-9])
- cpu=sparc
- vendor=$basic_machine
+ rdos32)
+ basic_machine=i386-pc
+ os=-rdos
;;
- leon-*|leon[3-9]-*)
- cpu=sparc
- vendor=`echo "$basic_machine" | sed 's/-.*//'`
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
;;
-
- *-*)
- IFS="-" read -r cpu vendor <<EOF
-$basic_machine
-EOF
+ rm[46]00)
+ basic_machine=mips-siemens
;;
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- cpu=$basic_machine
- vendor=pc
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
;;
- # These rules are duplicated from below for sake of the special case above;
- # i.e. things that normalized to x86 arches should also default to "pc"
- pc98)
- cpu=i386
- vendor=pc
+ s390 | s390-*)
+ basic_machine=s390-ibm
;;
- x64 | amd64)
- cpu=x86_64
- vendor=pc
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
;;
- # Recognize the basic CPU types without company name.
- *)
- cpu=$basic_machine
- vendor=unknown
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
;;
-esac
-
-unset -v basic_machine
-
-# Decode basic machines in the full and proper CPU-Company form.
-case $cpu-$vendor in
- # Here we handle the default manufacturer of certain CPU types in cannonical form. It is in
- # some cases the only manufacturer, in others, it is the most popular.
- craynv-unknown)
- vendor=cray
- os=${os:-unicosmp}
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
;;
- c90-unknown | c90-cray)
- vendor=cray
- os=${os:-unicos}
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
;;
- fx80-unknown)
- vendor=alliant
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
;;
- romp-unknown)
- vendor=ibm
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
;;
- mmix-unknown)
- vendor=knuth
+ sequent)
+ basic_machine=i386-sequent
;;
- microblaze-unknown | microblazeel-unknown)
- vendor=xilinx
+ sh5el)
+ basic_machine=sh5le-unknown
;;
- rs6000-unknown)
- vendor=ibm
+ simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
;;
- vax-unknown)
- vendor=dec
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
;;
- pdp11-unknown)
- vendor=dec
+ spur)
+ basic_machine=spur-unknown
;;
- we32k-unknown)
- vendor=att
+ st2000)
+ basic_machine=m68k-tandem
;;
- cydra-unknown)
- vendor=cydrome
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
;;
- i370-ibm*)
- vendor=ibm
+ strongarm-* | thumb-*)
+ basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- orion-unknown)
- vendor=highlevel
+ sun2)
+ basic_machine=m68000-sun
;;
- xps-unknown | xps100-unknown)
- cpu=xps100
- vendor=honeywell
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
;;
-
- # Here we normalize CPU types with a missing or matching vendor
- dpx20-unknown | dpx20-bull)
- cpu=rs6000
- vendor=bull
- os=${os:-bosx}
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
;;
-
- # Here we normalize CPU types irrespective of the vendor
- amd64-*)
- cpu=x86_64
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
;;
- blackfin-*)
- cpu=bfin
- os=linux
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
;;
- c54x-*)
- cpu=tic54x
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
;;
- c55x-*)
- cpu=tic55x
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
;;
- c6x-*)
- cpu=tic6x
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
;;
- e500v[12]-*)
- cpu=powerpc
- os=$os"spe"
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
;;
- mips3*-*)
- cpu=mips64
+ sun4)
+ basic_machine=sparc-sun
;;
- ms1-*)
- cpu=mt
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
;;
- m68knommu-*)
- cpu=m68k
- os=linux
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
;;
- m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
- cpu=s12z
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
;;
- openrisc-*)
- cpu=or32
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
;;
- parisc-*)
- cpu=hppa
- os=linux
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- cpu=i586
+ tile*)
+ basic_machine=$basic_machine-unknown
+ os=-linux-gnu
;;
- pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
- cpu=i686
+ tx39)
+ basic_machine=mipstx39-unknown
;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- cpu=i686
+ tx39el)
+ basic_machine=mipstx39el-unknown
;;
- pentium4-*)
- cpu=i786
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
;;
- pc98-*)
- cpu=i386
+ tower | tower-32)
+ basic_machine=m68k-ncr
;;
- ppc-* | ppcbe-*)
- cpu=powerpc
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
;;
- ppcle-* | powerpclittle-*)
- cpu=powerpcle
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
;;
- ppc64-*)
- cpu=powerpc64
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
;;
- ppc64le-* | powerpc64little-*)
- cpu=powerpc64le
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
;;
- sb1-*)
- cpu=mipsisa64sb1
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
;;
- sb1el-*)
- cpu=mipsisa64sb1el
+ vms)
+ basic_machine=vax-dec
+ os=-vms
;;
- sh5e[lb]-*)
- cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
;;
- spur-*)
- cpu=spur
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
;;
- strongarm-* | thumb-*)
- cpu=arm
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
;;
- tx39-*)
- cpu=mipstx39
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
;;
- tx39el-*)
- cpu=mipstx39el
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
;;
- x64-*)
- cpu=x86_64
+ x64)
+ basic_machine=x86_64-pc
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
- cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
+ basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
;;
- # Recognize the cannonical CPU Types that limit and/or modify the
- # company names they are paired with.
- cr16-*)
- os=${os:-elf}
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
;;
- crisv32-* | etraxfs*-*)
- cpu=crisv32
- vendor=axis
+ op50n)
+ basic_machine=hppa1.1-oki
;;
- cris-* | etrax*-*)
- cpu=cris
- vendor=axis
+ op60c)
+ basic_machine=hppa1.1-oki
;;
- crx-*)
- os=${os:-elf}
+ romp)
+ basic_machine=romp-ibm
;;
- neo-tandem)
- cpu=neo
- vendor=tandem
+ mmix)
+ basic_machine=mmix-knuth
;;
- nse-tandem)
- cpu=nse
- vendor=tandem
+ rs6000)
+ basic_machine=rs6000-ibm
;;
- nsr-tandem)
- cpu=nsr
- vendor=tandem
+ vax)
+ basic_machine=vax-dec
;;
- nsv-tandem)
- cpu=nsv
- vendor=tandem
+ pdp11)
+ basic_machine=pdp11-dec
;;
- nsx-tandem)
- cpu=nsx
- vendor=tandem
+ we32k)
+ basic_machine=we32k-att
;;
- s390-*)
- cpu=s390
- vendor=ibm
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
;;
- s390x-*)
- cpu=s390x
- vendor=ibm
+ cydra)
+ basic_machine=cydra-cydrome
;;
- tile*-*)
- os=${os:-linux-gnu}
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
;;
-
*)
- # Recognize the cannonical CPU types that are allowed with any
- # company name.
- case $cpu in
- 1750a | 580 \
- | a29k \
- | aarch64 | aarch64_be \
- | abacus \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
- | alphapca5[67] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arceb \
- | arm | arm[lb]e | arme[lb] | armv* \
- | avr | avr32 \
- | asmjs \
- | ba \
- | be32 | be64 \
- | bfin | bs2000 \
- | c[123]* | c30 | [cjt]90 | c4x \
- | c8051 | clipper | craynv | csky | cydra \
- | d10v | d30v | dlx | dsp16xx \
- | e2k | elxsi | epiphany \
- | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
- | h8300 | h8500 \
- | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | hexagon \
- | i370 | i*86 | i860 | i960 | ia16 | ia64 \
- | ip2k | iq2000 \
- | k1om \
- | le32 | le64 \
- | lm32 \
- | m32c | m32r | m32rle \
- | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k | v70 | w65 \
- | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip \
- | m88110 | m88k | maxq | mb | mcore | mep | metag \
- | microblaze | microblazeel \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64octeon | mips64octeonel \
- | mips64orion | mips64orionel \
- | mips64r5900 | mips64r5900el \
- | mips64vr | mips64vrel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa32r6 | mipsisa32r6el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64r6 | mipsisa64r6el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipsr5900 | mipsr5900el \
- | mipstx39 | mipstx39el \
- | mmix \
- | mn10200 | mn10300 \
- | moxie \
- | mt \
- | msp430 \
- | nds32 | nds32le | nds32be \
- | nfp \
- | nios | nios2 | nios2eb | nios2el \
- | none | np1 | ns16k | ns32k \
- | open8 \
- | or1k* \
- | or32 \
- | orion \
- | pdp10 | pdp11 | pj | pjl | pn | power \
- | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
- | pru \
- | pyramid \
- | riscv | riscv32 | riscv64 \
- | rl78 | romp | rs6000 | rx \
- | score \
- | sh | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
- | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
- | sparclite \
- | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
- | spu \
- | tahoe \
- | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
- | tron \
- | ubicom32 \
- | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
- | vax \
- | visium \
- | wasm32 \
- | we32k \
- | x86 | x86_64 | xc16x | xgate | xps100 \
- | xstormy16 | xtensa* \
- | ymp \
- | z8k | z80)
- ;;
-
- *)
- echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
- exit 1
- ;;
- esac
+ echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
+ exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
-case $vendor in
- digital*)
- vendor=dec
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
;;
- commodore*)
- vendor=cbm
+ *-commodore*)
+ basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
;;
*)
;;
@@ -1270,245 +1334,199 @@ esac
# Decode manufacturer-specific aliases for certain operating systems.
-if [ x$os != x ]
+if [ x"$os" != x"" ]
then
case $os in
# 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
+ # -solaris* is a basic system type, with this one exception.
+ -auroraux)
+ os=-auroraux
;;
- bluegene*)
- os=cnk
- ;;
- solaris1 | solaris1.*)
+ -solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
- solaris)
- os=solaris2
+ -solaris)
+ os=-solaris2
;;
- unixware*)
- os=sysv4.2uw
+ -unixware*)
+ os=-sysv4.2uw
;;
- gnu/linux*)
+ -gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# es1800 is here to avoid being matched by es* (a different OS)
- es1800*)
- os=ose
- ;;
- # Some version numbers need modification
- chorusos*)
- os=chorusos
- ;;
- isc)
- os=isc2.2
- ;;
- sco6)
- os=sco5v6
- ;;
- sco5)
- os=sco3.2v5
- ;;
- sco4)
- os=sco3.2v4
- ;;
- sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- ;;
- sco3.2v[4-9]* | sco5v6*)
- # Don't forget version if it is 3.2v4 or newer.
- ;;
- scout)
- # Don't match below
- ;;
- sco*)
- os=sco3.2v2
- ;;
- psos*)
- os=psos
+ -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.
- # sysv* is not here because it comes later, after sysvr4.
- gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
- | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
- | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
- | sym* | kopensolaris* | plan9* \
- | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
- | aos* | aros* | cloudabi* | sortix* \
- | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
- | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
- | 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* | hcos* \
- | chorusrdb* | cegcc* | glidix* \
- | cygwin* | msys* | pe* | 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* \
- | openstep* | oskit* | conix* | pw32* | nonstopux* \
- | storm-chaos* | tops10* | tenex* | tops20* | its* \
- | os2* | vos* | palmos* | uclinux* | nucleus* \
- | morphos* | superux* | rtmk* | windiss* \
- | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
- | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
- | midnightbsd*)
+ # -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]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+ | -sym* | -kopensolaris* | -plan9* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* | -aros* | -cloudabi* | -sortix* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -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* | -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* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
+ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
+ | -midnightbsd*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
- qnx*)
- case $cpu in
- x86 | i*86)
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
;;
*)
- os=nto-$os
+ os=-nto$os
;;
esac
;;
- hiux*)
- os=hiuxwe2
- ;;
- nto-qnx*)
+ -nto-qnx*)
;;
- nto*)
+ -nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
- sim | xray | os68k* | v88r* \
- | windows* | osx | abug | netware* | os9* \
- | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
- ;;
- linux-dietlibc)
- os=linux-dietlibc
- ;;
- linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- lynx*178)
- os=lynxos178
+ -sim | -xray | -os68k* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
- lynx*5)
- os=lynxos5
- ;;
- lynx*)
- os=lynxos
- ;;
- mac*)
+ -mac*)
os=`echo "$os" | sed -e 's|mac|macos|'`
;;
- opened*)
- os=openedition
+ -linux-dietlibc)
+ os=-linux-dietlibc
;;
- os400*)
- os=os400
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
- sunos5*)
+ -sunos5*)
os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
;;
- sunos6*)
+ -sunos6*)
os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
;;
- wince*)
- os=wince
+ -opened*)
+ os=-openedition
;;
- utek*)
- os=bsd
+ -os400*)
+ os=-os400
;;
- dynix*)
- os=bsd
+ -wince*)
+ os=-wince
;;
- acis*)
- os=aos
+ -utek*)
+ os=-bsd
;;
- atheos*)
- os=atheos
+ -dynix*)
+ os=-bsd
;;
- syllable*)
- os=syllable
+ -acis*)
+ os=-aos
;;
- 386bsd)
- os=bsd
+ -atheos*)
+ os=-atheos
;;
- ctix* | uts*)
- os=sysv
+ -syllable*)
+ os=-syllable
;;
- nova*)
- os=rtmk-nova
+ -386bsd)
+ os=-bsd
;;
- ns2)
- os=nextstep2
+ -ctix* | -uts*)
+ os=-sysv
;;
- nsk*)
- os=nsk
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2)
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
;;
# Preserve the version number of sinix5.
- sinix5.*)
+ -sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
- sinix*)
- os=sysv4
+ -sinix*)
+ os=-sysv4
;;
- tpf*)
- os=tpf
+ -tpf*)
+ os=-tpf
;;
- triton*)
- os=sysv3
+ -triton*)
+ os=-sysv3
;;
- oss*)
- os=sysv3
+ -oss*)
+ os=-sysv3
;;
- svr4*)
- os=sysv4
+ -svr4*)
+ os=-sysv4
;;
- svr3)
- os=sysv3
+ -svr3)
+ os=-sysv3
;;
- sysvr4)
- os=sysv4
+ -sysvr4)
+ os=-sysv4
;;
- # This must come after sysvr4.
- sysv*)
+ # This must come after -sysvr4.
+ -sysv*)
;;
- ose*)
- os=ose
+ -ose*)
+ os=-ose
;;
- *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
- os=mint
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
;;
- zvmoe)
- os=zvmoe
+ -zvmoe)
+ os=-zvmoe
;;
- dicos*)
- os=dicos
+ -dicos*)
+ os=-dicos
;;
- pikeos*)
+ -pikeos*)
# Until real need of OS specific support for
# particular features comes up, bare metal
# configurations are quite functional.
- case $cpu in
+ case $basic_machine in
arm*)
- os=eabi
+ os=-eabi
;;
*)
- os=elf
+ os=-elf
;;
esac
;;
- nacl*)
+ -nacl*)
;;
- ios)
+ -ios)
;;
- none)
- ;;
- *-eabi)
+ -none)
;;
*)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
exit 1
;;
@@ -1525,265 +1543,258 @@ else
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
-case $cpu-$vendor in
+case $basic_machine in
score-*)
- os=elf
+ os=-elf
;;
spu-*)
- os=elf
+ os=-elf
;;
*-acorn)
- os=riscix1.2
+ os=-riscix1.2
;;
arm*-rebel)
- os=linux
+ os=-linux
;;
arm*-semi)
- os=aout
+ os=-aout
;;
c4x-* | tic4x-*)
- os=coff
+ os=-coff
;;
c8051-*)
- os=elf
- ;;
- clipper-intergraph)
- os=clix
+ os=-elf
;;
hexagon-*)
- os=elf
+ os=-elf
;;
tic54x-*)
- os=coff
+ os=-coff
;;
tic55x-*)
- os=coff
+ os=-coff
;;
tic6x-*)
- os=coff
+ os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
- os=tops20
+ os=-tops20
;;
pdp11-*)
- os=none
+ os=-none
;;
*-dec | vax-*)
- os=ultrix4.2
+ os=-ultrix4.2
;;
m68*-apollo)
- os=domain
+ os=-domain
;;
i386-sun)
- os=sunos4.0.2
+ os=-sunos4.0.2
;;
m68000-sun)
- os=sunos3
+ os=-sunos3
;;
m68*-cisco)
- os=aout
+ os=-aout
;;
mep-*)
- os=elf
+ os=-elf
;;
mips*-cisco)
- os=elf
+ os=-elf
;;
mips*-*)
- os=elf
+ os=-elf
;;
or32-*)
- os=coff
+ os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
- os=sysv3
+ os=-sysv3
;;
sparc-* | *-sun)
- os=sunos4.1.1
+ os=-sunos4.1.1
;;
pru-*)
- os=elf
+ os=-elf
;;
*-be)
- os=beos
+ os=-beos
;;
*-ibm)
- os=aix
+ os=-aix
;;
*-knuth)
- os=mmixware
+ os=-mmixware
;;
*-wec)
- os=proelf
+ os=-proelf
;;
*-winbond)
- os=proelf
+ os=-proelf
;;
*-oki)
- os=proelf
+ os=-proelf
;;
*-hp)
- os=hpux
+ os=-hpux
;;
*-hitachi)
- os=hiux
+ os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=sysv
+ os=-sysv
;;
*-cbm)
- os=amigaos
+ os=-amigaos
;;
*-dg)
- os=dgux
+ os=-dgux
;;
*-dolphin)
- os=sysv3
+ os=-sysv3
;;
m68k-ccur)
- os=rtu
+ os=-rtu
;;
m88k-omron*)
- os=luna
+ os=-luna
;;
*-next)
- os=nextstep
+ os=-nextstep
;;
*-sequent)
- os=ptx
+ os=-ptx
;;
*-crds)
- os=unos
+ os=-unos
;;
*-ns)
- os=genix
+ os=-genix
;;
i370-*)
- os=mvs
+ os=-mvs
;;
*-gould)
- os=sysv
+ os=-sysv
;;
*-highlevel)
- os=bsd
+ os=-bsd
;;
*-encore)
- os=bsd
+ os=-bsd
;;
*-sgi)
- os=irix
+ os=-irix
;;
*-siemens)
- os=sysv4
+ os=-sysv4
;;
*-masscomp)
- os=rtu
+ os=-rtu
;;
f30[01]-fujitsu | f700-fujitsu)
- os=uxpv
+ os=-uxpv
;;
*-rom68k)
- os=coff
+ os=-coff
;;
*-*bug)
- os=coff
+ os=-coff
;;
*-apple)
- os=macos
+ os=-macos
;;
*-atari*)
- os=mint
- ;;
- *-wrs)
- os=vxworks
+ os=-mint
;;
*)
- os=none
+ os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
-case $vendor in
- unknown)
+vendor=unknown
+case $basic_machine in
+ *-unknown)
case $os in
- riscix*)
+ -riscix*)
vendor=acorn
;;
- sunos*)
+ -sunos*)
vendor=sun
;;
- cnk*|-aix*)
+ -cnk*|-aix*)
vendor=ibm
;;
- beos*)
+ -beos*)
vendor=be
;;
- hpux*)
+ -hpux*)
vendor=hp
;;
- mpeix*)
+ -mpeix*)
vendor=hp
;;
- hiux*)
+ -hiux*)
vendor=hitachi
;;
- unos*)
+ -unos*)
vendor=crds
;;
- dgux*)
+ -dgux*)
vendor=dg
;;
- luna*)
+ -luna*)
vendor=omron
;;
- genix*)
+ -genix*)
vendor=ns
;;
- clix*)
- vendor=intergraph
- ;;
- mvs* | opened*)
+ -mvs* | -opened*)
vendor=ibm
;;
- os400*)
+ -os400*)
vendor=ibm
;;
- ptx*)
+ -ptx*)
vendor=sequent
;;
- tpf*)
+ -tpf*)
vendor=ibm
;;
- vxsim* | vxworks* | windiss*)
+ -vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
- aux*)
+ -aux*)
vendor=apple
;;
- hms*)
+ -hms*)
vendor=hitachi
;;
- mpw* | macos*)
+ -mpw* | -macos*)
vendor=apple
;;
- *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
- vos*)
+ -vos*)
vendor=stratus
;;
esac
+ basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
;;
esac
-echo "$cpu-$vendor-$os"
+echo "$basic_machine$os"
exit
# Local variables:
-# eval: (add-hook 'before-save-hook '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/configure b/configure
index 034f9b66..45ee88a6 100755
--- a/configure
+++ b/configure
@@ -750,6 +750,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -840,6 +841,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1092,6 +1094,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1229,7 +1240,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1382,6 +1393,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -5413,7 +5425,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
-netbsd*)
+netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
else
@@ -6276,11 +6288,8 @@ _LT_EOF
test $ac_status = 0; }; then
# Now try to grab the symbols.
nlist=conftest.nm
- if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
- (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && test -s "$nlist"; then
+ $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5
+ if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
@@ -9101,6 +9110,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
openbsd* | bitrig*)
with_gnu_ld=no
;;
+ linux* | k*bsd*-gnu | gnu*)
+ link_all_deplibs=no
+ ;;
esac
ld_shlibs=yes
@@ -9355,7 +9367,7 @@ _LT_EOF
fi
;;
- netbsd*)
+ netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc=
@@ -10025,6 +10037,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
if test yes = "$lt_cv_irix_exported_symbol"; then
archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
fi
+ link_all_deplibs=no
else
archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
@@ -10046,7 +10059,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
esac
;;
- netbsd*)
+ netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
else
@@ -11141,9 +11154,6 @@ fi
# before this can be enabled.
hardcode_into_libs=yes
- # Add ABI-specific directories to the system library path.
- sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
-
# Ideally, we could use ldconfig to report *all* directores which are
# searched for libraries, however this is still not possible. Aside from not
# being certain /sbin/ldconfig is available, command
@@ -11152,7 +11162,7 @@ fi
# appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -11164,6 +11174,18 @@ fi
dynamic_linker='GNU/Linux ld.so'
;;
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
netbsd*)
version_type=sunos
need_lib_prefix=no
@@ -14564,7 +14586,6 @@ See \`config.log' for more details" "$LINENO" 5; }
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.
diff --git a/debian/changelog b/debian/changelog
index 9a59d048..ea6f8985 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.45-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Wed, 17 Jul 2019 14:00:00 -0400
+ -- Douglas Gilbert <dgilbert@interlog.com> Wed, 28 Aug 2019 13:00:00 -0400
sg3-utils (1.44-0.1) unstable; urgency=low
diff --git a/depcomp b/depcomp
index 4e0ae31b..65cbf709 100755
--- a/depcomp
+++ b/depcomp
@@ -1,4 +1,4 @@
-#!/usr/bin/sh
+#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2018-03-07.03; # UTC
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 9a1816eb..fc8e85d3 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -3,15 +3,16 @@ man_MANS = \
scsi_mandat.8 scsi_readcap.8 scsi_ready.8 scsi_satl.8 scsi_start.8 \
scsi_stop.8 scsi_temperature.8 sg3_utils.8 sg_bg_ctl.8 \
sg_compare_and_write.8 sg_decode_sense.8 sg_format.8 sg_get_config.8 \
- sg_get_lba_status.8 sg_ident.8 sg_inq.8 sg_logs.8 sg_luns.8 \
- sg_modes.8 sg_opcodes.8 sg_persist.8 sg_prevent.8 sg_raw.8 sg_rdac.8 \
- sg_read_attr.8 sg_read_block_limits.8 sg_read_buffer.8 \
- sg_read_long.8 sg_readcap.8 sg_reassign.8 sg_referrals.8 \
- sg_rep_zones.8 sg_requests.8 sg_reset_wp.8 sg_rmsn.8 sg_rtpg.8 \
- sg_safte.8 sg_sanitize.8 sg_sat_identify.8 sg_sat_phy_event.8 \
- sg_sat_read_gplog.8 sg_sat_set_features.8 sg_seek.8 sg_senddiag.8 \
- sg_ses.8 sg_ses_microcode.8 sg_start.8 sg_stpg.8 sg_stream_ctl.8 \
- sg_sync.8 sg_timestamp.8 sg_turs.8 sg_unmap.8 sg_verify.8 sg_vpd.8 \
+ sg_get_elem_status.8 sg_get_lba_status.8 sg_ident.8 sg_inq.8 \
+ sg_logs.8 sg_luns.8 sg_modes.8 sg_opcodes.8 sg_persist.8 \
+ sg_prevent.8 sg_raw.8 sg_rdac.8 sg_read_attr.8 \
+ sg_read_block_limits.8 sg_read_buffer.8 sg_read_long.8 sg_readcap.8 \
+ sg_reassign.8 sg_referrals.8 sg_rep_zones.8 sg_requests.8 \
+ sg_reset_wp.8 sg_rmsn.8 sg_rtpg.8 sg_safte.8 sg_sanitize.8 \
+ sg_sat_identify.8 sg_sat_phy_event.8 sg_sat_read_gplog.8 \
+ sg_sat_set_features.8 sg_seek.8 sg_senddiag.8 sg_ses.8 \
+ sg_ses_microcode.8 sg_start.8 sg_stpg.8 sg_stream_ctl.8 sg_sync.8 \
+ sg_timestamp.8 sg_turs.8 sg_unmap.8 sg_verify.8 sg_vpd.8 \
sg_wr_mode.8 sg_write_buffer.8 sg_write_long.8 sg_write_same.8 \
sg_write_verify.8 sg_write_x.8 sg_zone.8
CLEANFILES =
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 66e9d89f..6a37b4f8 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -271,6 +271,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -282,17 +283,17 @@ top_srcdir = @top_srcdir@
man_MANS = scsi_mandat.8 scsi_readcap.8 scsi_ready.8 scsi_satl.8 \
scsi_start.8 scsi_stop.8 scsi_temperature.8 sg3_utils.8 \
sg_bg_ctl.8 sg_compare_and_write.8 sg_decode_sense.8 \
- sg_format.8 sg_get_config.8 sg_get_lba_status.8 sg_ident.8 \
- sg_inq.8 sg_logs.8 sg_luns.8 sg_modes.8 sg_opcodes.8 \
- sg_persist.8 sg_prevent.8 sg_raw.8 sg_rdac.8 sg_read_attr.8 \
- sg_read_block_limits.8 sg_read_buffer.8 sg_read_long.8 \
- sg_readcap.8 sg_reassign.8 sg_referrals.8 sg_rep_zones.8 \
- sg_requests.8 sg_reset_wp.8 sg_rmsn.8 sg_rtpg.8 sg_safte.8 \
- sg_sanitize.8 sg_sat_identify.8 sg_sat_phy_event.8 \
- sg_sat_read_gplog.8 sg_sat_set_features.8 sg_seek.8 \
- sg_senddiag.8 sg_ses.8 sg_ses_microcode.8 sg_start.8 sg_stpg.8 \
- sg_stream_ctl.8 sg_sync.8 sg_timestamp.8 sg_turs.8 sg_unmap.8 \
- sg_verify.8 sg_vpd.8 sg_wr_mode.8 sg_write_buffer.8 \
+ sg_format.8 sg_get_config.8 sg_get_elem_status.8 \
+ sg_get_lba_status.8 sg_ident.8 sg_inq.8 sg_logs.8 sg_luns.8 \
+ sg_modes.8 sg_opcodes.8 sg_persist.8 sg_prevent.8 sg_raw.8 \
+ sg_rdac.8 sg_read_attr.8 sg_read_block_limits.8 \
+ sg_read_buffer.8 sg_read_long.8 sg_readcap.8 sg_reassign.8 \
+ sg_referrals.8 sg_rep_zones.8 sg_requests.8 sg_reset_wp.8 \
+ sg_rmsn.8 sg_rtpg.8 sg_safte.8 sg_sanitize.8 sg_sat_identify.8 \
+ sg_sat_phy_event.8 sg_sat_read_gplog.8 sg_sat_set_features.8 \
+ sg_seek.8 sg_senddiag.8 sg_ses.8 sg_ses_microcode.8 sg_start.8 \
+ sg_stpg.8 sg_stream_ctl.8 sg_sync.8 sg_timestamp.8 sg_turs.8 \
+ sg_unmap.8 sg_verify.8 sg_vpd.8 sg_wr_mode.8 sg_write_buffer.8 \
sg_write_long.8 sg_write_same.8 sg_write_verify.8 sg_write_x.8 \
sg_zone.8 $(am__append_1) $(am__append_3) $(am__append_5)
CLEANFILES = $(am__append_2) $(am__append_4) $(am__append_6)
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index af6d74e5..d62e0dba 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -1,10 +1,10 @@
-.TH SG3_UTILS "8" "July 2019" "sg3_utils\-1.45" SG3_UTILS
+.TH SG3_UTILS "8" "August 2019" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg3_utils \- a package of utilities for sending SCSI commands
.SH SYNOPSIS
.B sg_*
[\fI\-\-dry\-run\fR] [\fI\-\-enumerate\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
-[\fI\-\-in=FN\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-raw\fR]
+[\fI\-\-in=FN\fR] [\fI\-\-inhex=FN\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-raw\fR]
[\fI\-\-timeout=SECS\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
[\fIOTHER_OPTIONS\fR] \fIDEVICE\fR
.SH DESCRIPTION
@@ -574,9 +574,13 @@ Since the structure of the data returned by SCSI commands varies
considerably then the usage information or the manpage of the utility being
used should be checked. In some cases \fI\-\-hex\fR may need to be used
multiple times (and is more conveniently given as '\-HH' or '\-HHH).
-.br
-In some cases the name of the option with this functionality is
-\fI\-\-inhex=FN\fR.
+.TP
+\fB\-i\fR, \fB\-\-inhex\fR=\fIFN\fR
+This option has the same or similar functionality as \fI\-\-in=FN\fR. And
+perhaps 'inhex' is more descriptive since by default, ASCII hexadecimal is
+expected in the contents of file: \fIFN\fR. Alternatively the short form
+option may be \fI\-I\fR or \fI\-X\fR. See the "FORMAT OF FILES CONTAINING
+ASCII HEX" section below for more information.
.TP
\fB\-m\fR, \fB\-\-maxlen\fR=\fILEN\fR
several important SCSI commands (e.g. INQUIRY and MODE SENSE) have response
@@ -685,6 +689,18 @@ in the C programming language. The second hexadecimal representation is a
trailing "h" or "H" as found in (storage) standards. When hex numbers are
given, multipliers cannot be used. For example the decimal value "256" can
be given as "0x100" or "100h".
+.SH FORMAT OF FILES CONTAINING ASCII HEX
+Such a file is assumed to contain a sequence of one or two digit ASCII
+hexadecimal values separated by whitespace. "Whitespace consists of either
+spaces, tabs, blank lines, or any combination thereof". Each one or two digit
+ASCII hex pair is decoded into a byte (i.e. 8 bits). The following will be
+decoded to valid (ascending valued)
+bytes: '0', '01', '3', 'c', 'F', '4a', 'cC', 'ff'.
+Lines containing only whitespace are ignored. The contents of any line
+containing a hash mark ('#') is ignored from that point until the end of that
+line. Users are encouraged to use hash marks to introduce comments in hex
+files. The author uses the extension'.hex' on such files. Examples can be
+found in the 'inhex' directory.
.SH MICROCODE AND FIRMWARE
There are two standardized methods for downloading microcode (i.e. device
firmware) to a SCSI device. The more general way is with the SCSI WRITE
diff --git a/doc/sg_get_elem_status.8 b/doc/sg_get_elem_status.8
new file mode 100644
index 00000000..a4d533f2
--- /dev/null
+++ b/doc/sg_get_elem_status.8
@@ -0,0 +1,100 @@
+.TH SG_GET_ELEM_STATUS "8" "August 2019" "sg3_utils\-1.45" SG3_UTILS
+.SH NAME
+sg_get_elem_status \- send SCSI GET PHYSICAL ELEMENT STATUS command
+.SH SYNOPSIS
+.B sg_get_elem_status
+[\fI\-\-brief\fR] [\fI\-\-filter=FLT\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
+[\fI\-\-inhex=FN\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-raw\fR]
+[\fI\-\-readonly\fR] [\fI\-\-report\-type=RT\fR] [\fI\-\-starting=ELEM\fR]
+[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
+.SH DESCRIPTION
+.\" Add any additional description here
+.PP
+Send the SCSI GET PHYSICAL ELEMENT STATUS command to the \fIDEVICE\fR and
+output the response. The command was introduced in (draft) SBC\-4 revision
+16.
+.PP
+The default action is to decode the response into one physical element
+status descriptor per line then output a header and the status descriptors
+to stdout. The amount of output can be reduced by the \fI\-\-brief\fR option.
+.PP
+Rather than send this SCSI command to \fIDEVICE\fR, if the \fI\-\-inhex=FN\fR
+option is given, then the contents of the file named \fIFN\fR are decoded
+as ASCII hex and then processed if it was the response of this command.
+.SH OPTIONS
+Arguments to long options are mandatory for short options as well.
+.TP
+\fB\-b\fR, \fB\-\-brief\fR
+tbd
+.TP
+\fB\-f\fR, \fB\-\-filter\fR=\fIFLT\fR
+where \fIFLT\fR is placed in a two bit field called FILTER in the GET
+PHYSICAL ELEMENT STATUS command. Only two values are defined for that
+field: 0 for all element descriptors; 1 for those element descriptors that
+are outside 'spec' or have depopulation information to report. In both cases
+the REPORT TYPE and STARTING ELEMENT fields may further restrict (reduce)
+the number of element descriptors returned. The default value is zero.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+output the usage message then exit.
+.TP
+\fB\-H\fR, \fB\-\-hex\fR
+output response to this command in ASCII hex.
+.TP
+\fB\-i\fR, \fB\-\-inhex\fR=\fIFN\fR
+where \fIFN\fR is a function name whose contents are assumed to be ASCII
+hexadecimal. If \fIDEVICE\fR is also given then \fIDEVICE\fR is ignored,
+a warning is issued and the utility continues, decoding the file named
+\fIFN\fR. See the "FORMAT OF FILES CONTAINING ASCII HEX" section in the
+sg3_utils manpage for more information. If the \fI\-\-raw\fR option is
+also given then the contents of \fIFN\fR are treated as binary.
+.TP
+\fB\-m\fR, \fB\-\-maxlen\fR=\fILEN\fR
+where \fILEN\fR is the (maximum) response length in bytes. It is placed in
+the cdb's "allocation length" field. If not given then 32 is used. 32 is
+enough space for the response header only.
+\fILEN\fR should be a multiple of 32 (e.g. 32, 64, and 96 are suitable).
+.TP
+\fB\-r\fR, \fB\-\-raw\fR
+output response in binary (to stdout) unless the \fI\-\-inhex=FN\fR option
+is also given. In that case the input file name (\fIFN\fR) is decoded as
+binary (and the output is _not_ in binary).
+.TP
+\fB\-R\fR, \fB\-\-readonly\fR
+open the \fIDEVICE\fR read\-only (e.g. in Unix with the O_RDONLY flag).
+The default is to open it read\-write.
+.TP
+\fB\-t\fR, \fB\-\-report\-type\fR=\fIRT\fR
+where \fIRT\fR will be placed in the REPORT TYPE field of the GET PHYSICAL
+ELEMENT STATUS command. Currently only two values are defined: 0
+for 'physical element' and 1: for 'storage element'. The default value
+is 1 .
+.TP
+\fB\-s\fR, \fB\-\-starting\fR=\fIELEM\fR
+where \fIELEM\fR is the placed in the STARTING ELEMENT field of the GET
+PHYSICAL ELEMENT STATUS command. Only physical elements with identifiers
+equal to or greater than \fIELEM\fR are returned. The default value is zero
+which while it isn't a valid element identifier (since they must be
+non\-zero) is given in an example in Annex L of SBC\-4 revision 17. So
+an \fIELEM\fR of zero is assumed to be valid in this context.
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+increase the level of verbosity, (i.e. debug output). Additional output
+caused by this option is sent to stderr.
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+print the version string and then exit.
+.SH EXIT STATUS
+The exit status of sg_get_elem_status is 0 when it is successful. Otherwise
+see the sg3_utils(8) man page.
+.SH AUTHORS
+Written by Douglas Gilbert.
+.SH "REPORTING BUGS"
+Report bugs to <dgilbert at interlog dot com>.
+.SH COPYRIGHT
+Copyright \(co 2019 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.
+.SH "SEE ALSO"
+.B sg_get_lba_status(8), sg3_utils(8)
diff --git a/doc/sg_get_lba_status.8 b/doc/sg_get_lba_status.8
index bc35208f..347a958b 100644
--- a/doc/sg_get_lba_status.8
+++ b/doc/sg_get_lba_status.8
@@ -1,12 +1,13 @@
-.TH SG_GET_LBA_STATUS "8" "August 2018" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_GET_LBA_STATUS "8" "August 2019" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg_get_lba_status \- send SCSI GET LBA STATUS(16 or 32) command
.SH SYNOPSIS
.B sg_get_lba_status
[\fI\-\-16\fR] [\fI\-\-32\fR] [\fI\-\-brief\fR] [\fI\-\-element-id=EI\fR]
-[\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-lba=LBA\fR] [\fI\-\-maxlen=LEN\fR]
-[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-report\-type=RT\fR]
-[\fI\-\-scan-len=SL\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
+[\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-inhex=FN\fR] [\fI\-\-lba=LBA\fR]
+[\fI\-\-maxlen=LEN\fR] [\fI\-\-raw\fR] [\fI\-\-readonly\fR]
+[\fI\-\-report\-type=RT\fR] [\fI\-\-scan-len=SL\fR] [\fI\-\-verbose\fR]
+[\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -17,12 +18,17 @@ block provisioning should support this command. The GET LBA STATUS(32)
command was added in (draft) SBC\-4 revision 14.
.PP
The default action is to decode the response into one LBA status descriptor
-per line output to stdout. The descriptor LBA is output in hex (prefixed
-by '0x') and the number of blocks is output in decimal followed by the
-provisioning status and additional status in decimal. The provisioning status
-can be in the range 0 to 15 of which only 0 (mapped or unknown), 1 (unmapped),
-2 (anchored), 3 (mapped) and 4 (unknown) are used currently. The amount of
-output can be reduced by the \fI\-\-brief\fR option.
+per line then output a header and the status descriptors to stdout. The
+descriptor LBA is output in hex (prefixed by '0x') and the number of blocks
+is output in decimal followed by the provisioning status and additional status
+in decimal. The provisioning status can be in the range 0 to 15 of which only
+0 (mapped or unknown), 1 (unmapped), 2 (anchored), 3 (mapped) and 4 (unknown)
+are used currently. The amount of output can be reduced by the
+\fI\-\-brief\fR option.
+.PP
+Rather than send this SCSI command to \fIDEVICE\fR, if the \fI\-\-inhex=FN\fR
+option is given, then the contents of the file named \fIFN\fR are decoded
+as ASCII hex and then processed if it was the response of this command.
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
.TP
@@ -65,6 +71,13 @@ output the usage message then exit.
\fB\-H\fR, \fB\-\-hex\fR
output response to this command in ASCII hex.
.TP
+\fB\-i\fR, \fB\-\-inhex\fR=\fIFN\fR
+where \fIFN\fR is a filename whose contents are assumed to be ASCII
+hexadecimal bytes. See the "FORMAT OF FILES CONTAINING ASCII HEX" section
+in the sg3_utils manpage for more information. If \fIDEVICE\fR is also
+given then it is ignored. If the \fI\-\-raw\fR option is also given then
+the contents of \fIFN\fR are treated as binary.
+.TP
\fB\-l\fR, \fB\-\-lba\fR=\fILBA\fR
where \fILBA\fR is the starting Logical Block Address (LBA) to check the
provisioning status for. Note that the \fIDEVICE\fR chooses how many
@@ -77,7 +90,9 @@ enough space for the response header and one LBA status descriptor.
\fILEN\fR should be 8 plus a multiple of 16 (e.g. 24, 40, and 56 are suitable).
.TP
\fB\-r\fR, \fB\-\-raw\fR
-output response in binary (to stdout).
+output response in binary (to stdout) unless the \fI\-\-inhex=FN\fR option
+is also given. In that case the input file name (\fIFN\fR) is decoded as
+binary (and the output is _not_ in binary).
.TP
\fB\-R\fR, \fB\-\-readonly\fR
open the \fIDEVICE\fR read\-only (e.g. in Unix with the O_RDONLY flag).
@@ -126,9 +141,9 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2009\-2018 Douglas Gilbert
+Copyright \(co 2009\-2019 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.
.SH "SEE ALSO"
-.B sg_write_same(8), sg_unmap(8)
+.B sg_write_same(8), sg_unmap(8), sg3_utils(8)
diff --git a/doc/sg_ses.8 b/doc/sg_ses.8
index 43aff256..044fa1af 100644
--- a/doc/sg_ses.8
+++ b/doc/sg_ses.8
@@ -1,4 +1,4 @@
-.TH SG_SES "8" "July 2019" "sg3_utils\-1.45" SG3_UTILS
+.TH SG_SES "8" "August 2019" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg_ses \- access a SCSI Enclosure Services (SES) device
.SH SYNOPSIS
@@ -11,7 +11,7 @@ sg_ses \- access a SCSI Enclosure Services (SES) device
[\fI\-\-status\fR] [\fI\-\-verbose\fR] [\fI\-\-warn\fR] \fIDEVICE\fR
.PP
.B sg_ses
-[\fI\-\-byte1=B1\fR] [\fI\-\-clear=STR\fR] [\fI\-\-control\fR]
+\fI\-\-control\fR [\fI\-\-byte1=B1\fR] [\fI\-\-clear=STR\fR]
[\fI\-\-data=H,H...\fR] [\fI\-\-data=@FN\fR] [\fI\-\-descriptor=DES\fR]
[\fI\-\-dev\-slot\-num=SN\fR] [\fI\-\-index=IIA\fR | \fI\-\-index=TIA,II\fR]
[\fI\-\-mask\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-nickname=SEN\fR]
@@ -22,6 +22,10 @@ sg_ses \- access a SCSI Enclosure Services (SES) device
.B sg_ses
\fI\-\-data=@FN\fR \fI\-\-status\fR [\fI\-\-raw\fR \fI\-\-raw\fR]
[<all options from first form>]
+.br
+.B sg_ses
+\fI\-\-inhex=FN\fR \fI\-\-status\fR [\fI\-\-raw\fR \fI\-\-raw\fR]
+[<all options from first form>]
.PP
.B sg_ses
[\fI\-\-enumerate\fR] [\fI\-\-index=IIA\fR] [\fI\-\-list\fR] [\fI\-\-help\fR]
@@ -58,11 +62,12 @@ enclosure (e.g. requesting the "ident" (locate) LED to flash on a disk
carrier in an array) is typically done using a read\-modify\-write cycle.
See the section on CHANGING STATE below.
.PP
-The third form in the synopsis shows the options for decoding the contents
-of a file that holds a hexadecimal or binary representation of a SES
-dpage response. Typically an earlier invocation of the first form of this
-utility with the '\-HHHH' option would have generated that file. Since no
-SCSI commands are sent, the \fIDEVICE\fR argument if given will be ignored.
+The third form in the synopsis has two equivalent invocations shown. They
+decode the contents of a file (named \fIFN\fR) that holds a hexadecimal or
+binary representation of one, or many, SES dpage responses. Typically an
+earlier invocation of the first form of this utility with the '\-HHHH'
+option would have generated that file. Since no SCSI commands are sent, the
+\fIDEVICE\fR argument if given will be ignored.
.PP
The last form in the synopsis shows the options for providing command line
help (i.e. usage information), listing out dpage and field information tables
@@ -233,6 +238,14 @@ option or one of the \fI\-\-clear=STR\fR, \fI\-\-get=STR\fR or
\fI\-\-set=STR\fR options. To enumerate the available Element type
abbreviations use the \fI\-\-enumerate\fR option.
.TP
+\fB\-X\fR, \fB\-\-inhex\fR=\fIFN\fR
+where \fIFN\fR is a filename. It has the equivalent action of the
+\fI\-\-data=@FN\fR option. If \fIFN\fR is '\-' then stdin is read. This
+option has been given for compatibility with other utilities in this
+package that use \fI\-\-inhex=FN\fR (or \fI\-\-in=FN\fR) is a similar
+way. See the "FORMAT OF FILES CONTAINING ASCII HEX" section in the
+sg3_utils manpage for more information.
+.TP
\fB\-i\fR, \fB\-\-inner\-hex\fR
the outer levels of a status dpage are decoded and printed out but the
innermost level (e.g. the Element Status Descriptor) is output in hex. Also
diff --git a/include/Makefile.in b/include/Makefile.in
index 2e96a5fd..6ee60f64 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -291,6 +291,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/include/sg_lib.h b/include/sg_lib.h
index f6eda9db..f1256794 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -574,7 +574,8 @@ int hex2str(const uint8_t * b_str, int len, const char * leadin, int format,
* line or a comma, space or tab separated list of bytes. If no_space is
* set then a string of ACSII hex digits is expected, 2 per byte. Everything
* from and including a '#' on a line is ignored. Returns 0 if ok, or an
- * error code. */
+ * error code. If the error code is SG_LIB_LBA_OUT_OF_RANGE then mp_arr
+ * would be exceeded and both mp_arr and mp_arr_len are written to. */
int sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
uint8_t * mp_arr, int * mp_arr_len, int max_arr_len);
diff --git a/inhex/README b/inhex/README
new file mode 100644
index 00000000..d7654665
--- /dev/null
+++ b/inhex/README
@@ -0,0 +1,50 @@
+ Hex data for various sg3_utils utilities
+ ========================================
+
+The files in this folder contain hexadecimal data (in ASCII) and associated
+comments (prefixed with the hash mark symbol ('#')).
+
+The utility that each hex file is associated with can be determined by
+prepending "sg_" to these filenames then going to the 'src' folder (a
+sibling folder to this one) and look for a match or partial match on
+the name.
+
+For example:
+ vpd_dev_id.hex
+after prepending 'sg_' becomes:
+ sg_vpd_dev_id.hex
+which is a partial match on the sg_vpd utility.
+The remaining 'dev_id.hex' is meant to suggest the 'device identifier'
+VPD page which is a mandatory VPD page.
+
+Assuming sg3_utils is installed, it can be tested like this:
+ sg_vpd --inhex=<folder_holding_sg3_utils>/inhex/vpd_dev_id.hex
+
+And should output this:
+
+Device Identification VPD page:
+ Addressed logical unit:
+ designator type: NAA, code set: Binary
+ 0x5000c5003011cb2b
+ Target port:
+ designator type: NAA, code set: Binary
+ transport: Serial Attached SCSI Protocol (SPL-4)
+ 0x5000c5003011cb29
+ designator type: Relative target port, code set: Binary
+ transport: Serial Attached SCSI Protocol (SPL-4)
+ Relative target port: 0x1
+ Target device that contains addressed lu:
+ designator type: NAA, code set: Binary
+ transport: Serial Attached SCSI Protocol (SPL-4)
+ 0x5000c5003011cb28
+ designator type: SCSI name string, code set: UTF-8
+ SCSI name string:
+ naa.5000C5003011CB28
+
+
+Users are encouraged to send the author any ASCII hex files for utilities
+that support --inhex and don't have hex data already. Special cases are
+also welcome. They help the author test this code.
+
+Douglas Gilbert
+28th August 2019
diff --git a/inhex/get_elem_status.hex b/inhex/get_elem_status.hex
new file mode 100644
index 00000000..7db83c81
--- /dev/null
+++ b/inhex/get_elem_status.hex
@@ -0,0 +1,35 @@
+# To test sg_get_elem_status with dummy response to the SCSI
+# GET PHYSICAL ELEMENT SATUS command
+
+0 0 0 4
+0 0 0 2
+0 0 0 2
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+# first descriptor
+0 0 0 0
+0 0 0 1
+
+0 0 0 0 0
+0
+1
+2c
+0 0 0 0 11 22 33 0
+
+0 0 0 0 0 0 0 0
+
+# second descriptor
+0 0 0 0
+0 0 0 2
+
+0 0 0 0 0
+1
+1
+fe
+ff ff ff ff ff ff ff ff
+
+0 0 0 0 0 0 0 0
+
+
+
diff --git a/inhex/get_lba_status.hex b/inhex/get_lba_status.hex
new file mode 100644
index 00000000..97934fa6
--- /dev/null
+++ b/inhex/get_lba_status.hex
@@ -0,0 +1,14 @@
+
+
+0 0 0 24
+0 0 0 6
+
+0 0 0 0 0 0 0 0
+11 22 33 0
+
+0 0 0 0
+
+0 0 0 0 11 22 33 0
+0 0 0 44
+
+1 1 0 0
diff --git a/inhex/ses_areca_all.hex b/inhex/ses_areca_all.hex
new file mode 100644
index 00000000..96e3e46a
--- /dev/null
+++ b/inhex/ses_areca_all.hex
@@ -0,0 +1,186 @@
+
+# Supported Diagnostic Pages dpage:
+00 00 00 0b 00 01 02 04 05 07 0a 0d 0e 0f 3f
+
+# Configuration (SES) dpage:
+01 00 01 28 00 00 00 00 11 00 09 2c d5 b4 01 50
+3f c0 ec 16 41 72 65 63 61 20 20 20 41 52 43 2d
+38 30 32 38 30 31 2e 33 33 2e 36 33 30 31 33 33
+11 22 33 44 55 00 00 00 17 18 00 18 0e 01 00 1c
+18 01 00 0c 03 05 00 1a 04 02 00 17 12 02 00 1a
+19 03 00 16 02 02 00 17 06 01 00 18 41 72 72 61
+79 44 65 76 69 63 65 73 49 6e 53 75 62 45 6e 63
+6c 73 72 30 45 6e 63 6c 6f 73 75 72 65 45 6c 65
+6d 65 6e 74 49 6e 53 75 62 45 6e 63 6c 73 72 30
+53 41 53 20 45 78 70 61 6e 64 65 72 43 6f 6f 6c
+69 6e 67 45 6c 65 6d 65 6e 74 49 6e 53 75 62 45
+6e 63 6c 73 72 30 54 65 6d 70 53 65 6e 73 6f 72
+73 49 6e 53 75 62 45 6e 63 6c 73 72 30 56 6f 6c
+74 61 67 65 53 65 6e 73 6f 72 73 49 6e 53 75 62
+45 6e 63 6c 73 72 30 43 6f 6e 6e 65 63 74 6f 72
+73 49 6e 53 75 62 45 6e 63 6c 73 72 30 50 6f 77
+65 72 53 75 70 70 6c 79 49 6e 53 75 62 45 6e 63
+6c 73 72 30 41 75 64 69 62 6c 65 41 6c 61 72 6d
+49 6e 53 75 62 45 6e 63 6c 73 72 30
+
+# Enclosure Status (SES) dpage:
+02 02 00 cc 00 00 00 00 00 00 00 00 05 00 00 00
+05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00
+05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00
+05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00
+05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00
+05 00 00 00 01 00 00 00 05 00 00 00 05 00 00 00
+05 00 00 00 05 00 00 00 05 00 00 00 00 00 00 00
+01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
+05 00 00 10 05 00 00 10 05 00 00 10 05 00 00 10
+01 02 ee 07 00 00 00 00 01 00 45 00 01 00 56 00
+00 00 00 00 01 00 00 5e 01 00 00 b4 00 00 00 00
+01 05 00 00 01 05 00 00 01 05 00 00 00 00 00 00
+05 00 00 20 05 00 00 20 00 00 00 00 01 00 00 00
+
+# String In (SES) dpage:
+04 00 00 2e 57 65 20 68 61 76 65 20 69 6d 70 6c
+65 6d 65 6e 74 65 64 20 53 74 72 69 6e 67 20 49
+6e 20 44 69 61 67 6e 6f 73 74 69 63 20 50 61 67
+65 00
+
+# Threshold In (SES) dpage:
+05 00 00 c4 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 63 50 19 14 73 6e 19 14
+00 00 00 00 82 7f 70 6d 7a 77 69 66 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+
+# Element Descriptor (SES) dpage:
+07 00 03 0e 00 00 00 00 00 00 00 18 41 72 72 61
+79 44 65 76 69 63 65 73 49 6e 53 75 62 45 6e 63
+6c 73 72 30 00 00 00 08 53 4c 4f 54 20 30 31 00
+00 00 00 08 53 4c 4f 54 20 30 32 00 00 00 00 08
+53 4c 4f 54 20 30 33 00 00 00 00 08 53 4c 4f 54
+20 30 34 00 00 00 00 08 53 4c 4f 54 20 30 35 00
+00 00 00 08 53 4c 4f 54 20 30 36 00 00 00 00 08
+53 4c 4f 54 20 30 37 00 00 00 00 08 53 4c 4f 54
+20 30 38 00 00 00 00 08 53 4c 4f 54 20 30 39 00
+00 00 00 08 53 4c 4f 54 20 31 30 00 00 00 00 08
+53 4c 4f 54 20 31 31 00 00 00 00 08 53 4c 4f 54
+20 31 32 00 00 00 00 08 53 4c 4f 54 20 31 33 00
+00 00 00 08 53 4c 4f 54 20 31 34 00 00 00 00 08
+53 4c 4f 54 20 31 35 00 00 00 00 08 53 4c 4f 54
+20 31 36 00 00 00 00 08 53 4c 4f 54 20 31 37 00
+00 00 00 08 53 4c 4f 54 20 31 38 00 00 00 00 08
+53 4c 4f 54 20 31 39 00 00 00 00 08 53 4c 4f 54
+20 32 30 00 00 00 00 08 53 4c 4f 54 20 32 31 00
+00 00 00 08 53 4c 4f 54 20 32 32 00 00 00 00 08
+53 4c 4f 54 20 32 33 00 00 00 00 08 53 4c 4f 54
+20 32 34 00 00 00 00 1c 45 6e 63 6c 6f 73 75 72
+65 45 6c 65 6d 65 6e 74 49 6e 53 75 62 45 6e 63
+6c 73 72 30 00 00 00 12 45 6e 63 6c 6f 73 75 72
+65 45 6c 65 6d 65 6e 74 30 31 00 00 00 0c 53 41
+53 20 45 78 70 61 6e 64 65 72 00 00 00 09 45 78
+70 61 6e 64 65 72 30 00 00 00 1a 43 6f 6f 6c 69
+6e 67 45 6c 65 6d 65 6e 74 49 6e 53 75 62 45 6e
+63 6c 73 72 30 00 00 00 07 46 61 6e 20 30 31 00
+00 00 00 07 46 61 6e 20 30 32 00 00 00 00 07 46
+61 6e 20 30 33 00 00 00 00 07 46 61 6e 20 30 34
+00 00 00 00 07 43 50 55 46 61 6e 00 00 00 00 17
+54 65 6d 70 53 65 6e 73 6f 72 73 49 6e 53 75 62
+45 6e 63 6c 73 72 30 00 00 00 0c 45 4e 43 2e 20
+54 65 6d 70 20 20 00 00 00 00 0c 43 68 69 70 20
+54 65 6d 70 20 20 00 00 00 00 1a 56 6f 6c 74 61
+67 65 53 65 6e 73 6f 72 73 49 6e 53 75 62 45 6e
+63 6c 73 72 30 00 00 00 07 30 2e 39 35 56 20 00
+00 00 00 07 31 2e 38 56 20 20 00 00 00 00 16 43
+6f 6e 6e 65 63 74 6f 72 73 49 6e 53 75 62 45 6e
+63 6c 73 72 30 00 00 00 0c 43 6f 6e 6e 65 63 74
+6f 72 30 30 00 00 00 00 0c 43 6f 6e 6e 65 63 74
+6f 72 30 31 00 00 00 00 0c 43 6f 6e 6e 65 63 74
+6f 72 30 32 00 00 00 00 17 50 6f 77 65 72 53 75
+70 70 6c 79 49 6e 53 75 62 45 6e 63 6c 73 72 30
+00 00 00 0e 50 6f 77 65 72 53 75 70 70 6c 79 30
+31 00 00 00 00 0e 50 6f 77 65 72 53 75 70 70 6c
+79 30 32 00 00 00 00 18 41 75 64 69 62 6c 65 41
+6c 61 72 6d 49 6e 53 75 62 45 6e 63 6c 73 72 30
+00 00 00 0e 41 75 64 69 62 6c 65 2d 41 6c 61 72
+6d 00
+
+# Additional Element Status (SES-2) dpage:
+0a 00 03 bc 00 00 00 00 16 22 00 00 01 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 16 22 00 01
+01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+16 22 00 02 01 00 00 02 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 16 22 00 03 01 00 00 03 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 16 22 00 04 01 00 00 04
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 16 22 00 05
+01 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+16 22 00 06 01 00 00 06 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 16 22 00 07 01 00 00 07 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 16 22 00 08 01 00 00 08
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 16 22 00 09
+01 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+16 22 00 0a 01 00 00 0a 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 16 22 00 0b 01 00 00 0b 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 16 22 00 0c 01 00 00 0c
+20 00 00 02 50 01 b4 d5 16 ec c0 3f 50 01 51 7e
+85 c3 ef ff 14 00 00 00 00 00 00 00 16 22 00 0d
+01 00 00 0d 20 00 00 02 50 01 b4 d5 16 ec c0 3f
+50 01 51 7e 85 c3 ef ff 15 00 00 00 00 00 00 00
+16 22 00 0e 01 00 00 0e 20 00 00 02 50 01 b4 d5
+16 ec c0 3f 50 01 51 7e 85 c3 ef ff 16 00 00 00
+00 00 00 00 16 22 00 0f 01 00 00 0f 20 00 00 02
+50 01 b4 d5 16 ec c0 3f 50 01 51 7e 85 c3 ef ff
+17 00 00 00 00 00 00 00 16 22 00 10 01 00 00 10
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 16 22 00 11
+01 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+16 22 00 12 01 00 00 12 10 00 00 08 50 01 b4 d5
+16 ec c0 3f 50 00 c5 00 30 11 cb 29 00 00 00 00
+00 00 00 00 16 22 00 13 01 00 00 13 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 16 22 00 14 01 00 00 14
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 16 22 00 15
+01 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+16 22 00 16 01 00 00 16 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 16 22 00 17 01 00 00 17 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 16 56 00 00 24 40 00 00
+50 01 b4 d5 16 ec c0 3f ff 0d ff 0c ff 0e ff 0f
+ff 09 ff 08 ff 0a ff 0b ff 05 ff 04 ff 06 ff 07
+ff 01 ff 00 ff 02 ff 03 02 ff 02 ff 02 ff 02 ff
+01 ff 01 ff 01 ff 01 ff 00 ff 00 ff 00 ff 00 ff
+ff 11 ff 10 ff 12 ff 13 ff 15 ff 14 ff 16 ff 17
+
+# Supported SES Diagnostic Pages (SES-2) dpage:
+0d 00 00 0c 01 02 04 05 07 0a 0d 0e 0f 00 00 00
+
+# Download Microcode (SES-2) dpage:
+0e 00 00 14 00 00 00 00 00 00 00 00 00 10 00 00
+00 00 00 00 00 00 00 00
+
+# Subenclosure Nickname (SES-2) dpage:
+0f 00 00 2c 00 00 00 00 00 00 00 00 00 00 00 00
+45 76 61 6c 20 42 6f 61 72 64 20 4e 69 63 6b 6e
+61 6d 65 20 53 69 6d 75 6c 61 74 6f 72 20 20 20
diff --git a/inhex/vpd_consistuents.hex b/inhex/vpd_consistuents.hex
new file mode 100644
index 00000000..57fbb7cc
--- /dev/null
+++ b/inhex/vpd_consistuents.hex
@@ -0,0 +1,38 @@
+00 8b 00 c6
+
+00 03 00 00
+
+41 42 43 44 20 20 00 00
+41 42 43 44 45 46 47 48 41 42 43 44 44 44 44 44
+30 31 32 33
+
+00 00 00 2e
+
+01 00 00 14
+
+01 b5 00 10 00 00 00 00
+03 01 20 e0
+07 02 10 80 00 00 00 00
+
+01 00 00 12
+
+00 92 00 0e 00 00 00 00
+00 01 01 01 01 02 02 01
+09 09
+
+
+00 03 00 00
+
+53 45 41 47 41 54 45 20
+53 54 32 30 30 46 4d 30 30 37 33 20 20 20 20 20
+30 30 30 37
+
+00 00 00 50
+
+01 00 00 4c
+
+00 83 00 48 01 03 00 08 50 00 c5 00 30 11 cb 2b
+61 93 00 08 50 00 c5 00 30 11 cb 29 61 94 00 04
+00 00 00 01 61 a3 00 08 50 00 c5 00 30 11 cb 28
+03 28 00 18 6e 61 61 2e 35 30 30 30 43 35 30 30
+33 30 31 31 43 42 32 38 00 00 00 00
diff --git a/inhex/vpd_dev_id.hex b/inhex/vpd_dev_id.hex
new file mode 100644
index 00000000..073e87df
--- /dev/null
+++ b/inhex/vpd_dev_id.hex
@@ -0,0 +1,5 @@
+00 83 00 48 01 03 00 08 50 00 c5 00 30 11 cb 2b
+61 93 00 08 50 00 c5 00 30 11 cb 29 61 94 00 04
+00 00 00 01 61 a3 00 08 50 00 c5 00 30 11 cb 28
+03 28 00 18 6e 61 61 2e 35 30 30 30 43 35 30 30
+33 30 31 31 43 42 32 38 00 00 00 00
diff --git a/inhex/vpd_lbpro.hex b/inhex/vpd_lbpro.hex
new file mode 100644
index 00000000..639e74bd
--- /dev/null
+++ b/inhex/vpd_lbpro.hex
@@ -0,0 +1,4 @@
+
+01 b5 00 10 00 00 00 00
+03 01 20 e0
+07 02 10 80 00 00 00 00
diff --git a/inhex/vpd_sfs.hex b/inhex/vpd_sfs.hex
new file mode 100644
index 00000000..b9d282f5
--- /dev/null
+++ b/inhex/vpd_sfs.hex
@@ -0,0 +1,3 @@
+00 92 00 0e 00 00 00 00
+00 01 01 01 01 02 02 01
+09 09
diff --git a/install-sh b/install-sh
index defb86ae..8175c640 100755
--- a/install-sh
+++ b/install-sh
@@ -1,4 +1,4 @@
-#!/usr/bin/sh
+#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2018-03-11.20; # UTC
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 957ae211..a8bcf6ca 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -343,6 +343,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index d400abee..d187d8d3 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -913,7 +913,7 @@ sg_get_designation_descriptor_str(const char * lip, const uint8_t * ddp,
break;
}
ci_off = 0;
- if (16 == dlen) {
+ if (16 == dlen) { /* first 8 bytes are 'Identifier Extension' */
ci_off = 8;
id_ext = sg_get_unaligned_be64(ip);
n += sg_scnpr(b + n, blen - n, "%s Identifier extension: 0x%"
@@ -3351,7 +3351,8 @@ sg_get_llnum_nomult(const char * buf)
* line or a comma, space or tab separated list of bytes. If no_space is
* set then a string of ACSII hex digits is expected, 2 per byte. Everything
* from and including a '#' on a line is ignored. Returns 0 if ok, or an
- * error code. */
+ * error code. If the error code is SG_LIB_LBA_OUT_OF_RANGE then mp_arr
+ * would be exceeded and both mp_arr and mp_arr_len are written to. */
int
sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
uint8_t * mp_arr, int * mp_arr_len, int max_arr_len)
@@ -3359,6 +3360,7 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
bool has_stdin, split_line;
int fn_len, in_len, k, j, m, fd, err;
int off = 0;
+ int ret = 0;
unsigned int h;
const char * lcp;
FILE * fp;
@@ -3386,18 +3388,15 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
}
k = read(fd, mp_arr, max_arr_len);
if (k <= 0) {
- int ret = SG_LIB_SYNTAX_ERROR;
-
- if (0 == k)
+ if (0 == k) {
+ ret = SG_LIB_SYNTAX_ERROR;
pr2serr("read 0 bytes from binary file %s\n", fname);
- else {
+ } else {
ret = sg_convert_errno(errno);
pr2serr("read from binary file %s: %s\n", fname,
safe_strerror(errno));
}
- if (! has_stdin)
- close(fd);
- return ret;
+ goto bin_fini;
}
if ((0 == fstat(fd, &a_stat)) && S_ISFIFO(a_stat.st_mode)) {
/* pipe; keep reading till error or 0 read */
@@ -3409,30 +3408,32 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
err = errno;
pr2serr("read from binary pipe %s: %s\n", fname,
safe_strerror(err));
- if (! has_stdin)
- close(fd);
- return sg_convert_errno(err);
+ ret = sg_convert_errno(err);
+ goto bin_fini;
}
k += m;
}
}
*mp_arr_len = k;
+bin_fini:
if (! has_stdin)
close(fd);
- return 0;
- } else { /* So read the file as ASCII hex */
- if (has_stdin)
- fp = stdin;
- else {
- fp = fopen(fname, "r");
- if (NULL == fp) {
- err = errno;
- pr2serr("Unable to open %s for reading: %s\n", fname,
- safe_strerror(err));
- return sg_convert_errno(err);
- }
+ return ret;
+ }
+
+ /* So read the file as ASCII hex */
+ if (has_stdin)
+ fp = stdin;
+ else {
+ fp = fopen(fname, "r");
+ if (NULL == fp) {
+ err = errno;
+ pr2serr("Unable to open %s for reading: %s\n", fname,
+ safe_strerror(err));
+ ret = sg_convert_errno(err);
+ goto fini;
}
- }
+ }
carry_over[0] = 0;
for (j = 0; j < 512; ++j) {
@@ -3460,7 +3461,8 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
else {
pr2serr("%s: carry_over error ['%s'] around line %d\n",
__func__, carry_over, j + 1);
- goto bad;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
lcp = line + 1;
--in_len;
@@ -3481,7 +3483,8 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
if ((k < in_len) && ('#' != lcp[k]) && ('\r' != lcp[k])) {
pr2serr("%s: syntax error at line %d, pos %d\n", __func__,
j + 1, m + k + 1);
- goto bad;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
if (no_space) {
for (k = 0; isxdigit(*lcp) && isxdigit(*(lcp + 1));
@@ -3489,11 +3492,14 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
if (1 != sscanf(lcp, "%2x", &h)) {
pr2serr("%s: bad hex number in line %d, pos %d\n",
__func__, j + 1, (int)(lcp - line + 1));
- goto bad;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
if ((off + k) >= max_arr_len) {
pr2serr("%s: array length exceeded\n", __func__);
- goto bad;
+ *mp_arr_len = max_arr_len;
+ ret = SG_LIB_LBA_OUT_OF_RANGE;
+ goto fini;
}
mp_arr[off + k] = h;
}
@@ -3507,7 +3513,8 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
pr2serr("%s: hex number larger than 0xff in line "
"%d, pos %d\n", __func__, j + 1,
(int)(lcp - line + 1));
- goto bad;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
if (split_line && (1 == strlen(lcp))) {
/* single trailing hex digit might be a split pair */
@@ -3515,7 +3522,9 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
}
if ((off + k) >= max_arr_len) {
pr2serr("%s: array length exceeded\n", __func__);
- goto bad;
+ ret = SG_LIB_LBA_OUT_OF_RANGE;
+ *mp_arr_len = max_arr_len;
+ goto fini;
}
mp_arr[off + k] = h;
lcp = strpbrk(lcp, " ,\t");
@@ -3531,7 +3540,8 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
}
pr2serr("%s: error in line %d, at pos %d\n", __func__,
j + 1, (int)(lcp - line + 1));
- goto bad;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
}
off += (k + 1);
@@ -3541,10 +3551,10 @@ sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
if (stdin != fp)
fclose(fp);
return 0;
-bad:
+fini:
if (stdin != fp)
fclose(fp);
- return SG_LIB_SYNTAX_ERROR;
+ return ret;
}
/* Extract character sequence from ATA words as in the model string
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index ba0a431f..2ab80e6b 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -19,7 +19,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "2.63 20190716";/* spc5r22, sbc4r17 */
+const char * sg_lib_version_str = "2.67 20190822";/* spc5r22, sbc4r17 */
/* indexed by pdt; those that map to own index do not decay */
@@ -529,6 +529,10 @@ struct sg_lib_value_name_t sg_lib_zoning_out_arr[] = {
/* Zoning in [0x95] service actions */
struct sg_lib_value_name_t sg_lib_zoning_in_arr[] = {
{0x0, PDT_ZBC, "Report zones"},
+ {0x6, PDT_ZBC, "Report realms"}, /* 19-032r3 */
+ {0x7, PDT_ZBC, "Report zone domains"}, /* 19-032r3 */
+ {0x8, PDT_ZBC, "Zone activate"}, /* 19-032r3 */
+ {0x9, PDT_ZBC, "Zone query"}, /* 19-032r3 */
{0xffff, 0, NULL},
};
@@ -718,6 +722,7 @@ struct sg_lib_asc_ascq_t sg_lib_asc_ascq[] =
{0x04,0x21,"Logical unit not ready, hard reset required"},
{0x04,0x22,"Logical unit not ready, power cycle required"},
{0x04,0x23,"Logical unit not ready, affiliation required"},
+ {0x04,0x24,"Depopulation in progress"}, /* spc5r15 */
{0x05,0x00,"Logical unit does not respond to selection"},
{0x06,0x00,"No reference position found"},
{0x07,0x00,"Multiple peripheral devices selected"},
@@ -753,6 +758,7 @@ struct sg_lib_asc_ascq_t sg_lib_asc_ascq[] =
{0x0B,0x11,"Warning - low operating humidity limit exceeded"},
{0x0B,0x12,"Warning - microcode security at risk"},
{0x0B,0x13,"Warning - microcode digital signature validation failure"},
+ {0x0B,0x14,"Warning - physical element status change"}, /* spc5r15 */
{0x0C,0x00,"Write error"},
{0x0C,0x01,"Write error - recovered with auto reallocation"},
{0x0C,0x02,"Write error - auto reallocation failed"},
@@ -1026,6 +1032,7 @@ struct sg_lib_asc_ascq_t sg_lib_asc_ascq[] =
{0x31,0x01,"Format command failed"},
{0x31,0x02,"Zoned formatting failed due to spare linking"},
{0x31,0x03,"Sanitize command failed"},
+ {0x31,0x04,"Depopulation failed"}, /* spc5r15 */
{0x32,0x00,"No defect spare location available"},
{0x32,0x01,"Defect list update failure"},
{0x33,0x00,"Tape length error"},
@@ -1560,6 +1567,7 @@ struct sg_lib_simple_value_name_t sg_lib_nvme_admin_cmd_arr[] =
{0x81, "Security Send"},
{0x82, "Security Receive"},
{0x84, "Sanitize"}, /* last NVM specific in 1.3a */
+ {0x86, "Get LBA status"}, /* NVM specific, new in 1.4 */
/* Vendor specific 0xc0 to 0xff */
{0xffff, NULL}, /* Sentinel */
};
@@ -1635,7 +1643,11 @@ struct sg_lib_value_name_t sg_lib_nvme_cmd_status_arr[] =
{0x1d, 11, "Sanitize in progress"},
{0x1e, 5, "SGL data block granularity invalid"},
{0x1f, 5, "Command not supported for queue in CMB"},
+ {0x20, 18, "Namespace is write protected"}, /* NVMe 1.4 */
+ {0x21, 6, "Command interrupted"}, /* NVMe 1.4 */
+ {0x22, 5, "Transient transport error"}, /* NVMe 1.4 */
+ /* 0x80 - 0xbf: I/O command set specific */
/* Generic command status values, NVM (I/O) Command Set */
{0x80, 12, "LBA out of range"},
{0x81, 3, "Capacity exceeded"},
@@ -1680,6 +1692,9 @@ struct sg_lib_value_name_t sg_lib_nvme_cmd_status_arr[] =
{0x120, 5, "Invalid secondary controller state"},
{0x121, 5, "Invalid number of controller resources"},
{0x122, 5, "Invalid resource identifier"},
+ {0x123, 5, "Sanitize prohibited while PM enabled"}, /* NVMe 1.4 */
+ {0x124, 5, "ANA group identifier invalid"}, /* NVMe 1.4 */
+ {0x125, 5, "ANA attach failed"}, /* NVMe 1.4 */
/* Command specific status values, Status Code Type (SCT): 1h
* for NVM (I/O) Command Set */
diff --git a/ltmain.sh b/ltmain.sh
index 7f3523d3..c12c197b 100755
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -31,7 +31,7 @@
PROGRAM=libtool
PACKAGE=libtool
-VERSION=2.4.6
+VERSION="2.4.6 Debian-2.4.6-9"
package_revision=2.4.6
@@ -1370,7 +1370,7 @@ func_lt_ver ()
#! /bin/sh
# Set a version string for this script.
-scriptversion=2014-01-07.03; # UTC
+scriptversion=2015-10-07.11; # UTC
# A portable, pluggable option parser for Bourne shell.
# Written by Gary V. Vaughan, 2010
@@ -1530,6 +1530,8 @@ func_run_hooks ()
{
$debug_cmd
+ _G_rc_run_hooks=false
+
case " $hookable_fns " in
*" $1 "*) ;;
*) func_fatal_error "'$1' does not support hook funcions.n" ;;
@@ -1538,16 +1540,16 @@ func_run_hooks ()
eval _G_hook_fns=\$$1_hooks; shift
for _G_hook in $_G_hook_fns; do
- eval $_G_hook '"$@"'
-
- # store returned options list back into positional
- # parameters for next 'cmd' execution.
- eval _G_hook_result=\$${_G_hook}_result
- eval set dummy "$_G_hook_result"; shift
+ if eval $_G_hook '"$@"'; then
+ # store returned options list back into positional
+ # parameters for next 'cmd' execution.
+ eval _G_hook_result=\$${_G_hook}_result
+ eval set dummy "$_G_hook_result"; shift
+ _G_rc_run_hooks=:
+ fi
done
- func_quote_for_eval ${1+"$@"}
- func_run_hooks_result=$func_quote_for_eval_result
+ $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
}
@@ -1557,10 +1559,16 @@ func_run_hooks ()
## --------------- ##
# In order to add your own option parsing hooks, you must accept the
-# full positional parameter list in your hook function, remove any
-# options that you action, and then pass back the remaining unprocessed
+# full positional parameter list in your hook function, you may remove/edit
+# any options that you action, and then pass back the remaining unprocessed
# options in '<hooked_function_name>_result', escaped suitably for
-# 'eval'. Like this:
+# 'eval'. In this case you also must return $EXIT_SUCCESS to let the
+# hook's caller know that it should pay attention to
+# '<hooked_function_name>_result'. Returning $EXIT_FAILURE signalizes that
+# arguments are left untouched by the hook and therefore caller will ignore the
+# result variable.
+#
+# Like this:
#
# my_options_prep ()
# {
@@ -1570,9 +1578,11 @@ func_run_hooks ()
# usage_message=$usage_message'
# -s, --silent don'\''t print informational messages
# '
-#
-# func_quote_for_eval ${1+"$@"}
-# my_options_prep_result=$func_quote_for_eval_result
+# # No change in '$@' (ignored completely by this hook). There is
+# # no need to do the equivalent (but slower) action:
+# # func_quote_for_eval ${1+"$@"}
+# # my_options_prep_result=$func_quote_for_eval_result
+# false
# }
# func_add_hook func_options_prep my_options_prep
#
@@ -1581,25 +1591,37 @@ func_run_hooks ()
# {
# $debug_cmd
#
+# args_changed=false
+#
# # Note that for efficiency, we parse as many options as we can
# # recognise in a loop before passing the remainder back to the
# # caller on the first unrecognised argument we encounter.
# while test $# -gt 0; do
# opt=$1; shift
# case $opt in
-# --silent|-s) opt_silent=: ;;
+# --silent|-s) opt_silent=:
+# args_changed=:
+# ;;
# # Separate non-argument short options:
# -s*) func_split_short_opt "$_G_opt"
# set dummy "$func_split_short_opt_name" \
# "-$func_split_short_opt_arg" ${1+"$@"}
# shift
+# args_changed=:
# ;;
-# *) set dummy "$_G_opt" "$*"; shift; break ;;
+# *) # Make sure the first unrecognised option "$_G_opt"
+# # is added back to "$@", we could need that later
+# # if $args_changed is true.
+# set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
# esac
# done
#
-# func_quote_for_eval ${1+"$@"}
-# my_silent_option_result=$func_quote_for_eval_result
+# if $args_changed; then
+# func_quote_for_eval ${1+"$@"}
+# my_silent_option_result=$func_quote_for_eval_result
+# fi
+#
+# $args_changed
# }
# func_add_hook func_parse_options my_silent_option
#
@@ -1611,16 +1633,32 @@ func_run_hooks ()
# $opt_silent && $opt_verbose && func_fatal_help "\
# '--silent' and '--verbose' options are mutually exclusive."
#
-# func_quote_for_eval ${1+"$@"}
-# my_option_validation_result=$func_quote_for_eval_result
+# false
# }
# func_add_hook func_validate_options my_option_validation
#
-# You'll alse need to manually amend $usage_message to reflect the extra
+# You'll also need to manually amend $usage_message to reflect the extra
# options you parse. It's preferable to append if you can, so that
# multiple option parsing hooks can be added safely.
+# func_options_finish [ARG]...
+# ----------------------------
+# Finishing the option parse loop (call 'func_options' hooks ATM).
+func_options_finish ()
+{
+ $debug_cmd
+
+ _G_func_options_finish_exit=false
+ if func_run_hooks func_options ${1+"$@"}; then
+ func_options_finish_result=$func_run_hooks_result
+ _G_func_options_finish_exit=:
+ fi
+
+ $_G_func_options_finish_exit
+}
+
+
# func_options [ARG]...
# ---------------------
# All the functions called inside func_options are hookable. See the
@@ -1630,17 +1668,28 @@ func_options ()
{
$debug_cmd
- func_options_prep ${1+"$@"}
- eval func_parse_options \
- ${func_options_prep_result+"$func_options_prep_result"}
- eval func_validate_options \
- ${func_parse_options_result+"$func_parse_options_result"}
+ _G_rc_options=false
+
+ for my_func in options_prep parse_options validate_options options_finish
+ do
+ if eval func_$my_func '${1+"$@"}'; then
+ eval _G_res_var='$'"func_${my_func}_result"
+ eval set dummy "$_G_res_var" ; shift
+ _G_rc_options=:
+ fi
+ done
- eval func_run_hooks func_options \
- ${func_validate_options_result+"$func_validate_options_result"}
+ # Save modified positional parameters for caller. As a top-level
+ # options-parser function we always need to set the 'func_options_result'
+ # variable (regardless the $_G_rc_options value).
+ if $_G_rc_options; then
+ func_options_result=$_G_res_var
+ else
+ func_quote_for_eval ${1+"$@"}
+ func_options_result=$func_quote_for_eval_result
+ fi
- # save modified positional parameters for caller
- func_options_result=$func_run_hooks_result
+ $_G_rc_options
}
@@ -1649,9 +1698,9 @@ func_options ()
# All initialisations required before starting the option parse loop.
# Note that when calling hook functions, we pass through the list of
# positional parameters. If a hook function modifies that list, and
-# needs to propogate that back to rest of this script, then the complete
+# needs to propagate that back to rest of this script, then the complete
# modified list must be put in 'func_run_hooks_result' before
-# returning.
+# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
func_hookable func_options_prep
func_options_prep ()
{
@@ -1661,10 +1710,14 @@ func_options_prep ()
opt_verbose=false
opt_warning_types=
- func_run_hooks func_options_prep ${1+"$@"}
+ _G_rc_options_prep=false
+ if func_run_hooks func_options_prep ${1+"$@"}; then
+ _G_rc_options_prep=:
+ # save modified positional parameters for caller
+ func_options_prep_result=$func_run_hooks_result
+ fi
- # save modified positional parameters for caller
- func_options_prep_result=$func_run_hooks_result
+ $_G_rc_options_prep
}
@@ -1678,18 +1731,20 @@ func_parse_options ()
func_parse_options_result=
+ _G_rc_parse_options=false
# this just eases exit handling
while test $# -gt 0; do
# Defer to hook functions for initial option parsing, so they
# get priority in the event of reusing an option name.
- func_run_hooks func_parse_options ${1+"$@"}
-
- # Adjust func_parse_options positional parameters to match
- eval set dummy "$func_run_hooks_result"; shift
+ if func_run_hooks func_parse_options ${1+"$@"}; then
+ eval set dummy "$func_run_hooks_result"; shift
+ _G_rc_parse_options=:
+ fi
# Break out of the loop if we already parsed every option.
test $# -gt 0 || break
+ _G_match_parse_options=:
_G_opt=$1
shift
case $_G_opt in
@@ -1704,7 +1759,10 @@ func_parse_options ()
;;
--warnings|--warning|-W)
- test $# = 0 && func_missing_arg $_G_opt && break
+ if test $# = 0 && func_missing_arg $_G_opt; then
+ _G_rc_parse_options=:
+ break
+ fi
case " $warning_categories $1" in
*" $1 "*)
# trailing space prevents matching last $1 above
@@ -1757,15 +1815,25 @@ func_parse_options ()
shift
;;
- --) break ;;
+ --) _G_rc_parse_options=: ; break ;;
-*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
- *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+ *) set dummy "$_G_opt" ${1+"$@"}; shift
+ _G_match_parse_options=false
+ break
+ ;;
esac
+
+ $_G_match_parse_options && _G_rc_parse_options=:
done
- # save modified positional parameters for caller
- func_quote_for_eval ${1+"$@"}
- func_parse_options_result=$func_quote_for_eval_result
+
+ if $_G_rc_parse_options; then
+ # save modified positional parameters for caller
+ func_quote_for_eval ${1+"$@"}
+ func_parse_options_result=$func_quote_for_eval_result
+ fi
+
+ $_G_rc_parse_options
}
@@ -1778,16 +1846,21 @@ func_validate_options ()
{
$debug_cmd
+ _G_rc_validate_options=false
+
# Display all warnings if -W was not given.
test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
- func_run_hooks func_validate_options ${1+"$@"}
+ if func_run_hooks func_validate_options ${1+"$@"}; then
+ # save modified positional parameters for caller
+ func_validate_options_result=$func_run_hooks_result
+ _G_rc_validate_options=:
+ fi
# Bail if the options were screwed!
$exit_cmd $EXIT_FAILURE
- # save modified positional parameters for caller
- func_validate_options_result=$func_run_hooks_result
+ $_G_rc_validate_options
}
@@ -2068,12 +2141,12 @@ include the following information:
compiler: $LTCC
compiler flags: $LTCFLAGS
linker: $LD (gnu? $with_gnu_ld)
- version: $progname (GNU libtool) 2.4.6
+ version: $progname $scriptversion Debian-2.4.6-9
automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Report bugs to <bug-libtool@gnu.org>.
-GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+GNU libtool home page: <http://www.gnu.org/s/libtool/>.
General help using GNU software: <http://www.gnu.org/gethelp/>."
exit 0
}
@@ -2124,7 +2197,7 @@ fi
# a configuration failure hint, and exit.
func_fatal_configuration ()
{
- func_fatal_error ${1+"$@"} \
+ func__fatal_error ${1+"$@"} \
"See the $PACKAGE documentation for more information." \
"Fatal configuration error."
}
@@ -2270,6 +2343,8 @@ libtool_options_prep ()
nonopt=
preserve_args=
+ _G_rc_lt_options_prep=:
+
# Shorthand for --mode=foo, only valid as the first argument
case $1 in
clean|clea|cle|cl)
@@ -2293,11 +2368,18 @@ libtool_options_prep ()
uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
shift; set dummy --mode uninstall ${1+"$@"}; shift
;;
+ *)
+ _G_rc_lt_options_prep=false
+ ;;
esac
- # Pass back the list of options.
- func_quote_for_eval ${1+"$@"}
- libtool_options_prep_result=$func_quote_for_eval_result
+ if $_G_rc_lt_options_prep; then
+ # Pass back the list of options.
+ func_quote_for_eval ${1+"$@"}
+ libtool_options_prep_result=$func_quote_for_eval_result
+ fi
+
+ $_G_rc_lt_options_prep
}
func_add_hook func_options_prep libtool_options_prep
@@ -2309,9 +2391,12 @@ libtool_parse_options ()
{
$debug_cmd
+ _G_rc_lt_parse_options=false
+
# Perform our own loop to consume as many options as possible in
# each iteration.
while test $# -gt 0; do
+ _G_match_lt_parse_options=:
_G_opt=$1
shift
case $_G_opt in
@@ -2386,15 +2471,22 @@ libtool_parse_options ()
func_append preserve_args " $_G_opt"
;;
- # An option not handled by this hook function:
- *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+ # An option not handled by this hook function:
+ *) set dummy "$_G_opt" ${1+"$@"} ; shift
+ _G_match_lt_parse_options=false
+ break
+ ;;
esac
+ $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
done
+ if $_G_rc_lt_parse_options; then
+ # save modified positional parameters for caller
+ func_quote_for_eval ${1+"$@"}
+ libtool_parse_options_result=$func_quote_for_eval_result
+ fi
- # save modified positional parameters for caller
- func_quote_for_eval ${1+"$@"}
- libtool_parse_options_result=$func_quote_for_eval_result
+ $_G_rc_lt_parse_options
}
func_add_hook func_parse_options libtool_parse_options
@@ -7274,10 +7366,12 @@ func_mode_link ()
# -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
# -specs=* GCC specs files
# -stdlib=* select c++ std lib with clang
+ # -fsanitize=* Clang/GCC memory and address sanitizer
+ # -fuse-ld=* Linker select flags for GCC
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
- -specs=*)
+ -specs=*|-fsanitize=*|-fuse-ld=*)
func_quote_for_eval "$arg"
arg=$func_quote_for_eval_result
func_append compile_command " $arg"
@@ -7570,7 +7664,10 @@ func_mode_link ()
case $pass in
dlopen) libs=$dlfiles ;;
dlpreopen) libs=$dlprefiles ;;
- link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ link)
+ libs="$deplibs %DEPLIBS%"
+ test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+ ;;
esac
fi
if test lib,dlpreopen = "$linkmode,$pass"; then
@@ -7889,19 +7986,19 @@ func_mode_link ()
# It is a libtool convenience library, so add in its objects.
func_append convenience " $ladir/$objdir/$old_library"
func_append old_convenience " $ladir/$objdir/$old_library"
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if $opt_preserve_dup_deps; then
+ case "$tmp_libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append tmp_libs " $deplib"
+ done
elif test prog != "$linkmode" && test lib != "$linkmode"; then
func_fatal_error "'$lib' is not a convenience library"
fi
- tmp_libs=
- for deplib in $dependency_libs; do
- deplibs="$deplib $deplibs"
- if $opt_preserve_dup_deps; then
- case "$tmp_libs " in
- *" $deplib "*) func_append specialdeplibs " $deplib" ;;
- esac
- fi
- func_append tmp_libs " $deplib"
- done
continue
fi # $pass = conv
@@ -8825,6 +8922,9 @@ func_mode_link ()
revision=$number_minor
lt_irix_increment=no
;;
+ *)
+ func_fatal_configuration "$modename: unknown library version type '$version_type'"
+ ;;
esac
;;
no)
diff --git a/missing b/missing
index ab658ed5..625aeb11 100755
--- a/missing
+++ b/missing
@@ -1,4 +1,4 @@
-#!/usr/bin/sh
+#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2018-03-07.03; # UTC
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index b0ddbe76..ece7febc 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -260,6 +260,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/sg3_utils.spec b/sg3_utils.spec
index aace11fc..dfc58d24 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -84,7 +84,7 @@ fi
%{_libdir}/*.la
%changelog
-* Wed Jul 17 2019 - dgilbert at interlog dot com
+* Wed Aug 28 2019 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.45
diff --git a/src/Makefile.am b/src/Makefile.am
index dfca3612..2c423d9d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,16 +1,16 @@
bin_PROGRAMS = \
sg_bg_ctl sg_compare_and_write sg_decode_sense sg_format \
- sg_get_config sg_get_lba_status sg_ident sg_inq sg_logs sg_luns \
- sg_modes sg_opcodes sg_persist sg_prevent sg_raw sg_rdac \
- sg_read_attr sg_read_block_limits sg_read_buffer sg_read_long \
- sg_readcap sg_reassign sg_referrals sg_rep_zones sg_requests \
- sg_reset_wp sg_rmsn sg_rtpg sg_safte sg_sanitize sg_sat_identify \
- sg_sat_phy_event sg_sat_read_gplog sg_sat_set_features sg_seek \
- sg_senddiag sg_ses sg_ses_microcode sg_start sg_stpg sg_stream_ctl \
- sg_sync sg_timestamp sg_turs sg_unmap sg_verify sg_vpd sg_wr_mode \
- sg_write_buffer sg_write_long sg_write_same sg_write_verify \
- sg_write_x sg_zone
+ sg_get_config sg_get_elem_status sg_get_lba_status sg_ident sg_inq \
+ sg_logs sg_luns sg_modes sg_opcodes sg_persist sg_prevent sg_raw \
+ sg_rdac sg_read_attr sg_read_block_limits sg_read_buffer \
+ sg_read_long sg_readcap sg_reassign sg_referrals sg_rep_zones \
+ sg_requests sg_reset_wp sg_rmsn sg_rtpg sg_safte sg_sanitize \
+ sg_sat_identify sg_sat_phy_event sg_sat_read_gplog \
+ sg_sat_set_features sg_seek sg_senddiag sg_ses sg_ses_microcode \
+ sg_start sg_stpg sg_stream_ctl sg_sync sg_timestamp sg_turs sg_unmap \
+ sg_verify sg_vpd sg_wr_mode sg_write_buffer sg_write_long \
+ sg_write_same sg_write_verify sg_write_x sg_zone
sg_scan_SOURCES =
@@ -76,6 +76,8 @@ sg_format_LDADD = ../lib/libsgutils2.la
sg_get_config_LDADD = ../lib/libsgutils2.la
+sg_get_elem_status_LDADD = ../lib/libsgutils2.la
+
sg_get_lba_status_LDADD = ../lib/libsgutils2.la
sg_ident_LDADD = ../lib/libsgutils2.la
diff --git a/src/Makefile.in b/src/Makefile.in
index 71605f34..d72d77f7 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -90,11 +90,11 @@ build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = sg_bg_ctl$(EXEEXT) sg_compare_and_write$(EXEEXT) \
sg_decode_sense$(EXEEXT) sg_format$(EXEEXT) \
- sg_get_config$(EXEEXT) sg_get_lba_status$(EXEEXT) \
- sg_ident$(EXEEXT) sg_inq$(EXEEXT) sg_logs$(EXEEXT) \
- sg_luns$(EXEEXT) sg_modes$(EXEEXT) sg_opcodes$(EXEEXT) \
- sg_persist$(EXEEXT) sg_prevent$(EXEEXT) sg_raw$(EXEEXT) \
- sg_rdac$(EXEEXT) sg_read_attr$(EXEEXT) \
+ sg_get_config$(EXEEXT) sg_get_elem_status$(EXEEXT) \
+ sg_get_lba_status$(EXEEXT) sg_ident$(EXEEXT) sg_inq$(EXEEXT) \
+ sg_logs$(EXEEXT) sg_luns$(EXEEXT) sg_modes$(EXEEXT) \
+ sg_opcodes$(EXEEXT) sg_persist$(EXEEXT) sg_prevent$(EXEEXT) \
+ sg_raw$(EXEEXT) sg_rdac$(EXEEXT) sg_read_attr$(EXEEXT) \
sg_read_block_limits$(EXEEXT) sg_read_buffer$(EXEEXT) \
sg_read_long$(EXEEXT) sg_readcap$(EXEEXT) sg_reassign$(EXEEXT) \
sg_referrals$(EXEEXT) sg_rep_zones$(EXEEXT) \
@@ -168,6 +168,9 @@ sg_format_DEPENDENCIES = ../lib/libsgutils2.la
sg_get_config_SOURCES = sg_get_config.c
sg_get_config_OBJECTS = sg_get_config.$(OBJEXT)
sg_get_config_DEPENDENCIES = ../lib/libsgutils2.la
+sg_get_elem_status_SOURCES = sg_get_elem_status.c
+sg_get_elem_status_OBJECTS = sg_get_elem_status.$(OBJEXT)
+sg_get_elem_status_DEPENDENCIES = ../lib/libsgutils2.la
sg_get_lba_status_SOURCES = sg_get_lba_status.c
sg_get_lba_status_OBJECTS = sg_get_lba_status.$(OBJEXT)
sg_get_lba_status_DEPENDENCIES = ../lib/libsgutils2.la
@@ -373,6 +376,7 @@ am__depfiles_remade = ./$(DEPDIR)/sg_bg_ctl.Po \
./$(DEPDIR)/sg_copy_results.Po ./$(DEPDIR)/sg_dd.Po \
./$(DEPDIR)/sg_decode_sense.Po ./$(DEPDIR)/sg_emc_trespass.Po \
./$(DEPDIR)/sg_format.Po ./$(DEPDIR)/sg_get_config.Po \
+ ./$(DEPDIR)/sg_get_elem_status.Po \
./$(DEPDIR)/sg_get_lba_status.Po ./$(DEPDIR)/sg_ident.Po \
./$(DEPDIR)/sg_inq.Po ./$(DEPDIR)/sg_inq_data.Po \
./$(DEPDIR)/sg_logs.Po ./$(DEPDIR)/sg_luns.Po \
@@ -428,10 +432,10 @@ am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = sg_bg_ctl.c sg_compare_and_write.c sg_copy_results.c sg_dd.c \
sg_decode_sense.c sg_emc_trespass.c sg_format.c \
- sg_get_config.c sg_get_lba_status.c sg_ident.c \
- $(sg_inq_SOURCES) sg_logs.c sg_luns.c sg_map.c sg_map26.c \
- sg_modes.c sg_opcodes.c sg_persist.c sg_prevent.c sg_raw.c \
- sg_rbuf.c sg_rdac.c sg_read.c sg_read_attr.c \
+ sg_get_config.c sg_get_elem_status.c sg_get_lba_status.c \
+ sg_ident.c $(sg_inq_SOURCES) sg_logs.c sg_luns.c sg_map.c \
+ sg_map26.c sg_modes.c sg_opcodes.c sg_persist.c sg_prevent.c \
+ sg_raw.c sg_rbuf.c sg_rdac.c sg_read.c sg_read_attr.c \
sg_read_block_limits.c sg_read_buffer.c sg_read_long.c \
sg_readcap.c sg_reassign.c sg_referrals.c sg_rep_zones.c \
sg_requests.c sg_reset.c sg_reset_wp.c sg_rmsn.c sg_rtpg.c \
@@ -445,10 +449,10 @@ SOURCES = sg_bg_ctl.c sg_compare_and_write.c sg_copy_results.c sg_dd.c \
sg_xcopy.c sg_zone.c sginfo.c sgm_dd.c sgp_dd.c
DIST_SOURCES = sg_bg_ctl.c sg_compare_and_write.c sg_copy_results.c \
sg_dd.c sg_decode_sense.c sg_emc_trespass.c sg_format.c \
- sg_get_config.c sg_get_lba_status.c sg_ident.c \
- $(sg_inq_SOURCES) sg_logs.c sg_luns.c sg_map.c sg_map26.c \
- sg_modes.c sg_opcodes.c sg_persist.c sg_prevent.c sg_raw.c \
- sg_rbuf.c sg_rdac.c sg_read.c sg_read_attr.c \
+ sg_get_config.c sg_get_elem_status.c sg_get_lba_status.c \
+ sg_ident.c $(sg_inq_SOURCES) sg_logs.c sg_luns.c sg_map.c \
+ sg_map26.c sg_modes.c sg_opcodes.c sg_persist.c sg_prevent.c \
+ sg_raw.c sg_rbuf.c sg_rdac.c sg_read.c sg_read_attr.c \
sg_read_block_limits.c sg_read_buffer.c sg_read_long.c \
sg_readcap.c sg_reassign.c sg_referrals.c sg_rep_zones.c \
sg_requests.c sg_reset.c sg_reset_wp.c sg_rmsn.c sg_rtpg.c \
@@ -597,6 +601,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -633,6 +638,7 @@ sg_decode_sense_LDADD = ../lib/libsgutils2.la
sg_emc_trespass_LDADD = ../lib/libsgutils2.la
sg_format_LDADD = ../lib/libsgutils2.la
sg_get_config_LDADD = ../lib/libsgutils2.la
+sg_get_elem_status_LDADD = ../lib/libsgutils2.la
sg_get_lba_status_LDADD = ../lib/libsgutils2.la
sg_ident_LDADD = ../lib/libsgutils2.la
sginfo_LDADD = ../lib/libsgutils2.la
@@ -810,6 +816,10 @@ sg_get_config$(EXEEXT): $(sg_get_config_OBJECTS) $(sg_get_config_DEPENDENCIES) $
@rm -f sg_get_config$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(sg_get_config_OBJECTS) $(sg_get_config_LDADD) $(LIBS)
+sg_get_elem_status$(EXEEXT): $(sg_get_elem_status_OBJECTS) $(sg_get_elem_status_DEPENDENCIES) $(EXTRA_sg_get_elem_status_DEPENDENCIES)
+ @rm -f sg_get_elem_status$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(sg_get_elem_status_OBJECTS) $(sg_get_elem_status_LDADD) $(LIBS)
+
sg_get_lba_status$(EXEEXT): $(sg_get_lba_status_OBJECTS) $(sg_get_lba_status_DEPENDENCIES) $(EXTRA_sg_get_lba_status_DEPENDENCIES)
@rm -f sg_get_lba_status$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(sg_get_lba_status_OBJECTS) $(sg_get_lba_status_LDADD) $(LIBS)
@@ -1064,6 +1074,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_emc_trespass.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_format.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_get_config.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_get_elem_status.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_get_lba_status.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_ident.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_inq.Po@am__quote@ # am--include-marker
@@ -1296,6 +1307,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/sg_emc_trespass.Po
-rm -f ./$(DEPDIR)/sg_format.Po
-rm -f ./$(DEPDIR)/sg_get_config.Po
+ -rm -f ./$(DEPDIR)/sg_get_elem_status.Po
-rm -f ./$(DEPDIR)/sg_get_lba_status.Po
-rm -f ./$(DEPDIR)/sg_ident.Po
-rm -f ./$(DEPDIR)/sg_inq.Po
@@ -1412,6 +1424,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/sg_emc_trespass.Po
-rm -f ./$(DEPDIR)/sg_format.Po
-rm -f ./$(DEPDIR)/sg_get_config.Po
+ -rm -f ./$(DEPDIR)/sg_get_elem_status.Po
-rm -f ./$(DEPDIR)/sg_get_lba_status.Po
-rm -f ./$(DEPDIR)/sg_ident.Po
-rm -f ./$(DEPDIR)/sg_inq.Po
diff --git a/src/sg_get_elem_status.c b/src/sg_get_elem_status.c
new file mode 100644
index 00000000..3e1473f9
--- /dev/null
+++ b/src/sg_get_elem_status.c
@@ -0,0 +1,587 @@
+/*
+ * Copyright (c) 2019 Douglas Gilbert.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the BSD_LICENSE file.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "sg_lib.h"
+#include "sg_lib_data.h"
+#include "sg_pt.h"
+#include "sg_cmds_basic.h"
+#include "sg_cmds_extra.h"
+#include "sg_unaligned.h"
+#include "sg_pr2serr.h"
+
+/* A utility program originally written for the Linux OS SCSI subsystem.
+ *
+ *
+ * This program issues the SCSI GET PHYSICAL ELEMENT STATUS command to the
+ * given SCSI device.
+ */
+
+static const char * version_str = "1.00 20190827"; /* sbc4r15,17 */
+
+
+#ifndef UINT32_MAX
+#define UINT32_MAX ((uint32_t)-1)
+#endif
+
+#define GET_PHY_ELEM_STATUS_SA 0x17
+#define DEF_GPES_BUFF_LEN 32
+#define MAX_GPES_BUFF_LEN ((1024 * 1024) + DEF_GPES_BUFF_LEN)
+#define GPES_DESC_OFFSET 32 /* descriptors starts at this byte offset */
+#define GPES_DESC_LEN 32
+
+#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
+#define DEF_PT_TIMEOUT 60 /* 60 seconds */
+
+struct gpes_desc_t { /* info in returned physical status descriptor */
+ bool restore_allowed;
+ uint32_t elem_id;
+ uint8_t phys_elem_type;
+ uint8_t phys_elem_health;
+ uint64_t assoc_cap; /* number of LBs removed if depopulated */
+};
+
+static uint8_t gpesBuff[DEF_GPES_BUFF_LEN];
+
+
+static struct option long_options[] = {
+ {"brief", no_argument, 0, 'b'},
+ {"filter", required_argument, 0, 'f'},
+ {"help", no_argument, 0, 'h'},
+ {"hex", no_argument, 0, 'H'},
+ {"in", required_argument, 0, 'i'}, /* silent, same as --inhex= */
+ {"inhex", required_argument, 0, 'i'},
+ {"maxlen", required_argument, 0, 'm'},
+ {"raw", no_argument, 0, 'r'},
+ {"readonly", no_argument, 0, 'R'},
+ {"report-type", required_argument, 0, 't'},
+ {"report_type", required_argument, 0, 't'},
+ {"starting", required_argument, 0, 's'},
+ {"verbose", no_argument, 0, 'v'},
+ {"version", no_argument, 0, 'V'},
+ {0, 0, 0, 0},
+};
+
+static void
+usage()
+{
+ pr2serr("Usage: sg_get_elem_status [--brief] [--filter=FLT] [--help] "
+ "[--hex]\n"
+ " [--inhex=FN] [--maxlen=LEN] [--raw] "
+ "[--readonly]\n"
+ " [--report-type=RT] [--starting=ELEM] "
+ "[--verbose]\n"
+ " [--version] DEVICE\n"
+ " where:\n"
+ " --brief|-b one descriptor per line\n"
+ " --filter=FLT|-f FLT FLT is 0 (def) for all physical "
+ "elements;\n"
+ " 1 for out of spec and depopulated "
+ "elements\n"
+ " --help|-h print out usage message\n"
+ " --hex|-H output in hexadecimal\n"
+ " --inhex=FN input taken from file FN rather than "
+ "DEVICE,\n"
+ " assumed to be ASCII hex or, if --raw, "
+ "in binary\n"
+ " --maxlen=LEN|-m LEN max response length (allocation "
+ "length in cdb)\n"
+ " (def: 0 -> %d bytes)\n",
+ DEF_GPES_BUFF_LEN );
+ pr2serr(" --raw|-r output in binary, unless --inhex=FN is "
+ "given in\n"
+ " in which case the input is assumed to be "
+ "binary\n"
+ " --readonly|-R open DEVICE read-only (def: read-write)\n"
+ " --report-type=RT|-t RT report type: 0-> physical "
+ "elements (def);\n"
+ " 1-> storage "
+ "elements\n"
+ " --starting=ELEM|-s ELEM ELEM is the lowest identifier "
+ "returned\n"
+ " (def: 1 which is lowest "
+ "identifier)\n"
+ " --verbose|-v increase verbosity\n"
+ " --version|-V print version string and exit\n\n"
+ "Performs a SCSI GET PHYSICAL ELEMENT STATUS command (see SBC-3 "
+ "or SBC-4).\nIf --inhex=FN is given then contents of FN is "
+ "assumed to be a response\nto this command in ASCII hex. "
+ "Returned element descriptors should be\nin ascending "
+ "identifier order.\n"
+ );
+}
+
+/* Invokes a SCSI GET PHYSICAL ELEMENT STATUS command (SBC-4). Return of
+ * 0 -> success, various SG_LIB_CAT_* positive values or -1 -> other errors */
+static int
+sg_ll_get_phy_elem_status(int sg_fd, uint32_t starting_elem, uint8_t filter,
+ uint8_t report_type, uint8_t * resp,
+ uint32_t alloc_len, int * residp, bool noisy,
+ int verbose)
+{
+ int k, ret, res, sense_cat;
+ uint8_t gpesCmd[16] = {SG_SERVICE_ACTION_IN_16,
+ GET_PHY_ELEM_STATUS_SA, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ uint8_t sense_b[SENSE_BUFF_LEN];
+ struct sg_pt_base * ptvp;
+ static const char * const cmd_name = "Get physical element status";
+
+ if (starting_elem)
+ sg_put_unaligned_be32(starting_elem, gpesCmd + 6);
+ sg_put_unaligned_be32(alloc_len, gpesCmd + 10);
+ if (filter)
+ gpesCmd[14] |= filter << 6;
+ if (report_type)
+ gpesCmd[14] |= (0xf & report_type);
+ if (verbose) {
+ pr2serr(" %s cdb: ", cmd_name);
+ for (k = 0; k < (int)sizeof(gpesCmd); ++k)
+ pr2serr("%02x ", gpesCmd[k]);
+ pr2serr("\n");
+ }
+
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ if (NULL == ptvp) {
+ pr2serr("%s: out of memory\n", cmd_name);
+ return -1;
+ }
+ set_scsi_pt_cdb(ptvp, gpesCmd, sizeof(gpesCmd));
+ set_scsi_pt_data_in(ptvp, resp, alloc_len);
+ set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
+ res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
+ ret = sg_cmds_process_resp(ptvp, cmd_name, res, noisy, verbose,
+ &sense_cat);
+ 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:
+ ret = 0;
+ break;
+ default:
+ ret = sense_cat;
+ break;
+ }
+ } else
+ ret = 0;
+ k = ret ? (int)alloc_len : get_scsi_pt_resid(ptvp);
+ if (residp)
+ *residp = k;
+ if ((verbose > 2) && ((alloc_len - k) > 0)) {
+ pr2serr("%s: parameter data returned:\n", cmd_name);
+ hex2stderr((const uint8_t *)resp, alloc_len - k,
+ ((verbose > 3) ? -1 : 1));
+ }
+ destruct_scsi_pt_obj(ptvp);
+ return ret;
+}
+
+static void
+dStrRaw(const char * str, int len)
+{
+ int k;
+
+ for (k = 0; k < len; ++k)
+ printf("%c", str[k]);
+}
+
+/* Decodes given physical element status descriptor. */
+static void
+decode_elem_status_desc(const uint8_t * bp, struct gpes_desc_t * pedp)
+{
+ if ((NULL == bp) || (NULL == pedp))
+ return;
+ pedp->elem_id = sg_get_unaligned_be32(bp + 4);
+ pedp->restore_allowed = (bool)(bp[13] & 1);
+ pedp->phys_elem_type = bp[14];
+ pedp->phys_elem_health = bp[15];
+ pedp->assoc_cap = sg_get_unaligned_be64(bp + 16);
+}
+
+
+int
+main(int argc, char * argv[])
+{
+ bool do_raw = false;
+ bool no_final_msg = false;
+ bool o_readonly = false;
+ bool verbose_given = false;
+ bool version_given = false;
+ int k, j, n, res, c, rlen, in_len;
+ int sg_fd = -1;
+ int do_brief = 0;
+ int do_hex = 0;
+ int resid = 0;
+ int ret = 0;
+ int maxlen = DEF_GPES_BUFF_LEN;
+ int verbose = 0;
+ uint8_t filter = 0;
+ uint8_t rt = 0;
+ uint32_t num_desc, num_desc_ret, id_elem_depop;
+ uint32_t d_blocks = 0;
+ uint32_t starting_elem = 0;
+ int64_t ll;
+ const char * device_name = NULL;
+ const char * in_fn = NULL;
+ const uint8_t * bp;
+ uint8_t * gpesBuffp = gpesBuff;
+ uint8_t * free_gpesBuffp = NULL;
+ struct gpes_desc_t a_ped;
+
+ while (1) {
+ int option_index = 0;
+
+ c = getopt_long(argc, argv, "bf:hHi:m:rRs:St:TvV", long_options,
+ &option_index);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'b':
+ ++do_brief;
+ break;
+ case 'f':
+ n = sg_get_num_nomult(optarg);
+ if ((n < 0) || (n > 15)) {
+ pr2serr("'--filter=RT' should be between 0 and 15 "
+ "(inclusive)\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ filter = n;
+ break;
+ case 'h':
+ case '?':
+ usage();
+ return 0;
+ case 'H':
+ ++do_hex;
+ break;
+ case 'i':
+ in_fn = optarg;
+ break;
+ case 'm':
+ maxlen = sg_get_num(optarg);
+ if ((maxlen < 0) || (maxlen > MAX_GPES_BUFF_LEN)) {
+ pr2serr("argument to '--maxlen' should be %d or less\n",
+ MAX_GPES_BUFF_LEN);
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ if (0 == maxlen)
+ maxlen = DEF_GPES_BUFF_LEN;
+ break;
+ case 'r':
+ do_raw = true;
+ break;
+ case 'R':
+ o_readonly = true;
+ break;
+ case 's':
+ ll = sg_get_llnum(optarg);
+ if ((ll < 0) || (ll > UINT32_MAX)) {
+ pr2serr("bad argument to '--starting='\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ starting_elem = (uint32_t)ll;
+ break;
+ case 't': /* --report-type=RT */
+ n = sg_get_num_nomult(optarg);
+ if ((n < 0) || (n > 15)) {
+ pr2serr("'--report-type=RT' should be between 0 and 15 "
+ "(inclusive)\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ rt = n;
+ break;
+ case 'v':
+ verbose_given = true;
+ ++verbose;
+ break;
+ case 'V':
+ version_given = true;
+ break;
+ default:
+ pr2serr("unrecognised option code 0x%x ??\n", c);
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ }
+ if (optind < argc) {
+ if (NULL == device_name) {
+ device_name = argv[optind];
+ ++optind;
+ }
+ if (optind < argc) {
+ for (; optind < argc; ++optind)
+ pr2serr("Unexpected extra argument: %s\n", argv[optind]);
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ }
+
+#ifdef DEBUG
+ pr2serr("In DEBUG mode, ");
+ if (verbose_given && version_given) {
+ pr2serr("but override: '-vV' given, zero verbose and continue\n");
+ verbose_given = false;
+ version_given = false;
+ verbose = 0;
+ } else if (! verbose_given) {
+ pr2serr("set '-vv'\n");
+ verbose = 2;
+ } else
+ pr2serr("keep verbose=%d\n", verbose);
+#else
+ if (verbose_given && version_given)
+ pr2serr("Not in DEBUG mode, so '-vV' has no special action\n");
+#endif
+ if (version_given) {
+ pr2serr("version: %s\n", version_str);
+ return 0;
+ }
+
+ if (maxlen > DEF_GPES_BUFF_LEN) {
+ gpesBuffp = (uint8_t *)sg_memalign(maxlen, 0, &free_gpesBuffp,
+ verbose > 3);
+ if (NULL == gpesBuffp) {
+ pr2serr("unable to allocate %d bytes on heap\n", maxlen);
+ return sg_convert_errno(ENOMEM);
+ }
+ }
+ if (device_name && in_fn) {
+ pr2serr("ignoring DEVICE, best to give DEVICE or --inhex=FN, but "
+ "not both\n");
+ device_name = NULL;
+ }
+ if (NULL == device_name) {
+ if (in_fn) {
+ if ((ret = sg_f2hex_arr(in_fn, do_raw, false, gpesBuffp,
+ &in_len, maxlen))) {
+ if (SG_LIB_LBA_OUT_OF_RANGE == ret) {
+ pr2serr("--maxlen=%d needs to be increased", maxlen);
+ if (in_len > 7) {
+ n = (sg_get_unaligned_be32(gpesBuffp + 4) *
+ GPES_DESC_LEN) + GPES_DESC_OFFSET;
+ pr2serr(" to at least %d\n", n);
+ } else
+ pr2serr("\n");
+ pr2serr("... decode what we have\n");
+ no_final_msg = true;
+ } else
+ goto fini;
+ }
+ if (verbose > 2)
+ pr2serr("Read %d [0x%x] bytes of user supplied data\n",
+ in_len, in_len);
+ if (do_raw)
+ do_raw = false; /* can interfere on decode */
+ if (in_len < 4) {
+ pr2serr("--in=%s only decoded %d bytes (needs 4 at least)\n",
+ in_fn, in_len);
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
+ }
+ res = 0;
+ goto start_response;
+ } else {
+ pr2serr("missing device name!\n\n");
+ usage();
+ ret = SG_LIB_FILE_ERROR;
+ no_final_msg = true;
+ goto fini;
+ }
+ }
+ if (do_raw) {
+ if (sg_set_binary_mode(STDOUT_FILENO) < 0) {
+ perror("sg_set_binary_mode");
+ ret = SG_LIB_FILE_ERROR;
+ goto fini;
+ }
+ }
+ sg_fd = sg_cmds_open_device(device_name, o_readonly, verbose);
+ if (sg_fd < 0) {
+ pr2serr("open error: %s: %s\n", device_name, safe_strerror(-sg_fd));
+ ret = sg_convert_errno(-sg_fd);
+ goto fini;
+ }
+
+ res = sg_ll_get_phy_elem_status(sg_fd, starting_elem, filter, rt,
+ gpesBuffp, maxlen, &resid, true, verbose);
+ ret = res;
+ if (res)
+ goto error;
+
+start_response:
+ k = maxlen - resid;
+ if (k < 4) {
+ pr2serr("Response too short (%d bytes) due to resid (%d)\n", k,
+ resid);
+ if ((k > 0) && (do_raw || do_hex)) {
+ if (do_hex)
+ hex2stdout(gpesBuffp, k, 1);
+ else
+ dStrRaw((const char *)gpesBuffp, k);
+ }
+ ret = SG_LIB_CAT_MALFORMED;
+ goto fini;
+ } else
+ maxlen -= resid;
+ num_desc = sg_get_unaligned_be32(gpesBuffp + 0);
+ if (maxlen > 7) {
+ num_desc_ret = sg_get_unaligned_be32(gpesBuffp + 4);
+ id_elem_depop = (maxlen > 11) ? sg_get_unaligned_be32(gpesBuffp + 8) :
+ 0;
+ } else {
+ num_desc_ret = 0;
+ id_elem_depop = 0;
+ }
+ rlen = (num_desc_ret * GPES_DESC_LEN) + GPES_DESC_OFFSET;
+ if ((verbose > 1) || (verbose && (rlen > maxlen))) {
+ pr2serr("response length %d bytes\n", rlen);
+ if (rlen > maxlen)
+ pr2serr(" ... which is greater than maxlen (allocation "
+ "length %d), truncation\n", maxlen);
+ }
+ if (rlen > maxlen)
+ rlen = maxlen;
+ if (do_raw) {
+ dStrRaw((const char *)gpesBuffp, rlen);
+ goto fini;
+ }
+ if (do_hex) {
+ hex2stdout(gpesBuffp, rlen, 1);
+ goto fini;
+ }
+
+#if 0
+ if (do_brief > 1) {
+ if (rlen < 24) {
+ pr2serr("Need maxlen and response length to be at least 24, "
+ "have %d bytes\n", rlen);
+ ret = SG_LIB_CAT_OTHER;
+ goto fini;
+ }
+ res = decode_lba_status_desc(gpesBuffp + 8, &d_lba, &d_blocks,
+ &add_status);
+ if ((res < 0) || (res > 15)) {
+ pr2serr("first LBA status descriptor returned %d ??\n", res);
+ ret = SG_LIB_LOGIC_ERROR;
+ goto fini;
+ }
+ if ((lba < d_lba) || (lba >= (d_lba + d_blocks))) {
+ pr2serr("given LBA not in range of first descriptor:\n"
+ " descriptor LBA: 0x");
+ for (j = 0; j < 8; ++j)
+ pr2serr("%02x", gpesBuffp[8 + j]);
+ pr2serr(" blocks: 0x%x p_status: %d add_status: 0x%x\n",
+ (unsigned int)d_blocks, res,
+ (unsigned int)add_status);
+ ret = SG_LIB_CAT_OTHER;
+ goto fini;
+ }
+ printf("%d\n", res);
+ goto fini;
+ }
+#endif
+
+ printf("Number of descriptors: %u\n", num_desc);
+ printf("Number of descriptors returned: %u\n", num_desc_ret);
+ printf("Identifier of element being depopulated: %u\n", id_elem_depop);
+ if (rlen < 64) {
+ printf("No complete physical element status descriptors available\n");
+ goto fini;
+ } else
+ printf("\n");
+
+ for (bp = gpesBuffp + GPES_DESC_OFFSET, k = 0; k < (int)num_desc_ret;
+ bp += GPES_DESC_LEN, ++k) {
+ if (0 == k)
+ printf("Element descriptors:\n");
+ decode_elem_status_desc(bp, &a_ped);
+ if (do_brief) {
+ printf("0x");
+ for (j = 0; j < 8; ++j)
+ printf("%02x", bp[j]);
+ printf(" 0x%x %d\n", (unsigned int)d_blocks, res);
+ } else {
+ printf("[%d] identifier: 0x%06x", k + 1, a_ped.elem_id);
+ if (sg_all_ffs((const uint8_t *)&a_ped.assoc_cap, 8))
+ printf(" associated LBs: not specified ");
+ else
+ printf(" associated LBs: 0x%" PRIx64 " ", a_ped.assoc_cap);
+ printf("health: ");
+ j = a_ped.phys_elem_health;
+ if (0 == j)
+ printf("not reported");
+ else if (j < 0x64)
+ printf("within manufacturer's specification limits <%d>", j);
+ else if (0x64 == j)
+ printf("at manufacturer's specification limits <%d>", j);
+ else if (j < 0xd0)
+ printf("outside manufacturer's specification limits <%d>", j);
+ else if (j < 0xfd)
+ printf("reserved [0x%x]", j);
+ else if (0xfd == j)
+ printf("depopulation completed, errors detected");
+ else if (0xfe == j)
+ printf("depopulation operations in progress");
+ else if (0xff == j)
+ printf("depopulation completed, no errors");
+ if (a_ped.restore_allowed)
+ printf(" [restore allowed]");
+ printf("\n");
+ }
+ }
+ goto fini;
+
+error:
+ if (SG_LIB_CAT_INVALID_OP == res)
+ pr2serr("Get LBA Status command not supported\n");
+ else if (SG_LIB_CAT_ILLEGAL_REQ == res)
+ pr2serr("Get LBA Status command: bad field in cdb\n");
+ else {
+ char b[80];
+
+ sg_get_category_sense_str(res, sizeof(b), b, verbose);
+ pr2serr("Get LBA Status command: %s\n", b);
+ }
+
+fini:
+ if (sg_fd >= 0) {
+ res = sg_cmds_close_device(sg_fd);
+ if (res < 0) {
+ pr2serr("close error: %s\n", safe_strerror(-res));
+ if (0 == ret)
+ ret = sg_convert_errno(-res);
+ }
+ }
+ if (free_gpesBuffp)
+ free(free_gpesBuffp);
+ if ((0 == verbose) && (! no_final_msg)) {
+ if (! sg_if_can2stderr("sg_get_elem_status failed: ", ret))
+ pr2serr("Some error occurred, try again with '-v' or '-vv' for "
+ "more information\n");
+ }
+ return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
+}
diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c
index 6018d4f1..1b9df4de 100644
--- a/src/sg_get_lba_status.c
+++ b/src/sg_get_lba_status.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2018 Douglas Gilbert.
+ * Copyright (c) 2009-2019 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -35,7 +35,7 @@
* device.
*/
-static const char * version_str = "1.18 20180812"; /* sbc4r15 */
+static const char * version_str = "1.20 20190822"; /* sbc4r15 */
#ifndef UINT32_MAX
#define UINT32_MAX ((uint32_t)-1)
@@ -44,7 +44,7 @@ static const char * version_str = "1.18 20180812"; /* sbc4r15 */
#define MAX_GLBAS_BUFF_LEN (1024 * 1024)
#define DEF_GLBAS_BUFF_LEN 24
-static uint8_t glbasBuff[DEF_GLBAS_BUFF_LEN];
+static uint8_t glbasFixedBuff[DEF_GLBAS_BUFF_LEN];
static struct option long_options[] = {
@@ -55,6 +55,8 @@ static struct option long_options[] = {
{"element_id", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"hex", no_argument, 0, 'H'},
+ {"in", required_argument, 0, 'i'}, /* silent, same as --inhex= */
+ {"inhex", required_argument, 0, 'i'},
{"lba", required_argument, 0, 'l'},
{"maxlen", required_argument, 0, 'm'},
{"raw", no_argument, 0, 'r'},
@@ -73,12 +75,12 @@ usage()
{
pr2serr("Usage: sg_get_lba_status [--16] [--32][--brief] "
"[--element-id=EI]\n"
- " [--help] [--hex] "
- "[--lba=LBA] [--maxlen=LEN]\n"
- " [--raw] [--readonly] "
- "[--report-type=RT]\n"
- " [--scan-len=SL] [--verbose] "
- "[--version] DEVICE\n"
+ " [--help] [--hex] [--inhex=FN] "
+ "[--lba=LBA]\n"
+ " [--maxlen=LEN] [--raw] [--readonly]\n"
+ " [--report-type=RT] [--scan-len=SL] "
+ "[--verbose]\n"
+ " [--version] DEVICE\n"
" where:\n"
" --16|-S use GET LBA STATUS(16) cdb (def)\n"
" --32|-T use GET LBA STATUS(32) cdb\n"
@@ -91,13 +93,19 @@ usage()
"(def: 0)\n"
" --help|-h print out usage message\n"
" --hex|-H output in hexadecimal\n"
+ " --inhex=FN input taken from file FN rather than "
+ "DEVICE,\n"
+ " assumed to be ASCII hex or, if --raw, "
+ "in binary\n"
" --lba=LBA|-l LBA starting LBA (logical block address) "
"(def: 0)\n"
" --maxlen=LEN|-m LEN max response length (allocation "
"length in cdb)\n"
" (def: 0 -> %d bytes)\n",
DEF_GLBAS_BUFF_LEN );
- pr2serr(" --raw|-r output in binary\n"
+ pr2serr(" --raw|-r output in binary, unless if --inhex=FN "
+ "is given,\n"
+ " in which case input file is binary\n"
" --readonly|-R open DEVICE read-only (def: read-write)\n"
" --report-type=RT|-t RT report type: 0->all LBAs (def);\n"
" 1-> LBAs with non-zero "
@@ -113,7 +121,8 @@ usage()
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
"Performs a SCSI GET LBA STATUS(16) or GET LBA STATUS(32) "
- "command\n(SBC-3 and SBC-4)\n"
+ "command (SBC-3 and\nSBC-4). If --inhex=FN is given then "
+ "contents of FN is assumed to be a response\nto this command.\n"
);
}
@@ -156,10 +165,12 @@ main(int argc, char * argv[])
bool do_16 = false;
bool do_32 = false;
bool do_raw = false;
+ bool no_final_msg = false;
bool o_readonly = false;
bool verbose_given = false;
bool version_given = false;
- int sg_fd, k, j, res, c, rlen, num_descs, completion_cond;
+ int k, j, res, c, rlen, num_descs, completion_cond, in_len;
+ int sg_fd = -1;
int do_brief = 0;
int do_hex = 0;
int ret = 0;
@@ -174,14 +185,15 @@ main(int argc, char * argv[])
int64_t ll;
uint64_t lba = 0;
const char * device_name = NULL;
+ const char * in_fn = NULL;
const uint8_t * bp;
- uint8_t * glbasBuffp = glbasBuff;
+ uint8_t * glbasBuffp = glbasFixedBuff;
uint8_t * free_glbasBuffp = NULL;
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "be:hHl:m:rRs:St:TvV", long_options,
+ c = getopt_long(argc, argv, "be:hi:Hl:m:rRs:St:TvV", long_options,
&option_index);
if (c == -1)
break;
@@ -205,6 +217,9 @@ main(int argc, char * argv[])
case 'H':
++do_hex;
break;
+ case 'i':
+ in_fn = optarg;
+ break;
case 'l':
ll = sg_get_llnum(optarg);
if (-1 == ll) {
@@ -220,6 +235,8 @@ main(int argc, char * argv[])
MAX_GLBAS_BUFF_LEN);
return SG_LIB_SYNTAX_ERROR;
}
+ if (0 == maxlen)
+ maxlen = DEF_GLBAS_BUFF_LEN;
break;
case 'r':
do_raw = true;
@@ -296,11 +313,6 @@ main(int argc, char * argv[])
return 0;
}
- if (NULL == device_name) {
- pr2serr("missing device name!\n");
- usage();
- return SG_LIB_SYNTAX_ERROR;
- }
if (maxlen > DEF_GLBAS_BUFF_LEN) {
glbasBuffp = (uint8_t *)sg_memalign(maxlen, 0, &free_glbasBuffp,
verbose > 3);
@@ -309,11 +321,48 @@ main(int argc, char * argv[])
return sg_convert_errno(ENOMEM);
}
}
+ if (device_name && in_fn) {
+ pr2serr("ignoring DEVICE, best to give DEVICE or --inhex=FN, but "
+ "not both\n");
+ device_name = NULL;
+ }
+ if (NULL == device_name) {
+ if (in_fn) {
+ if ((ret = sg_f2hex_arr(in_fn, do_raw, false, glbasBuffp,
+ &in_len, maxlen))) {
+ if (SG_LIB_LBA_OUT_OF_RANGE == ret) {
+ no_final_msg = true;
+ pr2serr("... decode what we have, --maxlen=%d needs to "
+ "be increased\n", maxlen);
+ } else
+ goto fini;
+ }
+ if (verbose > 2)
+ pr2serr("Read %d [0x%x] bytes of user supplied data\n",
+ in_len, in_len);
+ if (do_raw)
+ do_raw = false; /* can interfere on decode */
+ if (in_len < 4) {
+ pr2serr("--in=%s only decoded %d bytes (needs 4 at least)\n",
+ in_fn, in_len);
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
+ }
+ res = 0;
+ goto start_response;
+ } else {
+ pr2serr("missing device name!\n\n");
+ usage();
+ ret = SG_LIB_FILE_ERROR;
+ no_final_msg = true;
+ goto fini;
+ }
+ }
if (do_raw) {
if (sg_set_binary_mode(STDOUT_FILENO) < 0) {
perror("sg_set_binary_mode");
ret = SG_LIB_FILE_ERROR;
- goto free_buff;
+ goto fini;
}
}
if (do_16 && do_32) {
@@ -334,7 +383,7 @@ main(int argc, char * argv[])
if (sg_fd < 0) {
pr2serr("open error: %s: %s\n", device_name, safe_strerror(-sg_fd));
ret = sg_convert_errno(-sg_fd);
- goto free_buff;
+ goto fini;
}
res = 0;
@@ -346,151 +395,158 @@ main(int argc, char * argv[])
glbasBuffp, maxlen, true, verbose);
ret = res;
- if (0 == res) {
- /* in sbc3r25 offset for calculating the 'parameter data length'
- * (rlen variable below) was reduced from 8 to 4. */
- if (maxlen >= 4)
- rlen = sg_get_unaligned_be32(glbasBuffp + 0) + 4;
- else
- rlen = maxlen;
- k = (rlen > maxlen) ? maxlen : rlen;
- if (do_raw) {
- dStrRaw((const char *)glbasBuffp, k);
- goto the_end;
- }
- if (do_hex) {
- hex2stdout(glbasBuffp, k, 1);
- goto the_end;
- }
- if (maxlen < 4) {
- if (verbose)
- pr2serr("Exiting because allocation length (maxlen) less "
- "than 4\n");
- goto the_end;
- }
- if ((verbose > 1) || (verbose && (rlen > maxlen))) {
- pr2serr("response length %d bytes\n", rlen);
- if (rlen > maxlen)
- pr2serr(" ... which is greater than maxlen (allocation "
- "length %d), truncation\n", maxlen);
- }
+ if (res)
+ goto error;
+
+start_response:
+ /* in sbc3r25 offset for calculating the 'parameter data length'
+ * (rlen variable below) was reduced from 8 to 4. */
+ if (maxlen >= 4)
+ rlen = sg_get_unaligned_be32(glbasBuffp + 0) + 4;
+ else
+ rlen = maxlen;
+ k = (rlen > maxlen) ? maxlen : rlen;
+ if (do_raw) {
+ dStrRaw((const char *)glbasBuffp, k);
+ goto fini;
+ }
+ if (do_hex) {
+ hex2stdout(glbasBuffp, k, 1);
+ goto fini;
+ }
+ if (maxlen < 4) {
+ if (verbose)
+ pr2serr("Exiting because allocation length (maxlen) less "
+ "than 4\n");
+ goto fini;
+ }
+ if ((verbose > 1) || (verbose && (rlen > maxlen))) {
+ pr2serr("response length %d bytes\n", rlen);
if (rlen > maxlen)
- rlen = maxlen;
+ pr2serr(" ... which is greater than maxlen (allocation "
+ "length %d), truncation\n", maxlen);
+ }
+ if (rlen > maxlen)
+ rlen = maxlen;
- if (do_brief > 1) {
- if (rlen < 24) {
- pr2serr("Need maxlen and response length to be at least 24, "
- "have %d bytes\n", rlen);
- ret = SG_LIB_CAT_OTHER;
- goto the_end;
- }
- res = decode_lba_status_desc(glbasBuffp + 8, &d_lba, &d_blocks,
- &add_status);
- if ((res < 0) || (res > 15)) {
- pr2serr("first LBA status descriptor returned %d ??\n", res);
- ret = SG_LIB_LOGIC_ERROR;
- goto the_end;
- }
- if ((lba < d_lba) || (lba >= (d_lba + d_blocks))) {
- pr2serr("given LBA not in range of first descriptor:\n"
- " descriptor LBA: 0x");
- for (j = 0; j < 8; ++j)
- pr2serr("%02x", glbasBuffp[8 + j]);
- pr2serr(" blocks: 0x%x p_status: %d add_status: 0x%x\n",
- (unsigned int)d_blocks, res,
- (unsigned int)add_status);
- ret = SG_LIB_CAT_OTHER;
- goto the_end;
- }
- printf("%d\n", res);
- goto the_end;
+ if (do_brief > 1) {
+ if (rlen < 24) {
+ pr2serr("Need maxlen and response length to be at least 24, "
+ "have %d bytes\n", rlen);
+ ret = SG_LIB_CAT_OTHER;
+ goto fini;
}
+ res = decode_lba_status_desc(glbasBuffp + 8, &d_lba, &d_blocks,
+ &add_status);
+ if ((res < 0) || (res > 15)) {
+ pr2serr("first LBA status descriptor returned %d ??\n", res);
+ ret = SG_LIB_LOGIC_ERROR;
+ goto fini;
+ }
+ if ((lba < d_lba) || (lba >= (d_lba + d_blocks))) {
+ pr2serr("given LBA not in range of first descriptor:\n"
+ " descriptor LBA: 0x");
+ for (j = 0; j < 8; ++j)
+ pr2serr("%02x", glbasBuffp[8 + j]);
+ pr2serr(" blocks: 0x%x p_status: %d add_status: 0x%x\n",
+ (unsigned int)d_blocks, res,
+ (unsigned int)add_status);
+ ret = SG_LIB_CAT_OTHER;
+ goto fini;
+ }
+ printf("%d\n", res);
+ goto fini;
+ }
- if (rlen < 24) {
- printf("No complete LBA status descriptors available\n");
- goto the_end;
+ if (rlen < 24) {
+ printf("No complete LBA status descriptors available\n");
+ goto fini;
+ }
+ num_descs = (rlen - 8) / 16;
+ completion_cond = (*(glbasBuffp + 7) >> 1) & 7; /* added sbc4r14 */
+ if (do_brief)
+ printf("Completion condition=%d\n", completion_cond);
+ else {
+ switch (completion_cond) {
+ case 0:
+ printf("No indication of the completion condition\n");
+ break;
+ case 1:
+ printf("Command completed due to meeting allocation length "
+ "(--maxlen=LEN (def 24))\n");
+ break;
+ case 2:
+ printf("Command completed due to meeting scan length "
+ "(--scan-len=SL)\n");
+ break;
+ case 3:
+ printf("Command completed due to meeting capacity of "
+ "medium\n");
+ break;
+ default:
+ printf("Command completion is reserved [%d]\n",
+ completion_cond);
+ break;
}
- num_descs = (rlen - 8) / 16;
- completion_cond = (*(glbasBuffp + 7) >> 1) & 7; /* added sbc4r14 */
- if (do_brief)
- printf("Completion condition=%d\n", completion_cond);
- else {
- switch (completion_cond) {
+ }
+ printf("RTP=%d\n", *(glbasBuffp + 7) & 0x1); /* added sbc4r12 */
+ if (verbose)
+ pr2serr("%d complete LBA status descriptors found\n", num_descs);
+ for (bp = glbasBuffp + 8, k = 0; k < num_descs; bp += 16, ++k) {
+ res = decode_lba_status_desc(bp, &d_lba, &d_blocks, &add_status);
+ if ((res < 0) || (res > 15))
+ pr2serr("descriptor %d: bad LBA status descriptor returned "
+ "%d\n", k + 1, res);
+ if (do_brief) {
+ printf("0x");
+ for (j = 0; j < 8; ++j)
+ printf("%02x", bp[j]);
+ printf(" 0x%x %d %d\n", (unsigned int)d_blocks, res,
+ add_status);
+ } else {
+ printf("[%d] LBA: 0x", k + 1);
+ for (j = 0; j < 8; ++j)
+ printf("%02x", bp[j]);
+ printf(" blocks: %10u", (unsigned int)d_blocks);
+ switch (res) {
case 0:
- printf("No indication of the completion condition\n");
+ printf(" mapped (or unknown)");
break;
case 1:
- printf("Command completed due to meeting allocation length "
- "(--maxlen=LEN (def 24))\n");
+ printf(" deallocated");
break;
case 2:
- printf("Command completed due to meeting scan length "
- "(--scan-len=SL)\n");
+ printf(" anchored");
break;
case 3:
- printf("Command completed due to meeting capacity of "
- "medium\n");
+ printf(" mapped"); /* sbc4r12 */
+ break;
+ case 4:
+ printf(" unknown"); /* sbc4r12 */
break;
default:
- printf("Command completion is reserved [%d]\n",
- completion_cond);
+ printf(" Provisioning status: %d", res);
break;
}
- }
- printf("RTP=%d\n", *(glbasBuffp + 7) & 0x1); /* added sbc4r12 */
- if (verbose)
- pr2serr("%d complete LBA status descriptors found\n", num_descs);
- for (bp = glbasBuffp + 8, k = 0; k < num_descs; bp += 16, ++k) {
- res = decode_lba_status_desc(bp, &d_lba, &d_blocks, &add_status);
- if ((res < 0) || (res > 15))
- pr2serr("descriptor %d: bad LBA status descriptor returned "
- "%d\n", k + 1, res);
- if (do_brief) {
- printf("0x");
- for (j = 0; j < 8; ++j)
- printf("%02x", bp[j]);
- printf(" 0x%x %d\n", (unsigned int)d_blocks, res);
- } else {
- printf("descriptor LBA: 0x");
- for (j = 0; j < 8; ++j)
- printf("%02x", bp[j]);
- printf(" blocks: %u", (unsigned int)d_blocks);
- switch (res) {
- case 0:
- printf(" mapped (or unknown)");
- break;
- case 1:
- printf(" deallocated");
- break;
- case 2:
- printf(" anchored");
- break;
- case 3:
- printf(" mapped"); /* sbc4r12 */
- break;
- case 4:
- printf(" unknown"); /* sbc4r12 */
- break;
- default:
- printf(" Provisioning status: %d", res);
- break;
- }
- switch (add_status) {
- case 0:
- printf("\n");
- break;
- case 1:
- printf(" [may return unrecovered errors]\n");
- break;
- default:
- printf(" [add_status: 0x%x]\n", (unsigned int)add_status);
- break;
- }
+ switch (add_status) {
+ case 0:
+ printf("\n");
+ break;
+ case 1:
+ printf(" [may return unrecovered errors]\n");
+ break;
+ default:
+ printf(" [add_status: 0x%x]\n", (unsigned int)add_status);
+ break;
}
}
- if ((num_descs * 16) + 8 < rlen)
- pr2serr("incomplete trailing LBA status descriptors found\n");
- } else if (SG_LIB_CAT_INVALID_OP == res)
+ }
+ if ((num_descs * 16) + 8 < rlen)
+ pr2serr("incomplete trailing LBA status descriptors found\n");
+ goto fini;
+
+error:
+ if (SG_LIB_CAT_INVALID_OP == res)
pr2serr("Get LBA Status command not supported\n");
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
pr2serr("Get LBA Status command: bad field in cdb\n");
@@ -501,17 +557,18 @@ main(int argc, char * argv[])
pr2serr("Get LBA Status command: %s\n", b);
}
-the_end:
- res = sg_cmds_close_device(sg_fd);
- if (res < 0) {
- pr2serr("close error: %s\n", safe_strerror(-res));
- if (0 == ret)
- ret = sg_convert_errno(-res);
+fini:
+ if (sg_fd >= 0) {
+ res = sg_cmds_close_device(sg_fd);
+ if (res < 0) {
+ pr2serr("close error: %s\n", safe_strerror(-res));
+ if (0 == ret)
+ ret = sg_convert_errno(-res);
+ }
}
-free_buff:
if (free_glbasBuffp)
free(free_glbasBuffp);
- if (0 == verbose) {
+ if ((0 == verbose) && (! no_final_msg)) {
if (! sg_if_can2stderr("sg_get_lba_status failed: ", ret))
pr2serr("Some error occurred, try again with '-v' or '-vv' for "
"more information\n");
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 2319c9ed..5ee6792f 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -51,7 +51,7 @@
#include "sg_pt_nvme.h"
#endif
-static const char * version_str = "2.01 20190520"; /* SPC-5 rev 22 */
+static const char * version_str = "2.02 20190815"; /* SPC-5 rev 22 */
/* INQUIRY notes:
* It is recommended that the initial allocation length given to a
@@ -3768,7 +3768,9 @@ nvme_id_namespace(struct sg_pt_base * ptvp, uint32_t nsid,
clear_scsi_pt_obj(ptvp);
id_cmdp->nsid = nsid;
- id_cmdp->cdw10 = 0x0; /* CNS=0x0 Identify NS */
+ id_cmdp->cdw10 = 0x0; /* CNS=0x0 Identify NS (CNTID=0) */
+ id_cmdp->cdw11 = 0x0; /* NVMSETID=0 (only valid when CNS=0x4) */
+ id_cmdp->cdw14 = 0x0; /* UUID index (assume not supported) */
set_scsi_pt_data_in(ptvp, id_dinp, id_din_len);
set_scsi_pt_sense(ptvp, resp, sizeof(resp));
set_scsi_pt_cdb(ptvp, (const uint8_t *)id_cmdp, sizeof(*id_cmdp));
@@ -3793,7 +3795,7 @@ nvme_id_namespace(struct sg_pt_base * ptvp, uint32_t nsid,
}
static void
-show_nvme_id_ctl(const uint8_t *dinp, const char *dev_name, int do_long)
+show_nvme_id_ctrl(const uint8_t *dinp, const char *dev_name, int do_long)
{
bool got_fguid;
uint8_t ver_min, ver_ter, mtds;
@@ -3820,6 +3822,8 @@ show_nvme_id_ctl(const uint8_t *dinp, const char *dev_name, int do_long)
oacs = sg_get_unaligned_le16(dinp + 256);
if (0x1ff & oacs) {
printf(" Optional admin command support:\n");
+ if (0x200 & oacs)
+ printf(" Get LBA status\n"); /* NVMe 1.4 */
if (0x100 & oacs)
printf(" Doorbell buffer config\n");
if (0x80 & oacs)
@@ -3843,6 +3847,8 @@ show_nvme_id_ctl(const uint8_t *dinp, const char *dev_name, int do_long)
oncs = sg_get_unaligned_le16(dinp + 256);
if (0x7f & oncs) {
printf(" Optional NVM command support:\n");
+ if (0x80 & oncs)
+ printf(" Verify\n"); /* NVMe 1.4 */
if (0x40 & oncs)
printf(" Timestamp feature\n");
if (0x20 & oncs)
@@ -3942,7 +3948,7 @@ show_nvme_id_ctl(const uint8_t *dinp, const char *dev_name, int do_long)
}
}
-/* Send a NVMe Identify(CNS=1, nsid=0) and decode Controller info. If the
+/* Send a NVMe Identify(CNS=1) and decode Controller info. If the
* device name includes a namespace indication (e.g. /dev/nvme0ns1) then
* an Identify namespace command is sent to that namespace (e.g. 1). If the
* device name does not contain a namespace indication (e.g. /dev/nvme0)
@@ -3951,7 +3957,7 @@ show_nvme_id_ctl(const uint8_t *dinp, const char *dev_name, int do_long)
* 1 . The CNS (Controller or Namespace Structure) field is CDW10 7:0, was
* only bit 0 in NVMe 1.0 and bits 1:0 in NVMe 1.1, thereafter 8 bits. */
static int
-do_nvme_identify(int pt_fd, const struct opts_t * op)
+do_nvme_identify_ctrl(int pt_fd, const struct opts_t * op)
{
int ret = 0;
int vb = op->verbose;
@@ -3978,8 +3984,8 @@ do_nvme_identify(int pt_fd, const struct opts_t * op)
memset(id_cmdp, 0, sizeof(*id_cmdp));
id_cmdp->opcode = 0x6;
nsid = get_pt_nvme_nsid(ptvp);
- /* leave id_cmdp->nsid at 0 */
- id_cmdp->cdw10 = 0x1; /* CNS=0x1 Identify controller */
+ id_cmdp->cdw10 = 0x1; /* CNS=0x1 --> Identify controller */
+ /* id_cmdp->nsid is a "don't care" when CNS=1, so leave as 0 */
id_dinp = sg_memalign(pg_sz, pg_sz, &free_id_dinp, false);
if (NULL == id_dinp) {
pr2serr("%s: sg_memalign problem\n", __func__);
@@ -4009,7 +4015,7 @@ do_nvme_identify(int pt_fd, const struct opts_t * op)
}
goto skip1;
}
- show_nvme_id_ctl(id_dinp, op->device_name, op->do_long);
+ show_nvme_id_ctrl(id_dinp, op->device_name, op->do_long);
skip1:
if (op->do_only)
goto fini;
@@ -4373,7 +4379,7 @@ main(int argc, char * argv[])
if ((3 == n) || (4 == n)) { /* NVMe char or NVMe block */
op->possible_nvme = true;
if (! op->page_given) {
- ret = do_nvme_identify(sg_fd, op);
+ ret = do_nvme_identify_ctrl(sg_fd, op);
goto fini2;
}
}
diff --git a/src/sg_logs.c b/src/sg_logs.c
index c60b50a1..e11e8523 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -36,7 +36,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.75 20190516"; /* spc5r22 + sbc4r17 */
+static const char * version_str = "1.77 20190822"; /* spc5r22 + sbc4r17 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -124,6 +124,7 @@ static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"hex", no_argument, 0, 'H'},
{"in", required_argument, 0, 'i'},
+ {"inhex", required_argument, 0, 'i'},
{"list", no_argument, 0, 'l'},
{"maxlen", required_argument, 0, 'm'},
{"name", no_argument, 0, 'n'},
@@ -4921,7 +4922,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x1:
printf(" Maximum explicitly open zones:");
@@ -4934,7 +4935,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x2:
printf(" Maximum implicitly open zones:");
@@ -4947,7 +4948,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x3:
printf(" Minimum empty zones:");
@@ -4960,10 +4961,10 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x4:
- printf(" Maximum number of non-sequential zones:");
+ printf(" Maximum non-sequential zones:");
if ((pl < 8) || (num < 8)) {
if (num < 8)
pr2serr("\n truncated by response length, expected "
@@ -4973,7 +4974,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x5:
printf(" Zones emptied:");
@@ -4986,7 +4987,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x6:
printf(" Suboptimal write commands:");
@@ -4999,7 +5000,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x7:
printf(" Commands exceeding optimal limit:");
@@ -5012,7 +5013,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x8:
printf(" Failed explicit opens:");
@@ -5025,7 +5026,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0x9:
printf(" Read rule violations:");
@@ -5038,7 +5039,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
case 0xa:
printf(" Write rule violations:");
@@ -5051,7 +5052,7 @@ show_zoned_block_dev_stats(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %" PRIu64 "\n", sg_get_unaligned_be64(bp + 4));
+ printf(" %" PRIu32 "\n", sg_get_unaligned_be32(bp + 8));
break;
default:
printf(" Reserved [parameter_code=0x%x]:\n", pc);
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 31c7dd08..2325b8b4 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -38,7 +38,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static const char * version_str = "2.45 20190714"; /* ses4r03 */
+static const char * version_str = "2.46 20190826"; /* ses4r03 */
#define MX_ALLOC_LEN ((64 * 1024) - 4) /* max allowable for big enclosures */
#define MX_ELEM_HDR 1024
@@ -755,6 +755,7 @@ static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"hex", no_argument, 0, 'H'},
{"index", required_argument, 0, 'I'},
+ {"inhex", required_argument, 0, 'X'},
{"inner-hex", no_argument, 0, 'i'},
{"inner_hex", no_argument, 0, 'i'},
{"join", no_argument, 0, 'j'},
@@ -811,7 +812,7 @@ static uint8_t ses3_element_cmask_arr[NUM_ETC][4] = {
static int read_hex(const char * inp, uint8_t * arr, int mx_arr_len,
- int * arr_len, bool in_hex, int verb);
+ int * arr_len, bool in_hex, bool may_gave_at, int verb);
static int strcase_eq(const char * s1p, const char * s2p);
static void enumerate_diag_pages(void);
static bool saddr_non_zero(const uint8_t * bp);
@@ -832,16 +833,18 @@ usage(int help_num)
" [--raw] [--readonly] [--sas-addr=SA] [--status] "
"[--verbose]\n"
" [--warn] DEVICE\n\n"
- " sg_ses [--byte1=B1] [--clear=STR] [--control] "
+ " sg_ses --control [--byte1=B1] [--clear=STR] "
"[--data=H,H...]\n"
" [--descriptor=DES] [--dev-slot-num=SN] "
"[--index=IIA | =TIA,II]\n"
- " [--mask] [--maxlen=LEN] [--nickid=SEID] "
- "[--nickname=SEN]\n"
- " [--page=PG] [--sas-addr=SA] [--set=STR] "
- "[--verbose]\n"
- " DEVICE\n\n"
+ " [--inhex=FN] [--mask] [--maxlen=LEN] "
+ "[--nickid=SEID]\n"
+ " [--nickname=SEN] [--page=PG] [--sas-addr=SA] "
+ "[--set=STR]\n"
+ " [--verbose] DEVICE\n\n"
" sg_ses --data=@FN --status [-rr] [<most options from "
+ "first form>]\n"
+ " sg_ses --inhex=FN --status [-rr] [<most options from "
"first form>]\n\n"
" sg_ses [--enumerate] [--help] [--index=IIA] [--list] "
"[--version]\n\n"
@@ -858,6 +861,8 @@ usage(int help_num)
"[-A SA] [-S STR]\n"
" [-v] DEVICE\n\n"
" sg_ses -d @FN -s [-rr] [<most options from first "
+ "form>]\n"
+ " sg_ses -X FN -s [-rr] [<most options from first "
"form>]\n\n"
" sg_ses [-e] [-h] [-I IIA] [-l] [-V]\n"
);
@@ -935,6 +940,7 @@ usage(int help_num)
" DEVICE). Use twice for clear,get,set "
"acronyms\n"
" --hex|-H print page response (or field) in hex\n"
+ " --inhex=FN|-X FN alternate form of --data=@FN\n"
" --inner-hex|-i print innermost level of a"
" status page in hex\n"
" --list|-l same as '--enumerate' option\n"
@@ -1129,6 +1135,7 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
{
int c, j, n, d_len, ret;
const char * data_arg = NULL;
+ const char * inhex_arg = NULL;
uint64_t saddr;
const char * cp;
@@ -1346,6 +1353,10 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
return SG_LIB_SYNTAX_ERROR;
}
break;
+ case 'X': /* --inhex=FN for compatibility with other utils */
+ inhex_arg = optarg;
+ op->do_data = true;
+ break;
default:
pr2serr("unrecognised option code 0x%x ??\n", c);
goto err_help;
@@ -1372,13 +1383,23 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
pr2serr("unable to allocate %u bytes on heap\n", op->mx_arr_len);
return sg_convert_errno(ENOMEM);
}
- if (data_arg) {
- if (read_hex(data_arg, op->data_arr + DATA_IN_OFF,
- op->mx_arr_len - DATA_IN_OFF, &op->arr_len,
- (op->do_raw < 2), op->verbose)) {
- pr2serr("bad argument, expect '--data=H,H...', '--data=-' or "
- "'--data=@FN'\n");
- return SG_LIB_SYNTAX_ERROR;
+ if (data_arg || inhex_arg) {
+ if (inhex_arg) {
+ data_arg = inhex_arg;
+ if (read_hex(data_arg, op->data_arr + DATA_IN_OFF,
+ op->mx_arr_len - DATA_IN_OFF, &op->arr_len,
+ (op->do_raw < 2), false, op->verbose)) {
+ pr2serr("bad argument, expect '--inhex=FN' or '--inhex=-'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ } else {
+ if (read_hex(data_arg, op->data_arr + DATA_IN_OFF,
+ op->mx_arr_len - DATA_IN_OFF, &op->arr_len,
+ (op->do_raw < 2), true, op->verbose)) {
+ pr2serr("bad argument, expect '--data=H,H...', '--data=-' or "
+ "'--data=@FN'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
}
op->do_raw = 0;
/* struct data_in_desc_t stuff does not apply when --control */
@@ -3865,14 +3886,14 @@ truncated:
/* Reads hex data from command line, stdin or a file when in_hex is true.
* Reads binary from stdin or file when in_hex is false. Returns 0 on
- * success, 1 otherwise. If inp is a file, then the first skipped (since
- * (it should be '@'). */
+ * success, 1 otherwise. If inp is a file and may_have_at, then the
+ * first character is skipped to get filename (since it should be '@'). */
static int
read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
- bool in_hex, int vb)
+ bool in_hex, bool may_have_at, int vb)
{
bool has_stdin, split_line;
- int in_len, k, j, m, off;
+ int in_len, k, j, m, off, off_fn;
unsigned int h;
const char * lcp;
char * cp;
@@ -3883,6 +3904,7 @@ read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
if ((NULL == inp) || (NULL == arr) || (NULL == arr_len))
return 1;
+ off_fn = may_have_at ? 1 : 0;
lcp = inp;
in_len = strlen(inp);
if (0 == in_len) {
@@ -3898,9 +3920,9 @@ read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
if (has_stdin)
fd = STDIN_FILENO;
else {
- fd = open(inp + 1, O_RDONLY);
+ fd = open(inp + off_fn, O_RDONLY);
if (fd < 0) {
- pr2serr("unable to open binary file %s: %s\n", inp,
+ pr2serr("unable to open binary file %s: %s\n", inp + off_fn,
safe_strerror(errno));
return 1;
}
@@ -3908,9 +3930,9 @@ read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
k = read(fd, arr, mx_arr_len);
if (k <= 0) {
if (0 == k)
- pr2serr("read 0 bytes from binary file %s\n", inp);
+ pr2serr("read 0 bytes from binary file %s\n", inp + off_fn);
else
- pr2serr("read from binary file %s: %s\n", inp,
+ pr2serr("read from binary file %s: %s\n", inp + off_fn,
safe_strerror(errno));
if (! has_stdin)
close(fd);
@@ -3923,7 +3945,7 @@ read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
if (0 == m)
break;
if (m < 0) {
- pr2serr("read from binary pipe %s: %s\n", inp,
+ pr2serr("read from binary pipe %s: %s\n", inp + off_fn,
safe_strerror(errno));
if (! has_stdin)
close(fd);
@@ -3937,13 +3959,15 @@ read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
close(fd);
return 0;
}
- if (has_stdin || ('@' == inp[0])) { /* read from stdin or file */
+ if (has_stdin || (! may_have_at) || ('@' == inp[0])) {
+ /* read hex from stdin or file */
if (has_stdin)
fp = stdin;
else {
- fp = fopen(inp + 1, "r");
+ fp = fopen(inp + off_fn, "r");
if (NULL == fp) {
- pr2serr("%s: unable to open file: %s\n", __func__, inp + 1);
+ pr2serr("%s: unable to open file: %s\n", __func__,
+ inp + off_fn);
return 1;
}
}
diff --git a/testing/Makefile.cplus b/testing/Makefile.cplus
index 052e815e..871136ff 100644
--- a/testing/Makefile.cplus
+++ b/testing/Makefile.cplus
@@ -67,7 +67,7 @@ sg_tst_async: sg_tst_async.o $(LIBFILESNEW)
$(CXXLD) -o $@ $(LDFLAGS) $^
sgh_dd: sgh_dd.o $(LIBFILESNEW)
- $(CXXLD) -o $@ $(LDFLAGS) -pthread $^
+ $(CXXLD) -o $@ $(LDFLAGS) -pthread -latomic $^
install: $(EXECS)
install -d $(INSTDIR)
diff --git a/testing/sg_tst_async.cpp b/testing/sg_tst_async.cpp
index 74123456..aa05ca95 100644
--- a/testing/sg_tst_async.cpp
+++ b/testing/sg_tst_async.cpp
@@ -89,7 +89,7 @@
#include "sg_pt.h"
#include "sg_cmds.h"
-static const char * version_str = "1.37 20190618";
+static const char * version_str = "1.38 20190728";
static const char * util_name = "sg_tst_async";
/* This is a test program for checking the async usage of the Linux sg
@@ -191,6 +191,7 @@ struct opts_t {
bool block;
bool cmd_time;
bool direct;
+ bool excl;
bool generic_sync;
bool masync;
bool mmap_io;
@@ -274,6 +275,7 @@ static struct option long_options[] = {
{"cmd-time", no_argument, 0, 'c'},
{"cmd_time", no_argument, 0, 'c'},
{"direct", no_argument, 0, 'd'},
+ {"excl", no_argument, 0, 'e'},
{"force", no_argument, 0, 'f'},
{"generic-sync", no_argument, 0, 'g'},
{"generic_sync", no_argument, 0, 'g'},
@@ -309,23 +311,24 @@ static struct option long_options[] = {
static void
usage(void)
{
- printf("Usage: %s [--cmd-time] [--direct] [--force] [--generic-sync]\n"
- " [--help] [--lba=LBA+] [--lbsz=LBSZ] "
- "[--masync]\n"
- " [--maxqpt=QPT] [--mmap-io] [--numpt=NPT] "
- "[--noxfer]\n"
- " [--override=OVN] [--pack-id] [--qat=AT] "
- "[-qfav=FAV]\n"
- " [--read] [--stats] [--submit] "
- "[--szlb=LB[,NLBS]]\n"
- " [--tnum=NT] [--tur] [--v3] [--v4] "
- "[--verbose]\n"
- " [--version] [--wait=MS] [--write] "
- "<sg_disk_device>*\n",
+ printf("Usage: %s [--cmd-time] [--direct] [--excl] [--force]\n"
+ " [--generic-sync] [--help] [--lba=LBA+] "
+ "[--lbsz=LBSZ]\n"
+ " [--masync] [--maxqpt=QPT] [--mmap-io] "
+ "[--numpt=NPT]\n"
+ " [--noxfer] [--override=OVN] [--pack-id] "
+ "[--qat=AT]\n"
+ " [-qfav=FAV] [--read] [--stats] [--submit]\n"
+ " [--szlb=LB[,NLBS]] [--tnum=NT] [--tur] "
+ "[--v3] [--v4]\n"
+ " [--verbose] [--version] [--wait=MS] "
+ "[--write]\n"
+ " <sg_disk_device>*\n",
util_name);
printf(" where\n");
printf(" --cmd-time|-c calculate per command average time (ns)\n");
printf(" --direct|-d do direct_io (def: indirect)\n");
+ printf(" --excl|-e do wait_exclusive calls\n");
printf(" --force|-f force: any sg device (def: only scsi_debug "
"owned)\n");
printf(" WARNING: <lba> written to if '-W' given\n");
@@ -883,6 +886,8 @@ work_sync_thread(int id, const char * dev_name, unsigned int /* hi_lba */,
pr_rusage(id);
goto err_out;
}
+ if (vb > 2)
+ pr2serr_lk(">>>> id=%d: open(%s) --> fd=%d\n", id, dev_name, sg_fd);
ptp = construct_scsi_pt_obj_with_fd(sg_fd, vb);
err = 0;
@@ -897,7 +902,7 @@ work_sync_thread(int id, const char * dev_name, unsigned int /* hi_lba */,
memset(cdb, 0, sizeof(cdb)); /* TUR's cdb is 6 zeros */
set_scsi_pt_cdb(ptp, cdb, sizeof(cdb));
set_scsi_pt_sense(ptp, sense_b, sizeof(sense_b));
- set_scsi_pt_packet_id(ptp, uniq_pack_id.fetch_add(1));
+ set_scsi_pt_packet_id(ptp, uniq_pack_id.fetch_add(1));
++thr_sync_starts;
rs = do_scsi_pt(ptp, -1, DEF_PT_TIMEOUT, vb);
n = sg_cmds_process_resp(ptp, "Test unit ready", rs,
@@ -1026,6 +1031,8 @@ work_thread(int id, struct opts_t * op)
pr_rusage(id);
return;
}
+ if (vb > 2)
+ pr2serr_lk(">>>> id=%d: open(%s) --> fd=%d\n", id, dev_name, sg_fd);
if (op->pack_id_force) {
k = 1;
if (ioctl(sg_fd, SG_SET_FORCE_PACK_ID, &k) < 0)
@@ -1054,6 +1061,10 @@ work_thread(int id, struct opts_t * op)
seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_MORE_ASYNC;
seip->ctl_flags |= SG_CTL_FLAGM_MORE_ASYNC;
}
+ if (op->excl) {
+ seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_EXCL_WAITQ;
+ seip->ctl_flags |= SG_CTL_FLAGM_EXCL_WAITQ;
+ }
if (ioctl(sg_fd, SG_SET_GET_EXTENDED, seip) < 0) {
pr2serr_lk("ioctl(EXTENDED(TIME_IN_NS)) failed, errno=%d %s\n",
errno, strerror(errno));
@@ -1764,7 +1775,7 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "34acdfghl:L:mM:n:NO:pq:Q:Rs:St:TuvVw:W",
+ c = getopt_long(argc, argv, "34acdefghl:L:mM:n:NO:pq:Q:Rs:St:TuvVw:W",
long_options, &option_index);
if (c == -1)
break;
@@ -1791,6 +1802,9 @@ main(int argc, char * argv[])
case 'd':
op->direct = true;
break;
+ case 'e':
+ op->excl = true;
+ break;
case 'f':
force = true;
break;
diff --git a/testing/sgh_dd.cpp b/testing/sgh_dd.cpp
index 48b195b1..c5bb731a 100644
--- a/testing/sgh_dd.cpp
+++ b/testing/sgh_dd.cpp
@@ -108,7 +108,7 @@
using namespace std;
-static const char * version_str = "1.40 20190725";
+static const char * version_str = "1.41 20190817";
#ifdef __GNUC__
#ifndef __clang__
@@ -852,7 +852,7 @@ page4:
"probably jumped out of active state and\nthe slave request "
"entered it while some other nodes were being printed.\n\n");
pr2serr("Busy state:\n"
- "Busy state (abreviated to 'bsy' in the /proc/scsi/sg/debug "
+ "Busy state (abbreviated to 'bsy' in the /proc/scsi/sg/debug "
"output)\nis entered during request setup and completion. It "
"is intended to be\na temporary state. It should not block "
"but does sometimes (e.g. in\nblock_get_request()). Even so "
diff --git a/testing/sgs_dd.c b/testing/sgs_dd.c
index 022f528e..6f71283c 100644
--- a/testing/sgs_dd.c
+++ b/testing/sgs_dd.c
@@ -81,7 +81,7 @@
#include "sg_unaligned.h"
-static const char * version_str = "4.11 20190625";
+static const char * version_str = "4.12 20190824";
static const char * my_name = "sgs_dd";
#define DEF_BLOCK_SIZE 512
@@ -226,8 +226,9 @@ read_capacity(int sg_fd, int * num_sect, int * sect_sz)
io_hdr.timeout = DEF_TIMEOUT;
if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) {
+ res = -errno;
perror("read_capacity (SG_IO) error");
- return -1;
+ return res;
}
res = sg_err_category3(&io_hdr);
if (SG_LIB_CAT_UNIT_ATTENTION == res)
@@ -387,11 +388,12 @@ sg_finish_io(Rq_coll * clp, bool wr, Rq_elem ** repp)
if (rep)
dio = rep->wr ? clp->oflag.dio : clp->iflag.dio;
if (res < 0) {
+ res = -errno;
fprintf(stderr, "%s: read(): %s [%d]\n", __func__, strerror(errno),
errno);
if (rep)
rep->state = SGQ_IO_ERR;
- return -1;
+ return res;
}
if (! (rep && (SGQ_IO_STARTED == rep->state))) {
fprintf(stderr, "%s: bad usr_ptr\n", __func__);
@@ -432,15 +434,17 @@ do_v4:
if (use_pack || use_tag) {
while (true) {
if ( ((res = ioctl(fd, SG_GET_NUM_WAITING, &n))) < 0) {
+ res = -errno;
fprintf(stderr, "%s: ioctl(SG_GET_NUM_WAITING): %s [%d]\n",
__func__, strerror(errno), errno);
- return -1;
+ return res;
}
if (n > 0) {
if ( ((res = ioctl(fd, SG_GET_PACK_ID, &id))) < 0) {
+ res = -errno;
fprintf(stderr, "%s: ioctl(SG_GET_PACK_ID): %s [%d]\n",
__func__, strerror(errno), errno);
- return -1;
+ return res;
}
/* got pack_id or tag of first waiting */
break;
@@ -459,11 +463,12 @@ do_v4:
;
rep = (Rq_elem *)(unsigned long)io_v4.usr_ptr;
if (res < 0) {
+ res = -errno;
fprintf(stderr, "%s: ioctl(SG_IORECEIVE): %s [%d]\n", __func__,
strerror(errno), errno);
if (rep)
rep->state = SGQ_IO_ERR;
- return -1;
+ return res;
}
if (! (rep && (SGQ_IO_STARTED == rep->state))) {
fprintf(stderr, "%s: bad usr_ptr=0x%p\n", __func__, rep);
@@ -649,6 +654,7 @@ start_read(Rq_coll * clp)
res = sg_start_io(clp, rep);
if (1 == res) { /* ENOMEM, find what's available+try that */
if ((res = ioctl(clp->infd, SG_GET_RESERVED_SIZE, &buf_sz)) < 0) {
+ res = -errno;
perror("RESERVED_SIZE ioctls failed");
return res;
}
@@ -673,6 +679,7 @@ start_read(Rq_coll * clp)
(EINTR == errno))
;
if (res < 0) {
+ res = -errno;
snprintf(ebuff, EBUFF_SZ, "sgs_dd: reading, in_blk=%d ", rep->blk);
perror(ebuff);
rep->state = SGQ_IO_ERR;
@@ -736,6 +743,7 @@ start_write(Rq_coll * clp)
rep->num_blks * clp->bs)) < 0) && (EINTR == errno))
;
if (res < 0) {
+ res = -errno;
snprintf(ebuff, EBUFF_SZ, "sgs_dd: output, out_blk=%d ", rep->blk);
perror(ebuff);
rep->state = SGQ_IO_ERR;
@@ -1296,6 +1304,7 @@ main(int argc, char * argv[])
fprintf(stderr, "start_read: res=%d\n", res);
break;
}
+ res = 0;
}
if (SGQ_CAN_WRITE & crw) {
res = start_write(clp);
@@ -1303,6 +1312,7 @@ main(int argc, char * argv[])
fprintf(stderr, "start_write: res=%d\n", res);
break;
}
+ res = 0;
}
}
@@ -1329,5 +1339,5 @@ main(int argc, char * argv[])
fprintf(stderr, "SIGIO/SIGPOLL signals received: %d, RT sigs: %d\n",
clp->sigs_io_received, clp->sigs_rt_received);
remove_elems(clp);
- return res;
+ return res < 0 ? 99 : res;
}