diff -Nru lsscsi-0.28/aclocal.m4 lsscsi-0.30/aclocal.m4 --- lsscsi-0.28/aclocal.m4 2014-08-25 19:03:01.000000000 +0000 +++ lsscsi-0.30/aclocal.m4 2018-05-03 21:15:12.000000000 +0000 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.14.1 -*- Autoconf -*- +# generated automatically by aclocal 1.15.1 -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.14' +[am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.14.1], [], +m4_if([$1], [1.15.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,74 @@ # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.14.1])dnl +[AM_AUTOMAKE_VERSION([1.15.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) +# Copyright (C) 2011-2017 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_AR([ACT-IF-FAIL]) +# ------------------------- +# Try to determine the archiver interface, and trigger the ar-lib wrapper +# if it is needed. If the detection of archiver interface fails, run +# ACT-IF-FAIL (default is to abort configure with a proper error message). +AC_DEFUN([AM_PROG_AR], +[AC_BEFORE([$0], [LT_INIT])dnl +AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl +AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([ar-lib])dnl +AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) +: ${AR=ar} + +AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], + [AC_LANG_PUSH([C]) + am_cv_ar_interface=ar + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], + [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([am_ar_try]) + if test "$ac_status" -eq 0; then + am_cv_ar_interface=ar + else + am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([am_ar_try]) + if test "$ac_status" -eq 0; then + am_cv_ar_interface=lib + else + am_cv_ar_interface=unknown + fi + fi + rm -f conftest.lib libconftest.a + ]) + AC_LANG_POP([C])]) + +case $am_cv_ar_interface in +ar) + ;; +lib) + # Microsoft lib, so override with the ar-lib wrapper script. + # FIXME: It is wrong to rewrite AR. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__AR in this case, + # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something + # similar. + AR="$am_aux_dir/ar-lib $AR" + ;; +unknown) + m4_default([$1], + [AC_MSG_ERROR([could not determine $AR interface])]) + ;; +esac +AC_SUBST([AR])dnl +]) + # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -103,15 +163,14 @@ # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -142,7 +201,7 @@ Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -333,7 +392,7 @@ # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -409,7 +468,7 @@ # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -499,8 +558,8 @@ # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl @@ -573,7 +632,11 @@ END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi -fi]) +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. +]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further @@ -602,7 +665,7 @@ done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -613,7 +676,7 @@ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -623,7 +686,7 @@ fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -645,7 +708,7 @@ # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -680,7 +743,7 @@ # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -730,7 +793,7 @@ # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -771,7 +834,7 @@ # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -798,7 +861,7 @@ # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -827,7 +890,7 @@ AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -874,7 +937,7 @@ # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -893,7 +956,7 @@ # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -974,7 +1037,7 @@ rm -f conftest.file ]) -# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2009-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1034,7 +1097,7 @@ _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1062,7 +1125,7 @@ INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1081,7 +1144,7 @@ # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff -Nru lsscsi-0.28/ar-lib lsscsi-0.30/ar-lib --- lsscsi-0.28/ar-lib 1970-01-01 00:00:00.000000000 +0000 +++ lsscsi-0.30/ar-lib 2018-05-03 21:15:12.000000000 +0000 @@ -0,0 +1,270 @@ +#! /bin/sh +# Wrapper for Microsoft lib.exe + +me=ar-lib +scriptversion=2012-03-01.08; # UTC + +# Copyright (C) 2010-2017 Free Software Foundation, Inc. +# Written by Peter Rosin . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + + +# func_error message +func_error () +{ + echo "$me: $1" 1>&2 + exit 1 +} + +file_conv= + +# func_file_conv build_file +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv in + mingw) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_at_file at_file operation archive +# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE +# for each of them. +# When interpreting the content of the @FILE, do NOT use func_file_conv, +# since the user would need to supply preconverted file names to +# binutils ar, at least for MinGW. +func_at_file () +{ + operation=$2 + archive=$3 + at_file_contents=`cat "$1"` + eval set x "$at_file_contents" + shift + + for member + do + $AR -NOLOGO $operation:"$member" "$archive" || exit $? + done +} + +case $1 in + '') + func_error "no command. Try '$0 --help' for more information." + ;; + -h | --h*) + cat < +# To verbosely try running with an older (unsupported) autoconf: +# AUTOCONF_VERSION=2.50 ./autogen.sh --verbose # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License VERSION 2 as -# published by the Free Software Foundation. You are not allowed to -# use any other version of the license; unless you got the explicit -# permission from the author to do so. +# Author: +# Christopher Sean Morrison # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Patches: +# Sebastian Pipping # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +###################################################################### + +# set to minimum acceptable version of autoconf +if [ "x$AUTOCONF_VERSION" = "x" ] ; then + AUTOCONF_VERSION=2.52 +fi +# set to minimum acceptable version of automake +if [ "x$AUTOMAKE_VERSION" = "x" ] ; then + AUTOMAKE_VERSION=1.6.0 +fi +# set to minimum acceptable version of libtool +if [ "x$LIBTOOL_VERSION" = "x" ] ; then + LIBTOOL_VERSION=1.4.2 +fi + + +################## +# ident function # +################## +ident ( ) { + # extract copyright from header + __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`" + if [ "x$__copyright" = "x" ] ; then + __copyright="`date +%Y`" + fi + + # extract version from CVS Id string + __id="$Id: autogen.sh 33925 2009-03-01 23:27:06Z brlcad $" + __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`" + if [ "x$__version" = "x" ] ; then + __version="" + fi + + echo "autogen.sh build preparation script by Christopher Sean Morrison" + echo " + config.guess download patch by Sebastian Pipping (2008-12-03)" + echo "revised 3-clause BSD-style license, copyright (c) $__copyright" + echo "script version $__version, ISO/IEC 9945 POSIX shell script" +} + + +################## +# USAGE FUNCTION # +################## +usage ( ) { + echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [-d|--download] [--version]" + echo " --help Help on $NAME_OF_AUTOGEN usage" + echo " --verbose Verbose progress output" + echo " --quiet Quiet suppressed progress output" + echo " --download Download the latest config.guess from gnulib" + echo " --version Only perform GNU Build System version checks" + echo + echo "Description: This script will validate that minimum versions of the" + echo "GNU Build System tools are installed and then run autoreconf for you." + echo "Should autoreconf fail, manual preparation steps will be run" + echo "potentially accounting for several common preparation issues. The" + + echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER," + echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS" + echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the" + echo "default automatic detection behavior." + echo + + ident + + return 0 +} + + +########################## +# VERSION_ERROR FUNCTION # +########################## +version_error ( ) { + if [ "x$1" = "x" ] ; then + echo "INTERNAL ERROR: version_error was not provided a version" + exit 1 + fi + if [ "x$2" = "x" ] ; then + echo "INTERNAL ERROR: version_error was not provided an application name" + exit 1 + fi + $ECHO + $ECHO "ERROR: To prepare the ${PROJECT} build system from scratch," + $ECHO " at least version $1 of $2 must be installed." + $ECHO + $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will" + $ECHO "run configure or make. Either the GNU Autotools will need to be installed" + $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source" + $ECHO "code on another system and then transferred to here. -- Cheers!" + $ECHO +} + +########################## +# VERSION_CHECK FUNCTION # +########################## +version_check ( ) { + if [ "x$1" = "x" ] ; then + echo "INTERNAL ERROR: version_check was not provided a minimum version" + exit 1 + fi + _min="$1" + if [ "x$2" = "x" ] ; then + echo "INTERNAL ERROR: version check was not provided a comparison version" + exit 1 + fi + _cur="$2" + + # needed to handle versions like 1.10 and 1.4-p6 + _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" + _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" + + _min_major="`echo $_min | cut -d. -f1`" + _min_minor="`echo $_min | cut -d. -f2`" + _min_patch="`echo $_min | cut -d. -f3`" + + _cur_major="`echo $_cur | cut -d. -f1`" + _cur_minor="`echo $_cur | cut -d. -f2`" + _cur_patch="`echo $_cur | cut -d. -f3`" + + if [ "x$_min_major" = "x" ] ; then + _min_major=0 + fi + if [ "x$_min_minor" = "x" ] ; then + _min_minor=0 + fi + if [ "x$_min_patch" = "x" ] ; then + _min_patch=0 + fi + if [ "x$_cur_minor" = "x" ] ; then + _cur_major=0 + fi + if [ "x$_cur_minor" = "x" ] ; then + _cur_minor=0 + fi + if [ "x$_cur_patch" = "x" ] ; then + _cur_patch=0 + fi + + $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}" + + if [ $_min_major -lt $_cur_major ] ; then + return 0 + elif [ $_min_major -eq $_cur_major ] ; then + if [ $_min_minor -lt $_cur_minor ] ; then + return 0 + elif [ $_min_minor -eq $_cur_minor ] ; then + if [ $_min_patch -lt $_cur_patch ] ; then + return 0 + elif [ $_min_patch -eq $_cur_patch ] ; then + return 0 + fi + fi + fi + return 1 +} + + +###################################### +# LOCATE_CONFIGURE_TEMPLATE FUNCTION # +###################################### +locate_configure_template ( ) { + _pwd="`pwd`" + if test -f "./configure.ac" ; then + echo "./configure.ac" + elif test -f "./configure.in" ; then + echo "./configure.in" + elif test -f "$_pwd/configure.ac" ; then + echo "$_pwd/configure.ac" + elif test -f "$_pwd/configure.in" ; then + echo "$_pwd/configure.in" + elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then + echo "$PATH_TO_AUTOGEN/configure.ac" + elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then + echo "$PATH_TO_AUTOGEN/configure.in" + fi +} + + +################## +# argument check # +################## +ARGS="$*" +PATH_TO_AUTOGEN="`dirname $0`" +NAME_OF_AUTOGEN="`basename $0`" +AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN" + +LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4" + +if [ "x$HELP" = "x" ] ; then + HELP=no +fi +if [ "x$QUIET" = "x" ] ; then + QUIET=no +fi +if [ "x$VERBOSE" = "x" ] ; then + VERBOSE=no +fi +if [ "x$VERSION_ONLY" = "x" ] ; then + VERSION_ONLY=no +fi +if [ "x$DOWNLOAD" = "x" ] ; then + DOWNLOAD=no +fi +if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then + AUTORECONF_OPTIONS="-i -f" +fi +if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then + AUTOCONF_OPTIONS="-f" +fi +if [ "x$AUTOMAKE_OPTIONS" = "x" ] ; then + AUTOMAKE_OPTIONS="-a -c -f" +fi +ALT_AUTOMAKE_OPTIONS="-a -c" +if [ "x$LIBTOOLIZE_OPTIONS" = "x" ] ; then + LIBTOOLIZE_OPTIONS="--automake -c -f" +fi +ALT_LIBTOOLIZE_OPTIONS="--automake --copy --force" +if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then + ACLOCAL_OPTIONS="" +fi +if [ "x$AUTOHEADER_OPTIONS" = "x" ] ; then + AUTOHEADER_OPTIONS="" +fi +if [ "x$CONFIG_GUESS_URL" = "x" ] ; then + CONFIG_GUESS_URL="http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/config.guess;hb=HEAD" +fi +for arg in $ARGS ; do + case "x$arg" in + x--help) HELP=yes ;; + x-[hH]) HELP=yes ;; + x--quiet) QUIET=yes ;; + x-[qQ]) QUIET=yes ;; + x--verbose) VERBOSE=yes ;; + x-[dD]) DOWNLOAD=yes ;; + x--download) DOWNLOAD=yes ;; + x-[vV]) VERBOSE=yes ;; + x--version) VERSION_ONLY=yes ;; + *) + echo "Unknown option: $arg" + echo + usage + exit 1 + ;; + esac +done + + +##################### +# environment check # +##################### + +# sanity check before recursions potentially begin +if [ ! -f "$AUTOGEN_SH" ] ; then + echo "INTERNAL ERROR: $AUTOGEN_SH does not exist" + if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then + echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH" + fi + exit 1 +fi +# force locale setting to C so things like date output as expected +LC_ALL=C -dir=`echo "$0" | sed 's,[^/]*$,,'` -test "x${dir}" = "x" && dir='.' +# commands that this script expects +for __cmd in echo head tail pwd ; do + echo "test" | $__cmd > /dev/null 2>&1 + if [ $? != 0 ] ; then + echo "INTERNAL ERROR: '${__cmd}' command is required" + exit 2 + fi +done +echo "test" | grep "test" > /dev/null 2>&1 +if test ! x$? = x0 ; then + echo "INTERNAL ERROR: grep command is required" + exit 1 +fi +echo "test" | sed "s/test/test/" > /dev/null 2>&1 +if test ! x$? = x0 ; then + echo "INTERNAL ERROR: sed command is required" + exit 1 +fi + + +# determine the behavior of echo +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +# determine the behavior of head +case "x`echo 'head' | head -n 1 2>&1`" in + *xhead*) HEAD_N="n " ;; + *) HEAD_N="" ;; +esac + +# determine the behavior of tail +case "x`echo 'tail' | tail -n 1 2>&1`" in + *xtail*) TAIL_N="n " ;; + *) TAIL_N="" ;; +esac + +VERBOSE_ECHO=: +ECHO=: +if [ "x$QUIET" = "xyes" ] ; then + if [ "x$VERBOSE" = "xyes" ] ; then + echo "Verbose output quelled by quiet option. Further output disabled." + fi +else + ECHO=echo + if [ "x$VERBOSE" = "xyes" ] ; then + echo "Verbose output enabled" + VERBOSE_ECHO=echo + fi +fi + + +# allow a recursive run to disable further recursions +if [ "x$RUN_RECURSIVE" = "x" ] ; then + RUN_RECURSIVE=yes +fi + + +################################################ +# check for help arg and bypass version checks # +################################################ +if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then + HELP=yes +fi +if [ "x$HELP" = "xyes" ] ; then + usage + $ECHO "---" + $ECHO "Help was requested. No preparation or configuration will be performed." + exit 0 +fi + + +####################### +# set up signal traps # +####################### +untrap_abnormal ( ) { + for sig in 1 2 13 15; do + trap - $sig + done +} + +# do this cleanup whenever we exit. +trap ' + # start from the root + if test -d "$START_PATH" ; then + cd "$START_PATH" + fi + + # restore/delete backup files + if test "x$PFC_INIT" = "x1" ; then + recursive_restore + fi +' 0 + +# trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15) +for sig in 1 2 13 15; do + trap ' + $ECHO "" + $ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'" + + # start from the root + if test -d "$START_PATH" ; then + cd "$START_PATH" + fi + + # clean up on abnormal exit + $VERBOSE_ECHO "rm -rf autom4te.cache" + rm -rf autom4te.cache + + if test -f "acinclude.m4.$$.backup" ; then + $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4" + chmod u+w acinclude.m4 + cat acinclude.m4.$$.backup > acinclude.m4 + + $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup" + rm -f acinclude.m4.$$.backup + fi + + { (exit 1); exit 1; } +' $sig +done + + +############################# +# look for a configure file # +############################# +if [ "x$CONFIGURE" = "x" ] ; then + CONFIGURE="`locate_configure_template`" + if [ ! "x$CONFIGURE" = "x" ] ; then + $VERBOSE_ECHO "Found a configure template: $CONFIGURE" + fi +else + $ECHO "Using CONFIGURE environment variable override: $CONFIGURE" +fi +if [ "x$CONFIGURE" = "x" ] ; then + if [ "x$VERSION_ONLY" = "xyes" ] ; then + CONFIGURE=/dev/null + else + $ECHO + $ECHO "A configure.ac or configure.in file could not be located implying" + $ECHO "that the GNU Build System is at least not used in this directory. In" + $ECHO "any case, there is nothing to do here without one of those files." + $ECHO + $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" + exit 1 + fi +fi -if test "x`cd "${dir}" 2>/dev/null && pwd`" != "x`pwd`" -then - echo "This script must be executed directly from the source directory." +#################### +# get project name # +#################### +if [ "x$PROJECT" = "x" ] ; then + PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + if [ "x$PROJECT" = "xAC_INIT" ] ; then + # projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead + PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + fi + if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then + PROJECT="project" + fi + if [ "x$PROJECT" = "x" ] ; then + PROJECT="project" + fi +else + $ECHO "Using PROJECT environment variable override: $PROJECT" +fi +$ECHO "Preparing the $PROJECT build system...please wait" +$ECHO + + +######################## +# check for autoreconf # +######################## +HAVE_AUTORECONF=no +if [ "x$AUTORECONF" = "x" ] ; then + for AUTORECONF in autoreconf ; do + $VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version" + $AUTORECONF --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + HAVE_AUTORECONF=yes + break + fi + done +else + HAVE_AUTORECONF=yes + $ECHO "Using AUTORECONF environment variable override: $AUTORECONF" +fi + + +########################## +# autoconf version check # +########################## +_acfound=no +if [ "x$AUTOCONF" = "x" ] ; then + for AUTOCONF in autoconf ; do + $VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version" + $AUTOCONF --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + _acfound=yes + break + fi + done +else + _acfound=yes + $ECHO "Using AUTOCONF environment variable override: $AUTOCONF" +fi + +_report_error=no +if [ ! "x$_acfound" = "xyes" ] ; then + $ECHO "ERROR: Unable to locate GNU Autoconf." + _report_error=yes +else + _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" + if [ "x$_version" = "x" ] ; then + _version="0.0.0" + fi + $ECHO "Found GNU Autoconf version $_version" + version_check "$AUTOCONF_VERSION" "$_version" + if [ $? -ne 0 ] ; then + _report_error=yes + fi +fi +if [ "x$_report_error" = "xyes" ] ; then + version_error "$AUTOCONF_VERSION" "GNU Autoconf" + exit 1 +fi + + +########################## +# automake version check # +########################## +_amfound=no +if [ "x$AUTOMAKE" = "x" ] ; then + for AUTOMAKE in automake ; do + $VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version" + $AUTOMAKE --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + _amfound=yes + break + fi + done +else + _amfound=yes + $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE" +fi + + +_report_error=no +if [ ! "x$_amfound" = "xyes" ] ; then + $ECHO + $ECHO "ERROR: Unable to locate GNU Automake." + _report_error=yes +else + _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" + if [ "x$_version" = "x" ] ; then + _version="0.0.0" + fi + $ECHO "Found GNU Automake version $_version" + version_check "$AUTOMAKE_VERSION" "$_version" + if [ $? -ne 0 ] ; then + _report_error=yes + fi +fi +if [ "x$_report_error" = "xyes" ] ; then + version_error "$AUTOMAKE_VERSION" "GNU Automake" exit 1 fi -rm -f config.cache acconfig.h -# echo "- libtoolize." && \ -# libtoolize --force && \ -echo "- aclocal." && \ -aclocal && \ -echo "- autoconf." && \ -autoconf && \ -echo "- autoheader." && \ -autoheader && \ -echo "- automake." && \ -automake --add-missing --gnu && \ -exit 0 +######################## +# check for libtoolize # +######################## +HAVE_LIBTOOLIZE=yes +HAVE_ALT_LIBTOOLIZE=no +_ltfound=no +if [ "x$LIBTOOLIZE" = "x" ] ; then + LIBTOOLIZE=libtoolize + $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version" + $LIBTOOLIZE --version > /dev/null 2>&1 + if [ ! $? = 0 ] ; then + HAVE_LIBTOOLIZE=no + $ECHO + if [ "x$HAVE_AUTORECONF" = "xno" ] ; then + $ECHO "Warning: libtoolize does not appear to be available." + else + $ECHO "Warning: libtoolize does not appear to be available. This means that" + $ECHO "the automatic build preparation via autoreconf will probably not work." + $ECHO "Preparing the build by running each step individually, however, should" + $ECHO "work and will be done automatically for you if autoreconf fails." + fi + + # look for some alternates + for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do + $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version" + _glibtoolize="`$tool --version > /dev/null 2>&1`" + if [ $? = 0 ] ; then + $VERBOSE_ECHO "Found $tool --version" + _glti="`which $tool`" + if [ "x$_glti" = "x" ] ; then + $VERBOSE_ECHO "Cannot find $tool with which" + continue; + fi + if test ! -f "$_glti" ; then + $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file" + continue; + fi + _gltidir="`dirname $_glti`" + if [ "x$_gltidir" = "x" ] ; then + $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti" + continue; + fi + if test ! -d "$_gltidir" ; then + $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory" + continue; + fi + HAVE_ALT_LIBTOOLIZE=yes + LIBTOOLIZE="$tool" + $ECHO + $ECHO "Fortunately, $tool was found which means that your system may simply" + $ECHO "have a non-standard or incomplete GNU Autotools install. If you have" + $ECHO "sufficient system access, it may be possible to quell this warning by" + $ECHO "running:" + $ECHO + sudo -V > /dev/null 2>&1 + if [ $? = 0 ] ; then + $ECHO " sudo ln -s $_glti $_gltidir/libtoolize" + $ECHO + else + $ECHO " ln -s $_glti $_gltidir/libtoolize" + $ECHO + $ECHO "Run that as root or with proper permissions to the $_gltidir directory" + $ECHO + fi + _ltfound=yes + break + fi + done + else + _ltfound=yes + fi +else + _ltfound=yes + $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE" +fi + + +############################ +# libtoolize version check # +############################ +_report_error=no +if [ ! "x$_ltfound" = "xyes" ] ; then + $ECHO + $ECHO "ERROR: Unable to locate GNU Libtool." + _report_error=yes +else + _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" + if [ "x$_version" = "x" ] ; then + _version="0.0.0" + fi + $ECHO "Found GNU Libtool version $_version" + version_check "$LIBTOOL_VERSION" "$_version" + if [ $? -ne 0 ] ; then + _report_error=yes + fi +fi +if [ "x$_report_error" = "xyes" ] ; then + version_error "$LIBTOOL_VERSION" "GNU Libtool" + exit 1 +fi + + +##################### +# check for aclocal # +##################### +if [ "x$ACLOCAL" = "x" ] ; then + for ACLOCAL in aclocal ; do + $VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version" + $ACLOCAL --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + break + fi + done +else + $ECHO "Using ACLOCAL environment variable override: $ACLOCAL" +fi + + +######################## +# check for autoheader # +######################## +if [ "x$AUTOHEADER" = "x" ] ; then + for AUTOHEADER in autoheader ; do + $VERBOSE_ECHO "Checking autoheader version: $AUTOHEADER --version" + $AUTOHEADER --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + break + fi + done +else + $ECHO "Using AUTOHEADER environment variable override: $AUTOHEADER" +fi + + +######################### +# check if version only # +######################### +$VERBOSE_ECHO "Checking whether to only output version information" +if [ "x$VERSION_ONLY" = "xyes" ] ; then + $ECHO + ident + $ECHO "---" + $ECHO "Version requested. No preparation or configuration will be performed." + exit 0 +fi + + +################################# +# PROTECT_FROM_CLOBBER FUNCTION # +################################# +protect_from_clobber ( ) { + PFC_INIT=1 + + # protect COPYING & INSTALL from overwrite by automake. the + # automake force option will (inappropriately) ignore the existing + # contents of a COPYING and/or INSTALL files (depending on the + # version) instead of just forcing *missing* files like it does + # for AUTHORS, NEWS, and README. this is broken but extremely + # prevalent behavior, so we protect against it by keeping a backup + # of the file that can later be restored. + + for file in COPYING INSTALL ; do + if test -f ${file} ; then + if test -f ${file}.$$.protect_from_automake.backup ; then + $VERBOSE_ECHO "Already backed up ${file} in `pwd`" + else + $VERBOSE_ECHO "Backing up ${file} in `pwd`" + $VERBOSE_ECHO "cp -p ${file} ${file}.$$.protect_from_automake.backup" + cp -p ${file} ${file}.$$.protect_from_automake.backup + fi + fi + done +} + + +############################## +# RECURSIVE_PROTECT FUNCTION # +############################## +recursive_protect ( ) { + + # for projects using recursive configure, run the build + # preparation steps for the subdirectories. this function assumes + # START_PATH was set to pwd before recursion begins so that + # relative paths work. + + # git 'r done, protect COPYING and INSTALL from being clobbered + protect_from_clobber + + if test -d autom4te.cache ; then + $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" + $VERBOSE_ECHO "rm -rf autom4te.cache" + rm -rf autom4te.cache + fi + + # find configure template + _configure="`locate_configure_template`" + if [ "x$_configure" = "x" ] ; then + return + fi + # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure" + + # look for subdirs + # $VERBOSE_ECHO "Looking for subdirs in `pwd`" + _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + CHECK_DIRS="" + for dir in $_det_config_subdirs ; do + if test -d "`pwd`/$dir" ; then + CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" + fi + done + + # process subdirs + if [ ! "x$CHECK_DIRS" = "x" ] ; then + $VERBOSE_ECHO "Recursively scanning the following directories:" + $VERBOSE_ECHO " $CHECK_DIRS" + for dir in $CHECK_DIRS ; do + $VERBOSE_ECHO "Protecting files from automake in $dir" + cd "$START_PATH" + eval "cd $dir" + + # recursively git 'r done + recursive_protect + done + fi +} # end of recursive_protect + + +############################# +# RESTORE_CLOBBERED FUNCION # +############################# +restore_clobbered ( ) { + + # The automake (and autoreconf by extension) -f/--force-missing + # option may overwrite COPYING and INSTALL even if they do exist. + # Here we restore the files if necessary. + + spacer=no + + for file in COPYING INSTALL ; do + if test -f ${file}.$$.protect_from_automake.backup ; then + if test -f ${file} ; then + # compare entire content, restore if needed + if test "x`cat ${file}`" != "x`cat ${file}.$$.protect_from_automake.backup`" ; then + if test "x$spacer" = "xno" ; then + $VERBOSE_ECHO + spacer=yes + fi + # restore the backup + $VERBOSE_ECHO "Restoring ${file} from backup (automake -f likely clobbered it)" + $VERBOSE_ECHO "rm -f ${file}" + rm -f ${file} + $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" + mv ${file}.$$.protect_from_automake.backup ${file} + fi # check contents + elif test -f ${file}.$$.protect_from_automake.backup ; then + $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" + mv ${file}.$$.protect_from_automake.backup ${file} + fi # -f ${file} + + # just in case + $VERBOSE_ECHO "rm -f ${file}.$$.protect_from_automake.backup" + rm -f ${file}.$$.protect_from_automake.backup + fi # -f ${file}.$$.protect_from_automake.backup + done + + CONFIGURE="`locate_configure_template`" + if [ "x$CONFIGURE" = "x" ] ; then + return + fi + + _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + if test ! -d "$_aux_dir" ; then + _aux_dir=. + fi + + for file in config.guess config.sub ltmain.sh ; do + if test -f "${_aux_dir}/${file}" ; then + $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\"" + rm -f "${_aux_dir}/${file}.backup" + fi + done +} # end of restore_clobbered + + +############################## +# RECURSIVE_RESTORE FUNCTION # +############################## +recursive_restore ( ) { + + # restore COPYING and INSTALL from backup if they were clobbered + # for each directory recursively. + + # git 'r undone + restore_clobbered + + # find configure template + _configure="`locate_configure_template`" + if [ "x$_configure" = "x" ] ; then + return + fi + + # look for subdirs + _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + CHECK_DIRS="" + for dir in $_det_config_subdirs ; do + if test -d "`pwd`/$dir" ; then + CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" + fi + done + + # process subdirs + if [ ! "x$CHECK_DIRS" = "x" ] ; then + $VERBOSE_ECHO "Recursively scanning the following directories:" + $VERBOSE_ECHO " $CHECK_DIRS" + for dir in $CHECK_DIRS ; do + $VERBOSE_ECHO "Checking files for automake damage in $dir" + cd "$START_PATH" + eval "cd $dir" + + # recursively git 'r undone + recursive_restore + done + fi +} # end of recursive_restore + + +####################### +# INITIALIZE FUNCTION # +####################### +initialize ( ) { + + # this routine performs a variety of directory-specific + # initializations. some are sanity checks, some are preventive, + # and some are necessary setup detection. + # + # this function sets: + # CONFIGURE + # SEARCH_DIRS + # CONFIG_SUBDIRS + + ################################## + # check for a configure template # + ################################## + CONFIGURE="`locate_configure_template`" + if [ "x$CONFIGURE" = "x" ] ; then + $ECHO + $ECHO "A configure.ac or configure.in file could not be located implying" + $ECHO "that the GNU Build System is at least not used in this directory. In" + $ECHO "any case, there is nothing to do here without one of those files." + $ECHO + $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" + exit 1 + fi + + ##################### + # detect an aux dir # + ##################### + _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + if test ! -d "$_aux_dir" ; then + _aux_dir=. + else + $VERBOSE_ECHO "Detected auxillary directory: $_aux_dir" + fi + + ################################ + # detect a recursive configure # + ################################ + CONFIG_SUBDIRS="" + _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + for dir in $_det_config_subdirs ; do + if test -d "`pwd`/$dir" ; then + $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir" + CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir" + fi + done + + ########################################################### + # make sure certain required files exist for GNU projects # + ########################################################### + _marker_found="" + _marker_found_message_intro='Detected non-GNU marker "' + _marker_found_message_mid='" in ' + for marker in foreign cygnus ; do + _marker_found_message=${_marker_found_message_intro}${marker}${_marker_found_message_mid} + _marker_found="`grep 'AM_INIT_AUTOMAKE.*'${marker} $CONFIGURE`" + if [ ! "x$_marker_found" = "x" ] ; then + $VERBOSE_ECHO "${_marker_found_message}`basename \"$CONFIGURE\"`" + break + fi + if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then + _marker_found="`grep 'AUTOMAKE_OPTIONS.*'${marker} Makefile.am`" + if [ ! "x$_marker_found" = "x" ] ; then + $VERBOSE_ECHO "${_marker_found_message}Makefile.am" + break + fi + fi + done + if [ "x${_marker_found}" = "x" ] ; then + _suggest_foreign=no + for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do + if [ ! -f $file ] ; then + $VERBOSE_ECHO "Touching ${file} since it does not exist" + _suggest_foreign=yes + touch $file + fi + done + + if [ "x${_suggest_foreign}" = "xyes" ] ; then + $ECHO + $ECHO "Warning: Several files expected of projects that conform to the GNU" + $ECHO "coding standards were not found. The files were automatically added" + $ECHO "for you since you do not have a 'foreign' declaration specified." + $ECHO + $ECHO "Considered adding 'foreign' to AM_INIT_AUTOMAKE in `basename \"$CONFIGURE\"`" + if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then + $ECHO "or to AUTOMAKE_OPTIONS in your top-level Makefile.am file." + fi + $ECHO + fi + fi + + ################################################## + # make sure certain generated files do not exist # + ################################################## + for file in config.guess config.sub ltmain.sh ; do + if test -f "${_aux_dir}/${file}" ; then + $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\"" + mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup" + fi + done + + ############################ + # search alternate m4 dirs # + ############################ + SEARCH_DIRS="" + for dir in m4 ; do + if [ -d $dir ] ; then + $VERBOSE_ECHO "Found extra aclocal search directory: $dir" + SEARCH_DIRS="$SEARCH_DIRS -I $dir" + fi + done + + ###################################### + # remove any previous build products # + ###################################### + if test -d autom4te.cache ; then + $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" + $VERBOSE_ECHO "rm -rf autom4te.cache" + rm -rf autom4te.cache + fi +# tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it +# if test -f aclocal.m4 ; then +# $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it" +# $VERBOSE_ECHO "rm -f aclocal.m4" +# rm -f aclocal.m4 +# fi + +} # end of initialize() + + +############## +# initialize # +############## + +# stash path +START_PATH="`pwd`" + +# Before running autoreconf or manual steps, some prep detection work +# is necessary or useful. Only needs to occur once per directory, but +# does need to traverse the entire subconfigure hierarchy to protect +# files from being clobbered even by autoreconf. +recursive_protect + +# start from where we started +cd "$START_PATH" + +# get ready to process +initialize + + +######################################### +# DOWNLOAD_GNULIB_CONFIG_GUESS FUNCTION # +######################################### + +# TODO - should make sure wget/curl exist and/or work before trying to +# use them. + +download_gnulib_config_guess () { + # abuse gitweb to download gnulib's latest config.guess via HTTP + config_guess_temp="config.guess.$$.download" + ret=1 + for __cmd in wget curl fetch ; do + $VERBOSE_ECHO "Checking for command ${__cmd}" + ${__cmd} --version > /dev/null 2>&1 + ret=$? + if [ ! $ret = 0 ] ; then + continue + fi + + __cmd_version=`${__cmd} --version | head -n 1 | sed -e 's/^[^0-9]\+//' -e 's/ .*//'` + $VERBOSE_ECHO "Found ${__cmd} ${__cmd_version}" + + opts="" + case ${__cmd} in + wget) + opts="-O" + ;; + curl) + opts="-o" + ;; + fetch) + opts="-t 5 -f" + ;; + esac + + $VERBOSE_ECHO "Running $__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" + eval "$__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" > /dev/null 2>&1 + if [ $? = 0 ] ; then + mv -f "${config_guess_temp}" ${_aux_dir}/config.guess + ret=0 + break + fi + done + + if [ ! $ret = 0 ] ; then + $ECHO "Warning: config.guess download failed from: $CONFIG_GUESS_URL" + rm -f "${config_guess_temp}" + fi +} + + +############################## +# LIBTOOLIZE_NEEDED FUNCTION # +############################## +libtoolize_needed () { + ret=1 # means no, don't need libtoolize + for feature in AC_PROG_LIBTOOL AM_PROG_LIBTOOL LT_INIT ; do + $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" + found="`grep \"^$feature.*\" $CONFIGURE`" + if [ ! "x$found" = "x" ] ; then + ret=0 # means yes, need to run libtoolize + break + fi + done + return ${ret} +} + + + +############################################ +# prepare build via autoreconf or manually # +############################################ +reconfigure_manually=no +if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then + $ECHO + $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C" + + $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS" + autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoreconf_output" + + if [ ! $ret = 0 ] ; then + if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then + if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then + $ECHO + $ECHO "Warning: autoreconf failed but due to what is usually a common libtool" + $ECHO "misconfiguration issue. This problem is encountered on systems that" + $ECHO "have installed libtoolize under a different name without providing a" + $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable." + $ECHO + $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE" + + export LIBTOOLIZE + RUN_RECURSIVE=no + export RUN_RECURSIVE + untrap_abnormal + + $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + exit $? + fi + fi + + $ECHO "Warning: $AUTORECONF failed" + + if test -f ltmain.sh ; then + $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should" + fi + + $ECHO "Attempting to run the preparation steps individually" + reconfigure_manually=yes + else + if [ "x$DOWNLOAD" = "xyes" ] ; then + if libtoolize_needed ; then + download_gnulib_config_guess + fi + fi + fi +else + reconfigure_manually=yes +fi + + +############################ +# LIBTOOL_FAILURE FUNCTION # +############################ +libtool_failure ( ) { + + # libtool is rather error-prone in comparison to the other + # autotools and this routine attempts to compensate for some + # common failures. the output after a libtoolize failure is + # parsed for an error related to AC_PROG_LIBTOOL and if found, we + # attempt to inject a project-provided libtool.m4 file. + + _autoconf_output="$1" + + if [ "x$RUN_RECURSIVE" = "xno" ] ; then + # we already tried the libtool.m4, don't try again + return 1 + fi + + if test -f "$LIBTOOL_M4" ; then + found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`" + if test ! "x$found_libtool" = "x" ; then + if test -f acinclude.m4 ; then + rm -f acinclude.m4.$$.backup + $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup" + cat acinclude.m4 > acinclude.m4.$$.backup + fi + $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4" + chmod u+w acinclude.m4 + cat "$LIBTOOL_M4" >> acinclude.m4 + + # don't keep doing this + RUN_RECURSIVE=no + export RUN_RECURSIVE + untrap_abnormal + + $ECHO + $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4" + $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + exit $? + fi + fi +} + + +########################### +# MANUAL_AUTOGEN FUNCTION # +########################### +manual_autogen ( ) { + + ################################################## + # Manual preparation steps taken are as follows: # + # aclocal [-I m4] # + # libtoolize --automake -c -f # + # aclocal [-I m4] # + # autoconf -f # + # autoheader # + # automake -a -c -f # + ################################################## + + ########### + # aclocal # + ########### + $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" + aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$aclocal_output" + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi + + ############## + # libtoolize # + ############## + if libtoolize_needed ; then + if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then + $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS" + libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$libtoolize_output" + + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi + else + if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then + $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS" + libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$libtoolize_output" + + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi + fi + fi + + ########### + # aclocal # + ########### + # re-run again as instructed by libtoolize + $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" + aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$aclocal_output" + + # libtoolize might put ltmain.sh in the wrong place + if test -f ltmain.sh ; then + if test ! -f "${_aux_dir}/ltmain.sh" ; then + $ECHO + $ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory" + $ECHO + $ECHO "Fortunately, the problem can be worked around by simply copying the" + $ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you." + $ECHO + $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\"" + cp -p ltmain.sh "${_aux_dir}/ltmain.sh" + $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C" + fi + fi # ltmain.sh + + if [ "x$DOWNLOAD" = "xyes" ] ; then + download_gnulib_config_guess + fi + fi # libtoolize_needed + + ############ + # autoconf # + ############ + $VERBOSE_ECHO + $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS" + autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoconf_output" + + if [ ! $ret = 0 ] ; then + # retry without the -f and check for usage of macros that are too new + ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE" + ac2_55_macros="AC_COMPILER_IFELSE AC_FUNC_MBRTOWC AC_HEADER_STDBOOL AC_LANG_CONFTEST AC_LANG_SOURCE AC_LANG_PROGRAM AC_LANG_CALL AC_LANG_FUNC_TRY_LINK AC_MSG_FAILURE AC_PREPROC_IFELSE" + ac2_54_macros="AC_C_BACKSLASH_A AC_CONFIG_LIBOBJ_DIR AC_GNU_SOURCE AC_PROG_EGREP AC_PROG_FGREP AC_REPLACE_FNMATCH AC_FUNC_FNMATCH_GNU AC_FUNC_REALLOC AC_TYPE_MBSTATE_T" + + macros_to_search="" + ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`" + ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`" + + if [ $ac_major -lt 2 ] ; then + macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros" + else + if [ $ac_minor -lt 54 ] ; then + macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros" + elif [ $ac_minor -lt 55 ] ; then + macros_to_search="$ac2_59_macros $ac2_55_macros" + elif [ $ac_minor -lt 59 ] ; then + macros_to_search="$ac2_59_macros" + fi + fi + + configure_ac_macros=__none__ + for feature in $macros_to_search ; do + $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" + found="`grep \"^$feature.*\" $CONFIGURE`" + if [ ! "x$found" = "x" ] ; then + if [ "x$configure_ac_macros" = "x__none__" ] ; then + configure_ac_macros="$feature" + else + configure_ac_macros="$feature $configure_ac_macros" + fi + fi + done + if [ ! "x$configure_ac_macros" = "x__none__" ] ; then + $ECHO + $ECHO "Warning: Unsupported macros were found in $CONFIGURE" + $ECHO + $ECHO "The `basename \"$CONFIGURE\"` file was scanned in order to determine if any" + $ECHO "unsupported macros are used that exceed the minimum version" + $ECHO "settings specified within this file. As such, the following macros" + $ECHO "should be removed from configure.ac or the version numbers in this" + $ECHO "file should be increased:" + $ECHO + $ECHO "$configure_ac_macros" + $ECHO + $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C" + fi + + ################### + # autoconf, retry # + ################### + $VERBOSE_ECHO + $VERBOSE_ECHO "$AUTOCONF" + autoconf_output="`$AUTOCONF 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoconf_output" + + if [ ! $ret = 0 ] ; then + # test if libtool is busted + libtool_failure "$autoconf_output" + + # let the user know what went wrong + cat <. # # This program is free software; you can redistribute it and/or modify diff -Nru lsscsi-0.28/config.guess lsscsi-0.30/config.guess --- lsscsi-0.28/config.guess 2008-03-19 19:39:31.000000000 +0000 +++ lsscsi-0.30/config.guess 2018-05-03 21:15:12.000000000 +0000 @@ -1,13 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2005-02-10' +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 -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -16,24 +15,22 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# Please send patches to . + me=`echo "$0" | sed -e 's,.*/,,'` @@ -42,7 +39,7 @@ Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -53,8 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -66,11 +62,11 @@ while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -104,16 +100,16 @@ 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 -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$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 ; + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -123,7 +119,7 @@ ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' +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) @@ -136,12 +132,40 @@ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "$UNAME_SYSTEM" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi + ;; +esac + # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -151,22 +175,33 @@ # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -176,7 +211,14 @@ fi ;; *) - os=netbsd + os=netbsd + ;; + esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -184,74 +226,62 @@ # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - amd64:OpenBSD:*:*) - echo x86_64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - cats:OpenBSD:*:*) - echo arm-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - luna88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + echo "$machine-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" + exit ;; *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" + exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" + exit ;; + *:SolidBSD:*:*) + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" + exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -261,76 +291,73 @@ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 - exit 0;; + exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-amigaos + exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-morphos + exit ;; *:OS/390:*:*) echo i370-ibm-openedition - exit 0 ;; + exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe - exit 0 ;; + exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit 0 ;; + echo powerpc-ibm-os400 + exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; + echo arm-acorn-riscix"$UNAME_RELEASE" + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp - exit 0;; + exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -338,32 +365,51 @@ else echo pyramid-pyramid-bsd fi - exit 0 ;; + exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 - exit 0 ;; + exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 - exit 0 ;; + exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; + sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux"$UNAME_RELEASE" + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + 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 # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) @@ -371,26 +417,26 @@ ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" + exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; + echo m68k-sun-sunos"$UNAME_RELEASE" + exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac - exit 0 ;; + exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; + echo sparc-auspex-sunos"$UNAME_RELEASE" + exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -400,44 +446,44 @@ # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-milan-mint"$UNAME_RELEASE" + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-hades-mint"$UNAME_RELEASE" + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-unknown-mint"$UNAME_RELEASE" + exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit 0 ;; + echo m68k-apple-machten"$UNAME_RELEASE" + exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; + echo powerpc-apple-machten"$UNAME_RELEASE" + exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 - exit 0 ;; + exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + echo mips-dec-ultrix"$UNAME_RELEASE" + exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + echo vax-dec-ultrix"$UNAME_RELEASE" + exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; + echo clipper-intergraph-clix"$UNAME_RELEASE" + exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -446,94 +492,95 @@ #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos"$UNAME_RELEASE" + exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax - exit 0 ;; + exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix - exit 0 ;; + exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 - exit 0 ;; + exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 - exit 0 ;; + exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi - exit 0 ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 - exit 0 ;; + exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 - exit 0 ;; + exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd - exit 0 ;; + exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" + exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix - exit 0 ;; + exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" + exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -544,128 +591,143 @@ exit(0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi - exit 0 ;; - *:AIX:*:[45]) + exit ;; + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" + exit ;; *:AIX:*:*) echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + exit ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 - exit 0 ;; + exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx - exit 0 ;; + exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 - exit 0 ;; + exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd - exit 0 ;; + exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 - exit 0 ;; + exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ "$HP_ARCH" = hppa2.0w ] then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + 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 + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" + exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" + exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -690,355 +752,364 @@ exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd - exit 0 ;; + exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd - exit 0 ;; + exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf - exit 0 ;; + exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf - exit 0 ;; + exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi - exit 0 ;; + exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites - exit 0 ;; + exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit 0 ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit 0 ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit 0 ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit 0 ;; + exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" + exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + echo sparc-unknown-bsdi"$UNAME_RELEASE" + exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case "$UNAME_PROCESSOR" in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; + echo "$UNAME_MACHINE"-pc-cygwin + exit ;; + *:MINGW64*:*) + echo "$UNAME_MACHINE"-pc-mingw64 + exit ;; + *:MINGW*:*) + echo "$UNAME_MACHINE"-pc-mingw32 + exit ;; + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys + exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit 0 ;; + echo "$UNAME_MACHINE"-pc-pw32 + exit ;; + *:Interix*:*) + case "$UNAME_MACHINE" in + x86) + echo i586-pc-interix"$UNAME_RELEASE" + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix"$UNAME_RELEASE" + exit ;; + IA64) + echo ia64-unknown-interix"$UNAME_RELEASE" + exit ;; + esac ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - amd64:CYGWIN*:*:*) + echo "$UNAME_MACHINE"-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; + exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" + exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit 0 ;; + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" + exit ;; i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; + echo "$UNAME_MACHINE"-pc-minix + exit ;; + aarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + eval "$set_cc_for_build" + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + else + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + hexagon:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef mips64 - #undef mips64el + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 + CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-"$LIBC" + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-"$LIBC" + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-"$LIBC" + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-"$LIBC" + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-"$LIBC" + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-"$LIBC" + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" + exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + tile*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + vax:Linux:*:*) + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" + exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; + 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" + exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 - exit 0 ;; + exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; + # Use sysv4.2uw... so that sysv4* matches it. + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" + exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; + echo "$UNAME_MACHINE"-pc-os2-emx + exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-stop + exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo "$UNAME_MACHINE"-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos"$UNAME_RELEASE" + exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + echo "$UNAME_MACHINE"-pc-msdosdjgpp + exit ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi - exit 0 ;; - i*86:*:5:[78]*) + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" + exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1048,383 +1119,333 @@ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi - exit 0 ;; + exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 - exit 0 ;; + exit ;; paragon:*:*:*) echo i860-intel-osf1 - exit 0 ;; + exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi - exit 0 ;; + exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv - exit 0 ;; + exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv - exit 0 ;; + exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix - exit 0 ;; + exit ;; M68*:*:R3V[5678]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + echo m68k-unknown-lynxos"$UNAME_RELEASE" + exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 - exit 0 ;; + exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + echo sparc-unknown-lynxos"$UNAME_RELEASE" + exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + echo rs6000-unknown-lynxos"$UNAME_RELEASE" + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos"$UNAME_RELEASE" + exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; + echo mips-dde-sysv"$UNAME_RELEASE" + exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 - exit 0 ;; + exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 - exit 0 ;; + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo "$UNAME_MACHINE"-stratus-vos + exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos - exit 0 ;; + exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; + echo m68k-apple-aux"$UNAME_RELEASE" + exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 - exit 0 ;; + exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi - exit 0 ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos - exit 0 ;; + exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos - exit 0 ;; + exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos - exit 0 ;; + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; + echo sx4-nec-superux"$UNAME_RELEASE" + exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; + echo sx5-nec-superux"$UNAME_RELEASE" + exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; + echo sx6-nec-superux"$UNAME_RELEASE" + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" + exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + echo powerpc-apple-rhapsody"$UNAME_RELEASE" + exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; + eval "$set_cc_for_build" + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" + exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" + exit ;; *:QNX:*:4*) echo i386-pc-qnx - exit 0 ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; + exit ;; + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux - exit 0 ;; + exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv - exit 0 ;; + exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" + exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-plan9 + exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 - exit 0 ;; + exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex - exit 0 ;; + exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 - exit 0 ;; + exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 - exit 0 ;; + exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 - exit 0 ;; + exit ;; *:ITS:*:*) echo pdp10-unknown-its - exit 0 ;; + exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; + echo mips-sei-seiux"$UNAME_RELEASE" + exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms && exit 0 ;; - I*) echo ia64-dec-vms && exit 0 ;; - V*) echo vax-dec-vms && exit 0 ;; + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "$UNAME_MACHINE" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix - exit 0 ;; + exit ;; + i*86:skyos:*:*) + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" + exit ;; + i*86:rdos:*:*) + echo "$UNAME_MACHINE"-pc-rdos + exit ;; + i*86:AROS:*:*) + echo "$UNAME_MACHINE"-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif +echo "$0: unable to guess system type" >&2 -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 </dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} +NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize +the system type. Please install a C compiler and try again. EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi + ;; +esac cat >&2 < in order to provide the needed -information to handle your system. +This script (version $timestamp), has failed to recognize the +operating system you are using. If your script is old, overwrite *all* +copies of config.guess and config.sub with the latest versions from: + + https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +and + https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp @@ -1443,16 +1464,16 @@ /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff -Nru lsscsi-0.28/config.h.in lsscsi-0.30/config.h.in --- lsscsi-0.28/config.h.in 2010-12-24 20:55:41.000000000 +0000 +++ lsscsi-0.30/config.h.in 2018-04-24 04:38:10.000000000 +0000 @@ -1,5 +1,47 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_BYTESWAP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_NVME_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Found NVMe */ +#undef HAVE_NVME + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* use generic little-endian/big-endian instead */ +#undef IGNORE_FAST_LEBE + +/* compile out NVMe support */ +#undef IGNORE_NVME + /* Name of package */ #undef PACKAGE @@ -21,5 +63,8 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + /* Version number of package */ #undef VERSION diff -Nru lsscsi-0.28/config.sub lsscsi-0.30/config.sub --- lsscsi-0.28/config.sub 2008-03-19 19:39:31.000000000 +0000 +++ lsscsi-0.30/config.sub 2018-05-03 21:15:12.000000000 +0000 @@ -1,42 +1,40 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2005-02-10' +timestamp='2018-02-22' -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# 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 -# the Free Software Foundation; either version 2 of the License, or +# 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - +# along with this program; if not, see . +# # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. + +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -55,12 +53,11 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -70,8 +67,7 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -83,11 +79,11 @@ while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -98,8 +94,8 @@ *local*) # First pass through any local machine types. - echo $1 - exit 0;; + echo "$1" + exit ;; * ) break ;; @@ -116,17 +112,24 @@ # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + 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/'` + 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/.*-/-/'` + basic_machine=`echo "$1" | sed 's/-[^-]*$//'` + if [ "$basic_machine" != "$1" ] + then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac @@ -145,10 +148,13 @@ -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) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -163,54 +169,65 @@ os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -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/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos @@ -227,56 +244,114 @@ # 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 | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ + | 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 \ - | fr30 | frv \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | 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 \ - | mips64vr | mips64vrel \ + | 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 \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | 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 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) + | 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 ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' @@ -287,71 +362,102 @@ ;; # Object if more than one company name word. *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | 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-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | 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-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ - | v850-* | v850e-* | vax-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | 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-unknown + basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) @@ -364,7 +470,7 @@ basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -385,7 +491,7 @@ basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl @@ -410,6 +516,13 @@ 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 @@ -418,10 +531,35 @@ 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*) + 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 @@ -450,8 +588,8 @@ basic_machine=craynv-cray os=-unicosmp ;; - cr16c) - basic_machine=cr16c-unknown + cr16 | cr16-*) + basic_machine=cr16-unknown os=-elf ;; crds | unos) @@ -489,6 +627,10 @@ basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp @@ -497,10 +639,18 @@ basic_machine=rs6000-bull os=-bosx ;; - dpx2* | dpx2*-bull) + dpx2*) basic_machine=m68k-bull os=-sysv3 ;; + 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 @@ -590,9 +740,6 @@ hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; hppaosf) basic_machine=hppa1.1-hp os=-osf @@ -604,28 +751,27 @@ i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; - i386-vsta | vsta) + vsta) basic_machine=i386-unknown os=-vsta ;; @@ -643,8 +789,16 @@ basic_machine=m68k-isi os=-sysv ;; - m88k-omron*) - basic_machine=m88k-omron + 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 @@ -654,10 +808,21 @@ basic_machine=ns32k-utek os=-sysv ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; miniframe) basic_machine=m68000-convergent ;; @@ -666,10 +831,10 @@ os=-mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k @@ -679,14 +844,29 @@ 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 + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -715,7 +895,7 @@ basic_machine=v70-nec os=-sysv ;; - next | m*-next ) + next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) @@ -751,16 +931,27 @@ np1) 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-*) basic_machine=hppa1.1-oki os=-proelf ;; - or32 | or32-*) + openrisc | openrisc-*) basic_machine=or32-unknown - os=-coff ;; os400) basic_machine=powerpc-ibm @@ -782,6 +973,14 @@ 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) basic_machine=sparc-tti ;; @@ -791,6 +990,12 @@ 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 ;; @@ -804,41 +1009,42 @@ basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm @@ -847,6 +1053,14 @@ 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 @@ -873,6 +1087,10 @@ sb1el) basic_machine=mipsisa64sb1el-unknown ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; sei) basic_machine=mips-sei os=-seiux @@ -880,14 +1098,10 @@ sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown + sh5el) + basic_machine=sh5le-unknown ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -905,6 +1119,9 @@ basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -961,17 +1178,9 @@ basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown @@ -1033,6 +1242,9 @@ basic_machine=hppa1.1-winbond os=-proelf ;; + x64) + basic_machine=x86_64-pc + ;; xbox) basic_machine=i686-pc os=-mingw32 @@ -1040,14 +1252,13 @@ xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; none) basic_machine=none-none os=-none @@ -1076,25 +1287,15 @@ vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; @@ -1114,7 +1315,7 @@ # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac @@ -1122,10 +1323,10 @@ # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1136,49 +1337,60 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases that might get confused + # with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; - -svr4*) - os=-sysv4 - ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + -es1800*) + os=-ose + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. + # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -*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* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -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* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -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* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) + | -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*) @@ -1195,12 +1407,12 @@ -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + -sim | -xray | -os68k* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc @@ -1209,26 +1421,20 @@ os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) os=-wince ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; -utek*) os=-bsd ;; @@ -1253,7 +1459,7 @@ -nova*) os=-rtmk-nova ;; - -ns2 ) + -ns2) os=-nextstep2 ;; -nsk*) @@ -1266,7 +1472,7 @@ -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1275,7 +1481,7 @@ -oss*) os=-sysv3 ;; - -svr4) + -svr4*) os=-sysv4 ;; -svr3) @@ -1290,30 +1496,38 @@ -ose*) os=-ose ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; -zvmoe) os=-zvmoe ;; + -dicos*) + os=-dicos + ;; + -pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=-eabi + ;; + *) + os=-elf + ;; + esac + ;; + -nacl*) + ;; + -ios) + ;; -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 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1330,6 +1544,12 @@ # system, and we'll never get to this point. case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; *-acorn) os=-riscix1.2 ;; @@ -1339,9 +1559,24 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 @@ -1360,13 +1595,13 @@ ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; + mep-*) + os=-elf + ;; mips*-cisco) os=-elf ;; @@ -1382,13 +1617,16 @@ sparc-* | *-sun) os=-sunos4.1.1 ;; + pru-*) + os=-elf + ;; *-be) os=-beos ;; *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) @@ -1424,7 +1662,7 @@ m88k-omron*) os=-luna ;; - *-next ) + *-next) os=-nextstep ;; *-sequent) @@ -1439,9 +1677,6 @@ i370-*) os=-mvs ;; - *-next) - os=-nextstep3 - ;; *-gould) os=-sysv ;; @@ -1493,7 +1728,7 @@ -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) @@ -1551,15 +1786,15 @@ vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os -exit 0 +echo "$basic_machine$os" +exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff -Nru lsscsi-0.28/configure lsscsi-0.30/configure --- lsscsi-0.28/configure 2014-08-25 19:03:01.000000000 +0000 +++ lsscsi-0.30/configure 2018-04-24 04:38:10.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for lsscsi 0.28. +# Generated by GNU Autoconf 2.69 for lsscsi 0.30. # # Report bugs to . # @@ -197,7 +197,8 @@ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else @@ -579,15 +580,64 @@ # Identity of this package. PACKAGE_NAME='lsscsi' PACKAGE_TARNAME='lsscsi' -PACKAGE_VERSION='0.28' -PACKAGE_STRING='lsscsi 0.28' +PACKAGE_VERSION='0.30' +PACKAGE_STRING='lsscsi 0.30' PACKAGE_BUGREPORT='dgilbert@interlog.com' PACKAGE_URL='' +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +EGREP +GREP +CPP +ac_ct_AR +AR +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE @@ -654,6 +704,7 @@ docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -679,6 +730,8 @@ enable_silent_rules enable_maintainer_mode enable_dependency_tracking +enable_nvme_supp +enable_fast_lebe ' ac_precious_vars='build_alias host_alias @@ -687,7 +740,8 @@ CFLAGS LDFLAGS LIBS -CPPFLAGS' +CPPFLAGS +CPP' # Initialize some variables set by options. @@ -726,6 +780,7 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -978,6 +1033,15 @@ | -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=* \ @@ -1115,7 +1179,7 @@ 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. @@ -1228,7 +1292,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures lsscsi 0.28 to adapt to many kinds of systems. +\`configure' configures lsscsi 0.30 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1268,6 +1332,7 @@ --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] @@ -1289,12 +1354,16 @@ --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of lsscsi 0.28:";; + short | recursive ) echo "Configuration of lsscsi 0.30:";; esac cat <<\_ACEOF @@ -1311,6 +1380,8 @@ do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build + --disable-nvme-supp remove all or most NVMe code + --disable-fast-lebe use generic little-endian/big-endian code instead Some influential environment variables: CC C compiler command @@ -1320,6 +1391,7 @@ LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1387,7 +1459,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -lsscsi configure 0.28 +lsscsi configure 0.30 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1438,11 +1510,212 @@ as_fn_set_status $ac_retval } # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------------ ## +## Report this to dgilbert@interlog.com ## +## ------------------------------------ ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by lsscsi $as_me 0.28, which was +It was created by lsscsi $as_me 0.30, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -1791,7 +2064,7 @@ -am__api_version='1.14' +am__api_version='1.15' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do @@ -1992,8 +2265,8 @@ ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in @@ -2012,7 +2285,7 @@ $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -2306,7 +2579,7 @@ # Define the identity of the package. PACKAGE='lsscsi' - VERSION='0.28' + VERSION='0.30' cat >>confdefs.h <<_ACEOF @@ -2340,8 +2613,8 @@ # mkdir_p='$(MKDIR_P)' -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' @@ -2399,6 +2672,7 @@ fi fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. @@ -3464,7 +3738,701 @@ + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + +# AM_PROG_AR is supported and needed since automake v1.12+ + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar lib "link -lib" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar lib "link -lib" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 +$as_echo_n "checking the archiver ($AR) interface... " >&6; } +if ${am_cv_ar_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + am_cv_ar_interface=ar + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int some_variable = 0; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 + (eval $am_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + am_cv_ar_interface=ar + else + am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 + (eval $am_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + am_cv_ar_interface=lib + else + am_cv_ar_interface=unknown + fi + fi + rm -f conftest.lib libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 +$as_echo "$am_cv_ar_interface" >&6; } + +case $am_cv_ar_interface in +ar) + ;; +lib) + # Microsoft lib, so override with the ar-lib wrapper script. + # FIXME: It is wrong to rewrite AR. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__AR in this case, + # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something + # similar. + AR="$am_aux_dir/ar-lib $AR" + ;; +unknown) + as_fn_error $? "could not determine $AR interface" "$LINENO" 5 + ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in linux/nvme_ioctl.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_NVME_IOCTL_H 1 +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define HAVE_NVME 1 +_ACEOF + +fi + +done + +for ac_header in byteswap.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "byteswap.h" "ac_cv_header_byteswap_h" "$ac_includes_default" +if test "x$ac_cv_header_byteswap_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_BYTESWAP_H 1 +_ACEOF + +fi + +done + + # AC_PROG_LIBTOOL + +# Check whether --enable-nvme-supp was given. +if test "${enable_nvme_supp+set}" = set; then : + enableval=$enable_nvme_supp; +cat >>confdefs.h <<_ACEOF +#define IGNORE_NVME 1 +_ACEOF + +fi + + +# Check whether --enable-fast-lebe was given. +if test "${enable_fast_lebe+set}" = set; then : + enableval=$enable_fast_lebe; +cat >>confdefs.h <<_ACEOF +#define IGNORE_FAST_LEBE 1 +_ACEOF + +fi + + ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile" cat >confcache <<\_ACEOF @@ -4000,7 +4968,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by lsscsi $as_me 0.28, which was +This file was extended by lsscsi $as_me 0.30, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4066,7 +5034,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -lsscsi config.status 0.28 +lsscsi config.status 0.30 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru lsscsi-0.28/configure.ac lsscsi-0.30/configure.ac --- lsscsi-0.28/configure.ac 2013-05-14 19:04:38.000000000 +0000 +++ lsscsi-0.30/configure.ac 2018-04-24 04:38:10.000000000 +0000 @@ -1,10 +1,28 @@ -AC_INIT(lsscsi, 0.28, dgilbert@interlog.com) +AC_INIT(lsscsi, 0.30, dgilbert@interlog.com) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_INSTALL + +AC_CANONICAL_HOST + +# AM_PROG_AR is supported and needed since automake v1.12+ +ifdef([AM_PROG_AR], [AM_PROG_AR], []) + +AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])], [], []) +AC_CHECK_HEADERS([byteswap.h], [], [], []) + # AC_PROG_LIBTOOL + +AC_ARG_ENABLE([nvme-supp], + AC_HELP_STRING([--disable-nvme-supp], [remove all or most NVMe code]), + [AC_DEFINE_UNQUOTED(IGNORE_NVME, 1, [compile out NVMe support], )], []) + +AC_ARG_ENABLE([fast-lebe], + AC_HELP_STRING([--disable-fast-lebe], [use generic little-endian/big-endian code instead]), + [AC_DEFINE_UNQUOTED(IGNORE_FAST_LEBE, 1, [use generic little-endian/big-endian instead], )], []) + AC_OUTPUT(Makefile src/Makefile doc/Makefile) diff -Nru lsscsi-0.28/debian/changelog lsscsi-0.30/debian/changelog --- lsscsi-0.28/debian/changelog 2017-12-05 07:22:04.000000000 +0000 +++ lsscsi-0.30/debian/changelog 2018-12-11 13:35:16.000000000 +0000 @@ -1,3 +1,12 @@ +lsscsi (0.30-0.1) unstable; urgency=medium + + * Non-maintainer upload. + * New upstream version 0.30, fixing FTBFS (Closes: #915429) + * Rebase patches; drop 128-bit wwn truncation fix that has been + integrated upstream + + -- Hilko Bengen Tue, 11 Dec 2018 14:35:16 +0100 + lsscsi (0.28-0.1) unstable; urgency=medium * Non-maintainer upload. diff -Nru lsscsi-0.28/debian/patches/FTBFS_kfreebsd.diff lsscsi-0.30/debian/patches/FTBFS_kfreebsd.diff --- lsscsi-0.28/debian/patches/FTBFS_kfreebsd.diff 2014-09-10 03:40:25.000000000 +0000 +++ lsscsi-0.30/debian/patches/FTBFS_kfreebsd.diff 2018-12-11 13:28:20.000000000 +0000 @@ -12,16 +12,18 @@ http://bugs.debian.org/559405 Forwarded: no +--- + src/lsscsi.c | 4 ++++ + 1 file changed, 4 insertions(+) -Index: lsscsi-0.27/src/lsscsi.c -=================================================================== ---- lsscsi-0.27.orig/src/lsscsi.c -+++ lsscsi-0.27/src/lsscsi.c -@@ -25,8 +25,11 @@ - #include - #include - #include --#include +diff --git a/src/lsscsi.c b/src/lsscsi.c +index 8d7bba2..d782d02 100644 +--- a/src/lsscsi.c ++++ b/src/lsscsi.c +@@ -33,7 +33,11 @@ + #include + #endif + #include +#ifdef linux #include +#else diff -Nru lsscsi-0.28/debian/patches/lsscsi-Fix-truncation-of-128-bit-wwn.patch lsscsi-0.30/debian/patches/lsscsi-Fix-truncation-of-128-bit-wwn.patch --- lsscsi-0.28/debian/patches/lsscsi-Fix-truncation-of-128-bit-wwn.patch 2017-12-05 07:22:04.000000000 +0000 +++ lsscsi-0.30/debian/patches/lsscsi-Fix-truncation-of-128-bit-wwn.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -Description: lsscsi: Fix truncation of 128-bit wwn - -From a20b8e3a393d6174171834be75b7f8314a027adb Mon Sep 17 00:00:00 2001 -From: Vaibhav Jain -Date: Thu, 20 Oct 2016 17:19:44 +0530 -Subject: [PATCH] lsscsi: Fix truncation of 128-bit wwn - -Currently with '--wwn' flag, 128-bit wwns gets truncated and their -last 3 hex-digits missing. Below is a comparison of wwn reported by -lsscsi compared to wwn info at /dev/disk/by-id directory. - -% lsscsi -w 0:0:5:0 -[0:0:5:0] disk 0x60050764008181941000000000000 /dev/sdad - -% ls -l /dev/disk/by-id/wwn-* -lrwxrwxrwx. 1 root root 10 Oct 19 01:08 /dev/disk/by-id/wwn-0x600507640081819410000000000001b1 -> ../../sdad - -To fix this, the patch increases the size of member wwn of struct -disk_wwn_node_entry to 35 chars to accommodate the extra '0x' prefix and -null terminator. Also the size of the buffer wwn_str thats used to -output wwn to the std-out is increased to match the corresponding -member of disk_wwn_node_entry. - -Link: https://bugs.launchpad.net/ubuntu/+source/lsscsi/+bug/1636467 -Link: https://bugzilla.redhat.com/show_bug.cgi?id=1387263 - -Cc: Jon Grimm -Cc: Vipin K Parashar -Reported-by: Ping Tian Han -Signed-off-by: Vaibhav Jain ---- - src/lsscsi.c | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -Forwarded: yes, https://github.com/hreinecke/lsscsi/pull/1 -Origin: https://github.com/hreinecke/lsscsi/pull/1/commits/a20b8e3a393d6174171834be75b7f8314a027adb -Bug: https://github.com/hreinecke/lsscsi/issues/2 -Bug-Debian: 867868 -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1636467 -Last-Update: 2017-07-10 ---- a/src/lsscsi.c -+++ b/src/lsscsi.c -@@ -200,8 +200,17 @@ - }; - static struct dev_node_list* dev_node_listhead = NULL; - -+/* WWN here is extracted from /dev/disk/by-id/wwn- which is -+ * created by udev 60-persistent-storage.rules using ID_WWN_WITH_EXTENSION. -+ * The udev ID_WWN_WITH_EXTENSION is the combination of char wwn[17] and -+ * char wwn_vendor_extension[17] from struct scsi_id_device. This macro -+ * defines the maximum length of char-array needed to store this wwn including -+ * the null-terminator. -+ */ -+#define DISK_WWN_MAX_LEN 35 -+ - struct disk_wwn_node_entry { -- char wwn[32]; -+ char wwn[DISK_WWN_MAX_LEN]; /* '0x' + wwn<128-bit> + */ - char disk_bname[12]; - }; - -@@ -2565,14 +2574,15 @@ - } - if (wd[0]) { - char dev_node[LMAX_NAME] = ""; -- char wwn_str[34]; -+ char wwn_str[DISK_WWN_MAX_LEN]; - enum dev_type typ; - - typ = (FT_BLOCK == non_sg.ft) ? BLK_DEV : CHR_DEV; - if (get_wwn) { - if ((BLK_DEV == typ) && - get_disk_wwn(wd, wwn_str, sizeof(wwn_str))) -- printf("%-30s ", wwn_str); -+ printf("%-*s ", DISK_WWN_MAX_LEN - 1, -+ wwn_str); - else - printf(" " - " "); diff -Nru lsscsi-0.28/debian/patches/series lsscsi-0.30/debian/patches/series --- lsscsi-0.28/debian/patches/series 2017-12-05 07:22:04.000000000 +0000 +++ lsscsi-0.30/debian/patches/series 2018-12-11 13:27:49.000000000 +0000 @@ -1,2 +1 @@ FTBFS_kfreebsd.diff -lsscsi-Fix-truncation-of-128-bit-wwn.patch diff -Nru lsscsi-0.28/depcomp lsscsi-0.30/depcomp --- lsscsi-0.28/depcomp 2008-03-19 19:39:31.000000000 +0000 +++ lsscsi-0.30/depcomp 2018-05-03 21:15:12.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2005-02-09.22 +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,9 +16,7 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -29,9 +27,9 @@ case $1 in '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] @@ -41,11 +39,11 @@ Environment variables: depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. + tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . @@ -58,6 +56,66 @@ ;; esac +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 @@ -70,6 +128,9 @@ rm -f "$tmpdepfile" +# Avoid interferences from the environment. +gccflag= dashmflag= + # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case @@ -81,9 +142,32 @@ fi if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc fi case "$depmode" in @@ -91,10 +175,22 @@ ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" stat=$? - if test $stat -eq 0; then : - else + if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi @@ -102,13 +198,17 @@ ;; gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then @@ -116,31 +216,31 @@ fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? - if test $stat -eq 0; then : - else + if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. + # The second -e expression handles DOS-style file names with drive + # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. +## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory +## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as -## well. +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -158,8 +258,7 @@ "$@" -MDupdate "$tmpdepfile" fi stat=$? - if test $stat -eq 0; then : - else + if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi @@ -167,99 +266,156 @@ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" - # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the + # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" + make_dummy_depfile fi rm -f "$tmpdepfile" ;; +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the + # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. - stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" + set_dir_from "$object" + set_base_from "$object" if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u "$@" -M fi stat=$? - - if test -f "$tmpdepfile"; then : - else - stripped=`echo "$stripped" | sed 's,^.*/,,'` - tmpdepfile="$stripped.u" + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat fi - if test $stat -eq 0; then : - else + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi - - if test -f "$tmpdepfile"; then - outname="$stripped.o" - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : + # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else + if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi @@ -271,68 +427,141 @@ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mecanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; #nosideeffect) # This comment above is used by automake to tell side-effect @@ -345,13 +574,13 @@ # Remove the call to Libtool. if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do + while test "X$1" != 'X--mode=compile'; do shift done shift fi - # Remove `-o $object'. + # Remove '-o $object'. IFS=" " for arg do @@ -371,18 +600,18 @@ done test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' + # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -396,41 +625,51 @@ "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do + while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift - cleared=no - for arg in "$@"; do + cleared=no eat=no + for arg + do case $cleared in no) set ""; shift cleared=yes ;; esac + if test $eat = yes; then + eat=no + continue + fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done - obj_suffix="`echo $object | sed 's/^.*\././'`" + obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; @@ -441,13 +680,13 @@ # Remove the call to Libtool. if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do + while test "X$1" != 'X--mode=compile'; do shift done shift fi - # Remove `-o $object'. + # Remove '-o $object'. IFS=" " for arg do @@ -466,9 +705,10 @@ esac done - "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" @@ -478,35 +718,56 @@ msvisualcpp) # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. + # always write the preprocessed file to stdout. "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + IFS=" " for arg do case "$arg" in + -o) + shift + ;; + $object) + shift + ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; + set fnord "$@" + shift + shift + ;; *) - set fnord "$@" "$arg" - shift - shift - ;; + set fnord "$@" "$arg" + shift + shift + ;; esac done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + none) exec "$@" ;; @@ -525,5 +786,6 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" # End: diff -Nru lsscsi-0.28/doc/lsscsi.8 lsscsi-0.30/doc/lsscsi.8 --- lsscsi-0.28/doc/lsscsi.8 2014-09-24 02:53:25.000000000 +0000 +++ lsscsi-0.30/doc/lsscsi.8 2018-06-13 01:49:03.000000000 +0000 @@ -1,33 +1,61 @@ -.TH lsscsi "8" "September 2014" "lsscsi\-0.28" LSSCSI +.TH lsscsi "8" "June 2018" "lsscsi\-0.30" LSSCSI .SH NAME -lsscsi \- list SCSI devices (or hosts) and their attributes +lsscsi \- list SCSI devices (or hosts), list NVMe devices .SH SYNOPSIS .B lsscsi -[\fI\-\-classic\fR] [\fI\-\-device\fR] [\fI\-\-generic\fR] [\fI\-\-help\fR] -[\fI\-\-hosts\fR] [\fI\-\-kname\fR] [\fI\-\-list\fR] [\fI\-\-lunhex\fR] -[\fI\-\-long\fR] [\fI\-\-protection\fR] [\fI\-\-protmode\fR] -[\fI\-\-scsi_id\fR] [\fI\-\-size\fR] [\fI\-\-sysfsroot=PATH\fR] -[\fI\-\-transport\fR] [\fI\-\-unit\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] -[\fI\-\-wwn\fR] [\fIH:C:T:L\fR] +[\fI\-\-brief\fR] [\fI\-\-classic\fR] [\fI\-\-controllers\fR] +[\fI\-\-device\fR] [\fI\-\-generic\fR] [\fI\-\-help\fR] [\fI\-\-hosts\fR] +[\fI\-\-kname\fR] [\fI\-\-list\fR] [\fI\-\-long\fR] [\fI\-\-long\-unit\fR] +[\fI\-\-lunhex\fR] [\fI\-\-no\-nvme\fR] [\fI\-\-pdt\fR] [\fI\-\-protection\fR] +[\fI\-\-protmode\fR] [\fI\-\-scsi_id\fR] [\fI\-\-size\fR] +[\fI\-\-sysfsroot=PATH\fR] [\fI\-\-sz\-lbs] [\fI\-\-transport\fR] +[\fI\-\-unit\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] [\fI\-\-wwn\fR] +[\fIH:C:T:L\fR] .SH DESCRIPTION .\" Add any additional description here .PP Uses information in sysfs (Linux kernel series 2.6 and later) to list SCSI -devices (or hosts) currently attached to the system. Options can be used to -control the amount and form of information provided for each device. -.PP -If a \fIH:C:T:L\fR argument is given then it acts as a filter and only -devices that match it are listed. The colons don't have to be present, -and '\-', '*', '?' or missing arguments at the end are interpreted as -wildcards. The default is '*:*:*:*' which means to match devices (i.e. -Logical Units). Any filter string using '*' of '?' should be surrounded by -single or double quotes to stop shell expansions. If '\-' is used as a -wildcard then the whole filter argument should be prefixed by '\-\- ' to -tell this utility there are no more options on the command line to be -interpreted. A leading '[' and trailing ']' are permitted (e.g. '[1:0:0]' -matches all LUNs on 1:0:0). May also be used to filter \fI\-\-hosts\fR -in which case only the \fIH\fR is active and may be either a number -or in the form "host" where is a host number. +devices (or hosts) currently attached to the system. Many non\-SCSI storage +devices (but not all) used the SCSI subsystem in Linux. In lsscsi version +0.30 support was added to list NVMe devices. +.PP +In single line per device (LU or NVMe namespace) mode, the default, each +line starts with a 4 element tuple surrounded by square brackets. For SCSI +devices the first element 'H' is the host number, the second element 'C' is +the controller number, the third element 'T' is the target number and the +final element is the Logical Unit Number (LUN). All four are integers. +For NVMe namespaces see two paragraphs down. When the \fI\-\-hosts\fR option +is given for SCSI devices the tuple is reduced to one element: the host +number. +.PP +If a \fIH:C:T:L\fR tuple is given as an argument on the command line then +it acts as a filter and only devices that match it are listed. The colons +don't have to be present, and '\-', '*', '?' or missing components at the +end are interpreted as wildcards. The default is '*:*:*:*' which means to +match devices (i.e. Logical Units). Any filter string using '*' of '?' +should be surrounded by single or double quotes to stop shell expansions. +If '\-' is used as a wildcard then the whole filter tuple should be prefixed +by '\-\- ' to tell this utility there are no more options on the command +line to be interpreted. A leading '[' and trailing ']' are permitted ( +e.g. '[1:0:0]' matches all LUNs on 1:0:0). May also be used to filter +\fI\-\-hosts\fR in which case only the \fIH\fR is active and may be either +a number or in the form "host" where is a host number. +.PP +For NVMe devices and controllers almost all of the previous paragraph +applies. The main difference is that "N" appears in the 'H' (first) position. +The 'C' position for NVMe is the controller's Linux generated "char" device +minor number which is the first number that appears in a typical NVMe +controller name, for example: "/dev/nvme2". The 'T' position for NVMe is +the "CNTLID" value. The final 'L' position is the NVMe namespace identifier +which is typically a sequential value starting at 1. The leading explicit "N" +for NVMe devices is converted internally into a large value (32,767) that +should not interfere with any Linux generated SCSI host number; it also means +that the numeric sort used to show hosts (controllers) and devices (LUs or +logical units) will always place NVMe devices and controllers after those +that use the SCSI subsystem. To filter using a \fIH:C:T:L\fR argument for +NVMe controllers, "hostN", "hostN:", "N" or "N:" may be used; when +no "" is given, only NVMe controllers will be listed (i.e. it lists no +SCSI hosts (HBAs)). .PP By default in this utility device node names (e.g. "/dev/sda" or "/dev/root_disk") are obtained by noting the major and minor numbers for @@ -42,13 +70,31 @@ An example of where this may be useful is kernel error logs which tend to report disk error messages using the disk's default kernel name. .SH OPTIONS -Arguments to long options are mandatory for short options as well. -The options are arranged in alphabetical order based on the long -option name. +Arguments to long options are mandatory for short options as well. The options +are arranged in alphabetical order based on the long option name. Hyphenated +long options can also take underscore, and vice versa (e.g. \fI\-\-scsi_id\fR +or \fI\-\-scsi\-id\fR are acceptable). +.TP +\fB\-b\fR, \fB\-\-brief\fR +reduces one line per device output to the tuple and the primary device name. +This may simplify scripts that process the output of this utility. With the +\fI\-\-generic\fR option it will show on each line the tuple (from which +the bsg pass\-through device name can be deduced), the primary device +name (which the block subsystem uses) and the sg device name (also a +pass\-through). +.br +When the \fI\-\-pdt\fR option is used together with this option the SCSI +Peripheral Device Type (PDT) is displayed in hex (with a leading "0x") +between the tuple and the primary device name. For NVMe namespaces "0x0" +is displayed (for a disk or direct access device). .TP \fB\-c\fR, \fB\-\-classic\fR The output is similar to that obtained from 'cat /proc/scsi/scsi' .TP +\fB\-C\fR, \fB\-\-controllers\fR +Lists NVMe controllers and SCSI hosts. This is a synonym for the +\fI\-\-hosts\fR option. +.TP \fB\-d\fR, \fB\-\-device\fR After outputting the (probable) SCSI device name the device node major and minor numbers are shown in brackets (e.g. "/dev/sda[8:0]"). @@ -56,13 +102,24 @@ \fB\-g\fR, \fB\-\-generic\fR Output the SCSI generic device file name. Note that if the sg driver is a module it may need to be loaded otherwise '\-' may appear. +.br +NVMe does not have generic (char) devices in the same sense as SCSI. +Instead NVMe Admin, NVM (i.e. block type commands such as Read and +Write) and MI (Management Interface (e.g. to an enclosure)) commands +are all sent to the containing controller whose device name is shown +when the \fI\-\-hosts\fR option is used. +.br +To unclutter the single line per device mode the \fI\-\-brief\fR option +combined with this option should help. .TP \fB\-h\fR, \fB\-\-help\fR Output the usage message and exit. .TP \fB\-H\fR, \fB\-\-hosts\fR -List the SCSI hosts currently attached to the system. If this option is -not given then SCSI devices are listed. +List the SCSI hosts and NVMe controllers currently attached to +the system. If this option is not given (and the \fI\-\-controllers\fR +option is not given) then SCSI devices (logical units (LUs)) followed by +NVMe devices (namespaces) are listed. .TP \fB\-k\fR, \fB\-\-kname\fR Use Linux default algorithm for naming devices (e.g. block major 8, @@ -80,6 +137,22 @@ outputs SCSI device (host) attributes one per line; preceded by two spaces; in the form "=". .TP +\fB\-U\fR, \fB\-\-long\-unit\fR +Output logical unit name in full, if available. It replaces the normal +vendor, product and revision strings given in the single logical unit per +line mode. If no logical unit name is found "none" is printed. If the +logical unit name is long (e.g. a UUID) then following fields are pushed +further to the right as required. This option is functionally equivalent to +the '\-uuu' option. +.br +If the option is used twice (e.g. '\-UU') then EUI, NAA, UUID and T10 vendor +ID formats are prefixed by "eui.", "naa.", "uuid." and "t10." respectively. +Note that SCSI name format used by iSCSI should already be prefixed +by 'iqn.'. Using the '\-\-unit' option 4 or more times (e.g. '\-uuuu') will +have the same action as '\-UU'. +.br +\fI\-\-long_unit\fR is also an acceptable form when invoking this option. +.TP \fB\-x\fR, \fB\-\-lunhex\fR when this option is used once the LUN in the tuple (at the start of each device line) is shown in "T10" format which is up to 16 hexadecimal @@ -89,6 +162,28 @@ two level LUN: 0x0355006600000000 will appear as 0x0355_0066. If this option is given twice (e.g. using the short form: '\-xx') then the full 16 hexadecimal digits are shown for each LUN, prefixed by "0x". +.br +For NVMe, the namespace identifier (nsid) is shown in the "L" position. The +nsid is a 32 bit unsigned quantities with 0x0 and 0xffffffff reserved. +Without this option, the nsid is shown in decimal. When this option is used +once the nsid is output in hex with a lead 0x and with up to 3 leading zeros. +When this option is used twice the nsid is output in hex with up to 7 leading +zeros. +.TP +\fB\-N\fR, \fB\-\-no\-nvme\fR +this option excludes NVMe devices and controllers for the output. This option +may be needed to stop NVMe device output interfering with specific format +output like that produced when the \fI\-\-classic\fR option is used. +.br +To only show NVMe devices, use 'lsscsi N', to only show NVMe controllers, +use 'lsscsi \-H N'. +.TP +\fB\-D\fR, \fB\-\-pdt\fR +this option displays the SCSI Peripheral Device Type (PDT) in hex preceded +by "0x". For NVME namespaces "0x0' is displayed which corresponds to a +disk ("Direct Access Device" or SSD). In single line output this hex PDT +replaces the device type abbreviation (e.g. "0x0 " replaces "disk ") +and appears after the tuple. .TP \fB\-p\fR, \fB\-\-protection\fR Output target (DIF) and initiator (DIX) protection types. @@ -105,10 +200,43 @@ name (e.g. /dev/sdc) and if there is no match "\-" is output. .TP \fB\-s\fR, \fB\-\-size\fR -Print disk capacity in human readable form. +Print disk capacity in human readable form. When given once, normal base +10 SI units are used as a prefix for 'B' which is bytes (aka octets). +For example MB, GB and TB stand for 10^6, 10^9 and 10^12 bytes +respectively. When given twice, IEC 80000\-3 prefixes for 'B' are used; +for example MiB, GiB and TiB stand for 2^20, 2^30 and 2^40 +bytes respectively. The output is rounded to 3 or less significant +figures in order to fit on a single line. +.br +If given three times (short form is the more convenient: '\-sss') then +the disk capacity as a logical block count is given. This is an exact +figure in decimal reported by the storage device at discovery. Discovery +is typically just after boot time, or when it was last attached if the +storage device is removable. +.br +To unclutter the single line per device mode the \fI\-\-brief\fR option +combined with this option should help. +.TP +\fB\-y\fR, \fB\-\-sysfsroot\fR=\fIPATH\fR +assumes sysfs is mounted at PATH instead of the default '/sys' . If this +option is given PATH should be an absolute path (i.e. start with '/'). +.TP +\fB\-S\fR, \fB\-\-sz\-lbs\fR +Print disk capacity as a number of logical blocks (which is the same +as '\-sss'). When used twice a comma is added followed by the logical +block size in bytes. It should be a number like 512 or 4096. +.br +If the logical block size cannot be found (e.g. because the version of +Linux predates the /sys/block//queue directory) then the number +of 512 byte blocks followed comma and then '512' is output irrespective of +what the true logical block size of the device is. This special case +action occurs whether this option is given one or more times. +.br +To unclutter the single line per device mode the \fI\-\-brief\fR option +combined with this option should help. .TP \fB\-t\fR, \fB\-\-transport\fR -Output transport information. This will be a target related information or, +Output transport information. This will be target related information or, if \fI\-\-hosts\fR is given, initiator related information. When used without \fI\-\-list\fR, a name or identifier (or both) are output on a single line, usually prefixed by the type of transport. For devices this information @@ -121,15 +249,17 @@ Output logical unit name, if available. If this option is given once or twice, then the 30 character field where the vendor, product and revision strings are usually placed is expanded to 32 characters and replaced by the -logical unit name. The first found of the NAA, EUI-64 or SCSI name string -is output unless a SCSI name string is found and the associated target -port indicates the iSCSI protocol, in which case the SCSI name string is -preferred. +logical unit name. If no logical unit name is found "none" is printed. +The first found of the NAA, EUI\-64 or SCSI name string is output unless a +SCSI name string is found and the associated target port indicates the +iSCSI protocol, in which case the SCSI name string is preferred. Finally +if there is no match on the above and a T10 Vendor ID descriptor is found +then it is used. .br If the name cannot fit in the 32 character field then it is truncated to the right and a trailing '_' character is used to alert the reader to the truncation. The 32 character width is chosen since that is large enough to -hold 16 byte NAA or EUI-64 identifiers. However SCSI name strings as used +hold 16 byte NAA or EUI\-64 identifiers. However SCSI name strings as used by iSCSI can be larger than that. .br If this option is used twice then this field is also 32 character wide. If @@ -137,7 +267,7 @@ a leading '_' character is used to alert the reader to the truncation. .br If this option is used three times the whole logical unit name is -output, and any remaining output on that line is skipped. +output, followed by several spaces. .br In order for this option to work, it needs a Linux kernel from and including 3.15 . It accesses the sysfs vpd_pg83 file for the device in question. Old @@ -149,22 +279,22 @@ more output. .TP \fB\-V\fR, \fB\-\-version\fR -outputs version information then exits. +outputs version information then exits. If used once outputs to stderr; if +used twice outputs to stdout and shortens the date to yyyymmdd numeric +format. .TP \fB\-w\fR, \fB\-\-wwn\fR outputs the WWN for disks instead of manufacturer, model and revision (or instead of transport information). The World Wide Name (WWN) is typically 64 bits long (16 hex digits) but could be up to 128 bits long. To indicate -the WWN is hexadecimal, it is prefixed by "0x". -.TP -\fB\-y\fR, \fB\-\-sysfsroot\fR=\fIPATH\fR -assumes sysfs is mounted at PATH instead of the default '/sys' . If this -option is given PATH should be an absolute path (i.e. start with '/'). +the WWN is hexadecimal, it is prefixed by "0x". The ATA/SATA WWN is +referred to as LU name in SCSI jargon; hence this option is more or less +superseded by the \fI\-\-unit\fR and \fI\-\-long\-unit\fR options. .SH TRANSPORTS This utility lists SCSI devices which are known as logical units (LU) in -the SCSI Architecture Model (ref: SAM\-4 at http://www.t10.org) or hosts +the SCSI Architecture Model (ref: SAM\-5 at http://www.t10.org) or hosts when the \fI\-\-hosts\fR option is given. A host is called an initiator in -SAM\-4. A SCSI command travels out via an initiator, across some transport +SAM\-5. A SCSI command travels out via an initiator, across some transport to a target and then onwards to a logical unit. A target device may contain several logical units. A target device has one or more ports that can be viewed as transport end points. Each FC and SAS disk is a single target @@ -240,6 +370,26 @@ given, in the absence of the \fI\-\-hosts\fR option. When the \fI\-\-hosts\fR option is given then only "spi:" is output on the summary line. .PP +For the PCIe transport (a.k.a. PCI Express) there at two possible storage +types: NVMe and SOP/PQI (SCSI over PCIe). There are very few examples of the +latter currently so this utility concentrates on NVMe. NVMe uses its own +command set and not SCSI but has many things in common. Rather than +re\-invent everything currently in use that SCSI has accumulated over nearly +40 years, NVMe is beginning to use some parts of SCSI. A recent example is +the SES\-3 standard for enclosure management which has been adopted by NVMe. +In SCSI a SES device is a logical unit with a peripheral device type (PDT) +of 0xd (for enclosure) so it will appear when the lsscsi utility is invoked +without any options. In NVMe is seems that an enclosure with appear as +attached to the management interface (MI) of a NVMe controller. This means +it should appear when "lsscsi \-\-hosts" is invoked. It is unclear whether +such a NVMe controller can have any storage namespaces associated with +it. The sg_ses utility (in the sg3_utils package) can then be given that NVMe +controller's device name (e.g. /dev/nmve1). +.br +When the \fI\-\-transport\fR option is given, after "pcie" the NVMe +controller's subsystem vendor id and device id are output, separated by a +colon (e.g. "pcie 0x8086:0x390a"). +.PP For the SCSI RDMA Protocol (SRP) the IB (InfiniBand) port's GUID is given. As an example, it has a form like this: 0002:c903:00fa:abcd . .PP @@ -324,10 +474,11 @@ .SH "REPORTING BUGS" Report bugs to . .SH COPYRIGHT -Copyright \(co 2003\-2014 Douglas Gilbert +Copyright \(co 2003\-2018 Douglas Gilbert .br This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH "SEE ALSO" .B lspci .B lsusb +.B lsblk diff -Nru lsscsi-0.28/doc/Makefile.in lsscsi-0.30/doc/Makefile.in --- lsscsi-0.28/doc/Makefile.in 2014-08-25 19:03:01.000000000 +0000 +++ lsscsi-0.30/doc/Makefile.in 2018-05-03 21:15:12.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -75,12 +85,14 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ subdir = doc -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = @@ -136,10 +148,12 @@ NROFF = nroff MANS = $(man_MANS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -147,6 +161,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ @@ -154,7 +169,9 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EGREP = @EGREP@ EXEEXT = @EXEEXT@ +GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -184,6 +201,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -191,14 +209,22 @@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ +build = @build@ build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +host = @host@ host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ @@ -214,6 +240,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -235,10 +262,9 @@ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu doc/Makefile -.PRECIOUS: Makefile + $(AUTOMAKE) --foreign doc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -455,6 +481,8 @@ pdf-am ps ps-am tags-am uninstall uninstall-am uninstall-man \ uninstall-man8 +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru lsscsi-0.28/install-sh lsscsi-0.30/install-sh --- lsscsi-0.28/install-sh 2008-03-19 19:39:31.000000000 +0000 +++ lsscsi-0.30/install-sh 2016-04-24 17:56:56.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2005-02-02.21 +scriptversion=2014-09-12.12; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,42 +35,57 @@ # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. +# from scratch. -# set DOITPROG to echo to test this script +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" +posix_mkdir= -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" +# Desired mode of installed file. +mode=0755 -chmodcmd="$chmodprog 0755" -chowncmd= chgrpcmd= -stripcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog rmcmd="$rmprog -f" -mvcmd="$mvprog" +stripcmd= + src= dst= dir_arg= -dstarg= -no_target_directory= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly -usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... @@ -80,108 +95,168 @@ In the 4th, create DIRECTORIES. Options: --c (ignored) --d create directories instead of installing files. --g GROUP $chgrpprog installed files to GROUP. --m MODE $chmodprog installed files to MODE. --o USER $chownprog installed files to USER. --s $stripprog installed files. --t DIRECTORY install into DIRECTORY. --T report an error if DSTFILE is a directory. ---help display this help and exit. ---version display version info and exit. + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG " -while test -n "$1"; do +while test $# -ne 0; do case $1 in - -c) shift - continue;; + -c) ;; - -d) dir_arg=true - shift - continue;; + -C) copy_on_change=true;; + + -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; + shift;; --help) echo "$usage"; exit $?;; - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -s) stripcmd=$stripprog - shift - continue;; - - -t) dstarg=$2 - shift - shift - continue;; - - -T) no_target_directory=true - shift - continue;; + shift;; + + -s) stripcmd=$stripprog;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - *) # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - test -n "$dir_arg$dstarg" && break - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dstarg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dstarg" - shift # fnord - fi - shift # arg - dstarg=$arg - done - break;; + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; esac + shift done -if test -z "$1"; then +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call `install-sh -d' without argument. + # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + for src do - # Protect names starting with `-'. + # Protect names problematic for 'test' and other utilities. case $src in - -*) src=./$src ;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src - src= - - if test -d "$dst"; then - mkdircmd=: - chmodcmd= - else - mkdircmd=$mkdirprog - fi + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. @@ -190,71 +265,173 @@ exit 1 fi - if test -z "$dstarg"; then + if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi - - dst=$dstarg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst ;; - esac + dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dstarg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi - dst=$dst/`basename "$src"` + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? fi fi - # This sed command emulates the dirname command. - dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` - - # Make sure that the destination directory exists. + obsolete_mkdir_used=false - # Skip lots of stat calls in the usual case. - if test ! -d "$dstdir"; then - defaultIFS=' - ' - IFS="${IFS-$defaultIFS}" - - oIFS=$IFS - # Some sh's can't handle IFS=/ for some reason. - IFS='%' - set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` - shift - IFS=$oIFS + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + # $RANDOM is not portable (e.g. dash); use it when possible to + # lower collision chance + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # As "mkdir -p" follows symlinks and we work in /tmp possibly; so + # create the $tmpdir first (and fail if unsuccessful) to make sure + # that nobody tries to guess the $tmpdir name. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac;; + esac - pathcomp= + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else - while test $# -ne 0 ; do - pathcomp=$pathcomp$1 + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir shift - if test ! -d "$pathcomp"; then - $mkdirprog "$pathcomp" - # mkdir can fail with a `File exist' error in case several - # install-sh are creating the directory concurrently. This - # is OK. - test -d "$pathcomp" || exit + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi - pathcomp=$pathcomp/ - done + fi fi if test -n "$dir_arg"; then - $doit $mkdircmd "$dst" \ - && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } - + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else - dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ @@ -262,10 +439,9 @@ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. - $doit $cpprog "$src" "$dsttmp" && + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -273,51 +449,60 @@ # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && - - # Now rename the file to the real destination. - { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ - || { - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - if test -f "$dstdir/$dstfile"; then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ - || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ - || { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 - (exit 1); exit 1 - } - else - : - fi - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" - } - } - fi || { (exit 1); exit 1; } -done + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || -# The final little trick to "correctly" pass the exit status to the exit trap. -{ - (exit 0); exit 0 -} + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" # End: diff -Nru lsscsi-0.28/lsscsi.spec lsscsi-0.30/lsscsi.spec --- lsscsi-0.28/lsscsi.spec 2014-09-24 02:53:25.000000000 +0000 +++ lsscsi-0.30/lsscsi.spec 2018-06-13 01:49:03.000000000 +0000 @@ -1,8 +1,8 @@ %define name lsscsi -%define version 0.28 +%define version 0.30 %define release 1 -Summary: List SCSI devices (or hosts) and associated information +Summary: List SCSI devices (or hosts) plus NVMe namespaces and ctls Name: %{name} Version: %{version} Release: %{release} @@ -16,10 +16,11 @@ %description Uses information provided by the sysfs pseudo file system in the Linux kernel 2.6 series, and later, to list SCSI devices (Logical -Units (e.g. disks)). It can list transport identifiers (e.g. SAS address -of a SAS disk), protection information configuration and size for storage -devices. Alternatively it can be used to list SCSI hosts (e.g. HBAs). By -default one line of information is output per device (or host). +Units (e.g. disks)) plus NVMe namespaces (SSDs). It can list transport +identifiers (e.g. SAS address of a SAS disk), protection information +configuration and size for storage devices. Alternatively it can be used +to list SCSI hosts (e.g. HBAs) or NVMe controllers. By default one line +of information is output per device (or host). Author: -------- @@ -53,6 +54,12 @@ %changelog +* Tue Jun 12 2018 - dgilbert at interlog dot com +- add NVMe support, minor tweaks + * lsscsi-0.30 +* Fri May 13 2016 - dgilbert at interlog dot com +- minor tweaks + * lsscsi-0.29 * Tue Sep 23 2014 - dgilbert at interlog dot com - add --unit to find LU names * lsscsi-0.28 diff -Nru lsscsi-0.28/Makefile.in lsscsi-0.30/Makefile.in --- lsscsi-0.28/Makefile.in 2014-08-25 19:03:01.000000000 +0000 +++ lsscsi-0.30/Makefile.in 2018-05-03 21:15:12.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -75,16 +85,15 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ subdir = . -DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ - $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) \ - $(srcdir)/config.h.in COPYING TODO compile config.guess \ - config.sub depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d @@ -148,6 +157,9 @@ CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \ + COPYING ChangeLog INSTALL NEWS README TODO ar-lib compile \ + config.guess config.sub depcomp install-sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -193,6 +205,7 @@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -200,6 +213,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ @@ -207,7 +221,9 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EGREP = @EGREP@ EXEEXT = @EXEEXT@ +GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -237,6 +253,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -244,14 +261,22 @@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ +build = @build@ build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +host = @host@ host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ @@ -267,6 +292,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -287,16 +313,15 @@ @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -.PRECIOUS: Makefile + $(AUTOMAKE) --foreign Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -502,7 +527,7 @@ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir @@ -518,17 +543,17 @@ $(am__post_remove_distdir) dist-tarZ: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir @@ -546,7 +571,7 @@ distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -556,23 +581,23 @@ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_inst + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=.. --prefix="$$dc_install_base" \ + --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ @@ -748,6 +773,8 @@ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ tags-am uninstall uninstall-am +.PRECIOUS: Makefile + distclean-local: rm -rf autom4te.cache diff -Nru lsscsi-0.28/missing lsscsi-0.30/missing --- lsscsi-0.28/missing 2008-03-19 19:39:31.000000000 +0000 +++ lsscsi-0.30/missing 2016-02-25 02:43:26.000000000 +0000 @@ -1,11 +1,10 @@ #! /bin/sh -# Common stub for a few missing GNU programs while installing. +# Common wrapper for a few potentially missing GNU programs. -scriptversion=2005-02-08.22 +scriptversion=2013-10-28.13; # UTC -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,9 +17,7 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -28,63 +25,40 @@ # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" + echo 1>&2 "Try '$0 --help' for more information" exit 1 fi -run=: +case $1 in -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. Send bug reports to ." exit $? @@ -96,262 +70,146 @@ ;; -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case "$1" in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - touch $file - ;; - - tar) - shift +# Run the given program, remember its exit status. +"$@"; st=$? - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; +# If it succeeded, we are done. +test $st -eq 0 && exit 0 - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi -exit 0 +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" # End: diff -Nru lsscsi-0.28/README lsscsi-0.30/README --- lsscsi-0.28/README 2014-09-24 02:53:25.000000000 +0000 +++ lsscsi-0.30/README 2016-05-13 22:49:40.000000000 +0000 @@ -13,4 +13,4 @@ causes blocks device names (e.g. /dev/sda) not to be found. Douglas Gilbert -23rd September 2014 +13th May 2016 diff -Nru lsscsi-0.28/src/lsscsi.c lsscsi-0.30/src/lsscsi.c --- lsscsi-0.28/src/lsscsi.c 2014-10-01 03:45:07.000000000 +0000 +++ lsscsi-0.30/src/lsscsi.c 2018-06-13 01:49:03.000000000 +0000 @@ -1,8 +1,9 @@ -/* This is a utility program for listing SCSI devices and hosts (HBAs) - * in the Linux operating system. It is applicable to kernel versions - * 2.6.1 and greater. +/* This is a utility program for listing storage devices and hosts (HBAs) + * that use the SCSI subsystems in the Linux operating system. It is + * applicable to kernel versions 2.6.1 and greater. In lsscsi version 0.30 + * support was added to additionally list NVMe devices and controllers. * - * Copyright (C) 2003-2014 D. Gilbert + * Copyright (C) 2003-2018 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -18,22 +19,33 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include +#include +#ifndef major +#include +#endif #include #include #include #define __STDC_FORMAT_MACROS 1 #include -static const char * version_str = "0.28 2014/09/30 [svn: r120]"; +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "sg_unaligned.h" + + +static const char * version_str = "0.30 2018/06/12 [svn: r154]"; #define FT_OTHER 0 #define FT_BLOCK 1 @@ -51,6 +63,9 @@ #define TRANSPORT_SATA 9 /* most likely SATA */ #define TRANSPORT_FCOE 10 #define TRANSPORT_SRP 11 +#define TRANSPORT_PCIE 12 /* most likely NVMe */ + +#define NVME_HOST_NUM 0x7fff /* 32767, high to avoid SCSI host numbers */ #ifdef PATH_MAX #define LMAX_PATH PATH_MAX @@ -66,6 +81,8 @@ #define LMAX_DEVPATH (LMAX_NAME + 128) +#define UINT64_LAST ((uint64_t)~0) + static int transport_id = TRANSPORT_UNKNOWN; @@ -88,36 +105,56 @@ static const char * srp_host = "/class/srp_host/"; static const char * dev_dir = "/dev"; static const char * dev_disk_byid_dir = "/dev/disk/by-id"; +#if (HAVE_NVME && (! IGNORE_NVME)) +/* static const char * bus_pci_prefix = "/bus/pci"; */ +/* static const char * bus_pcie_devs = "/bus/pci_express/devices"; */ +static const char * class_nvme = "/class/nvme/"; +/* static const char * class_nvme_subsys = "/class/nvme-subsystem/"; */ +#endif +/* For SCSI 'h' is host_num, 'c' is channel, 't' is target, 'l' is LUN is + * uint64_t and lun_arr[8] is LUN as 8 byte array. For NVMe, h=0x7fff + * (NVME_HOST_NUM) and displayed as 'N'; 'c' is Linux's NVMe controller + * number, 't' is NVMe Identify controller CTNLID field, and 'l' is + * namespace id (1 to (2**32)-1) rendered as a little endian 4 byte sequence + * in lun_arr, last 4 bytes are zeros. invalidate_hctl() puts -1 in + * integers, 0xff in bytes */ struct addr_hctl { - int h; + int h; /* if h==0x7fff, display as 'N' for NVMe */ int c; int t; - uint64_t l; /* Linux word flipped */ - unsigned char lun_arr[8]; /* T10, SAM-5 order */ + uint64_t l; /* SCSI: Linux word flipped; NVME: uint32_t */ + uint8_t lun_arr[8]; /* T10, SAM-5 order; NVME: little endian */ }; struct addr_hctl filter; -static int filter_active = 0; +static bool filter_active = false; struct lsscsi_opts { + bool brief; + bool classic; + bool dev_maj_min; /* --device */ + bool generic; + bool kname; + bool no_nvme; + bool pdt; /* (-D) peripheral device type in hex */ + bool protection; /* data integrity */ + bool protmode; /* data integrity */ + bool scsi_id; /* udev derived from /dev/disk/by-id/scsi* */ + bool transport_info; + bool wwn; int long_opt; /* --long */ - int classic; - int generic; - int dev_maj_min; /* --device */ - int kname; int lunhex; - int protection; /* data integrity */ - int protmode; /* data integrity */ - int scsi_id; /* udev derived from /dev/disk/by-id/scsi* */ - int size; - int transport; + int ssize; /* show storage size, once->base 10 (e.g. 3 GB + * twice ->base 2 (e.g. 3.1 GiB) + * thrice for number of logical blocks */ int unit; /* logical unit (LU) name: from vpd_pg83 */ int verbose; - int wwn; }; +static void tag_lun(const uint8_t * lunp, int * tag_arr); + static const char * scsi_device_types[] = { @@ -161,26 +198,35 @@ /* '--name' ('-n') option removed in version 0.11 and can now be reused */ static struct option long_options[] = { - {"classic", 0, 0, 'c'}, - {"device", 0, 0, 'd'}, - {"generic", 0, 0, 'g'}, - {"help", 0, 0, 'h'}, - {"hosts", 0, 0, 'H'}, - {"kname", 0, 0, 'k'}, - {"long", 0, 0, 'l'}, - {"list", 0, 0, 'L'}, - {"lunhex", 0, 0, 'x'}, - {"protection", 0, 0, 'p'}, - {"protmode", 0, 0, 'P'}, - {"scsi_id", 0, 0, 'i'}, - {"scsi-id", 0, 0, 'i'}, /* convenience, not documented */ - {"size", 0, 0, 's'}, - {"sysfsroot", 1, 0, 'y'}, - {"transport", 0, 0, 't'}, - {"unit", 0, 0, 'u'}, - {"verbose", 0, 0, 'v'}, - {"version", 0, 0, 'V'}, - {"wwn", 0, 0, 'w'}, + {"brief", no_argument, 0, 'b'}, + {"classic", no_argument, 0, 'c'}, + {"controllers", no_argument, 0, 'C'}, + {"device", no_argument, 0, 'd'}, + {"generic", no_argument, 0, 'g'}, + {"help", no_argument, 0, 'h'}, + {"hosts", no_argument, 0, 'H'}, + {"kname", no_argument, 0, 'k'}, + {"long", no_argument, 0, 'l'}, + {"list", no_argument, 0, 'L'}, + {"lunhex", no_argument, 0, 'x'}, + {"no-nvme", no_argument, 0, 'N'}, /* allow both '-' and '_' */ + {"no_nvme", no_argument, 0, 'N'}, + {"pdt", no_argument, 0, 'D'}, + {"protection", no_argument, 0, 'p'}, + {"protmode", no_argument, 0, 'P'}, + {"scsi_id", no_argument, 0, 'i'}, + {"scsi-id", no_argument, 0, 'i'}, /* convenience, not documented */ + {"size", no_argument, 0, 's'}, + {"sz-lbs", no_argument, 0, 'S'}, + {"sz_lbs", no_argument, 0, 'S'}, /* convenience, not documented */ + {"sysfsroot", required_argument, 0, 'y'}, + {"transport", no_argument, 0, 't'}, + {"unit", no_argument, 0, 'u'}, + {"long_unit", no_argument, 0, 'U'}, + {"long-unit", no_argument, 0, 'U'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"wwn", no_argument, 0, 'w'}, {0, 0, 0, 0} }; @@ -188,7 +234,7 @@ /* Device node list: contains the information needed to match a node with a * sysfs class device. */ #define DEV_NODE_LIST_ENTRIES 16 -enum dev_type { BLK_DEV, CHR_DEV}; +enum dev_type {BLK_DEV, CHR_DEV}; struct dev_node_entry { unsigned int maj, min; @@ -204,16 +250,26 @@ }; static struct dev_node_list* dev_node_listhead = NULL; +/* WWN here is extracted from /dev/disk/by-id/wwn- which is + * created by udev 60-persistent-storage.rules using ID_WWN_WITH_EXTENSION. + * The udev ID_WWN_WITH_EXTENSION is the combination of char wwn[17] and + * char wwn_vendor_extension[17] from struct scsi_id_device. This macro + * defines the maximum length of char-array needed to store this wwn including + * the null-terminator. + */ +#define DISK_WWN_MAX_LEN 35 + struct disk_wwn_node_entry { - char wwn[32]; - char disk_bname[12]; + char wwn[DISK_WWN_MAX_LEN]; /* '0x' + wwn<128-bit> + */ + /* */ + char disk_bname[12]; }; #define DISK_WWN_NODE_LIST_ENTRIES 16 struct disk_wwn_node_list { - struct disk_wwn_node_list *next; - unsigned int count; - struct disk_wwn_node_entry nodes[DISK_WWN_NODE_LIST_ENTRIES]; + struct disk_wwn_node_list *next; + unsigned int count; + struct disk_wwn_node_entry nodes[DISK_WWN_NODE_LIST_ENTRIES]; }; static struct disk_wwn_node_list * disk_wwn_node_listhead = NULL; @@ -231,20 +287,34 @@ static char sas_low_phy[LMAX_NAME]; static char sas_hold_end_device[LMAX_NAME]; +/* Code analyzer states that the following two pointers may reference local + * (auto or stack based) locations and thus may be dangling. However they + * are only use by iscsi_target_scan() (plus functions it * calls) which is + * invoked only in transport_tport(). And the local (auto or stack based) + * locations flagged by the analyzer are defined in the function scope of + * transport_tport(). Hence there is no problem. */ static const char * iscsi_dir_name; static const struct addr_hctl * iscsi_target_hct; + static int iscsi_tsession_num; static char errpath[LMAX_PATH]; -static const char * usage_message = -"Usage: lsscsi [--classic] [--device] [--generic] [--help] [--hosts]\n" - "\t\t[--kname] [--list] [--lunhex] [--long] [--protection]\n" - "\t\t[--scsi_id] [--size] [--sysfsroot=PATH] [--transport]\n" - "\t\t[--unit] [--verbose] [--version] [--wwn] []\n" +static const char * usage_message1 = +"Usage: lsscsi [--brief] [--classic] [--controllers] [--device] " + "[--generic]\n" + "\t\t[--help] [--hosts] [--kname] [--list] [--long] " + "[--long-unit]\n" + "\t\t[--lunhex] [--no-nvme] [--pdt] [--protection] [--prot-mode]\n" + "\t\t[--scsi_id] [--size] [--sz-lbs] [--sysfsroot=PATH] " + "[--transport]\n" + "\t\t[--unit] [--verbose] [--version] [--wwn] []\n" " where:\n" +" --brief|-b tuple and device name only\n" " --classic|-c alternate output similar to 'cat /proc/scsi/scsi'\n" +" --controllers|-C synonym for --hosts since NVMe controllers treated\n" +" like SCSI hosts\n" " --device|-d show device node's major + minor numbers\n" " --generic|-g show scsi generic device name\n" " --help|-h this usage information\n" @@ -253,22 +323,38 @@ " --list|-L additional information output one\n" " attribute=value per line\n" " --long|-l additional information output\n" +" --long-unit|-U print LU name in full, use twice to prefix with\n" +" '.naa', 'eui.', 'uuid.' or 't10.'\n" " --lunhex|-x show LUN part of tuple as hex number in T10 " -"format;\n" +"format;\n"; + +static const char * usage_message2 = " use twice to get full 16 digit hexadecimal LUN\n" +" --no-nvme|-N exclude NVMe devices from output\n" +" --pdt|-D show the peripheral device type in hex\n" " --protection|-p show target and initiator protection information\n" " --protmode|-P show negotiated protection information mode\n" " --scsi_id|-i show udev derived /dev/disk/by-id/scsi* entry\n" -" --size|-s show disk size\n" +" --size|-s show disk size, (once for decimal (e.g. 3 GB),\n" +" twice for power of two (e.g. 2.7 GiB),\n" +" thrice for number of blocks))\n" " --sysfsroot=PATH|-y PATH set sysfs mount point to PATH (def: /sys)\n" +" --sz-lbs|-S show size as a number of logical blocks; if used " +"twice\n" +" adds comma followed by logical block size in bytes\n" " --transport|-t transport information for target or, if '--hosts'\n" " given, for initiator\n" " --unit|-u logical unit (LU) name (aka WWN for ATA/SATA)\n" " --verbose|-v output path names where data is found\n" " --version|-V output version string and exit\n" " --wwn|-w output WWN for disks (from /dev/disk/by-id/wwn*)\n" -" filter output list (def: '*:*:*:*' (all))\n\n" -"List SCSI devices or hosts, optionally with additional information\n"; +" filter output list (def: '*:*:*:*' (all)). Meaning:\n" +" or for NVMe:\n" +" <'N':ctl_num:cntlid:namespace_id>\n\n" +"List SCSI devices or hosts, followed by NVMe namespaces or controllers.\n" +"Many storage devices (e.g. SATA disks and USB attached storage) use SCSI\n" +"command sets and hence are also listed by this utility. Hyphenated long\n" +"options can also take underscore (and vice versa).\n"; #ifdef __GNUC__ @@ -291,10 +377,224 @@ return n; } +#ifdef __GNUC__ +static int scnpr(char * cp, int cp_max_len, const char * fmt, ...) + __attribute__ ((format (printf, 3, 4))); +#else +static int scnpr(char * cp, int cp_max_len, const char * fmt, ...); +#endif + +/* Want safe, 'n += snprintf(b + n, blen - n, ...)' style sequence of + * functions. Returns number number of chars placed in cp excluding the + * trailing null char. So for cp_max_len > 0 the return value is always + * < cp_max_len; for cp_max_len <= 1 the return value is 0 and no chars + * are written to cp. Note this means that when cp_max_len = 1, this + * function assumes that cp[0] is the null character and does nothing + * (and returns 0). */ +static int +scnpr(char * cp, int cp_max_len, const char * fmt, ...) +{ + va_list args; + int n; + + if (cp_max_len < 2) + return 0; + va_start(args, fmt); + n = vsnprintf(cp, cp_max_len, fmt, args); + va_end(args); + return (n < cp_max_len) ? n : (cp_max_len - 1); +} + +#if 0 +static bool +all_zeros(const uint8_t * bp, int b_len) +{ + if ((NULL == bp) || (b_len <= 0)) + return false; + for (--b_len; b_len >= 0; --b_len) { + if (0x0 != bp[b_len]) + return false; + } + return true; +} + +static bool +all_ffs(const uint8_t * bp, int b_len) +{ + if ((NULL == bp) || (b_len <= 0)) + return false; + for (--b_len; b_len >= 0; --b_len) { + if (0xff != bp[b_len]) + return false; + } + return true; +} +#endif + +#if (HAVE_NVME && (! IGNORE_NVME)) + +/* trims leading whitespaces, if trim_leading is true; and trims trailing + * whitespaces, if trim_trailing is true. Edits s in place. If s is NULL + * or empty (or both bools are false) it does nothing. Returns length of + * processed string (or 0 if s is NULL). */ +static int +trim_lead_trail(char * s, bool trim_leading, bool trim_trailing) { + int n; + char * p = s; + + if ((NULL == s) || (0 == ((n = (int)strlen(p)))) || + (! (trim_leading && trim_trailing))) /* sanity checks */ + return s ? (int)strlen(s) : 0; + + if (trim_trailing) { + while (isspace((uint8_t)p[n - 1])) + p[--n] = 0; + } + if (trim_leading) { + while (*p && isspace((uint8_t)*p)) { + ++p; + --n; + } + memmove(s, p, n + 1); + } + return (int)strlen(s); +} + +/* Truncate or pad string to length n, plus adds null byte to str assumed to + * be at least n+1 bytes long. If shorter than n, pads with spaces to right. + * If truncated and trailing__on_trunc is true and last character (after + * truncate) is not whitespace, then places "_" in last character position. */ +static void +trunc_pad2n(char * str, int n, bool trailing__on_trunc) +{ + int slen = strlen(str); + + if (slen < n) { + memset(str + slen, ' ', n - slen); + str[n] = '\0'; + } else if (slen > n) { + str[n] = '\0'; + if ((n > 0) && trailing__on_trunc && (! isspace((uint8_t)str[n - 1]))) + str[n - 1] = '_'; + } +} + +static const char * bad_arg = "Bad_argument"; + +/* Opens the file 'dirp/fname' and searches for 'name'=, the first one found + * has its value (rest of line after "=") returned in 'b'. The 'name' is + * typically in upper case. Example: 'MAJOR=253' if name is 'MAJOR' returns + * pointer to string containing '253'. */ +static char * +name_eq2value(const char * dirp, const char * fname, const char * name, + int b_len, char * b) +{ + bool ok = false; + int k; + size_t len = 0; + size_t n; + char * full_name; + FILE * fp = NULL; + char line[132]; + + if (b_len > 0) + b[0] = '\0'; + if (b_len < 2) + return b; + if (dirp) + len = strlen(dirp); + if (fname) + len += strlen(fname); + if (len < 1) { + snprintf(b, b_len, "%s", bad_arg); + return b; + } + len += 20; + full_name = (char *)calloc(1, len); + if (NULL == full_name) + goto clean_up; + if (dirp && fname) + snprintf(full_name, len - 2, "%s/%s", dirp, fname); + else if (dirp) + snprintf(full_name, len - 2, "%s", dirp); + else /* fname must be nz (if zero(null) then len==0 above) */ + snprintf(full_name, len - 2, "%s", fname); + + fp = fopen(full_name, "r"); + if (NULL == fp) { +#if 0 + pr2serr("%s: unable to open %s\n", __func__, full_name); +#endif + goto clean_up; + } + if (strlen(name) >= (len - 2)) { + snprintf(b, b_len, "%s", bad_arg); + goto clean_up; + } + /* Re-use full_name as filename no longer needed */ + snprintf(full_name, len - 1, "%s=", name); + n = strlen(full_name); + + for (k = 0; k < 1024; ++k) { /* shouldn't be that many lines */ + if (NULL == fgets(line, sizeof(line), fp)) + break; + if (0 == strncmp(line, full_name, n)) { + ok = true; + break; + } + } + if (ok) { + snprintf(b, b_len, "%s", line + n); + n = strlen(b); + if ((n > 0) && ('\n' == b[n - 1])) + b[n - 1] = '\0'; /* remove trailing LF */ + } +clean_up: + free(full_name); + if (fp) + fclose(fp); + return b; +} + +#endif /* (HAVE_NVME && (! IGNORE_NVME)) */ + +/* Returns true if dirent entry is either a symlink or a directory + * starting_with given name. If starting_with is NULL choose all that are + * either symlinks or directories other than . or .. (own directory or + * parent) . Can be tricked cause symlink could point to .. (parent), for + * example. Otherwise return false. */ +static bool +dir_or_link(const struct dirent * s, const char * starting_with) +{ + if (DT_LNK == s->d_type) { + if (starting_with) + return 0 == strncmp(s->d_name, starting_with, + strlen(starting_with)); + return true; + } else if (DT_DIR != s->d_type) + return false; + else { /* Assume can't have zero length directory name */ + size_t len = strlen(s->d_name); + + if (starting_with) + return 0 == strncmp(s->d_name, starting_with, + strlen(starting_with)); + if (len > 2) + return true; + if ('.' == s->d_name[0]) { + if (1 == len) + return false; /* this directory: '.' */ + else if ('.' == s->d_name[1]) + return false; /* parent: '..' */ + } + return true; + } +} + static void usage(void) { - pr2serr("%s", usage_message); + pr2serr("%s%s", usage_message1, usage_message2); } /* Copies (dest_maxlen - 1) or less chars from src to dest. Less chars are @@ -312,9 +612,116 @@ memcpy(dest, src, dest_maxlen - 1); dest[dest_maxlen - 1] = '\0'; } else - memcpy(dest, src, (lp - src) + 1); + memcpy(dest, src, (lp - src) + 1); +} + +static uint64_t +lun_word_flip(uint64_t in) +{ + int k; + uint64_t res = 0; + + for (k = 0; ; ++k) { + res |= (in & 0xffff); + if (k > 2) + break; + res <<= 16; + in >>= 16; + } + return res; +} + +/* Bits 3, 2, 1, 0 in sel_mask select the h, c, t, l components respectively. + * Bits 4+5 of sel_mask convey the --lunhex option selecting l (LUN) in + * hex. Generates string of the form %d:%d:%d with a colon between + * components, returns 4th argument. */ +static char * +tuple2string(const struct addr_hctl * tp, int sel_mask, int blen, char * b) +{ + bool got1 = false; + bool is_nvme = (NVME_HOST_NUM == tp->h); + int n = 0; + + if (0x8 & sel_mask) { + if (is_nvme) + n += scnpr(b + n, blen - n, "N"); + else + n += scnpr(b + n, blen - n, "%d", tp->h); + got1 = true; + } + if (0x4 & sel_mask) { + n += scnpr(b + n, blen - n, "%s%d", got1 ? ":" : "", tp->c); + got1 = true; + } + if (0x2 & sel_mask) { + n += scnpr(b + n, blen - n, "%s%d", got1 ? ":" : "", tp->t); + got1 = true; + } + if ((! is_nvme ) && (0x1 & sel_mask)) { + int lunhex = (sel_mask >> 4) & 0x3; + + if (1 == lunhex) { /* -x (--lunhex) format */ + int ta, k; + int tag_arr[16]; + + n += scnpr(b + n, blen - n, "%s0x", got1 ? ":" : ""); + tag_lun(tp->lun_arr, tag_arr); + for (k = 0; k < 8; ++k) { + ta = tag_arr[k]; + if (ta <= 0) + break; + n += scnpr(b + n, blen - n, "%s%02x", + ((ta > 1) ? "_" : ""), + tp->lun_arr[k]); + } + } else if (lunhex > 1) /* -xx (--lunhex twice) */ + n += scnpr(b + n, blen - n, "%s0x%016" PRIx64, + got1 ? ":" : "", + lun_word_flip(tp->l)); + else if (UINT64_LAST == tp->l) + n += scnpr(b + n, blen - n, "%s", + got1 ? ":-1" : "-1"); + else + n += scnpr(b + n, blen - n, "%s%" PRIu64, + got1 ? ":" : "", tp->l); + } else if (0x1 & sel_mask) { /* now must be NVMe */ + int lunhex = (sel_mask >> 4) & 0x3; + + if (1 == lunhex) { /* -x (--lunhex) format */ + n += scnpr(b + n, blen - n, "%s0x", got1 ? ":" : ""); + n += scnpr(b + n, blen - n, "%04" PRIx32, + (uint32_t)tp->l); + } else if (lunhex > 1) { /* -xx (--lunhex twice) */ + n += scnpr(b + n, blen - n, "%s0x", got1 ? ":" : ""); + n += scnpr(b + n, blen - n, "%08" PRIx32, + (uint32_t)tp->l); + } else if (UINT32_MAX == tp->l) + n += scnpr(b + n, blen - n, "%s", + got1 ? ":-1" : "-1"); + else + n += scnpr(b + n, blen - n, "%s%" PRIu32, + got1 ? ":" : "", (uint32_t)tp->l); + } + return b; +} + +#if (HAVE_NVME && (! IGNORE_NVME)) + +static void +mk_nvme_tuple(struct addr_hctl * tp, int cdev_minor, int cntlid, + uint32_t nsid) +{ + tp->h = NVME_HOST_NUM; + tp->c = cdev_minor; + tp->t = cntlid; + // tp->l = nsid; + sg_put_unaligned_le32(nsid, tp->lun_arr); + memset(tp->lun_arr + 4, 0, 4); + tp->l = nsid; } +#endif + /* Returns remainder (*np % base) and replaces *np with (*np / base). * base needs to be > 0 */ static unsigned int @@ -328,32 +735,40 @@ } enum string_size_units { - STRING_UNITS_10, /* use powers of 10^3 (standard SI) */ + STRING_UNITS_10 = 0, /* use powers of 10^3 (standard SI) */ STRING_UNITS_2, /* use binary powers of 2^10 */ }; /** - * string_get_size - get the size in the specified units + * size2string - get the size in the specified units * @size: The size to be converted * @units: units to use (powers of 1000 or 1024) * @buf: buffer to format to * @len: length of buffer * - * This function returns a string formatted to 3 significant figures - * giving the size in the required units. Returns 0 on success or - * error on failure. @buf is always zero terminated. - * + * This function yields a string formatted to 3 significant figures + * giving the size in the required units. Returns true on success or + * false on failure. @buf is always zero terminated. */ -static int -string_get_size(uint64_t size, const enum string_size_units units, char *buf, - int len) +static bool +size2string(uint64_t size, const enum string_size_units units, char *buf, + int len) { + int i, j; + unsigned int res; + uint64_t sf_cap; + uint64_t remainder = 0; + char tmp[8]; const char *units_10[] = { "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL}; const char *units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL }; /* designated initializer are C99 but not yet C++; g++ and clang++ * accept them (with noise) */ +#ifdef __cplusplus + const char **units_str[] = {units_10, units_2, }; + const unsigned int divisor[] = {1000, 1024, }; +#else const char **units_str[] = { [STRING_UNITS_10] = units_10, [STRING_UNITS_2] = units_2, @@ -362,11 +777,7 @@ [STRING_UNITS_10] = 1000, [STRING_UNITS_2] = 1024, }; - int i, j; - unsigned int res; - uint64_t sf_cap; - uint64_t remainder = 0; - char tmp[8]; +#endif tmp[0] = '\0'; i = 0; @@ -377,7 +788,7 @@ } sf_cap = size; - for (j = 0; sf_cap*10 < 1000; j++) + for (j = 0; (sf_cap * 10) < 1000; ++j) sf_cap *= 10; if (j) { @@ -392,7 +803,7 @@ res = size; snprintf(buf, len, "%u%s%s", res, tmp, units_str[units][i]); - return 0; + return true; } @@ -416,28 +827,24 @@ static void invalidate_hctl(struct addr_hctl * p) { - int k; - if (p) { p->h = -1; p->c = -1; p->t = -1; - p->l = (uint64_t)~0; - for (k = 0; k < 8; ++k) - p->lun_arr[k] = 0xff; + p->l = UINT64_LAST; + /* le or be, it matters not; writing 0xff bytes */ + sg_put_unaligned_le64(p->l, p->lun_arr); } } /* Return 1 for directory entry that is link or directory (other than - * a directory name starting with dot). Else return 0. - */ + * a directory name starting with dot). Else return 0. */ static int -first_scandir_select(const struct dirent * s) +first_dir_scan_select(const struct dirent * s) { if (FT_OTHER != aa_first.ft) return 0; - if ((DT_LNK != s->d_type) && - ((DT_DIR != s->d_type) || ('.' == s->d_name[0]))) + if (! dir_or_link(s, NULL)) return 0; my_strcopy(aa_first.name, s->d_name, LMAX_NAME); aa_first.ft = FT_CHAR; /* dummy */ @@ -445,114 +852,96 @@ return 1; } +/* Selects symlinks and directories that don't start with "." */ static int -sub_scandir_select(const struct dirent * s) +sub_dir_scan_select(const struct dirent * s) { - if (s->d_type == DT_LNK) - return 1; - - if (s->d_type == DT_DIR && s->d_name[0] != '.') - return 1; - - return 0; + return (dir_or_link(s, NULL)) ? 1 : 0; } +/* Selects symlinks and directories that don't start with "." as long as + * they contain the string "scsi_disk". */ static int -sd_scandir_select(const struct dirent * s) +sd_dir_scan_select(const struct dirent * s) { - if (s->d_type != DT_LNK && s->d_type != DT_DIR) - return 0; - - if (s->d_name[0] == '.') - return 0; - - if (strstr(s->d_name, "scsi_disk")) - return 1; - - return 0; + return (dir_or_link(s, "scsi_disk")) ? 1 : 0; } /* Return 1 for directory entry that is link or directory (other than a * directory name starting with dot) that contains "block". Else return 0. */ static int -block_scandir_select(const struct dirent * s) +block_dir_scan_select(const struct dirent * s) { - if (s->d_type != DT_LNK && s->d_type != DT_DIR) - return 0; - - if (s->d_name[0] == '.') - return 0; - - if (strstr(s->d_name, "block")) - return 1; - - return 0; + return (dir_or_link(s, "block")) ? 1 : 0; } typedef int (* dirent_select_fn) (const struct dirent *); -static int +/* Scans directory dir_name, selecting elements on the basis of fn (NULL + * select all), into an unsorted list. The first item is assumed to be + * directories (or symlinks to) and it is appended, after a '/' to dir_name. + * Then if sub_str is found in that dir_name, it selects items that are + * directories or symlinks, the first of which is appended, after a '/', + * to dir_name. If conditions are met true is return, elae false. + */ +static bool sub_scan(char * dir_name, const char * sub_str, dirent_select_fn fn) { + int num, k, len; struct dirent ** namelist; - int num, i, len; num = scandir(dir_name, &namelist, fn, NULL); if (num <= 0) - return 0; + return false; len = strlen(dir_name); if (len >= LMAX_PATH) - return 0; + return false; snprintf(dir_name + len, LMAX_PATH - len, "/%s", namelist[0]->d_name); - for (i = 0; i < num; i++) - free(namelist[i]); + for (k = 0; k < num; ++k) + free(namelist[k]); free(namelist); - if (num && strstr(dir_name, sub_str) == 0) { - num = scandir(dir_name, &namelist, sub_scandir_select, NULL); + if (strstr(dir_name, sub_str) == 0) { + num = scandir(dir_name, &namelist, sub_dir_scan_select, NULL); if (num <= 0) - return 0; + return false; len = strlen(dir_name); if (len >= LMAX_PATH) - return 0; + return false; snprintf(dir_name + len, LMAX_PATH - len, "/%s", namelist[0]->d_name); - for (i = 0; i < num; i++) - free(namelist[i]); + for (k = 0; k < num; ++k) + free(namelist[k]); free(namelist); } - return 1; + return true; } /* Scan for block:sdN or block/sdN directory in - * /sys/bus/scsi/devices/h:c:i:l - */ -static int + * /sys/bus/scsi/devices/h:c:i:l */ +static bool block_scan(char * dir_name) { - return sub_scan(dir_name, "block:", block_scandir_select); + return sub_scan(dir_name, "block:", block_dir_scan_select); } /* Scan for scsi_disk:h:c:i:l or scsi_disk/h:c:i:l directory in - * /sys/bus/scsi/devices/h:c:i:l - */ -static int + * /sys/bus/scsi/devices/h:c:i:l */ +static bool sd_scan(char * dir_name) { - return sub_scan(dir_name, "scsi_disk:", sd_scandir_select); + return sub_scan(dir_name, "scsi_disk:", sd_dir_scan_select); } static int -enclosure_device_scandir_select(const struct dirent * s) +enclosure_device_dir_scan_select(const struct dirent * s) { - if ((DT_LNK != s->d_type) && - ((DT_DIR != s->d_type) || ('.' == s->d_name[0]))) - return 0; - if (strstr(s->d_name, "enclosure_device")){ - my_strcopy(enclosure_device.name, s->d_name, LMAX_NAME); + if (dir_or_link(s, "enclosure_device")) { + my_strcopy(enclosure_device.name, s->d_name, + LMAX_NAME); enclosure_device.ft = FT_CHAR; /* dummy */ enclosure_device.d_type = s->d_type; return 1; @@ -560,43 +949,45 @@ return 0; } -/* Return 1 for directory entry that is link or directory (other than a +/* Return true for directory entry that is link or directory (other than a * directory name starting with dot) that contains "enclosure_device". - * Else return 0. - */ -static int + * Else return false. */ +static bool enclosure_device_scan(const char * dir_name, const struct lsscsi_opts * op) { - struct dirent ** namelist; int num, k; + struct dirent ** namelist; - num = scandir(dir_name, &namelist, enclosure_device_scandir_select, + num = scandir(dir_name, &namelist, enclosure_device_dir_scan_select, NULL); if (num < 0) { if (op->verbose > 0) { - snprintf(errpath, LMAX_PATH, "scandir: %s", dir_name); + snprintf(errpath, LMAX_PATH, "%s: scandir: %s", + __func__, dir_name); perror(errpath); } - return -1; + return false; } for (k = 0; k < num; ++k) free(namelist[k]); free(namelist); - return num; + return !! num; } -/* scan for directory entry that is either a symlink or a directory */ +/* scan for directory entry that is either a symlink or a directory. Returns + * number found or -1 for error. */ static int scan_for_first(const char * dir_name, const struct lsscsi_opts * op) { - struct dirent ** namelist; int num, k; + struct dirent ** namelist; aa_first.ft = FT_OTHER; - num = scandir(dir_name, &namelist, first_scandir_select, NULL); + num = scandir(dir_name, &namelist, first_dir_scan_select, NULL); if (num < 0) { if (op->verbose > 0) { - snprintf(errpath, LMAX_PATH, "scandir: %s", dir_name); + snprintf(errpath, LMAX_PATH, "%s: scandir: %s", + __func__, dir_name); perror(errpath); } return -1; @@ -608,14 +999,13 @@ } static int -non_sg_scandir_select(const struct dirent * s) +non_sg_dir_scan_select(const struct dirent * s) { int len; if (FT_OTHER != non_sg.ft) return 0; - if ((DT_LNK != s->d_type) && - ((DT_DIR != s->d_type) || ('.' == s->d_name[0]))) + if (! dir_or_link(s, NULL)) return 0; if (0 == strncmp("scsi_changer", s->d_name, 12)) { my_strcopy(non_sg.name, s->d_name, LMAX_NAME); @@ -651,17 +1041,19 @@ return 0; } +/* Returns number found or -1 for error */ static int non_sg_scan(const char * dir_name, const struct lsscsi_opts * op) { - struct dirent ** namelist; int num, k; + struct dirent ** namelist; non_sg.ft = FT_OTHER; - num = scandir(dir_name, &namelist, non_sg_scandir_select, NULL); + num = scandir(dir_name, &namelist, non_sg_dir_scan_select, NULL); if (num < 0) { if (op->verbose > 0) { - snprintf(errpath, LMAX_PATH, "scandir: %s", dir_name); + snprintf(errpath, LMAX_PATH, "%s: scandir: %s", + __func__, dir_name); perror(errpath); } return -1; @@ -674,14 +1066,11 @@ static int -sg_scandir_select(const struct dirent * s) +sg_dir_scan_select(const struct dirent * s) { if (FT_OTHER != aa_sg.ft) return 0; - if ((DT_LNK != s->d_type) && - ((DT_DIR != s->d_type) || ('.' == s->d_name[0]))) - return 0; - if (0 == strncmp("scsi_generic", s->d_name, 12)) { + if (dir_or_link(s, "scsi_generic")) { my_strcopy(aa_sg.name, s->d_name, LMAX_NAME); aa_sg.ft = FT_CHAR; aa_sg.d_type = s->d_type; @@ -690,14 +1079,16 @@ return 0; } +/* Returns number of directories or links starting with "scsi_generic" + * found or -1 for error. */ static int sg_scan(const char * dir_name) { - struct dirent ** namelist; int num, k; + struct dirent ** namelist; aa_sg.ft = FT_OTHER; - num = scandir(dir_name, &namelist, sg_scandir_select, NULL); + num = scandir(dir_name, &namelist, sg_dir_scan_select, NULL); if (num < 0) return -1; for (k = 0; k < num; ++k) @@ -708,23 +1099,19 @@ static int -sas_port_scandir_select(const struct dirent * s) +sas_port_dir_scan_select(const struct dirent * s) { - if ((DT_LNK != s->d_type) && (DT_DIR != s->d_type)) - return 0; - if (0 == strncmp("port-", s->d_name, 5)) - return 1; - return 0; + return (dir_or_link(s, "port-")) ? 1 : 0; } static int sas_port_scan(const char * dir_name, struct dirent ***port_list) { - struct dirent ** namelist; int num; + struct dirent ** namelist; namelist = NULL; - num = scandir(dir_name, &namelist, sas_port_scandir_select, NULL); + num = scandir(dir_name, &namelist, sas_port_dir_scan_select, NULL); if (num < 0) { *port_list = NULL; return -1; @@ -735,14 +1122,12 @@ static int -sas_low_phy_scandir_select(const struct dirent * s) +sas_low_phy_dir_scan_select(const struct dirent * s) { - char * cp; int n, m; + char * cp; - if ((DT_LNK != s->d_type) && (DT_DIR != s->d_type)) - return 0; - if (0 == strncmp("phy", s->d_name, 3)) { + if (dir_or_link(s, "phy")) { if (0 == strlen(sas_low_phy)) my_strcopy(sas_low_phy, s->d_name, LMAX_NAME); else { @@ -765,15 +1150,15 @@ static int sas_low_phy_scan(const char * dir_name, struct dirent ***phy_list) { - struct dirent ** namelist=NULL; int num, k; + struct dirent ** namelist=NULL; memset(sas_low_phy, 0, sizeof(sas_low_phy)); - num = scandir(dir_name, &namelist, sas_low_phy_scandir_select, NULL); + num = scandir(dir_name, &namelist, sas_low_phy_dir_scan_select, NULL); if (num < 0) return -1; - if (!phy_list) { - for (k=0; kd_type) && (DT_DIR != s->d_type)) - return 0; - if (0 == strncmp("session", s->d_name, 7)) { + if (dir_or_link(s, "session")) { iscsi_tsession_num = atoi(s->d_name + 7); my_strcopy(buff, iscsi_dir_name, LMAX_PATH); off = strlen(buff); @@ -809,13 +1192,14 @@ static int iscsi_target_scan(const char * dir_name, const struct addr_hctl * hctl) { - struct dirent ** namelist; int num, k; + struct dirent ** namelist; iscsi_dir_name = dir_name; iscsi_target_hct = hctl; iscsi_tsession_num = -1; - num = scandir(dir_name, &namelist, iscsi_target_scandir_select, NULL); + num = scandir(dir_name, &namelist, iscsi_target_dir_scan_select, + NULL); if (num < 0) return -1; for (k = 0; k < num; ++k) @@ -826,8 +1210,8 @@ /* If 'dir_name'/'base_name' is a directory chdir to it. If that is successful - return 1, else 0 */ -static int + return true, else false */ +static bool if_directory_chdir(const char * dir_name, const char * base_name) { char b[LMAX_PATH]; @@ -835,90 +1219,92 @@ snprintf(b, sizeof(b), "%s/%s", dir_name, base_name); if (stat(b, &a_stat) < 0) - return 0; + return false; if (S_ISDIR(a_stat.st_mode)) { if (chdir(b) < 0) - return 0; - return 1; + return false; + return true; } - return 0; + return false; } /* If 'dir_name'/generic is a directory chdir to it. If that is successful - return 1. Otherwise look a directory of the form - 'dir_name'/scsi_generic:sg and if found chdir to it and return 1. - Otherwise return 0. */ -static int + return true. Otherwise look a directory of the form + 'dir_name'/scsi_generic:sg and if found chdir to it and return true. + Otherwise return false. */ +static bool if_directory_ch2generic(const char * dir_name) { + const char * old_name = "generic"; char b[LMAX_PATH]; struct stat a_stat; - const char * old_name = "generic"; snprintf(b, sizeof(b), "%s/%s", dir_name, old_name); if ((stat(b, &a_stat) >= 0) && S_ISDIR(a_stat.st_mode)) { if (chdir(b) < 0) - return 0; - return 1; + return false; + return true; } /* No "generic", so now look for "scsi_generic:sg" */ if (1 != sg_scan(dir_name)) - return 0; + return false; snprintf(b, sizeof(b), "%s/%s", dir_name, aa_sg.name); if (stat(b, &a_stat) < 0) - return 0; + return false; if (S_ISDIR(a_stat.st_mode)) { if (chdir(b) < 0) - return 0; - return 1; + return false; + return true; } - return 0; + return false; } /* If 'dir_name'/'base_name' is found places corresponding value in 'value' - * and returns 1 . Else returns 0. + * and returns true . Else returns false. */ -static int +static bool get_value(const char * dir_name, const char * base_name, char * value, int max_value_len) { - char b[LMAX_PATH]; - FILE * f; int len; + FILE * f; + char b[LMAX_PATH]; snprintf(b, sizeof(b), "%s/%s", dir_name, base_name); if (NULL == (f = fopen(b, "r"))) { - return 0; + return false; } if (NULL == fgets(value, max_value_len, f)) { /* assume empty */ value[0] = '\0'; fclose(f); - return 1; + return true; } len = strlen(value); if ((len > 0) && (value[len - 1] == '\n')) value[len - 1] = '\0'; fclose(f); - return 1; + return true; } -/* Allocate dev_node_list and collect info on every node in /dev. */ +/* Allocate dev_node_list and collect info on every char and block devices + * in /dev but not its subdirectories. This list excludes symlinks, even if + * they are to devices. */ static void collect_dev_nodes(void) { - DIR *dirp; + size_t dnl_sz = sizeof(struct dev_node_list); struct dirent *dep; - char device_path[LMAX_DEVPATH]; - struct stat stats; + DIR *dirp; struct dev_node_list *cur_list, *prev_list; struct dev_node_entry *cur_ent; + char device_path[LMAX_DEVPATH]; + struct stat stats; if (dev_node_listhead) return; /* already collected nodes */ - dev_node_listhead = (struct dev_node_list*) - malloc(sizeof(struct dev_node_list)); + dev_node_listhead = (struct dev_node_list *)calloc(1, dnl_sz); if (! dev_node_listhead) return; @@ -939,6 +1325,7 @@ dev_dir, dep->d_name); /* device_path[LMAX_PATH] = '\0'; */ + /* This will bypass all symlinks in /dev */ if (lstat(device_path, &stats)) continue; @@ -949,8 +1336,7 @@ /* Add to the list. */ if (cur_list->count >= DEV_NODE_LIST_ENTRIES) { prev_list = cur_list; - cur_list = (struct dev_node_list *) - malloc(sizeof(struct dev_node_list)); + cur_list = (struct dev_node_list *)calloc(1, dnl_sz); if (! cur_list) break; prev_list->next = cur_list; cur_list->next = NULL; @@ -969,7 +1355,6 @@ cur_list->count++; } - closedir(dirp); } @@ -992,18 +1377,19 @@ } /* Given a path to a class device, find the most recent device node with - * matching major/minor. Outputs to node which is assumed to be at least - * LMAX_NAME bytes long. Returns 1 if match found, 0 otherwise. */ -static int + * matching major/minor and type. Outputs to node which is assumed to be at + * least LMAX_NAME bytes long. Returns true if match found, false + * otherwise. */ +static bool get_dev_node(const char * wd, char * node, enum dev_type type) { - struct dev_node_list *cur_list; - struct dev_node_entry *cur_ent; - char value[LMAX_NAME]; + bool match_found = false; + unsigned int k = 0; unsigned int maj, min; time_t newest_mtime = 0; - int match_found = 0; - unsigned int k = 0; + struct dev_node_entry *cur_ent; + struct dev_node_list *cur_list; + char value[LMAX_NAME]; /* assume 'node' is at least 2 bytes long */ memcpy(node, "-", 2); @@ -1035,12 +1421,12 @@ if ((maj == cur_ent->maj) && (min == cur_ent->min) && (type == cur_ent->type)) { - if ((!match_found) || + if ((! match_found) || (difftime(cur_ent->mtime,newest_mtime) > 0)) { newest_mtime = cur_ent->mtime; my_strcopy(node, cur_ent->name, LMAX_NAME); } - match_found = 1; + match_found = true; } } @@ -1049,7 +1435,7 @@ } /* Allocate disk_wwn_node_list and collect info on every node in - * /dev/disk/by-id/wwn* that does not contain "part" . Returns + * /dev/disk/by-id/scsi-* that does not contain "part" . Returns * number of wwn nodes collected, 0 for already collected and * -1 for error. */ static int @@ -1057,24 +1443,24 @@ { int k; int num = 0; + size_t dwnl_sz = sizeof(struct disk_wwn_node_list); + struct disk_wwn_node_list *cur_list, *prev_list; + struct disk_wwn_node_entry *cur_ent; DIR *dirp; struct dirent *dep; char device_path[PATH_MAX + 1]; char symlink_path[PATH_MAX + 1]; struct stat stats; - struct disk_wwn_node_list *cur_list, *prev_list; - struct disk_wwn_node_entry *cur_ent; if (disk_wwn_node_listhead) return num; /* already collected nodes */ - disk_wwn_node_listhead = (struct disk_wwn_node_list *) - malloc(sizeof(struct disk_wwn_node_list)); + disk_wwn_node_listhead = + (struct disk_wwn_node_list *)calloc(1, dwnl_sz); if (! disk_wwn_node_listhead) return -1; cur_list = disk_wwn_node_listhead; - memset(cur_list, 0, sizeof(struct disk_wwn_node_list)); dirp = opendir(dev_disk_byid_dir); if (dirp == NULL) @@ -1084,10 +1470,14 @@ dep = readdir(dirp); if (dep == NULL) break; - if (memcmp("wwn-", dep->d_name, 4)) - continue; /* needs to start with "wwn-" */ + if (memcmp("scsi-", dep->d_name, 5)) + continue; /* needs to start with "scsi-" */ if (strstr(dep->d_name, "part")) continue; /* skip if contains "part" */ + if (dep->d_name[5] != '3' && + dep->d_name[5] != '2' && + dep->d_name[5] != '8') + continue; /* skip for invalid identifier */ snprintf(device_path, PATH_MAX, "%s/%s", dev_disk_byid_dir, dep->d_name); @@ -1104,16 +1494,16 @@ if (cur_list->count >= DISK_WWN_NODE_LIST_ENTRIES) { prev_list = cur_list; cur_list = (struct disk_wwn_node_list *) - malloc(sizeof(struct disk_wwn_node_list)); + calloc(1, dwnl_sz); if (! cur_list) break; - memset(cur_list, 0, sizeof(struct disk_wwn_node_list)); prev_list->next = cur_list; } cur_ent = &cur_list->nodes[cur_list->count]; - my_strcopy(cur_ent->wwn, dep->d_name + 4, - sizeof(cur_ent->wwn)); + my_strcopy(cur_ent->wwn, "0x", 2); + my_strcopy(cur_ent->wwn + 2, dep->d_name + 5, + sizeof(cur_ent->wwn) - 2); my_strcopy(cur_ent->disk_bname, basename(symlink_path), sizeof(cur_ent->disk_bname)); cur_list->count++; @@ -1142,15 +1532,15 @@ } /* Given a path to a class device, find the most recent device node with - matching major/minor. Returns 1 if match found, 0 otherwise. */ -static int + matching major/minor. Returns true if match found, false otherwise. */ +static bool get_disk_wwn(const char *wd, char * wwn_str, int max_wwn_str_len) { + unsigned int k = 0; + char * bn; struct disk_wwn_node_list *cur_list; struct disk_wwn_node_entry *cur_ent; char name[LMAX_PATH]; - char * bn; - unsigned int k = 0; my_strcopy(name, wd, sizeof(name)); name[sizeof(name) - 1] = '\0'; @@ -1158,7 +1548,7 @@ if (disk_wwn_node_listhead == NULL) { collect_disk_wwn_nodes(); if (disk_wwn_node_listhead == NULL) - return 0; + return false; } cur_list = disk_wwn_node_listhead; while (1) { @@ -1173,10 +1563,10 @@ if (0 == strcmp(cur_ent->disk_bname, bn)) { my_strcopy(wwn_str, cur_ent->wwn, max_wwn_str_len); wwn_str[max_wwn_str_len - 1] = '\0'; - return 1; + return true; } } - return 0; + return false; } /* @@ -1185,17 +1575,18 @@ * @pfx: Prefix of the symlink, e.g. "scsi-". * @dev: Device node to look up, e.g. "/dev/sda". * Returns a pointer to the name of the symlink without the prefix if a match - * has been found. The caller must free the pointer returned by this function. + * has been found. * Side effect: changes the working directory to @dir. + * Note: The caller must free the pointer returned by this function. */ static char * lookup_dev(const char *dir, const char *pfx, const char *dev) { - struct stat stats; unsigned st_rdev; DIR *dirp; struct dirent *entry; char *result = NULL; + struct stat stats; if (stat(dev, &stats) < 0) goto out; @@ -1223,16 +1614,16 @@ * @dev_node: Device node of the disk, e.g. "/dev/sda". * Return value: pointer to the SCSI ID if lookup succeeded or NULL if lookup * failed. - * The caller must free the returned buffer with free(). + * Note: The caller must free the returned buffer with free(). */ static char * get_disk_scsi_id(const char *dev_node) { - char sys_block[64]; - char holder[16]; char *scsi_id = NULL; DIR *dir; struct dirent *entry; + char holder[LMAX_PATH + 6]; + char sys_block[LMAX_PATH]; scsi_id = lookup_dev(dev_disk_byid_dir, "scsi-", dev_node); if (scsi_id) @@ -1267,12 +1658,12 @@ static char * get_usb_devname(const char * hname, const char * devname, char * b, int b_len) { - char buff[LMAX_DEVPATH]; - char bf2[LMAX_PATH]; int len; - const char * np; - char * cp; char * c2p; + char * cp; + const char * np; + char bf2[LMAX_PATH]; + char buff[LMAX_DEVPATH]; if (hname) { snprintf(buff, sizeof(buff), "%s%s", sysfsroot, scsi_host); @@ -1315,49 +1706,49 @@ * termination. Matches association, designator_type and/or code_set when * any of those values are greater than or equal to zero. */ int -sg_vpd_dev_id_iter(const unsigned char * initial_desig_desc, int page_len, +sg_vpd_dev_id_iter(const uint8_t * initial_desig_desc, int page_len, int * off, int m_assoc, int m_desig_type, int m_code_set) { - const unsigned char * ucp; - int k, c_set, assoc, desig_type; + const uint8_t * bp; + int k, c_set, assoc, desig_type; - for (k = *off, ucp = initial_desig_desc ; (k + 3) < page_len; ) { - k = (k < 0) ? 0 : (k + ucp[k + 3] + 4); - if ((k + 4) > page_len) - break; - c_set = (ucp[k] & 0xf); - if ((m_code_set >= 0) && (m_code_set != c_set)) - continue; - assoc = ((ucp[k + 1] >> 4) & 0x3); - if ((m_assoc >= 0) && (m_assoc != assoc)) - continue; - desig_type = (ucp[k + 1] & 0xf); - if ((m_desig_type >= 0) && (m_desig_type != desig_type)) - continue; - *off = k; - return 0; - } - return (k == page_len) ? -1 : -2; + for (k = *off, bp = initial_desig_desc ; (k + 3) < page_len; ) { + k = (k < 0) ? 0 : (k + bp[k + 3] + 4); + if ((k + 4) > page_len) + break; + c_set = (bp[k] & 0xf); + if ((m_code_set >= 0) && (m_code_set != c_set)) + continue; + assoc = ((bp[k + 1] >> 4) & 0x3); + if ((m_assoc >= 0) && (m_assoc != assoc)) + continue; + desig_type = (bp[k + 1] & 0xf); + if ((m_desig_type >= 0) && (m_desig_type != desig_type)) + continue; + *off = k; + return 0; + } + return (k == page_len) ? -1 : -2; } -/* Fetch logical unit (LU) name given the device name in the - * form: h:c:t:l tuple string (e.g. "2:0:1:0"). This is fetched via sysfs - * (lk 3.15 and later) in vpd_pg83. For later ATA and SATA devices this - ( may be its WWN. Normally take the first found in this order: - * NAA, EUI-64 then SCSI name string. However if a SCSI name string - * is present and the protocol is iSCSI (target port checked) then - * the SCSI name string is preferred. - */ +/* Fetch logical unit (LU) name given the device name in the form: + * h:c:t:l tuple string (e.g. "2:0:1:0"). This is fetched via sysfs (lk 3.15 + * and later) in vpd_pg83. For later ATA and SATA devices this may be its + * WWN. Normally take the first found in this order: NAA, EUI-64 * then SCSI + * name string. However if a SCSI name string is present and the protocol is + * iSCSI (target port checked) then the SCSI name string is preferred. If + * none of the above are present then check for T10 Vendor ID + * (designator_type=1) and use if available. */ static char * -get_lu_name(const char * devname, char * b, int b_len) +get_lu_name(const char * devname, char * b, int b_len, bool want_prefix) { + int fd, res, len, dlen, sns_dlen, off, k, n; + uint8_t *bp; + char *cp; char buff[LMAX_DEVPATH]; - unsigned char u[512]; - unsigned char u_sns[512]; + uint8_t u[512]; + uint8_t u_sns[512]; struct stat a_stat; - unsigned char *ucp; - char *cp; - int fd, res, len, dlen, sns_dlen, off, k; if ((NULL == b) || (b_len < 1)) return b; @@ -1376,93 +1767,148 @@ close(fd); if (VPD_DEVICE_ID != u[1]) return b; - len = (u[2] << 8) + u[3]; + len = sg_get_unaligned_be16(u + 2); if ((len + 4) != res) return b; - ucp = u + 4; + bp = u + 4; + cp = b; off = -1; - if (0 == sg_vpd_dev_id_iter(ucp, len, &off, VPD_ASSOC_LU, + if (0 == sg_vpd_dev_id_iter(bp, len, &off, VPD_ASSOC_LU, 8 /* SCSI name string (sns) */, 3 /* UTF-8 */)) { - sns_dlen = ucp[off + 3]; - memcpy(u_sns, ucp + off + 4, sns_dlen); + sns_dlen = bp[off + 3]; + memcpy(u_sns, bp + off + 4, sns_dlen); /* now want to check if this is iSCSI */ off = -1; - if (0 == sg_vpd_dev_id_iter(ucp, len, &off, VPD_ASSOC_TPORT, + if (0 == sg_vpd_dev_id_iter(bp, len, &off, VPD_ASSOC_TPORT, 8 /* SCSI name string (sns) */, 3 /* UTF-8 */)) { - if ((0x80 & ucp[1]) && - (TPROTO_ISCSI == (ucp[0] >> 4))) { + if ((0x80 & bp[1]) && + (TPROTO_ISCSI == (bp[0] >> 4))) { snprintf(b, b_len, "%.*s", sns_dlen, u_sns); return b; } } } else sns_dlen = 0; - if (0 == sg_vpd_dev_id_iter(ucp, len, &off, VPD_ASSOC_LU, + + if (0 == sg_vpd_dev_id_iter(bp, len, &off, VPD_ASSOC_LU, 3 /* NAA */, 1 /* binary */)) { - dlen = ucp[off + 3]; + dlen = bp[off + 3]; if (! ((8 == dlen) || (16 ==dlen))) return b; - cp = b; + if (want_prefix) { + if ((n = snprintf(cp, b_len, "naa.")) >= b_len) + n = b_len - 1; + cp += n; + b_len -= n; + } for (k = 0; ((k < dlen) && (b_len > 1)); ++k) { - snprintf(cp, b_len, "%02x", ucp[off + 4 + k]); + snprintf(cp, b_len, "%02x", bp[off + 4 + k]); cp += 2; b_len -= 2; } - } else if (0 == sg_vpd_dev_id_iter(ucp, len, &off, VPD_ASSOC_LU, + } else if (0 == sg_vpd_dev_id_iter(bp, len, &off, VPD_ASSOC_LU, 2 /* EUI */, 1 /* binary */)) { - dlen = ucp[off + 3]; + dlen = bp[off + 3]; if (! ((8 == dlen) || (12 == dlen) || (16 ==dlen))) return b; - cp = b; + if (want_prefix) { + if ((n = snprintf(cp, b_len, "eui.")) >= b_len) + n = b_len - 1; + cp += n; + b_len -= n; + } for (k = 0; ((k < dlen) && (b_len > 1)); ++k) { - snprintf(cp, b_len, "%02x", ucp[off + 4 + k]); + snprintf(cp, b_len, "%02x", bp[off + 4 + k]); cp += 2; b_len -= 2; } + } else if (0 == sg_vpd_dev_id_iter(bp, len, &off, VPD_ASSOC_LU, + 0xa /* UUID */, 1 /* binary */)) { + dlen = bp[off + 3]; + if ((1 != ((bp[off + 4] >> 4) & 0xf)) || (18 != dlen)) { + snprintf(cp, b_len, "??"); + /* cp += 2; */ + /* b_len -= 2; */ + } else { + if (want_prefix) { + if ((n = snprintf(cp, b_len, "uuid.")) >= + b_len) + n = b_len - 1; + cp += n; + b_len -= n; + } + for (k = 0; (k < 16) && (b_len > 1); ++k) { + if ((4 == k) || (6 == k) || (8 == k) || + (10 == k)) { + snprintf(cp, b_len, "-"); + ++cp; + --b_len; + } + snprintf(cp, b_len, "%02x", + (unsigned int)bp[off + 6 + k]); + cp += 2; + b_len -= 2; + } + } } else if (sns_dlen > 0) snprintf(b, b_len, "%.*s", sns_dlen, u_sns); + else if ((0 == sg_vpd_dev_id_iter(bp, len, &off, VPD_ASSOC_LU, + 0x1 /* T10 vendor ID */, -1)) && + ((bp[off] & 0xf) > 1 /* ASCII or UTF */)) { + dlen = bp[off + 3]; + if (dlen < 8) + return b; /* must have 8 byte T10 vendor id */ + if (want_prefix) { + if ((n = snprintf(cp, b_len, "t10.")) >= b_len) + n = b_len - 1; + cp += n; + b_len -= n; + } + snprintf(cp, b_len, "%.*s", dlen, bp + off + 4); + } return b; } -/* Parse colon_list into host/channel/target/lun ("hctl") array, - * return 1 if successful, else 0. - */ -static int +/* Parse colon_list into host/channel/target/lun ("hctl") array, return true + * if successful, else false. colon_list should point at first character of + * hctl (i.e. a digit) and yields a new value in *outp when true returned. */ +static bool parse_colon_list(const char * colon_list, struct addr_hctl * outp) { int k; - unsigned short u; uint64_t z; const char * elem_end; if ((! colon_list) || (! outp)) - return 0; + return false; +#if (HAVE_NVME && (! IGNORE_NVME)) + if ('N' == toupper((uint8_t)*colon_list)) + outp->h = NVME_HOST_NUM; + else +#endif if (1 != sscanf(colon_list, "%d", &outp->h)) - return 0; + return false; if (NULL == (elem_end = strchr(colon_list, ':'))) - return 0; + return false; colon_list = elem_end + 1; if (1 != sscanf(colon_list, "%d", &outp->c)) - return 0; + return false; if (NULL == (elem_end = strchr(colon_list, ':'))) - return 0; + return false; colon_list = elem_end + 1; if (1 != sscanf(colon_list, "%d", &outp->t)) - return 0; + return false; if (NULL == (elem_end = strchr(colon_list, ':'))) - return 0; + return false; colon_list = elem_end + 1; if (1 != sscanf(colon_list, "%" SCNu64 , &outp->l)) - return 0; + return false; z = outp->l; - for (k = 0; k < 4; ++k, z >>= 16) { - u = z & 0xffff; - outp->lun_arr[(2 * k) + 1] = u & 0xff; - outp->lun_arr[2 * k] = (u >> 8) & 0xff; - } - return 1; + for (k = 0; k < 8; k += 2, z >>= 16) + sg_put_unaligned_be16((uint16_t)z, outp->lun_arr + k); + return true; } /* Print enclosure device link from the rport- or end_device- */ @@ -1470,8 +1916,8 @@ print_enclosure_device(const char *devname, const char *path, const struct lsscsi_opts * op) { - struct addr_hctl hctl; char b[LMAX_PATH]; + struct addr_hctl hctl; if (parse_colon_list(devname, &hctl)) { snprintf(b, sizeof(b), @@ -1491,9 +1937,9 @@ static void get_local_srp_gid(const int h, char *b, int b_len) { + int port; char buff[LMAX_DEVPATH]; char value[LMAX_NAME]; - int port; snprintf(buff, sizeof(buff), "%s%shost%d", sysfsroot, scsi_host, h); if (!get_value(buff, "local_ib_port", value, sizeof(value))) @@ -1513,9 +1959,9 @@ /* * Obtain the original GUID of the remote InfiniBand port associated with a * SCSI host by stripping prefix fe80:0000:0000:0000: from its GID. An - * example: 0002:c903:00a0:5de2. + * example: 0002:c903:00a0:5de2. Returns true on success, else false. */ -static int +static bool get_srp_orig_dgid(const int h, char *b, int b_len) { char buff[LMAX_DEVPATH]; @@ -1525,17 +1971,17 @@ if (get_value(buff, "orig_dgid", value, sizeof(value)) && strlen(value) > 20) { snprintf(b, b_len, "%s", value + 20); - return 1; + return true; } - return 0; + return false; } /* * Obtain the GUID of the remote InfiniBand port associated with a SCSI host * by stripping prefix fe80:0000:0000:0000: from its GID. An example: - * 0002:c903:00a0:5de2. + * 0002:c903:00a0:5de2. Returns true on success else false. */ -static int +static bool get_srp_dgid(const int h, char *b, int b_len) { char buff[LMAX_DEVPATH]; @@ -1545,21 +1991,22 @@ if (get_value(buff, "dgid", value, sizeof(value)) && strlen(value) > 20) { snprintf(b, b_len, "%s", value + 20); - return 1; + return true; } - return 0; + return false; } /* Check host associated with 'devname' for known transport types. If so set - * transport_id, place a string in 'b' and return 1. Otherwise return 0. */ -static int + * transport_id, place a string in 'b' and return true. Otherwise return + * false. */ +static bool transport_init(const char * devname, /* const struct lsscsi_opts * op, */ int b_len, char * b) { - char buff[LMAX_DEVPATH]; - char wd[LMAX_PATH]; int off; char * cp; + char buff[LMAX_DEVPATH]; + char wd[LMAX_PATH]; struct stat a_stat; /* SPI host */ @@ -1567,7 +2014,7 @@ if ((stat(buff, &a_stat) >= 0) && S_ISDIR(a_stat.st_mode)) { transport_id = TRANSPORT_SPI; snprintf(b, b_len, "spi:"); - return 1; + return true; } /* FC host */ @@ -1589,11 +2036,11 @@ my_strcopy(b + off, ",", b_len - off); off = strlen(b); } else - return 0; + return false; if (get_value(buff, "port_id", b + off, b_len - off)) - return 1; + return true; else - return 0; + return false; } /* SRP host */ @@ -1605,7 +2052,7 @@ snprintf(b, b_len, "srp:"); if (sscanf(devname, "host%d", &h) == 1) get_local_srp_gid(h, b + strlen(b), b_len - strlen(b)); - return 1; + return true; } /* SAS host */ @@ -1616,13 +2063,13 @@ off = strlen(buff); snprintf(buff + off, sizeof(buff) - off, "/device"); if (sas_low_phy_scan(buff, NULL) < 1) - return 0; + return false; snprintf(buff, sizeof(buff), "%s%s%s", sysfsroot, sas_phy, sas_low_phy); snprintf(b, b_len, "sas:"); off = strlen(b); if (get_value(buff, "sas_address", b + off, b_len - off)) - return 1; + return true; else pr2serr("_init: no sas_address, wd=%s\n", buff); } @@ -1635,7 +2082,7 @@ snprintf(b, b_len, "sas:"); off = strlen(b); if (get_value(buff, "device_name", b + off, b_len - off)) - return 1; + return true; else pr2serr("_init: no device_name, wd=%s\n", buff); } @@ -1672,7 +2119,7 @@ strlen(buff2) != 18) break; snprintf(b, b_len, "sbp:%s", buff2 + 2); - return 1; + return true; } while (0); /* iSCSI host */ @@ -1683,7 +2130,7 @@ // >>> Can anything useful be placed after "iscsi:" in single line // host output? // Hmmm, probably would like SAM-4 ",i,0x" notation here. - return 1; + return true; } /* USB host? */ @@ -1691,7 +2138,7 @@ if (cp) { transport_id = TRANSPORT_USB; snprintf(b, b_len, "usb:%s", cp); - return 1; + return true; } /* ATA or SATA host, crude check: driver name */ @@ -1700,19 +2147,19 @@ if (0 == strcmp("ahci", wd)) { transport_id = TRANSPORT_SATA; snprintf(b, b_len, "sata:"); - return 1; + return true; } else if (strstr(wd, "ata")) { if (0 == memcmp("sata", wd, 4)) { transport_id = TRANSPORT_SATA; snprintf(b, b_len, "sata:"); - return 1; + return true; } transport_id = TRANSPORT_ATA; snprintf(b, b_len, "ata:"); - return 1; + return true; } } - return 0; + return false; } /* Given the transport_id of a SCSI host (initiator) associated with @@ -1721,16 +2168,16 @@ static void transport_init_longer(const char * path_name, const struct lsscsi_opts * op) { - char buff[LMAX_PATH]; - char bname[LMAX_NAME]; - char value[LMAX_NAME]; + int k, j, len; + int phynum; + int portnum; char * cp; struct stat a_stat; struct dirent ** phylist; struct dirent ** portlist; - int phynum; - int portnum; - int i, j, len; + char buff[LMAX_PATH]; + char bname[LMAX_NAME]; + char value[LMAX_NAME]; my_strcopy(buff, path_name, sizeof(buff)); cp = basename(buff); @@ -1812,12 +2259,12 @@ printf(" no configured phys\n"); return; } - for (i = 0; i < phynum; ++i) { + for (k = 0; k < phynum; ++k) { /* emit something potentially useful */ snprintf(buff, sizeof(buff), "%s%s%s", sysfsroot, sas_phy, - phylist[i]->d_name); - printf(" %s\n",phylist[i]->d_name); + phylist[k]->d_name); + printf(" %s\n",phylist[k]->d_name); if (get_value(buff, "sas_address", value, sizeof(value))) printf(" sas_address=%s\n", value); @@ -1848,22 +2295,22 @@ } return; } - for (i = 0; i < portnum; ++i) { /* for each host port */ + for (k = 0; k < portnum; ++k) { /* for each host port */ snprintf(buff, sizeof(buff), "%s%s%s", path_name, - "/device/", portlist[i]->d_name); + "/device/", portlist[k]->d_name); if ((phynum = sas_low_phy_scan(buff, &phylist)) < 1) { printf(" %s: phy list not available\n", - portlist[i]->d_name); - free(portlist[i]); + portlist[k]->d_name); + free(portlist[k]); continue; } snprintf(buff, sizeof(buff), "%s%s%s", sysfsroot, - sas_port, portlist[i]->d_name); + sas_port, portlist[k]->d_name); if (get_value(buff, "num_phys", value, sizeof(value))) { printf(" %s: num_phys=%s,", - portlist[i]->d_name, value); + portlist[k]->d_name, value); for (j = 0; j < phynum; ++j) { printf(" %s", phylist[j]->d_name); free(phylist[j]); @@ -1926,7 +2373,7 @@ if (op->verbose > 2) printf(" fetched from directory: %s\n", buff); - free(portlist[i]); + free(portlist[k]); } free(portlist); @@ -1990,6 +2437,9 @@ case TRANSPORT_SATA: printf(" transport=sata\n"); break; + case TRANSPORT_PCIE: + printf(" transport=pcie\n"); + break; default: if (op->verbose > 1) pr2serr("No transport information\n"); @@ -1999,24 +2449,25 @@ /* Attempt to determine the transport type of the SCSI device (LU) associated * with 'devname'. If found set transport_id, place string in 'b' and return - * 1. Otherwise return 0. */ -static int -transport_tport(const char * devname, /* const struct lsscsi_opts * op, */ + * true. Otherwise return false. */ +static bool +transport_tport(const char * devname, const struct lsscsi_opts * op, int b_len, char * b) { + bool ata_dev; + int off, n; + char * cp; char buff[LMAX_DEVPATH]; char wd[LMAX_PATH]; char nm[LMAX_NAME]; char tpgt[LMAX_NAME]; - char * cp; struct addr_hctl hctl; - int off, n, ata_dev; struct stat a_stat; if (! parse_colon_list(devname, &hctl)) - return 0; + return false; - /* SAS host? */ + /* check for SAS host */ snprintf(buff, sizeof(buff), "%s%shost%d", sysfsroot, sas_host, hctl.h); if ((stat(buff, &a_stat) >= 0) && S_ISDIR(a_stat.st_mode)) { @@ -2026,14 +2477,14 @@ class_scsi_dev, devname); if (if_directory_chdir(buff, "device")) { if (NULL == getcwd(wd, sizeof(wd))) - return 0; + return false; cp = strrchr(wd, '/'); if (NULL == cp) - return 0; + return false; *cp = '\0'; cp = strrchr(wd, '/'); if (NULL == cp) - return 0; + return false; *cp = '\0'; cp = basename(wd); my_strcopy(sas_hold_end_device, cp, @@ -2045,25 +2496,30 @@ off = strlen(b); if (get_value(buff, "sas_address", b + off, b_len - off)) - return 1; - else - pr2serr("%s: no sas_address, wd=%s\n", - __func__, buff); + return true; + else { /* non-SAS device in SAS domain */ + snprintf(b + off, b_len - off, + "0x0000000000000000"); + if (op->verbose > 1) + pr2serr("%s: no sas_address, wd=%s\n", + __func__, buff); + return true; + } } else pr2serr("%s: down FAILED: %s\n", __func__, buff); - return 0; + return false; } - /* SPI host? */ + /* not SAS, so check for SPI host */ snprintf(buff, sizeof(buff), "%s%shost%d", sysfsroot, spi_host, hctl.h); if ((stat(buff, &a_stat) >= 0) && S_ISDIR(a_stat.st_mode)) { transport_id = TRANSPORT_SPI; snprintf(b, b_len, "spi:%d", hctl.t); - return 1; + return true; } - /* FC host? */ + /* no, so check for FC host */ snprintf(buff, sizeof(buff), "%s%shost%d", sysfsroot, fc_host, hctl.h); if ((stat(buff, &a_stat) >= 0) && S_ISDIR(a_stat.st_mode)) { @@ -2082,24 +2538,24 @@ off = strlen(b); if (get_value(buff, "port_name", b + off, b_len - off)) { off = strlen(b); - my_strcopy(b + off, ",", sizeof(b) - off); + my_strcopy(b + off, ",", b_len - off); off = strlen(b); } else - return 0; + return false; if (get_value(buff, "port_id", b + off, b_len - off)) - return 1; + return true; else - return 0; + return false; } - /* SRP host? */ + /* no, so check for SRP host */ snprintf(buff, sizeof(buff), "%s%shost%d", sysfsroot, srp_host, hctl.h); if (stat(buff, &a_stat) >= 0 && S_ISDIR(a_stat.st_mode)) { transport_id = TRANSPORT_SRP; snprintf(b, b_len, "srp:"); get_local_srp_gid(hctl.h, b + strlen(b), b_len - strlen(b)); - return 1; + return true; } /* SAS class representation or SBP? */ @@ -2110,14 +2566,14 @@ snprintf(b, b_len, "sas:"); off = strlen(b); if (get_value(".", "sas_addr", b + off, b_len - off)) - return 1; + return true; else pr2serr("%s: no sas_addr, wd=%s\n", __func__, buff); } else if (get_value(buff, "ieee1394_id", wd, sizeof(wd))) { /* IEEE1394 SBP device */ transport_id = TRANSPORT_SBP; snprintf(b, b_len, "sbp:%s", wd); - return 1; + return true; } /* iSCSI device? */ @@ -2125,20 +2581,20 @@ iscsi_host, hctl.h); if ((stat(buff, &a_stat) >= 0) && S_ISDIR(a_stat.st_mode)) { if (1 != iscsi_target_scan(buff, &hctl)) - return 0; + return false; transport_id = TRANSPORT_ISCSI; snprintf(buff, sizeof(buff), "%s%ssession%d", sysfsroot, iscsi_session, iscsi_tsession_num); if (! get_value(buff, "targetname", nm, sizeof(nm))) - return 0; + return false; if (! get_value(buff, "tpgt", tpgt, sizeof(tpgt))) - return 0; + return false; n = atoi(tpgt); // output target port name as per sam4r08, annex A, table A.3 snprintf(b, b_len, "%s,t,0x%x", nm, n); // >>> That reference says maximum length of targetname is 223 bytes // (UTF-8) excluding trailing null. - return 1; + return true; } /* USB device? */ @@ -2146,18 +2602,18 @@ if (cp) { transport_id = TRANSPORT_USB; snprintf(b, b_len, "usb:%s", cp); - return 1; + return true; } /* ATA or SATA device, crude check: driver name */ snprintf(buff, sizeof(buff), "%s%shost%d", sysfsroot, scsi_host, hctl.h); if (get_value(buff, "proc_name", wd, sizeof(wd))) { - ata_dev = 0; + ata_dev = false; if (0 == strcmp("ahci", wd)) { transport_id = TRANSPORT_SATA; snprintf(b, b_len, "sata:"); - ata_dev = 1; + ata_dev = true; } else if (strstr(wd, "ata")) { if (0 == memcmp("sata", wd, 4)) { transport_id = TRANSPORT_SATA; @@ -2166,16 +2622,16 @@ transport_id = TRANSPORT_ATA; snprintf(b, b_len, "ata:"); } - ata_dev = 1; + ata_dev = true; } if (ata_dev) { off = strlen(b); snprintf(b + off, b_len - off, "%s", - get_lu_name(devname, wd, sizeof(wd))); - return 1; + get_lu_name(devname, wd, sizeof(wd), false)); + return true; } } - return 0; + return false; } /* Given the transport_id of the SCSI device (LU) associated with 'devname' @@ -2183,13 +2639,13 @@ static void transport_tport_longer(const char * devname, const struct lsscsi_opts * op) { + char * cp; char path_name[LMAX_DEVPATH]; char buff[LMAX_DEVPATH]; char b2[LMAX_DEVPATH]; char wd[LMAX_PATH]; char value[LMAX_NAME]; struct addr_hctl hctl; - char * cp; #if 0 snprintf(buff, sizeof(buff), "%s/scsi_device:%s", path_name, devname); @@ -2267,7 +2723,9 @@ printf(" port_state=%s\n", value); if (get_value(buff, "roles", value, sizeof(value))) printf(" roles=%s\n", value); - print_enclosure_device(devname, b2, op); +// xxxxxxxxxxxx following call to print_enclosure_device fails since b2 is +// inappropriate, comment out since might be useless (check with FCP folks) + // print_enclosure_device(devname, b2, op); if (get_value(buff, "scsi_target_id", value, sizeof(value))) printf(" scsi_target_id=%s\n", value); if (get_value(buff, "supported_classes", value, @@ -2284,7 +2742,7 @@ break; case TRANSPORT_SRP: printf(" transport=srp\n"); - if (!parse_colon_list(devname, &hctl)) + if (! parse_colon_list(devname, &hctl)) break; if (get_srp_orig_dgid(hctl.h, value, sizeof(value))) printf(" orig_dgid=%s\n", value); @@ -2429,13 +2887,13 @@ break; case TRANSPORT_ATA: printf(" transport=ata\n"); - cp = get_lu_name(devname, b2, sizeof(b2)); + cp = get_lu_name(devname, b2, sizeof(b2), false); if (strlen(cp) > 0) printf(" wwn=%s\n", cp); break; case TRANSPORT_SATA: printf(" transport=sata\n"); - cp = get_lu_name(devname, b2, sizeof(b2)); + cp = get_lu_name(devname, b2, sizeof(b2), false); if (strlen(cp) > 0) printf(" wwn=%s\n", cp); break; @@ -2452,7 +2910,7 @@ { char value[LMAX_NAME]; - if (op->transport > 0) { + if (op->transport_info) { transport_tport_longer(devname, op); return; } @@ -2569,16 +3027,95 @@ } } +#if (HAVE_NVME && (! IGNORE_NVME)) + +/* NVMe longer data for namespace listing */ +static void +longer_nd_entry(const char * path_name, const char * devname, + const struct lsscsi_opts * op) +{ + char value[LMAX_NAME]; + const int vlen = sizeof(value); + + if (devname) { ; } /* suppress warning */ + if (op->long_opt) { + bool sing = (op->long_opt > 2); + const char * sep = sing ? "\n" : ""; + + if (get_value(path_name, "capability", value, vlen)) + printf(" capability=%s%s", value, sep); + else + printf(" capability=?%s", sep); + if (get_value(path_name, "ext_range", value, vlen)) + printf(" ext_range=%s%s", value, sep); + else + printf(" ext_range=?%s", sep); + if (get_value(path_name, "hidden", value, vlen)) + printf(" hidden=%s%s", value, sep); + else + printf(" hidden=?%s", sep); + if (get_value(path_name, "nsid", value, vlen)) + printf(" nsid=%s%s", value, sep); + else + printf(" nsid=?%s", sep); + if (get_value(path_name, "range", value, vlen)) + printf(" range=%s%s", value, sep); + else + printf(" range=?%s", sep); + if (get_value(path_name, "removable", value, vlen)) + printf(" removable=%s%s", value, sep); + else + printf(" removable=?%s", sep); + if (op->long_opt > 1) { + if (! sing) + printf("\n"); + if (get_value(path_name, "queue/nr_requests", value, + vlen)) + printf(" nr_requests=%s%s", value, sep); + else + printf(" nr_requests=?%s", sep); + if (get_value(path_name, "queue/read_ahead_kb", value, + vlen)) + printf(" read_ahead_kb=%s%s", value, sep); + else + printf(" read_ahead_kb=?%s", sep); + if (get_value(path_name, "queue/write_cache", value, + vlen)) + printf(" write_cache=%s%s", value, sep); + else + printf(" write_cache=?%s", sep); + if (! sing) + printf("\n"); + if (get_value(path_name, "queue/logical_block_size", + value, vlen)) + printf(" logical_block_size=%s%s", value, + sep); + else + printf(" logical_block_size=?%s", sep); + if (get_value(path_name, "queue/physical_block_size", + value, vlen)) + printf(" physical_block_size=%s%s", value, + sep); + else + printf(" physical_block_size=?%s", sep); + } + if (! sing) + printf("\n"); + } +} + +#endif /* (HAVE_NVME && (! IGNORE_NVME)) */ + static void one_classic_sdev_entry(const char * dir_name, const char * devname, const struct lsscsi_opts * op) { - struct addr_hctl hctl; + int type, scsi_level; char buff[LMAX_DEVPATH]; char wd[LMAX_PATH]; char dev_node[LMAX_NAME]; char value[LMAX_NAME]; - int type, scsi_level; + struct addr_hctl hctl; snprintf(buff, sizeof(buff), "%s/%s", dir_name, devname); if (! parse_colon_list(devname, &hctl)) @@ -2656,10 +3193,11 @@ * prefixed. Example: lunp: 01 22 00 33 00 00 00 00 generates tag_arr * of 1, 1, 2, 1, 0 ... 0 and might be printed as 0x0122_0033 . */ static void -tag_lun(const unsigned char * lunp, int * tag_arr) +tag_lun(const uint8_t * lunp, int * tag_arr) { - int k, a_method, bus_id, len_fld, e_a_method, next_level; - unsigned char not_spec[2] = {0xff, 0xff}; + bool next_level; + int k, a_method, bus_id, len_fld, e_a_method; + uint8_t not_spec[2] = {0xff, 0xff}; if (NULL == tag_arr) return; @@ -2673,13 +3211,13 @@ return; } for (k = 0; k < 4; ++k, lunp += 2) { - next_level = 0; + next_level = false; a_method = (lunp[0] >> 6) & 0x3; switch (a_method) { case 0: /* peripheral device addressing method */ bus_id = lunp[0] & 0x3f; if (bus_id) - next_level = 1; + next_level = true; tag_lun_helper(tag_arr, k, 2); break; case 1: /* flat space addressing method */ @@ -2720,71 +3258,54 @@ } } -static uint64_t -lun_word_flip(uint64_t in) -{ - uint64_t res = 0; - int k; - - for (k = 0; ; ++k) { - res |= (in & 0xffff); - if (k > 2) - break; - res <<= 16; - in >>= 16; - } - return res; -} - /* List one SCSI device (LU) on a line. */ static void one_sdev_entry(const char * dir_name, const char * devname, const struct lsscsi_opts * op) { + bool get_wwn = false; + int type, n, vlen; + int devname_len = 13; char buff[LMAX_DEVPATH]; - char wd[LMAX_PATH]; char extra[LMAX_DEVPATH]; char value[LMAX_NAME]; - int type, k, n, len, ta; - int devname_len = 13; - int get_wwn = 0; + char wd[LMAX_PATH]; struct addr_hctl hctl; - int tag_arr[16]; if (op->classic) { one_classic_sdev_entry(dir_name, devname, op); return; } - len = sizeof(value); + vlen = sizeof(value); snprintf(buff, sizeof(buff), "%s/%s", dir_name, devname); if (op->lunhex && parse_colon_list(devname, &hctl)) { - snprintf(value, len, "[%d:%d:%d:0x", - hctl.h, hctl.c, hctl.t); - if (1 == op->lunhex) { - tag_lun(hctl.lun_arr, tag_arr); - for (k = 0; k < 8; ++k) { - ta = tag_arr[k]; - if (ta <= 0) - break; - n = strlen(value); - snprintf(value + n, len - n, "%s%02x", - ((ta > 1) ? "_" : ""), - hctl.lun_arr[k]); - } - n = strlen(value); - snprintf(value + n, len - n, "]"); - } else { - n = strlen(value); - snprintf(value + n, len - n, "%016" PRIx64 "]", - lun_word_flip(hctl.l)); - } + int sel_mask = 0xf; + char b[80]; + + sel_mask |= (1 == op->lunhex) ? 0x10 : 0x20; + snprintf(value, vlen, "[%s]", + tuple2string(&hctl, sel_mask, sizeof(b), b)); devname_len = 28; } else - snprintf(value, sizeof(value), "[%s]", devname); + snprintf(value, vlen, "[%s]", devname); - /* left justified with field length of devname_len */ - printf("%-*s", devname_len, value); - if (! get_value(buff, "type", value, sizeof(value))) { + if ((int)strlen(value) >= devname_len) + printf("%s ", value); /* if very long, append a space */ + else /* left justified with field length of devname_len */ + printf("%-*s", devname_len, value); + if (op->pdt) { + char b[16]; + + if (get_value(buff, "type", value, vlen) && + (1 == sscanf(value, "%d", &type)) && + (type >= 0) && (type < 32)) + snprintf(b, sizeof(b), "0x%x", type); + else + snprintf(b, sizeof(b), "-1"); + printf("%-8s", b); + } else if (op->brief) + ; + else if (! get_value(buff, "type", value, vlen)) { printf("type? "); } else if (1 != sscanf(value, "%d", &type)) { printf("type?? "); @@ -2794,17 +3315,18 @@ printf("%s ", scsi_short_device_types[type]); if (op->wwn) - ++get_wwn; - if (op->transport) { - if (transport_tport(devname, /* op, */ - sizeof(value), value)) + get_wwn = true; + if (op->transport_info) { + if (transport_tport(devname, op, vlen, value)) printf("%-30s ", value); else printf(" "); } else if (op->unit) { - get_lu_name(devname, value, sizeof(value)); + get_lu_name(devname, value, vlen, op->unit > 3); n = strlen(value); - if (1 == op->unit) { + if (n < 1) /* left justified "none" means no lu name */ + printf("%-32s ", "none"); + else if (1 == op->unit) { if (n < 33) printf("%-32s ", value); else { @@ -2820,22 +3342,20 @@ value[n - 32] = '_'; printf("%-32s ", value + n - 32); } - } else { /* -uuu, output in full, skip rest of line */ - printf("%-s\n", value); - return; - } - } else { - if (get_value(buff, "vendor", value, sizeof(value))) + } else /* -uuu, output in full, append rest of line */ + printf("%-s ", value); + } else if (! op->brief) { + if (get_value(buff, "vendor", value, vlen)) printf("%-8s ", value); else printf("vendor? "); - if (get_value(buff, "model", value, sizeof(value))) + if (get_value(buff, "model", value, vlen)) printf("%-16s ", value); else printf("model? "); - if (get_value(buff, "rev", value, sizeof(value))) + if (get_value(buff, "rev", value, vlen)) printf("%-4s ", value); else printf("rev? "); @@ -2863,14 +3383,15 @@ } if (wd[0]) { char dev_node[LMAX_NAME] = ""; - char wwn_str[34]; + char wwn_str[DISK_WWN_MAX_LEN]; enum dev_type typ; typ = (FT_BLOCK == non_sg.ft) ? BLK_DEV : CHR_DEV; if (get_wwn) { if ((BLK_DEV == typ) && get_disk_wwn(wd, wwn_str, sizeof(wwn_str))) - printf("%-30s ", wwn_str); + printf("%-*s ", DISK_WWN_MAX_LEN - 1, + wwn_str); else printf(" " " "); @@ -2885,8 +3406,7 @@ printf("%-9s", dev_node); if (op->dev_maj_min) { - if (get_value(wd, "dev", value, - sizeof(value))) + if (get_value(wd, "dev", value, vlen)) printf("[%s]", value); else printf("[dev?]"); @@ -2983,29 +3503,59 @@ printf(" %-4s", "-"); } - if (op->size) { + if (op->ssize) { + uint64_t blk512s; char blkdir[LMAX_DEVPATH]; my_strcopy(blkdir, buff, sizeof(blkdir)); - value[0] = 0; - if (type == 0 && - block_scan(blkdir) && - if_directory_chdir(blkdir, ".") && - get_value(".", "size", value, sizeof(value))) { - uint64_t blocks = atoll(value); - - blocks <<= 9; - if (blocks > 0 && - !string_get_size(blocks, STRING_UNITS_10, value, - sizeof(value))) { - printf(" %6s", value); + if (! ((0 == type) && block_scan(blkdir) && + if_directory_chdir(blkdir, ".") && + get_value(".", "size", value, vlen)) ) { + printf(" %6s", "-"); + goto fini_line; + } + blk512s = atoll(value); + + if (op->ssize > 2) { + int lbs = 0; + char bb[32]; + + if (get_value(".", "queue/logical_block_size", bb, + sizeof(bb))) { + lbs = atoi(bb); + if (lbs < 1) + printf(" %12s,[lbs<1 ?]", value); + else if (512 == lbs) + printf(" %12s%s", value, + (op->ssize > 3) ? ",512" : ""); + else { + int64_t byts = 512 * blk512s; + + snprintf(value, vlen, "%" PRId64, + (byts / lbs)); + if (op->ssize > 3) + printf(" %12s,%d", value, + lbs); + else + printf(" %12s", value); + } } else + printf(" %12s,512", value); + } else { + enum string_size_units unit_val = (0x1 & op->ssize) ? + STRING_UNITS_10 : STRING_UNITS_2; + + blk512s <<= 9; + if (blk512s > 0 && + size2string(blk512s, unit_val, value, vlen)) + printf(" %6s", value); + else printf(" %6s", "-"); - } else - printf(" %6s", "-"); + } } +fini_line: printf("\n"); if (op->long_opt > 0) longer_d_entry(buff, devname, op); @@ -3022,7 +3572,7 @@ } static int -sdev_scandir_select(const struct dirent * s) +sdev_dir_scan_select(const struct dirent * s) { /* Following no longer needed but leave for early lk 2.6 series */ if (strstr(s->d_name, "mt")) @@ -3047,7 +3597,7 @@ if (((-1 == filter.h) || (s_hctl.h == filter.h)) && ((-1 == filter.c) || (s_hctl.c == filter.c)) && ((-1 == filter.t) || (s_hctl.t == filter.t)) && - (((uint64_t)~0 == filter.l) || + ((UINT64_LAST == filter.l) || (s_hctl.l == filter.l))) return 1; else @@ -3059,11 +3609,423 @@ return 0; } -/* Returns -1 if (a->d_name < b->d_name) ; 0 if they are equal - * and 1 otherwise. - * Function signature was more generic before version 0.23 : - * static int sdev_scandir_sort(const void * a, const void * b) - */ +#if (HAVE_NVME && (! IGNORE_NVME)) + +/* List one NVMe namespace (NS) on a line. */ +static void +one_ndev_entry(const char * nvme_ctl_abs, const char * nvme_ns_rel, + const struct lsscsi_opts * op) +{ + int n, m; + int cdev_minor = 0; + int cntlid = 0; + int vb = op->verbose; + int devname_len = 13; + int sel_mask = 0xf; + uint32_t nsid = 0; + char * cp; + char buff[LMAX_DEVPATH]; + char value[LMAX_NAME]; + char dev_node[LMAX_NAME + 16] = ""; + char wd[LMAX_PATH]; + char devname[64]; + char ctl_model[48]; + char b[80]; + const int vlen = sizeof(value); + struct addr_hctl hctl; + + snprintf(buff, sizeof(buff), "%s/%s", nvme_ctl_abs, nvme_ns_rel); + if ((0 == strncmp(nvme_ns_rel, "nvme", 4)) && + (1 == sscanf(nvme_ns_rel + 4, "%d", &cdev_minor))) + ; + else if (vb) + pr2serr("%s: unable to find %s in %s\n", __func__, + "cdev_minor", nvme_ns_rel); + + if (get_value(nvme_ctl_abs, "cntlid", value, vlen)) { + if (1 != sscanf(value, "%d", &cntlid)) { + if (vb) + pr2serr("%s: trying to decode: %s as " + "cntlid\n", __func__, value); + } + if (filter_active && (-1 != filter.t) && (cntlid != filter.t)) + return; /* doesn't meet filter condition */ + } else if (vb) + pr2serr("%s: unable to find %s under %s\n", __func__, + "cntlid", nvme_ctl_abs); + +#ifdef __cplusplus + cp = strrchr((char *)nvme_ns_rel, 'n'); +#else + cp = strrchr(nvme_ns_rel, 'n'); +#endif + if ((NULL == cp) || ('v' == *(cp + 1)) || + (1 != sscanf(cp + 1, "%u", &nsid))) { + if (vb) + pr2serr("%s: unable to find nsid in %s\n", __func__, + nvme_ns_rel); + } + mk_nvme_tuple(&hctl, cdev_minor, cntlid, nsid); + + if (op->lunhex) { + sel_mask |= (1 == op->lunhex) ? 0x10 : 0x20; + devname_len = 28; + } + snprintf(value, vlen, "[%s]", + tuple2string(&hctl, sel_mask, sizeof(devname), devname)); + + if ((int)strlen(value) >= devname_len) + printf("%s ", value); /* if very long, append a space */ + else /* left justified with field length of devname_len */ + printf("%-*s", devname_len, value); + + if (op->pdt) + printf("%-8s", "0x0"); + else if (op->brief) + ; + else if (vb) /* NVMe namespace can only be NVM device */ + printf("dsk/nvm "); + else + printf("disk "); + + + if (op->wwn) { + if (get_value(buff, "wwid", value, vlen)) + printf("%-41s ", value); + else + printf("%-41s ", "wwid?"); + } else if (op->transport_info) { + if (get_value(buff, "device/transport", value, vlen)) { + const char * svp = "device/device/subsystem_vendor"; + const char * sdp = "device/device/subsystem_device"; + char bb[80]; + + if (0 == strcmp("pcie" , value)) { + + if (get_value(buff, svp, b, sizeof(b)) && + get_value(buff, sdp, bb, sizeof(bb))) { + snprintf(value , vlen, "pcie %s:%s", + b, bb); + printf("%-41s ", value); + } else + printf("%-41s ", "transport?"); + } else + printf("%-41s ", value); + } else + printf("%-41s ", "transport?"); + } else if (op->unit) { + if (get_value(buff, "wwid", value, vlen)) { + if ((op->unit < 4) && + (0 == strncmp("eui.", value, 4))) + printf("%-41s ", value + 4); + else + printf("%-41s ", value); + } else + printf("%-41s ", "wwid?"); + } else if (! op->brief) { + if (! get_value(nvme_ctl_abs, "model", ctl_model, + sizeof(ctl_model))) + snprintf(ctl_model, sizeof(ctl_model), "- "); + n = trim_lead_trail(ctl_model, true, true); + snprintf(b, sizeof(b), "__%u", nsid); + m = strlen(b); + if (n > (41 - m)) + memcpy(ctl_model + 41 - m, b, m + 1); + else + strcat(ctl_model, b); + printf("%-41s ", ctl_model); + } + + if (op->kname) + snprintf(dev_node, sizeof(dev_node), "%s/%s", + dev_dir, nvme_ns_rel); + else if (! get_dev_node(buff, dev_node, BLK_DEV)) + snprintf(dev_node, sizeof(dev_node), "- "); + + printf("%-9s", dev_node); + if (op->dev_maj_min) { + if (get_value(buff, "dev", value, vlen)) + printf(" [%s]", value); + else + printf(" [dev?]"); + } + + if (op->ssize) { + uint64_t blk512s; + + if (! get_value(buff, "size", value, vlen)) { + printf(" %6s", "-"); + goto fini_line; + } + blk512s = atoll(value); + /* tabbing 8 should be banned, use goto to win some space */ + if (op->ssize > 2) { + int lbs = 0; + char bb[32]; + + if (get_value(buff, "queue/logical_block_size", bb, + sizeof(bb))) { + lbs = atoi(bb); + if (lbs < 1) + printf(" %12s,[lbs<1 ?]", value); + else if (512 == lbs) + printf(" %12s%s", value, + (op->ssize > 3) ? ",512" : ""); + else { + int64_t byts = 512 * blk512s; + + snprintf(value, vlen, "%" PRId64, + (byts / lbs)); + if (op->ssize > 3) + printf(" %12s,%d", value, + lbs); + else + printf(" %12s", value); + } + } else + printf(" %12s,512", value); + } else { + enum string_size_units unit_val = (0x1 & op->ssize) ? + STRING_UNITS_10 : STRING_UNITS_2; + + blk512s <<= 9; + if (blk512s > 0 && + size2string(blk512s, unit_val, value, vlen)) + printf(" %6s", value); + else + printf(" %6s", "-"); + } + } + +fini_line: + printf("\n"); + if (op->long_opt > 0) + longer_nd_entry(buff, devname, op); + if (vb > 0) { + printf(" dir: %s [", buff); + if (if_directory_chdir(buff, "")) { + if (NULL == getcwd(wd, sizeof(wd))) + printf("?"); + else + printf("%s", wd); + } + printf("]\n"); + } +} + +static int +ndev_dir_scan_select(const struct dirent * s) +{ + int cdev_minor; /* /dev/nvme char device minor */ + + if ((0 == strncmp(s->d_name, "nvme", 4)) && + (1 == sscanf(s->d_name + 4, "%d", &cdev_minor))) { + if (filter_active) { + if (((-1 == filter.h) || + (NVME_HOST_NUM == filter.h)) && + ((-1 == filter.c) || (cdev_minor == filter.c))) + return 1; + else + return 0; + } else + return 1; + } + return 0; +} + +static int +ndev_dir_scan_select2(const struct dirent * s) +{ + int cdev_minor; + uint32_t nsid; + char * cp; + + /* What to do about NVMe controller CNTLID field? */ + if (strncmp(s->d_name, "nvme", 4)) + return 0; +#ifdef __cplusplus + cp = strchr((char *)s->d_name + 4, 'n'); +#else + cp = strchr(s->d_name + 4, 'n'); +#endif + if (NULL == cp) + return 0; + if ((1 == sscanf(s->d_name + 4, "%d", &cdev_minor)) && + (1 == sscanf(cp + 1, "%u", &nsid))) { + if (filter_active) { /* filter cntlid (.t) in caller */ + if (((-1 == filter.h) || + (NVME_HOST_NUM == filter.h)) && + ((-1 == filter.c) || (cdev_minor == filter.c)) && + /* ((-1 == filter.t) || (s_hctl.t == filter.t)) && */ + ((UINT64_LAST == filter.l) || (nsid == filter.l))) + return 1; + else + return 0; + } else + return 1; + } + return 0; +} + +static void +one_nhost_entry(const char * dir_name, const char * nvme_ctl_rel, + const struct lsscsi_opts * op) +{ + int vlen; + int vb = op->verbose; + uint32_t cdev_minor; + const char * nullname1 = ""; + const char * nullname2 = "(null)"; + char buff[LMAX_DEVPATH]; + char value[LMAX_DEVPATH]; + char wd[LMAX_PATH]; + char b[80]; + char bb[80]; + + vlen = sizeof(value); + if (1 == sscanf(nvme_ctl_rel, "nvme%u", &cdev_minor)) + printf("[N:%u] ", cdev_minor); + else + printf("[N:?] "); + snprintf(buff, sizeof(buff), "%s%s", dir_name, nvme_ctl_rel); + + if (op->kname) + snprintf(value, vlen, "%s/%s", dev_dir, nvme_ctl_rel); + else if (! get_dev_node(buff, value, CHR_DEV)) + snprintf(value, vlen, "- "); + printf("%-9s", value); + if (op->dev_maj_min) { + char * bp; + + bp = name_eq2value(buff, "uevent", "MAJOR", sizeof(b), b); + if (strlen(bp) > 1) + printf(" [%s:%s]", bp, name_eq2value(buff, "uevent", + "MINOR", sizeof(bb), bb)); + else + printf(" [dev?]"); + } + if (op->transport_info) { + const char * svp = "device/subsystem_vendor"; + const char * sdp = "device/subsystem_device"; + + printf(" "); + if (get_value(buff, "transport", value, vlen)) { + if (0 == strcmp("pcie" , value)) { + if (get_value(buff, svp, b, sizeof(b)) && + get_value(buff, sdp, bb, sizeof(bb))) + printf("pcie %s:%s", b, bb); + else + printf("pcie ?:?"); + } else + printf("%s%s\n", (vb ? "transport=" : ""), + value); + } else if (vb) + printf("transport=?\n"); + printf("\n"); + } else if (op->wwn) { + if (get_value(buff, "subsysnqn", value, vlen)) + printf(" %s%s\n", (vb ? "subsysnqn=" : ""), + value); + else if (vb) + printf("subsysnqn=?\n"); + } else if (op->unit) { + if (get_value(buff, "device/subsystem_vendor", value, vlen)) { + printf(" %s%s:", (vb ? "vin=" : ""), value); + if (get_value(buff, "device/subsystem_device", value, + vlen)) + printf("%s\n", value); + else + printf("??\n"); + } else if (vb) + printf("subsystem_vendor=?\n"); + } else if (op->long_opt > 0) { + bool sing = (op->long_opt > 2); + const char * sep = sing ? "\n" : ""; + + if (get_value(buff, "cntlid", value, vlen)) + printf("%s cntlid=%s%s", sep, value, sep); + else if (vb) + printf("%s cntlid=?%s", sep, sep); + if (get_value(buff, "state", value, vlen)) + printf(" state=%s%s", value, sep); + else if (vb) + printf(" state=?%s", sep); + if (get_value(buff, "device/current_link_width", value, vlen)) + printf(" current_link_width=%s%s", value, sep); + else if (vb) + printf(" current_link_width=?%s", sep); + if (get_value(buff, "firmware_rev", value, vlen)) + printf(" firmware_rev=%s%s", value, sep); + else if (vb) + printf(" firmware_rev=?%s", sep); + if (! sing) + printf("\n"); + if (op->long_opt > 1) { + if (get_value(buff, "device/current_link_speed", + value, vlen)) + printf(" current_link_speed=%s%s", value, + sep); + else if (vb) + printf(" current_link_speed=?%s", sep); + if (get_value(buff, "model", value, vlen)) { + trim_lead_trail(value, true, true); + printf(" model=%s%s", value, sep); + } else if (vb) + printf(" model=?%s", sep); + if (get_value(buff, "serial", value, vlen)) { + trim_lead_trail(value, true, true); + printf(" serial=%s%s", value, sep); + } else if (vb) + printf(" serial=?%s", sep); + if (! sing) + printf("\n"); + } + } else if (! op->brief) { + if (get_value(buff, "model", value, vlen) && + strncmp(value, nullname1, 6) && + strncmp(value, nullname2, 6)) { + trim_lead_trail(value, true, true); + trunc_pad2n(value, 32, true); + } else + strcpy(value, nullname1); + printf(" %-32s ", value); + + if (get_value(buff, "serial", value, vlen) && + strncmp(value, nullname1, 6) && + strncmp(value, nullname2, 6)) { + trim_lead_trail(value, true, true); + trunc_pad2n(value, 18, true); + } else + strcpy(value, nullname1); + printf(" %-18s ", value); + + if (get_value(buff, "firmware_rev", value, vlen) && + strncmp(value, nullname1, 6) && + strncmp(value, nullname2, 6)) { + trim_lead_trail(value, true, true); + trunc_pad2n(value, 8, false); + } else + strcpy(value, nullname1); + printf(" %-8s\n", value); + } else + printf("\n"); + if (vb > 0) { + printf(" dir: %s\n device dir: ", buff); + if (if_directory_chdir(buff, "device")) { + if (NULL == getcwd(wd, sizeof(wd))) + printf("?"); + else + printf("%s", wd); + } + printf("\n"); + } +} + +#endif /* (HAVE_NVME && (! IGNORE_NVME)) */ + +/* This is a compare function for numeric sort based on hctl tuple. + * Returns -1 if (a->d_name < b->d_name) ; 0 if they are equal + * and 1 otherwise. */ static int sdev_scandir_sort(const struct dirent ** a, const struct dirent ** b) { @@ -3073,32 +4035,88 @@ struct addr_hctl right_hctl; if (! parse_colon_list(lnam, &left_hctl)) { - pr2serr("%s: left parse failed\n", __func__); + pr2serr("%s: left parse failed: %.20s\n", __func__, + (lnam ? lnam : "")); return -1; } if (! parse_colon_list(rnam, &right_hctl)) { - pr2serr("%s: right parse failed\n", __func__); + pr2serr("%s: right parse failed: %.20s\n", __func__, + (rnam ? rnam : "")); return 1; } return cmp_hctl(&left_hctl, &right_hctl); } +#if (HAVE_NVME && (! IGNORE_NVME)) + +/* This is a compare function for numeric sort based on hctl tuple. Similar + * to sdev_scandir_sort() but converts entries like "nvme2" into a hctl tuple. + * Returns -1 if (a->d_name < b->d_name) ; 0 if they are equal + * and 1 otherwise. */ +static int +nhost_scandir_sort(const struct dirent ** a, const struct dirent ** b) +{ + const char * lnam = (*a)->d_name; + const char * rnam = (*b)->d_name; + struct addr_hctl left_hctl; + struct addr_hctl right_hctl; + + if (strchr(lnam, ':')) { + if (! parse_colon_list(lnam, &left_hctl)) { + pr2serr("%s: left parse failed: %.20s\n", __func__, + (lnam ? lnam : "")); + return -1; + } + } else { + if (1 == sscanf(lnam, "nvme%d", &left_hctl.c)) { + left_hctl.h = NVME_HOST_NUM; + left_hctl.t = 0; + left_hctl.l = 0; + } else { + pr2serr("%s: left sscanf failed: %.20s\n", __func__, + (lnam ? lnam : "")); + return -1; + } + } + if (strchr(rnam, ':')) { + if (! parse_colon_list(rnam, &right_hctl)) { + pr2serr("%s: right parse failed: %.20s\n", __func__, + (rnam ? rnam : "")); + return 1; + } + } else { + if (1 == sscanf(rnam, "nvme%d", &right_hctl.c)) { + right_hctl.h = NVME_HOST_NUM; + right_hctl.t = 0; + right_hctl.l = 0; + } else { + pr2serr("%s: right sscanf failed: %.20s\n", __func__, + (rnam ? rnam : "")); + return -1; + } + } + return cmp_hctl(&left_hctl, &right_hctl); +} + +#endif /* (HAVE_NVME && (! IGNORE_NVME)) */ + /* List SCSI devices (LUs). */ static void list_sdevices(const struct lsscsi_opts * op) { + int num, k; + struct dirent ** namelist; char buff[LMAX_DEVPATH]; char name[LMAX_NAME]; - struct dirent ** namelist; - int num, k; snprintf(buff, sizeof(buff), "%s%s", sysfsroot, bus_scsi_devs); - num = scandir(buff, &namelist, sdev_scandir_select, + num = scandir(buff, &namelist, sdev_dir_scan_select, sdev_scandir_sort); if (num < 0) { /* scsi mid level may not be loaded */ if (op->verbose > 0) { - snprintf(name, sizeof(name), "scandir: %s", buff); + snprintf(name, sizeof(name), "%s: scandir: %s", + __func__, buff); perror(name); printf("SCSI mid level module may not be loaded\n"); } @@ -3120,13 +4138,72 @@ free_disk_wwn_node_list(); } +#if (HAVE_NVME && (! IGNORE_NVME)) + +/* List NVME devices (namespaces). */ +static void +list_ndevices(const struct lsscsi_opts * op) +{ + int num, num2, k, j; + struct dirent ** name_list; + struct dirent ** namelist2; + char buff[LMAX_DEVPATH]; + char buff2[LMAX_DEVPATH]; + char ebuf[120]; + + snprintf(buff, sizeof(buff), "%s%s", sysfsroot, class_nvme); + + num = scandir(buff, &name_list, ndev_dir_scan_select, + nhost_scandir_sort); + if (num < 0) { /* NVMe module may not be loaded */ + if (op->verbose > 0) { + snprintf(ebuf, sizeof(ebuf), "%s: scandir: %s", + __func__, buff); + perror(ebuf); + printf("NVMe module may not be loaded\n"); + } + return; + } + for (k = 0; k < num; ++k) { + snprintf(buff2, sizeof(buff2), "%s%s", buff, + name_list[k]->d_name); + free(name_list[k]); + num2 = scandir(buff2, &namelist2, ndev_dir_scan_select2, + sdev_scandir_sort); + if (num2 < 0) { + if (op->verbose > 0) { + snprintf(ebuf, sizeof(ebuf), "%s: scandir" + "(2): %s", __func__, buff); + perror(ebuf); + } + /* already freed name_list[k] so move to next */ + ++k; + break; + } + for (j = 0; j < num2; ++j) { + transport_id = TRANSPORT_UNKNOWN; + one_ndev_entry(buff2, namelist2[j]->d_name, op); + free(namelist2[j]); + } + free(namelist2); + } + for ( ; k < num; ++k) /* clean out rest of name_list[] */ + free(name_list[k]); + + free(name_list); + if (op->wwn) + free_disk_wwn_node_list(); +} + +#endif /* (HAVE_NVME && (! IGNORE_NVME)) */ + /* List host (initiator) attributes when --long given (one or more times). */ static void longer_h_entry(const char * path_name, const struct lsscsi_opts * op) { char value[LMAX_NAME]; - if (op->transport > 0) { + if (op->transport_info) { transport_init_longer(path_name, op); return; } @@ -3203,12 +4280,12 @@ one_host_entry(const char * dir_name, const char * devname, const struct lsscsi_opts * op) { + unsigned int host_id; + const char * nullname1 = ""; + const char * nullname2 = "(null)"; char buff[LMAX_DEVPATH]; char value[LMAX_NAME]; char wd[LMAX_PATH]; - const char * nullname1 = ""; - const char * nullname2 = "(null)"; - unsigned int host_id; if (op->classic) { // one_classic_host_entry(dir_name, devname, op); @@ -3231,7 +4308,7 @@ } else printf(" proc_name=???? "); - if (op->transport > 0) { + if (op->transport_info) { if (transport_init(devname, /* op, */ sizeof(value), value)) printf("%s\n", value); else @@ -3255,7 +4332,7 @@ } static int -host_scandir_select(const struct dirent * s) +host_dir_scan_select(const struct dirent * s) { int h; @@ -3276,15 +4353,13 @@ /* Returns -1 if (a->d_name < b->d_name) ; 0 if they are equal * and 1 otherwise. - * Function signature was more generic before version 0.23 : - * static int host_scandir_sort(const void * a, const void * b) */ static int -host_scandir_sort(const struct dirent ** a, const struct dirent ** b) +shost_scandir_sort(const struct dirent ** a, const struct dirent ** b) { + unsigned int l, r; const char * lnam = (*a)->d_name; const char * rnam = (*b)->d_name; - unsigned int l, r; if (1 != sscanf(lnam, "host%u", &l)) return -1; @@ -3298,19 +4373,20 @@ } static void -list_hosts(const struct lsscsi_opts * op) +list_shosts(const struct lsscsi_opts * op) { + int num, k; + struct dirent ** namelist; char buff[LMAX_DEVPATH]; char name[LMAX_NAME]; - struct dirent ** namelist; - int num, k; snprintf(buff, sizeof(buff), "%s%s", sysfsroot, scsi_host); - num = scandir(buff, &namelist, host_scandir_select, - host_scandir_sort); + num = scandir(buff, &namelist, host_dir_scan_select, + shost_scandir_sort); if (num < 0) { - snprintf(name, sizeof(name), "scandir: %s", buff); + snprintf(name, sizeof(name), "%s: scandir: %s", + __func__, buff); perror(name); return; } @@ -3326,21 +4402,57 @@ free(namelist); } -/* Return 0 if able to decode, otherwise 1 */ -static int +#if (HAVE_NVME && (! IGNORE_NVME)) + +/* List NVME hosts (controllers). */ +static void +list_nhosts(const struct lsscsi_opts * op) +{ + int num, k; + struct dirent ** namelist; + char buff[LMAX_DEVPATH]; + char ebuf[120]; + + snprintf(buff, sizeof(buff), "%s%s", sysfsroot, class_nvme); + + num = scandir(buff, &namelist, ndev_dir_scan_select, + nhost_scandir_sort); + if (num < 0) { /* NVMe module may not be loaded */ + if (op->verbose > 0) { + snprintf(ebuf, sizeof(ebuf), "%s: scandir: %s", + __func__, buff); + perror(ebuf); + printf("NVMe module may not be loaded\n"); + } + return; + } + for (k = 0; k < num; ++k) { + transport_id = TRANSPORT_UNKNOWN; + one_nhost_entry(buff, namelist[k]->d_name, op); + free(namelist[k]); + } + free(namelist); + if (op->wwn) + free_disk_wwn_node_list(); +} + +#endif /* (HAVE_NVME && (! IGNORE_NVME)) */ + +/* Return true if able to decode, otherwise false */ +static bool one_filter_arg(const char * arg, struct addr_hctl * filtp) { + int val, k, n, res; + uint64_t val64; const char * cp; const char * cpe; char buff[64]; - int val, k, n, res; - uint64_t val64; cp = arg; while ((*cp == ' ') || (*cp == '\t') || (*cp == '[')) ++cp; if ('\0' == *cp) - return 0; + return true; for (k = 0; *cp; cp = cpe + 1, ++k) { cpe = strchr(cp, ':'); if (cpe) @@ -3350,30 +4462,37 @@ cpe = cp + n - 1; } val = -1; - val64 = (uint64_t)~0; + val64 = UINT64_LAST; if (n > ((int)sizeof(buff) - 1)) { pr2serr("intermediate sting in %s too long (n=%d)\n", arg, n); - return 1; + return false; } if ((n > 0) && ('-' != *cp) && ('*' != *cp) && ('?' != *cp)) { memcpy(buff, cp, n); buff[n] = '\0'; if (3 == k) { if (('0' == buff[0]) && - ('X' == toupper(buff[1]))) + ('X' == toupper((uint8_t)buff[1]))) res = sscanf(buff, "%" SCNx64 , &val64); else res = sscanf(buff, "%" SCNu64 , &val64); - } else + } else { res = sscanf(buff, "%d", &val); + if ((0 == res) && (0 == k) && (1 == n) && + ('N' == toupper((uint8_t)buff[0]))) { + /* take 'N' as NVMe indication */ + res = 1; + val = NVME_HOST_NUM; + } + } if ((1 != res) && (NULL == strchr(buff, ']'))) { ; pr2serr("cannot decode %s as an integer\n", buff); - return 1; + return false; } } switch (k) { @@ -3383,33 +4502,33 @@ case 3: filtp->l = val64; break; default: pr2serr("expect three colons at most in %s\n", arg); - return 1; + return false; } } - return 0; + return true; } -/* Return 0 if able to decode, otherwise 1 */ -static int +/* Return true if able to decode, otherwise false */ +static bool decode_filter_arg(const char * a1p, const char * a2p, const char * a3p, const char * a4p, struct addr_hctl * filtp) { - char b1[256]; - char * b1p; int n, rem; + char * b1p; + char b1[256]; if ((NULL == a1p) || (NULL == filtp)) { pr2serr("bad call to decode_filter\n"); - return 1; + return false; } filtp->h = -1; filtp->c = -1; filtp->t = -1; - filtp->l = (uint64_t)~0; + filtp->l = UINT64_LAST; if ((0 == strncmp("host", a1p, 4)) && (1 == sscanf(a1p, "host%d", &n)) && ( n >= 0)) { filtp->h = n; - return 0; + return true; } if ((NULL == a2p) || strchr(a1p, ':')) return one_filter_arg(a1p, filtp); @@ -3446,19 +4565,20 @@ err_out: pr2serr("filter arguments exceed internal buffer size (%d)\n", (int)sizeof(b1)); - return 1; + return false; } int main(int argc, char **argv) { + bool do_sdevices = true; + bool do_hosts = false; /* checked before do_sdevices */ int c; - int do_sdevices = 1; - int do_hosts = 0; - struct lsscsi_opts opts; - struct lsscsi_opts * op; + int version_count = 0; const char * cp; + struct lsscsi_opts * op; + struct lsscsi_opts opts; op = &opts; cp = getenv("LSSCSI_LUNHEX_OPT"); @@ -3467,32 +4587,41 @@ while (1) { int option_index = 0; - c = getopt_long(argc, argv, "cdghHiklLpPstuvVwxy:", + c = getopt_long(argc, argv, "bcCdDghHiklLNpPsStuUvVwxy:", long_options, &option_index); if (c == -1) break; switch (c) { + case 'b': + op->brief = true; + break; case 'c': - ++op->classic; + op->classic = true; + break; + case 'C': /* synonym for --hosts, NVMe perspective */ + do_hosts = true; break; case 'd': - ++op->dev_maj_min; + op->dev_maj_min = true; + break; + case 'D': /* --pdt */ + op->pdt = true; break; case 'g': - ++op->generic; + op->generic = true; break; case 'h': usage(); return 0; case 'H': - ++do_hosts; + do_hosts = true; break; case 'i': - ++op->scsi_id; + op->scsi_id = true; break; case 'k': - ++op->kname; + op->kname = true; break; case 'l': ++op->long_opt; @@ -3500,29 +4629,38 @@ case 'L': op->long_opt += 3; break; + case 'N': + op->no_nvme = true; + break; case 'p': - ++op->protection; + op->protection = true; break; case 'P': - ++op->protmode; + op->protmode = true; break; case 's': - ++op->size; + ++op->ssize; + break; + case 'S': + op->ssize += 3; break; case 't': - ++op->transport; + op->transport_info = true; break; case 'u': ++op->unit; break; + case 'U': + op->unit += 3; + break; case 'v': ++op->verbose; break; case 'V': - pr2serr("version: %s\n", version_str); - return 0; + ++version_count; + break; case 'w': - ++op->wwn; + op->wwn = true; break; case 'x': ++op->lunhex; @@ -3540,6 +4678,30 @@ return 1; } } + if (version_count > 0) { + int yr, mon, day; + char * p; + char b[64]; + + if (1 == version_count) { + pr2serr("version: %s\n", version_str); + return 0; + } + cp = strchr(version_str, '/'); + if (cp && (3 == sscanf(cp - 4, "%d/%d/%d", &yr, &mon, &day))) + ; + else { + pr2serr("version:: %s\n", version_str); + return 0; + } + strncpy(b, version_str, sizeof(b) - 1); + p = (char *)strchr(b, '/'); + snprintf(p - 4, sizeof(b) - (p - 4 - b), "%d%02d%02d ", + yr, mon, day); + b[strlen(b)] = ' '; + printf("%s\n", b); + return 0; + } if (optind < argc) { const char * a1p = NULL; @@ -3563,21 +4725,28 @@ a4p = argv[optind++]; } } - if (decode_filter_arg(a1p, a2p, a3p, a4p, &filter)) - return 1; + if ((0 == memcmp("host", a1p, 4)) || + (0 == memcmp("HOST", a1p, 4))) { + if (! decode_filter_arg(a1p + 4, a2p, a3p, a4p, + &filter)) + return 1; + } else { + if (! decode_filter_arg(a1p, a2p, a3p, a4p, &filter)) + return 1; + } if ((filter.h != -1) || (filter.c != -1) || - (filter.t != -1) || (filter.l != (uint64_t)~0)) - filter_active = 1; + (filter.t != -1) || (filter.l != UINT64_LAST)) + filter_active = true; } if ((0 == op->lunhex) && cp) { if (1 == sscanf(cp, "%d", &c)) op->lunhex = c; } - if (op->transport && op->unit) { + if (op->transport_info && op->unit) { pr2serr("use '--transport' or '--unit' but not both\n"); return 1; } - if (op->transport && + if (op->transport_info && ((1 == op->long_opt) || (2 == op->long_opt))) { pr2serr("please use '--list' (rather than '--long') with " "--transport\n"); @@ -3595,10 +4764,19 @@ if (op->verbose > 1) { printf(" sysfsroot: %s\n", sysfsroot); } - if (do_hosts) - list_hosts(op); - else if (do_sdevices) + if (do_hosts) { + list_shosts(op); +#if (HAVE_NVME && (! IGNORE_NVME)) + if (! op->no_nvme) + list_nhosts(op); +#endif + } else if (do_sdevices) { list_sdevices(op); +#if (HAVE_NVME && (! IGNORE_NVME)) + if (! op->no_nvme) + list_ndevices(op); +#endif + } free_dev_node_list(); diff -Nru lsscsi-0.28/src/Makefile.am lsscsi-0.30/src/Makefile.am --- lsscsi-0.28/src/Makefile.am 2014-08-25 19:03:01.000000000 +0000 +++ lsscsi-0.30/src/Makefile.am 2018-06-05 17:20:03.000000000 +0000 @@ -1,7 +1,7 @@ bin_PROGRAMS = lsscsi # C++/clang testing -## CC = gcc +## CC = gcc-8 ## CC = g++ ## CC = clang ## CC = clang++ @@ -12,8 +12,11 @@ # -std= can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W +# AM_CFLAGS = -Wall -W -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wshadow -Wjump-misses-init # AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11 +# AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11 --analyze # AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c++11 +# AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=gnu++1z lsscsi_SOURCES = lsscsi.c diff -Nru lsscsi-0.28/src/Makefile.in lsscsi-0.30/src/Makefile.in --- lsscsi-0.28/src/Makefile.in 2014-08-25 19:03:01.000000000 +0000 +++ lsscsi-0.30/src/Makefile.in 2018-05-03 21:15:12.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -76,14 +86,15 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ bin_PROGRAMS = lsscsi$(EXEEXT) subdir = src -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = @@ -147,10 +158,12 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -158,6 +171,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ @@ -165,7 +179,9 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EGREP = @EGREP@ EXEEXT = @EXEEXT@ +GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -195,6 +211,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -202,14 +219,22 @@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ +build = @build@ build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +host = @host@ host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ @@ -225,6 +250,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -240,8 +266,11 @@ # -std= can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W +# AM_CFLAGS = -Wall -W -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wshadow -Wjump-misses-init # AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11 +# AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11 --analyze # AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c++11 +# AM_CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=gnu++1z lsscsi_SOURCES = lsscsi.c all: all-am @@ -256,10 +285,9 @@ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile -.PRECIOUS: Makefile + $(AUTOMAKE) --foreign src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -550,6 +578,8 @@ ps ps-am tags tags-am uninstall uninstall-am \ uninstall-binPROGRAMS +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru lsscsi-0.28/src/sg_unaligned.h lsscsi-0.30/src/sg_unaligned.h --- lsscsi-0.28/src/sg_unaligned.h 1970-01-01 00:00:00.000000000 +0000 +++ lsscsi-0.30/src/sg_unaligned.h 2018-04-24 04:38:10.000000000 +0000 @@ -0,0 +1,489 @@ +#ifndef SG_UNALIGNED_H +#define SG_UNALIGNED_H + +/* + * Copyright (c) 2014-2018 Douglas Gilbert. + * All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the BSD_LICENSE file. + */ + +#include +#include /* for uint8_t and friends */ +#include /* for memcpy */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* These inline functions convert integers (always unsigned) to byte streams + * and vice versa. They have two goals: + * - change the byte ordering of integers between host order and big + * endian ("_be") or little endian ("_le") + * - copy the big or little endian byte stream so it complies with any + * alignment that host integers require + * + * Host integer to given endian byte stream is a "_put_" function taking + * two arguments (integer and pointer to byte stream) returning void. + * Given endian byte stream to host integer is a "_get_" function that takes + * one argument and returns an integer of appropriate size (uint32_t for 24 + * bit operations, uint64_t for 48 bit operations). + * + * Big endian byte format "on the wire" is the default used by SCSI + * standards (www.t10.org). Big endian is also the network byte order. + * Little endian is used by ATA, PCI and NVMe. + */ + +/* The generic form of these routines was borrowed from the Linux kernel, + * via mhvtl. There is a specialised version of the main functions for + * little endian or big endian provided that not-quite-standard defines for + * endianness are available from the compiler and the header + * (a GNU extension) has been detected by ./configure . To force the + * generic version, use './configure --disable-fast-lebe ' . */ + +/* Note: Assumes that the source and destination locations do not overlap. + * An example of overlapping source and destination: + * sg_put_unaligned_le64(j, ((uint8_t *)&j) + 1); + * Best not to do things like that. + */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" /* need this to see if HAVE_BYTESWAP_H */ +#endif + +#undef GOT_UNALIGNED_SPECIALS /* just in case */ + +#if defined(__BYTE_ORDER__) && defined(HAVE_BYTESWAP_H) && \ + ! defined(IGNORE_FAST_LEBE) + +#if defined(__LITTLE_ENDIAN__) || (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + +#define GOT_UNALIGNED_SPECIALS 1 + +#include /* for bswap_16(), bswap_32() and bswap_64() */ + +// #warning ">>>>>> Doing Little endian special unaligneds" + +static inline uint16_t sg_get_unaligned_be16(const void *p) +{ + uint16_t u; + + memcpy(&u, p, 2); + return bswap_16(u); +} + +static inline uint32_t sg_get_unaligned_be32(const void *p) +{ + uint32_t u; + + memcpy(&u, p, 4); + return bswap_32(u); +} + +static inline uint64_t sg_get_unaligned_be64(const void *p) +{ + uint64_t u; + + memcpy(&u, p, 8); + return bswap_64(u); +} + +static inline void sg_put_unaligned_be16(uint16_t val, void *p) +{ + uint16_t u = bswap_16(val); + + memcpy(p, &u, 2); +} + +static inline void sg_put_unaligned_be32(uint32_t val, void *p) +{ + uint32_t u = bswap_32(val); + + memcpy(p, &u, 4); +} + +static inline void sg_put_unaligned_be64(uint64_t val, void *p) +{ + uint64_t u = bswap_64(val); + + memcpy(p, &u, 8); +} + +static inline uint16_t sg_get_unaligned_le16(const void *p) +{ + uint16_t u; + + memcpy(&u, p, 2); + return u; +} + +static inline uint32_t sg_get_unaligned_le32(const void *p) +{ + uint32_t u; + + memcpy(&u, p, 4); + return u; +} + +static inline uint64_t sg_get_unaligned_le64(const void *p) +{ + uint64_t u; + + memcpy(&u, p, 8); + return u; +} + +static inline void sg_put_unaligned_le16(uint16_t val, void *p) +{ + memcpy(p, &val, 2); +} + +static inline void sg_put_unaligned_le32(uint32_t val, void *p) +{ + memcpy(p, &val, 4); +} + +static inline void sg_put_unaligned_le64(uint64_t val, void *p) +{ + memcpy(p, &val, 8); +} + +#elif defined(__BIG_ENDIAN__) || (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + +#define GOT_UNALIGNED_SPECIALS 1 + +#include + +// #warning ">>>>>> Doing BIG endian special unaligneds" + +static inline uint16_t sg_get_unaligned_le16(const void *p) +{ + uint16_t u; + + memcpy(&u, p, 2); + return bswap_16(u); +} + +static inline uint32_t sg_get_unaligned_le32(const void *p) +{ + uint32_t u; + + memcpy(&u, p, 4); + return bswap_32(u); +} + +static inline uint64_t sg_get_unaligned_le64(const void *p) +{ + uint64_t u; + + memcpy(&u, p, 8); + return bswap_64(u); +} + +static inline void sg_put_unaligned_le16(uint16_t val, void *p) +{ + uint16_t u = bswap_16(val); + + memcpy(p, &u, 2); +} + +static inline void sg_put_unaligned_le32(uint32_t val, void *p) +{ + uint32_t u = bswap_32(val); + + memcpy(p, &u, 4); +} + +static inline void sg_put_unaligned_le64(uint64_t val, void *p) +{ + uint64_t u = bswap_64(val); + + memcpy(p, &u, 8); +} + +static inline uint16_t sg_get_unaligned_be16(const void *p) +{ + uint16_t u; + + memcpy(&u, p, 2); + return u; +} + +static inline uint32_t sg_get_unaligned_be32(const void *p) +{ + uint32_t u; + + memcpy(&u, p, 4); + return u; +} + +static inline uint64_t sg_get_unaligned_be64(const void *p) +{ + uint64_t u; + + memcpy(&u, p, 8); + return u; +} + +static inline void sg_put_unaligned_be16(uint16_t val, void *p) +{ + memcpy(p, &val, 2); +} + +static inline void sg_put_unaligned_be32(uint32_t val, void *p) +{ + memcpy(p, &val, 4); +} + +static inline void sg_put_unaligned_be64(uint64_t val, void *p) +{ + memcpy(p, &val, 8); +} + +#endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ +#endif /* #if defined __BYTE_ORDER__ && defined && + * ! defined IGNORE_FAST_LEBE */ + + +#ifndef GOT_UNALIGNED_SPECIALS + +/* Now we have no tricks left, so use the only way this can be done + * correctly in C safely: lots of shifts. */ + +// #warning ">>>>>> Doing GENERIC unaligneds" + +static inline uint16_t sg_get_unaligned_be16(const void *p) +{ + return ((const uint8_t *)p)[0] << 8 | ((const uint8_t *)p)[1]; +} + +static inline uint32_t sg_get_unaligned_be32(const void *p) +{ + return ((const uint8_t *)p)[0] << 24 | ((const uint8_t *)p)[1] << 16 | + ((const uint8_t *)p)[2] << 8 | ((const uint8_t *)p)[3]; +} + +static inline uint64_t sg_get_unaligned_be64(const void *p) +{ + return (uint64_t)sg_get_unaligned_be32(p) << 32 | + sg_get_unaligned_be32((const uint8_t *)p + 4); +} + +static inline void sg_put_unaligned_be16(uint16_t val, void *p) +{ + ((uint8_t *)p)[0] = (uint8_t)(val >> 8); + ((uint8_t *)p)[1] = (uint8_t)val; +} + +static inline void sg_put_unaligned_be32(uint32_t val, void *p) +{ + sg_put_unaligned_be16(val >> 16, p); + sg_put_unaligned_be16(val, (uint8_t *)p + 2); +} + +static inline void sg_put_unaligned_be64(uint64_t val, void *p) +{ + sg_put_unaligned_be32(val >> 32, p); + sg_put_unaligned_be32(val, (uint8_t *)p + 4); +} + + +static inline uint16_t sg_get_unaligned_le16(const void *p) +{ + return ((const uint8_t *)p)[1] << 8 | ((const uint8_t *)p)[0]; +} + +static inline uint32_t sg_get_unaligned_le32(const void *p) +{ + return ((const uint8_t *)p)[3] << 24 | ((const uint8_t *)p)[2] << 16 | + ((const uint8_t *)p)[1] << 8 | ((const uint8_t *)p)[0]; +} + +static inline uint64_t sg_get_unaligned_le64(const void *p) +{ + return (uint64_t)sg_get_unaligned_le32((const uint8_t *)p + 4) << 32 | + sg_get_unaligned_le32(p); +} + +static inline void sg_put_unaligned_le16(uint16_t val, void *p) +{ + ((uint8_t *)p)[0] = val & 0xff; + ((uint8_t *)p)[1] = val >> 8; +} + +static inline void sg_put_unaligned_le32(uint32_t val, void *p) +{ + sg_put_unaligned_le16(val >> 16, (uint8_t *)p + 2); + sg_put_unaligned_le16(val, p); +} + +static inline void sg_put_unaligned_le64(uint64_t val, void *p) +{ + sg_put_unaligned_le32(val >> 32, (uint8_t *)p + 4); + sg_put_unaligned_le32(val, p); +} + +#endif /* #ifndef GOT_UNALIGNED_SPECIALS */ + +/* Following are lesser used conversions that don't have specializations + * for endianness; big endian first. In summary these are the 24, 48 bit and + * given-length conversions plus the "nz" conditional put conversions. */ + +/* Now big endian, get 24+48 then put 24+48 */ +static inline uint32_t sg_get_unaligned_be24(const void *p) +{ + return ((const uint8_t *)p)[0] << 16 | ((const uint8_t *)p)[1] << 8 | + ((const uint8_t *)p)[2]; +} + +/* Assume 48 bit value placed in uint64_t */ +static inline uint64_t sg_get_unaligned_be48(const void *p) +{ + return (uint64_t)sg_get_unaligned_be16(p) << 32 | + sg_get_unaligned_be32((const uint8_t *)p + 2); +} + +/* Returns 0 if 'num_bytes' is less than or equal to 0 or greater than + * 8 (i.e. sizeof(uint64_t)). Else returns result in uint64_t which is + * an 8 byte unsigned integer. */ +static inline uint64_t sg_get_unaligned_be(int num_bytes, const void *p) +{ + if ((num_bytes <= 0) || (num_bytes > (int)sizeof(uint64_t))) + return 0; + else { + const uint8_t * xp = (const uint8_t *)p; + uint64_t res = *xp; + + for (++xp; num_bytes > 1; ++xp, --num_bytes) + res = (res << 8) | *xp; + return res; + } +} + +static inline void sg_put_unaligned_be24(uint32_t val, void *p) +{ + ((uint8_t *)p)[0] = (val >> 16) & 0xff; + ((uint8_t *)p)[1] = (val >> 8) & 0xff; + ((uint8_t *)p)[2] = val & 0xff; +} + +/* Assume 48 bit value placed in uint64_t */ +static inline void sg_put_unaligned_be48(uint64_t val, void *p) +{ + sg_put_unaligned_be16(val >> 32, p); + sg_put_unaligned_be32(val, (uint8_t *)p + 2); +} + +/* Now little endian, get 24+48 then put 24+48 */ +static inline uint32_t sg_get_unaligned_le24(const void *p) +{ + return (uint32_t)sg_get_unaligned_le16(p) | + ((const uint8_t *)p)[2] << 16; +} + +/* Assume 48 bit value placed in uint64_t */ +static inline uint64_t sg_get_unaligned_le48(const void *p) +{ + return (uint64_t)sg_get_unaligned_le16((const uint8_t *)p + 4) << 32 | + sg_get_unaligned_le32(p); +} + +static inline void sg_put_unaligned_le24(uint32_t val, void *p) +{ + ((uint8_t *)p)[2] = (val >> 16) & 0xff; + ((uint8_t *)p)[1] = (val >> 8) & 0xff; + ((uint8_t *)p)[0] = val & 0xff; +} + +/* Assume 48 bit value placed in uint64_t */ +static inline void sg_put_unaligned_le48(uint64_t val, void *p) +{ + ((uint8_t *)p)[5] = (val >> 40) & 0xff; + ((uint8_t *)p)[4] = (val >> 32) & 0xff; + ((uint8_t *)p)[3] = (val >> 24) & 0xff; + ((uint8_t *)p)[2] = (val >> 16) & 0xff; + ((uint8_t *)p)[1] = (val >> 8) & 0xff; + ((uint8_t *)p)[0] = val & 0xff; +} + +/* Returns 0 if 'num_bytes' is less than or equal to 0 or greater than + * 8 (i.e. sizeof(uint64_t)). Else returns result in uint64_t which is + * an 8 byte unsigned integer. */ +static inline uint64_t sg_get_unaligned_le(int num_bytes, const void *p) +{ + if ((num_bytes <= 0) || (num_bytes > (int)sizeof(uint64_t))) + return 0; + else { + const uint8_t * xp = (const uint8_t *)p + (num_bytes - 1); + uint64_t res = *xp; + + for (--xp; num_bytes > 1; --xp, --num_bytes) + res = (res << 8) | *xp; + return res; + } +} + +/* Since cdb and parameter blocks are often memset to zero before these + * unaligned function partially fill them, then check for a val of zero + * and ignore if it is with these variants. First big endian, then little */ +static inline void sg_nz_put_unaligned_be16(uint16_t val, void *p) +{ + if (val) + sg_put_unaligned_be16(val, p); +} + +static inline void sg_nz_put_unaligned_be24(uint32_t val, void *p) +{ + if (val) { + ((uint8_t *)p)[0] = (val >> 16) & 0xff; + ((uint8_t *)p)[1] = (val >> 8) & 0xff; + ((uint8_t *)p)[2] = val & 0xff; + } +} + +static inline void sg_nz_put_unaligned_be32(uint32_t val, void *p) +{ + if (val) + sg_put_unaligned_be32(val, p); +} + +static inline void sg_nz_put_unaligned_be64(uint64_t val, void *p) +{ + if (val) + sg_put_unaligned_be64(val, p); +} + +static inline void sg_nz_put_unaligned_le16(uint16_t val, void *p) +{ + if (val) + sg_put_unaligned_le16(val, p); +} + +static inline void sg_nz_put_unaligned_le24(uint32_t val, void *p) +{ + if (val) { + ((uint8_t *)p)[2] = (val >> 16) & 0xff; + ((uint8_t *)p)[1] = (val >> 8) & 0xff; + ((uint8_t *)p)[0] = val & 0xff; + } +} + +static inline void sg_nz_put_unaligned_le32(uint32_t val, void *p) +{ + if (val) + sg_put_unaligned_le32(val, p); +} + +static inline void sg_nz_put_unaligned_le64(uint64_t val, void *p) +{ + if (val) + sg_put_unaligned_le64(val, p); +} + + +#ifdef __cplusplus +} +#endif + +#endif /* SG_UNALIGNED_H */ diff -Nru lsscsi-0.28/TODO lsscsi-0.30/TODO --- lsscsi-0.28/TODO 2013-05-08 23:01:19.000000000 +0000 +++ lsscsi-0.30/TODO 2018-06-13 01:49:03.000000000 +0000 @@ -5,3 +5,5 @@ - add unit option for different size representations [proposed by Pascal Gregis 20121019] + - done: -s: SI units for bytes; -ss: IEC 80000-3 prefixes for bytes + (e.g. 3.56GiB); -sss: size as logical block count, exact in decimal