diff --git a/patches/sg3_utils-1.30.patch b/patches/sg3_utils-1.30.patch index 16928bb..652c934 100644 --- a/patches/sg3_utils-1.30.patch +++ b/patches/sg3_utils-1.30.patch @@ -1,1164 +1,1709 @@ -commit e0f2b89c4886b5650054418321960980848fce51 -Author: Ronnie Sahlberg -Date: Sun Dec 5 09:08:20 2010 +1100 - - iscsi support - -diff --git a/configure.ac b/configure.ac -index 5c7314f..f7c9867 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -76,4 +76,34 @@ AC_ARG_ENABLE([win32-spt-direct], - AC_DEFINE_UNQUOTED(WIN32_SPT_DIRECT, 1, [enable Win32 SPT Direct], ) +diff --git a/README b/README +index ac0696c..49a58c1 100644 +--- a/README ++++ b/README +@@ -7,6 +7,8 @@ command set. Apart from SCSI parallel interface (SPI) devices, the SCSI + command set is used by ATAPI devices (CD/DVDs and tapes), USB mass storage + devices, Fibre Channel disks, IEEE 1394 storage devices (that use the + "SBP" protocol), SAS, iSCSI and FCoE devices (amongst others). ++On some platforms the package can also access iSCSI devices directly ++using a built-in iscsi client. See the iSCSI section below for more info. + + This package originally targeted the Linux SCSI subsystem. Since most + operating systems contain a SCSI command pass-through mechanism, many +@@ -329,6 +331,44 @@ The more recent utilities that use "getopt_long" only are: + sg_vpd sg_write_buffer sg_write_long sg_write_same sg_wr_mode + + ++iSCSI support ++============= ++On some platforms (Linux) sg3_utils can be built with iSCSI support. ++When built with iSCSI support, the utilities will be able to access iSCSI ++devices directly using a built-in iSCSI client, without having to first make ++the devices visible to the host. ++This is very useful for cases where you have very many iSCSI targets you want ++to manage and very many LUNs, in which case it may be impractical to make all ++those devices visible to the local host. ++ ++In order to get access to the iSCSI functionality, the sg3_utils package must ++be built and linked against the iscsi client library from : ++ https://github.com/sahlberg/libiscsi ++When configuring and building sg3_utils, the build process will detect if ++this library is available and if it is build a version of sg3_utils with ++iSCSI support. ++ ++With iSCSI support, you can specify a iSCSI URL instead of the /dev/sg* ++device that most of the utilities take. ++ ++Example: ++ sudo sg_inq iscsi://karelin/iqn.ronnie.test/1 ++Which means : Use LUN 1 on the target with the name "iqn.ronnie.test" ++that is available on network host "karelin". ++ ++The full form of the iSCSI URL is : ++ iscsi://[[%]@][:]// ++ ++iSCSI Authentication: ++The package supports normal iSCSI CHAP authentication to those targets that ++require it. ++This is done by specifying hte CHAP username and password as part of the iSCSI ++URL. ++ ++Example: ++ sudo sg_inq iscsi://ronnie%secret@karelin/iqn.ronnie.test/1 ++ ++ + Dangerous code + ============== + This code: +diff --git a/aclocal.m4 b/aclocal.m4 +index 4e0d256..c5f3fc1 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -13,8 +13,8 @@ + + m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, +-[m4_warning([this file was generated for autoconf 2.67. ++m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, ++[m4_warning([this file was generated for autoconf 2.65. + You have another version of autoconf. It may work, but is not guaranteed to. + 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'.])]) +diff --git a/config.guess b/config.guess +index c2246a4..e3a2116 100755 +--- a/config.guess ++++ b/config.guess +@@ -1,10 +1,10 @@ + #! /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, 2006, 2007, 2008, 2009, 2010 ++# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + # Free Software Foundation, Inc. + +-timestamp='2009-12-30' ++timestamp='2009-06-10' + + # 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 +@@ -27,16 +27,16 @@ timestamp='2009-12-30' + # the same distribution terms that you use for the rest of that program. + + +-# Originally written by Per Bothner. Please send patches (context +-# diff format) to and include a ChangeLog +-# entry. ++# Originally written by Per Bothner . ++# Please send patches to . Submit a context ++# diff and a properly formatted ChangeLog entry. + # + # 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: +-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD ++# The plan is that this can be called by configure scripts if you ++# don't specify an explicit build system type. + + me=`echo "$0" | sed -e 's,.*/,,'` + +@@ -56,9 +56,8 @@ version="\ + 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, 2006, 2007, 2008, 2009, 2010 Free +-Software Foundation, Inc. ++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, ++2002, 2003, 2004, 2005, 2006, 2007, 2008 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." +@@ -334,9 +333,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + 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" +@@ -811,12 +807,12 @@ EOF + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; +- *:Interix*:*) ++ *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; +- authenticamd | genuineintel | EM64T) ++ EM64T | authenticamd | genuineintel) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) +@@ -858,20 +854,6 @@ EOF + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + 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="libc1" ; else LIBC="" ; fi +- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} +- exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ +@@ -894,17 +876,6 @@ EOF + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; +- i*86:Linux:*:*) +- LIBC=gnu +- eval $set_cc_for_build +- sed 's/^ //' << EOF >$dummy.c +- #ifdef __dietlibc__ +- LIBC=dietlibc +- #endif +-EOF +- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` +- echo "${UNAME_MACHINE}-pc-linux-${LIBC}" +- exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; +@@ -930,18 +901,39 @@ EOF + #endif + #endif + EOF +- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` ++ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' ++ /^CPU/{ ++ s: ::g ++ p ++ }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; ++ ppc:Linux:*:*) ++ echo powerpc-unknown-linux-gnu ++ exit ;; ++ ppc64:Linux:*:*) ++ echo powerpc64-unknown-linux-gnu ++ 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="libc1" ; else LIBC="" ; fi ++ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ++ exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; +- parisc64:Linux:*:* | hppa64:Linux:*:*) +- echo hppa64-unknown-linux-gnu +- exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in +@@ -950,11 +942,8 @@ EOF + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; +- ppc64:Linux:*:*) +- echo powerpc64-unknown-linux-gnu +- exit ;; +- ppc:Linux:*:*) +- echo powerpc-unknown-linux-gnu ++ parisc64:Linux:*:* | hppa64:Linux:*:*) ++ echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux +@@ -977,6 +966,58 @@ EOF + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; ++ 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" ++ ;; ++ 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 ++ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) ++ LIBC=gnu ++ #else ++ LIBC=gnuaout ++ #endif ++ #endif ++ #ifdef __dietlibc__ ++ LIBC=dietlibc ++ #endif ++EOF ++ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' ++ /^LIBC/{ ++ s: ::g ++ p ++ }'`" ++ test x"${LIBC}" != x && { ++ echo "${UNAME_MACHINE}-pc-linux-${LIBC}" ++ exit ++ } ++ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; 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 +@@ -1206,16 +1247,6 @@ EOF + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in +- i386) +- eval $set_cc_for_build +- 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 +- UNAME_PROCESSOR="x86_64" +- fi +- fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} +diff --git a/config.sub b/config.sub +index c2d1257..eb0389a 100755 +--- a/config.sub ++++ b/config.sub +@@ -1,10 +1,10 @@ + #! /bin/sh + # Configuration validation subroutine script. + # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ++# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + # Free Software Foundation, Inc. + +-timestamp='2010-01-22' ++timestamp='2009-06-11' + + # This file is (in principle) common to ALL GNU software. + # The presence of a machine in this file suggests that SOME GNU software +@@ -32,16 +32,13 @@ timestamp='2010-01-22' + + + # Please send patches to . Submit a context +-# diff and a properly formatted GNU ChangeLog entry. ++# diff and a properly formatted ChangeLog entry. + # + # 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: +-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +- + # 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. +@@ -75,9 +72,8 @@ Report bugs and patches to ." + version="\ + GNU config.sub ($timestamp) + +-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +-Software Foundation, Inc. ++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, ++2002, 2003, 2004, 2005, 2006, 2007, 2008 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." +@@ -153,7 +149,7 @@ case $os in + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ +- -apple | -axis | -knuth | -cray | -microblaze) ++ -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; +@@ -288,7 +284,6 @@ case $basic_machine in + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ +- | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ +@@ -296,14 +291,13 @@ case $basic_machine in + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ +- | ubicom32 \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; +- m6811 | m68hc11 | m6812 | m68hc12 | picochip) ++ m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none +@@ -346,7 +340,7 @@ case $basic_machine in + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ +- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ ++ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ +@@ -374,17 +368,15 @@ case $basic_machine in + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ +- | romp-* | rs6000-* | rx-* \ ++ | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ +- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ +- | tile-* | tilegx-* \ ++ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tron-* \ +- | ubicom32-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ +@@ -734,9 +726,6 @@ case $basic_machine in + basic_machine=ns32k-utek + os=-sysv + ;; +- microblaze) +- basic_machine=microblaze-xilinx +- ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 +@@ -1087,11 +1076,6 @@ case $basic_machine in + basic_machine=tic6x-unknown + os=-coff + ;; +- # This must be matched before tile*. +- tilegx*) +- basic_machine=tilegx-unknown +- os=-linux-gnu +- ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu +@@ -1263,9 +1247,6 @@ case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. +- -auroraux) +- os=-auroraux +- ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; +@@ -1287,8 +1268,8 @@ case $os in + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ +- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ +- | -sym* | -kopensolaris* \ ++ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ ++ | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ +@@ -1309,7 +1290,7 @@ case $os in + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ +- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) ++ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) +@@ -1442,8 +1423,6 @@ case $os in + -dicos*) + os=-dicos + ;; +- -nacl*) +- ;; + -none) + ;; + *) +diff --git a/configure b/configure +index bd26a28..3d39ef8 100755 +--- a/configure ++++ b/configure +@@ -1,13 +1,13 @@ + #! /bin/sh + # Guess values for system-dependent variables and create Makefiles. +-# Generated by GNU Autoconf 2.67 for sg3_utils 1.31. ++# Generated by GNU Autoconf 2.65 for sg3_utils 1.31. + # + # Report bugs to . + # + # + # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +-# Foundation, Inc. ++# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, ++# Inc. + # + # + # This configure script is free software; the Free Software Foundation +@@ -319,7 +319,7 @@ $as_echo X"$as_dir" | + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" +- } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" ++ } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + + } # as_fn_mkdir_p +@@ -359,19 +359,19 @@ else + fi # as_fn_arith + + +-# as_fn_error STATUS ERROR [LINENO LOG_FD] +-# ---------------------------------------- ++# as_fn_error ERROR [LINENO LOG_FD] ++# --------------------------------- + # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are + # provided, also output the error to LOG_FD, referencing LINENO. Then exit the +-# script with STATUS, using 1 if that was 0. ++# script with status $?, using 1 if that was 0. + as_fn_error () + { +- as_status=$1; test $as_status -eq 0 && as_status=1 +- if test "$4"; then +- as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 ++ as_status=$?; test $as_status -eq 0 && as_status=1 ++ if test "$3"; then ++ as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi +- $as_echo "$as_me: error: $2" >&2 ++ $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status + } # as_fn_error + +@@ -682,7 +682,7 @@ test -n "$DJDIR" || exec 7<&0 &1 + + # Name of the host. +-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, ++# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, + # so uname gets run too. + ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +@@ -955,9 +955,8 @@ do + fi + + case $ac_option in +- *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; +- *=) ac_optarg= ;; +- *) ac_optarg=yes ;; ++ *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; ++ *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. +@@ -1002,7 +1001,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error $? "invalid feature name: $ac_useropt" ++ as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1028,7 +1027,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error $? "invalid feature name: $ac_useropt" ++ as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1232,7 +1231,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error $? "invalid package name: $ac_useropt" ++ as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1248,7 +1247,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error $? "invalid package name: $ac_useropt" ++ as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1278,8 +1277,8 @@ do + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + +- -*) as_fn_error $? "unrecognized option: \`$ac_option' +-Try \`$0 --help' for more information" ++ -*) as_fn_error "unrecognized option: \`$ac_option' ++Try \`$0 --help' for more information." + ;; + + *=*) +@@ -1287,7 +1286,7 @@ Try \`$0 --help' for more information" + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) +- as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; ++ as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; +@@ -1305,13 +1304,13 @@ done + + if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` +- as_fn_error $? "missing argument to $ac_option" ++ as_fn_error "missing argument to $ac_option" + fi + + if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; +- fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; ++ fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac + fi +@@ -1334,7 +1333,7 @@ do + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac +- as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" ++ as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + done + + # There might be people who depend on the old broken behavior: `$host' +@@ -1348,8 +1347,8 @@ target=$target_alias + if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe +- $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. +- If a cross compiler is detected then cross compile mode will be used" >&2 ++ $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. ++ If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +@@ -1364,9 +1363,9 @@ test "$silent" = yes && exec 6>/dev/null + ac_pwd=`pwd` && test -n "$ac_pwd" && + ac_ls_di=`ls -di .` && + ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || +- as_fn_error $? "working directory cannot be determined" ++ as_fn_error "working directory cannot be determined" + test "X$ac_ls_di" = "X$ac_pwd_ls_di" || +- as_fn_error $? "pwd does not report name of working directory" ++ as_fn_error "pwd does not report name of working directory" + + + # Find the source files, if location was not specified. +@@ -1405,11 +1404,11 @@ else + fi + if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." +- as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" ++ as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + fi + ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" + ac_abs_confdir=`( +- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" ++ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + pwd)` + # When building in place, set srcdir=. + if test "$ac_abs_confdir" = "$ac_pwd"; then +@@ -1449,7 +1448,7 @@ Configuration: + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit +- -q, --quiet, --silent do not print \`checking ...' messages ++ -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files +@@ -1611,9 +1610,9 @@ test -n "$ac_init_help" && exit $ac_status + if $ac_init_version; then + cat <<\_ACEOF + sg3_utils configure 1.31 +-generated by GNU Autoconf 2.67 ++generated by GNU Autoconf 2.65 + +-Copyright (C) 2010 Free Software Foundation, Inc. ++Copyright (C) 2009 Free Software Foundation, Inc. + This configure script is free software; the Free Software Foundation + gives unlimited permission to copy, distribute and modify it. + _ACEOF +@@ -1717,7 +1716,7 @@ 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 "test \"\${$3+set}\"" = set; then : ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -1760,7 +1759,7 @@ $as_echo "$ac_try_echo"; } >&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 $ac_status = 0; } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : +@@ -1826,7 +1825,7 @@ ac_fn_c_check_func () + 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 "test \"\${$3+set}\"" = set; then : ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -1889,7 +1888,7 @@ This file contains any messages produced by compilers while + running configure, to aid debugging if configure makes a mistake. + + It was created by sg3_utils $as_me 1.31, which was +-generated by GNU Autoconf 2.67. Invocation command line was ++generated by GNU Autoconf 2.65. Invocation command line was + + $ $0 $@ + +@@ -1999,9 +1998,11 @@ trap 'exit_status=$? + { + echo + +- $as_echo "## ---------------- ## ++ cat <<\_ASBOX ++## ---------------- ## + ## Cache variables. ## +-## ---------------- ##" ++## ---------------- ## ++_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, + ( +@@ -2035,9 +2036,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) + echo -+ -+AC_MSG_CHECKING(if libiscsi is available) -+ac_save_CFLAGS="$CFLAGS" -+ac_save_LIBS="$LIBS" -+CFLAGS="" -+LIBS="-liscsi" -+AC_TRY_RUN([ -+/* -+ * Just see if we can compile/link with libiscsi -+ */ -+#include -+int main(int argc, const char *argv[]) -+{ -+ iscsi_create_context(""); -+ return 0; -+} -+], ac_cv_have_libiscsi=yes, ac_cv_have_libiscsi=no, -+ [echo $ac_n "compile with LIBISCSI. Assuming OK... $ac_c" -+ ac_cv_have_libiscsi=yes]) -+CFLAGS="$ac_save_CFLAGS" -+LIBS="$ac_save_LIBS" -+if test "$ac_cv_have_libiscsi" = yes ; then -+ AC_MSG_RESULT(yes) -+ AC_SUBST([libiscsi], ['-liscsi']) -+ AC_DEFINE_UNQUOTED(CONFIG_LIBISCSI, 1, [we have libiscsi support], ) -+else -+ AC_MSG_RESULT(no) -+ AC_SUBST([libiscsi], ['']) -+fi -+ - AC_OUTPUT(Makefile include/Makefile lib/Makefile src/Makefile doc/Makefile) -diff --git a/include/sg_pt_iscsi.h b/include/sg_pt_iscsi.h -new file mode 100644 -index 0000000..f849eb0 ---- /dev/null -+++ b/include/sg_pt_iscsi.h -@@ -0,0 +1,34 @@ -+/* -+ * Copyright (c) 2010 Ronnie Sahlberg -+ * All rights reserved. -+ * Use of this source code is governed by a BSD-style -+ * license that can be found in the BSD_LICENSE file. -+ */ -+ -+extern struct sg_context *iscsi; -+ -+#define ISCSI_FAKE_FD 0x7fffffff -+ -+int do_iscsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose); -+struct sg_pt_base *construct_iscsi_pt_obj(void); -+void clear_iscsi_pt_obj(struct sg_pt_base * vp); -+void destruct_iscsi_pt_obj(struct sg_pt_base * vp); -+void set_iscsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len); -+void set_iscsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int max_sense_len); -+void set_iscsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len); -+void set_iscsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len); -+int get_iscsi_pt_resid(const struct sg_pt_base * vp); -+int get_iscsi_pt_result_category(const struct sg_pt_base * vp); -+int get_iscsi_pt_os_err(const struct sg_pt_base * vp); -+int get_iscsi_pt_sense_len(const struct sg_pt_base * vp); -+void set_iscsi_pt_packet_id(struct sg_pt_base * vp, int pack_id); -+int iscsi_pt_close_device(int device_fd); -+char *get_iscsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b); -+int get_iscsi_pt_transport_err(const struct sg_pt_base * vp); -+char *get_iscsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b); -+void set_iscsi_pt_tag(struct sg_pt_base * vp, uint64_t tag); -+void set_iscsi_pt_task_management(struct sg_pt_base * vp, int tmf_code); -+void set_iscsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority); -+int get_iscsi_pt_duration_ms(const struct sg_pt_base * vp); -+int get_iscsi_pt_status_response(const struct sg_pt_base * vp); -+int iscsi_pt_open_device(const char *device_name, int read_only, int verbose); -diff --git a/lib/Makefile.am b/lib/Makefile.am -index 3d5213e..6990f12 100644 ---- a/lib/Makefile.am -+++ b/lib/Makefile.am -@@ -8,6 +8,7 @@ libsgutils2_la_SOURCES = \ - sg_cmds_extra.c \ - sg_cmds_mmc.c \ - sg_pt_common.c \ -+ sg_pt_iscsi.c \ - sg_pt_linux.c \ - sg_io_linux.c +- $as_echo "## ----------------- ## ++ cat <<\_ASBOX ++## ----------------- ## + ## Output variables. ## +-## ----------------- ##" ++## ----------------- ## ++_ASBOX + echo + for ac_var in $ac_subst_vars + do +@@ -2050,9 +2053,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + echo -@@ -33,6 +34,7 @@ libsgutils2_la_SOURCES = \ - sg_pt_win32.c + if test -n "$ac_subst_files"; then +- $as_echo "## ------------------- ## ++ cat <<\_ASBOX ++## ------------------- ## + ## File substitutions. ## +-## ------------------- ##" ++## ------------------- ## ++_ASBOX + echo + for ac_var in $ac_subst_files + do +@@ -2066,9 +2071,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + fi - EXTRA_libsgutils2_la_SOURCES = \ -+ sg_pt_iscsi.c \ - sg_pt_linux.c \ - sg_io_linux.c \ - sg_pt_freebsd.c \ -@@ -55,6 +57,7 @@ libsgutils2_la_SOURCES = \ - sg_pt_win32.c + if test -s confdefs.h; then +- $as_echo "## ----------- ## ++ cat <<\_ASBOX ++## ----------- ## + ## confdefs.h. ## +-## ----------- ##" ++## ----------- ## ++_ASBOX + echo + cat confdefs.h + echo +@@ -2123,12 +2130,7 @@ _ACEOF + ac_site_file1=NONE + ac_site_file2=NONE + if test -n "$CONFIG_SITE"; then +- # We do not want a PATH search for config.site. +- case $CONFIG_SITE in #(( +- -*) ac_site_file1=./$CONFIG_SITE;; +- */*) ac_site_file1=$CONFIG_SITE;; +- *) ac_site_file1=./$CONFIG_SITE;; +- esac ++ ac_site_file1=$CONFIG_SITE + elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +@@ -2143,11 +2145,7 @@ do + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 + $as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 +- . "$ac_site_file" \ +- || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "failed to load site script $ac_site_file +-See \`config.log' for more details" "$LINENO" 5 ; } ++ . "$ac_site_file" + fi + done - EXTRA_libsgutils2_la_SOURCES = \ -+ sg_pt_iscsi.c \ - sg_pt_linux.c \ - sg_io_linux.c \ - sg_pt_freebsd.c \ -@@ -77,6 +80,7 @@ libsgutils2_la_SOURCES = \ - sg_pt_freebsd.c +@@ -2223,7 +2221,7 @@ if $ac_cache_corrupted; then + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 + $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} +- as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 ++ as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + fi + ## -------------------- ## + ## Main body of script. ## +@@ -2241,22 +2239,16 @@ am__api_version='1.11' - EXTRA_libsgutils2_la_SOURCES = \ -+ sg_pt_iscsi.c \ - sg_pt_linux.c \ - sg_io_linux.c \ - sg_linux_inc.h \ -@@ -100,6 +104,7 @@ libsgutils2_la_SOURCES = \ - sg_pt_solaris.c + ac_aux_dir= + for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do +- if test -f "$ac_dir/install-sh"; then +- ac_aux_dir=$ac_dir +- ac_install_sh="$ac_aux_dir/install-sh -c" +- break +- elif test -f "$ac_dir/install.sh"; then +- ac_aux_dir=$ac_dir +- ac_install_sh="$ac_aux_dir/install.sh -c" +- break +- elif test -f "$ac_dir/shtool"; then +- ac_aux_dir=$ac_dir +- ac_install_sh="$ac_aux_dir/shtool install -c" +- break +- fi ++ for ac_t in install-sh install.sh shtool; do ++ if test -f "$ac_dir/$ac_t"; then ++ ac_aux_dir=$ac_dir ++ ac_install_sh="$ac_aux_dir/$ac_t -c" ++ break 2 ++ fi ++ done + done + if test -z "$ac_aux_dir"; then +- as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 ++ as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + fi - EXTRA_libsgutils2_la_SOURCES = \ -+ sg_pt_iscsi.c \ - sg_pt_linux.c \ - sg_io_linux.c \ - sg_linux_inc.h \ -@@ -123,6 +128,7 @@ libsgutils2_la_SOURCES = \ - sg_pt_osf1.c + # These three variables are undocumented and unsupported, +@@ -2372,11 +2364,11 @@ am_lf=' + ' + case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) +- as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;; ++ as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; + esac + case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) +- as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;; ++ as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; + esac - EXTRA_libsgutils2_la_SOURCES = \ -+ sg_pt_iscsi.c \ - sg_pt_linux.c \ - sg_io_linux.c \ - sg_pt_freebsd.c \ -@@ -140,7 +146,7 @@ lib_LTLIBRARIES = libsgutils2.la + # Do `set' in a subshell so we don't clobber the current shell's +@@ -2398,7 +2390,7 @@ if ( + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". +- as_fn_error $? "ls -t appears to fail. Make sure there is not a broken ++ as_fn_error "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi - libsgutils2_la_LDFLAGS = -version-info 2:0:0 +@@ -2408,7 +2400,7 @@ then + # Ok. + : + else +- as_fn_error $? "newly created file is older than distributed files! ++ as_fn_error "newly created file is older than distributed files! + Check your system clock" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +@@ -2646,7 +2638,7 @@ done + $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } + set x ${MAKE-make} + ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : ++if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 + else + cat >conftest.make <<\_ACEOF +@@ -2654,7 +2646,7 @@ SHELL = /bin/sh + all: + @echo '@@@%%%=$(MAKE)=@@@%%%' + _ACEOF +-# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. ++# GNU make sometimes prints "make[1]: Entering...", which would confuse us. + case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; +@@ -2688,7 +2680,7 @@ if test "`cd $srcdir && pwd`" != "`pwd`"; then + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then +- as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 ++ as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi + fi --libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@ -+libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@ @libiscsi@ - libsgutils2_la_DEPENDENCIES = @GETOPT_O_FILES@ +@@ -3070,8 +3062,8 @@ fi + + test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "no acceptable C compiler found in \$PATH +-See \`config.log' for more details" "$LINENO" 5 ; } ++as_fn_error "no acceptable C compiler found in \$PATH ++See \`config.log' for more details." "$LINENO" 5; } + + # Provide some information about the compiler. + $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +@@ -3185,8 +3177,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 + + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error 77 "C compiler cannot create executables +-See \`config.log' for more details" "$LINENO" 5 ; } ++{ as_fn_set_status 77 ++as_fn_error "C compiler cannot create executables ++See \`config.log' for more details." "$LINENO" 5; }; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + $as_echo "yes" >&6; } +@@ -3228,8 +3221,8 @@ done + 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 $? "cannot compute suffix of executables: cannot compile and link +-See \`config.log' for more details" "$LINENO" 5 ; } ++as_fn_error "cannot compute suffix of executables: cannot compile and link ++See \`config.log' for more details." "$LINENO" 5; } + fi + rm -f conftest conftest$ac_cv_exeext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +@@ -3286,9 +3279,9 @@ $as_echo "$ac_try_echo"; } >&5 + 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 $? "cannot run C compiled programs. ++as_fn_error "cannot run C compiled programs. + If you meant to cross compile, use \`--host'. +-See \`config.log' for more details" "$LINENO" 5 ; } ++See \`config.log' for more details." "$LINENO" 5; } + fi + fi + fi +@@ -3339,8 +3332,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 + + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "cannot compute suffix of object files: cannot compile +-See \`config.log' for more details" "$LINENO" 5 ; } ++as_fn_error "cannot compute suffix of object files: cannot compile ++See \`config.log' for more details." "$LINENO" 5; } + fi + rm -f conftest.$ac_cv_objext conftest.$ac_ext + fi +@@ -3780,7 +3773,7 @@ ltmain="$ac_aux_dir/ltmain.sh" + + # 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_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; } +@@ -3791,16 +3784,16 @@ else + 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 ++ 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 ++ 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 ;; ++*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; + esac + build=$ac_cv_build + ac_save_IFS=$IFS; IFS='-' +@@ -3825,7 +3818,7 @@ else + 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 ++ as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + fi + + fi +@@ -3833,7 +3826,7 @@ fi + $as_echo "$ac_cv_host" >&6; } + case $ac_cv_host in + *-*-*) ;; +-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; ++*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; + esac + host=$ac_cv_host + ac_save_IFS=$IFS; IFS='-' +@@ -3906,7 +3899,7 @@ esac + done + IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then +- as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 ++ as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi + else + ac_cv_path_SED=$SED +@@ -3982,7 +3975,7 @@ esac + 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 ++ 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 +@@ -4048,7 +4041,7 @@ esac + 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 ++ 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 +@@ -4115,7 +4108,7 @@ esac + done + IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then +- as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi + else + ac_cv_path_FGREP=$FGREP +@@ -4231,7 +4224,7 @@ else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } + fi +-test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 ++test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 + $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } + if test "${lt_cv_prog_gnu_ld+set}" = set; then : +@@ -4433,13 +4426,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : + else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext +- (eval echo "\"\$as_me:4436: $ac_compile\"" >&5) ++ (eval echo "\"\$as_me:4429: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 +- (eval echo "\"\$as_me:4439: $NM \\\"conftest.$ac_objext\\\"\"" >&5) ++ (eval echo "\"\$as_me:4432: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 +- (eval echo "\"\$as_me:4442: output\"" >&5) ++ (eval echo "\"\$as_me:4435: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" +@@ -5645,7 +5638,7 @@ ia64-*-hpux*) + ;; + *-*-irix6*) + # Find out which ABI we are using. +- echo '#line 5648 "configure"' > conftest.$ac_ext ++ echo '#line 5641 "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? +@@ -6434,7 +6427,7 @@ else + # Broken: fails on valid input. + continue + fi +-rm -f conftest.err conftest.i conftest.$ac_ext ++rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. +@@ -6450,11 +6443,11 @@ else + ac_preproc_ok=: + break + fi +-rm -f conftest.err conftest.i conftest.$ac_ext ++rm -f conftest.err conftest.$ac_ext + + done + # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +-rm -f conftest.i conftest.err conftest.$ac_ext ++rm -f conftest.err conftest.$ac_ext + if $ac_preproc_ok; then : + break + fi +@@ -6493,7 +6486,7 @@ else + # Broken: fails on valid input. + continue + fi +-rm -f conftest.err conftest.i conftest.$ac_ext ++rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. +@@ -6509,18 +6502,18 @@ else + ac_preproc_ok=: + break + fi +-rm -f conftest.err conftest.i conftest.$ac_ext ++rm -f conftest.err conftest.$ac_ext + + done + # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +-rm -f conftest.i conftest.err conftest.$ac_ext ++rm -f 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 ; } ++as_fn_error "C preprocessor \"$CPP\" fails sanity check ++See \`config.log' for more details." "$LINENO" 5; } + fi + + ac_ext=c +@@ -6649,7 +6642,8 @@ 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 : ++eval as_val=\$$as_ac_Header ++ if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF + #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 + _ACEOF +@@ -7170,11 +7164,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:7173: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:7167: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 +- echo "$as_me:7177: \$? = $ac_status" >&5 ++ echo "$as_me:7171: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. +@@ -7509,11 +7503,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:7512: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:7506: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 +- echo "$as_me:7516: \$? = $ac_status" >&5 ++ echo "$as_me:7510: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. +@@ -7614,11 +7608,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:7617: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:7611: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 +- echo "$as_me:7621: \$? = $ac_status" >&5 ++ echo "$as_me:7615: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized +@@ -7669,11 +7663,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:7672: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:7666: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 +- echo "$as_me:7676: \$? = $ac_status" >&5 ++ echo "$as_me:7670: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized +@@ -10053,7 +10047,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 10056 "configure" ++#line 10050 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -10149,7 +10143,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 10152 "configure" ++#line 10146 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -10498,7 +10492,8 @@ ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE + #endif + + " +-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : ++eval as_val=\$$as_ac_Header ++ if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF + #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 + _ACEOF +@@ -10849,7 +10844,6 @@ DEFS=-DHAVE_CONFIG_H + + ac_libobjs= + ac_ltlibobjs= +-U= + for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' +@@ -10873,39 +10867,39 @@ else + fi + + if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then +- as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. ++ as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then +- as_fn_error $? "conditional \"AMDEP\" was never defined. ++ as_fn_error "conditional \"AMDEP\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then +- as_fn_error $? "conditional \"am__fastdepCC\" was never defined. ++ as_fn_error "conditional \"am__fastdepCC\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${OS_FREEBSD_TRUE}" && test -z "${OS_FREEBSD_FALSE}"; then +- as_fn_error $? "conditional \"OS_FREEBSD\" was never defined. ++ as_fn_error "conditional \"OS_FREEBSD\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${OS_LINUX_TRUE}" && test -z "${OS_LINUX_FALSE}"; then +- as_fn_error $? "conditional \"OS_LINUX\" was never defined. ++ as_fn_error "conditional \"OS_LINUX\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${OS_OSF_TRUE}" && test -z "${OS_OSF_FALSE}"; then +- as_fn_error $? "conditional \"OS_OSF\" was never defined. ++ as_fn_error "conditional \"OS_OSF\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${OS_SOLARIS_TRUE}" && test -z "${OS_SOLARIS_FALSE}"; then +- as_fn_error $? "conditional \"OS_SOLARIS\" was never defined. ++ as_fn_error "conditional \"OS_SOLARIS\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${OS_WIN32_MINGW_TRUE}" && test -z "${OS_WIN32_MINGW_FALSE}"; then +- as_fn_error $? "conditional \"OS_WIN32_MINGW\" was never defined. ++ as_fn_error "conditional \"OS_WIN32_MINGW\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + if test -z "${OS_WIN32_CYGWIN_TRUE}" && test -z "${OS_WIN32_CYGWIN_FALSE}"; then +- as_fn_error $? "conditional \"OS_WIN32_CYGWIN\" was never defined. ++ as_fn_error "conditional \"OS_WIN32_CYGWIN\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + +@@ -11055,19 +11049,19 @@ export LANGUAGE + (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +-# as_fn_error STATUS ERROR [LINENO LOG_FD] +-# ---------------------------------------- ++# as_fn_error ERROR [LINENO LOG_FD] ++# --------------------------------- + # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are + # provided, also output the error to LOG_FD, referencing LINENO. Then exit the +-# script with STATUS, using 1 if that was 0. ++# script with status $?, using 1 if that was 0. + as_fn_error () + { +- as_status=$1; test $as_status -eq 0 && as_status=1 +- if test "$4"; then +- as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 ++ as_status=$?; test $as_status -eq 0 && as_status=1 ++ if test "$3"; then ++ as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi +- $as_echo "$as_me: error: $2" >&2 ++ $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status + } # as_fn_error + +@@ -11263,7 +11257,7 @@ $as_echo X"$as_dir" | + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" +- } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" ++ } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + + } # as_fn_mkdir_p +@@ -11317,7 +11311,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + # values after options handling. + ac_log=" + This file was extended by sg3_utils $as_me 1.31, which was +-generated by GNU Autoconf 2.67. Invocation command line was ++generated by GNU Autoconf 2.65. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS +@@ -11383,10 +11377,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" + ac_cs_version="\\ + sg3_utils config.status 1.31 +-configured by $0, generated by GNU Autoconf 2.67, ++configured by $0, generated by GNU Autoconf 2.65, + with options \\"\$ac_cs_config\\" + +-Copyright (C) 2010 Free Software Foundation, Inc. ++Copyright (C) 2009 Free Software Foundation, Inc. + This config.status script is free software; the Free Software Foundation + gives unlimited permission to copy, distribute and modify it." + +@@ -11404,16 +11398,11 @@ ac_need_defaults=: + while test $# != 0 + do + case $1 in +- --*=?*) ++ --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; +- --*=) +- ac_option=`expr "X$1" : 'X\([^=]*\)='` +- ac_optarg= +- ac_shift=: +- ;; + *) + ac_option=$1 + ac_optarg=$2 +@@ -11435,7 +11424,6 @@ do + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; +- '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; +@@ -11448,7 +11436,7 @@ do + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header +- as_fn_error $? "ambiguous option: \`$1' ++ as_fn_error "ambiguous option: \`$1' + Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; +@@ -11457,7 +11445,7 @@ Try \`$0 --help' for more information.";; + ac_cs_silent=: ;; + + # This is an error. +- -*) as_fn_error $? "unrecognized option: \`$1' ++ -*) as_fn_error "unrecognized option: \`$1' + Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" +@@ -11775,7 +11763,7 @@ do + "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + +- *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; ++ *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac + done + +@@ -11813,7 +11801,7 @@ $debug || + { + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ++} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 + + # Set up the scripts for CONFIG_FILES section. + # No need to generate them if there are no CONFIG_FILES. +@@ -11830,7 +11818,7 @@ if test "x$ac_cr" = x; then + fi + ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` + if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then +- ac_cs_awk_cr='\\r' ++ ac_cs_awk_cr='\r' + else + ac_cs_awk_cr=$ac_cr + fi +@@ -11844,18 +11832,18 @@ _ACEOF + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" + } >conf$$subs.sh || +- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ++ as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ++ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + ac_delim='%!_!# ' + for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || +- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ++ as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then +- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ++ as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +@@ -11944,28 +11932,20 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + else + cat + fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ +- || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 ++ || as_fn_error "could not setup config files machinery" "$LINENO" 5 + _ACEOF + +-# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and ++# VPATH may cause trouble with some makes, so we remove $(srcdir), ++# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and + # trailing colons and then remove the whole line if VPATH becomes empty + # (actually we leave an empty line to preserve line numbers). + if test "x$srcdir" = x.; then +- ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +-h +-s/// +-s/^/:/ +-s/[ ]*$/:/ +-s/:\$(srcdir):/:/g +-s/:\${srcdir}:/:/g +-s/:@srcdir@:/:/g +-s/^:*// ++ ac_vpsub='/^[ ]*VPATH[ ]*=/{ ++s/:*\$(srcdir):*/:/ ++s/:*\${srcdir}:*/:/ ++s/:*@srcdir@:*/:/ ++s/^\([^=]*=[ ]*\):*/\1/ + s/:*$// +-x +-s/\(=[ ]*\).*/\1/ +-G +-s/\n// + s/^[^=]*=[ ]*$// + }' + fi +@@ -11993,7 +11973,7 @@ for ac_last_try in false false :; do + if test -z "$ac_t"; then + break + elif $ac_last_try; then +- as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 ++ as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +@@ -12078,7 +12058,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + _ACAWK + _ACEOF + cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +- as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 ++ as_fn_error "could not setup config headers machinery" "$LINENO" 5 + fi # test -n "$CONFIG_HEADERS" + + +@@ -12091,7 +12071,7 @@ do + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; +- :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; ++ :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac +@@ -12119,7 +12099,7 @@ do + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || +- as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; ++ as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" +@@ -12146,7 +12126,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ +- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac +@@ -12283,22 +12263,22 @@ s&@MKDIR_P@&$ac_MKDIR_P&;t t + $ac_datarootdir_hack + " + eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ +- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 + + test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +-which seems to be undefined. Please make sure it is defined" >&5 ++which seems to be undefined. Please make sure it is defined." >&5 + $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +-which seems to be undefined. Please make sure it is defined" >&2;} ++which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ +- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # +@@ -12309,19 +12289,19 @@ which seems to be undefined. Please make sure it is defined" >&2;} + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ +- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 + $as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ +- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ +- || as_fn_error $? "could not create -" "$LINENO" 5 ++ || as_fn_error "could not create -" "$LINENO" 5 + fi + # Compute "$ac_file"'s index in $config_headers. + _am_arg="$ac_file" +@@ -13106,7 +13086,7 @@ _ACEOF + ac_clean_files=$ac_clean_files_save + + test $ac_write_fail = 0 || +- as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 ++ as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + + # configure is writing to config.log, and then calls config.status. +@@ -13127,7 +13107,7 @@ if test "$no_create" != yes; then + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. +- $ac_cs_success || as_fn_exit 1 ++ $ac_cs_success || as_fn_exit $? + fi + if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 diff --git a/lib/sg_pt_iscsi.c b/lib/sg_pt_iscsi.c -new file mode 100644 -index 0000000..8f09baf ---- /dev/null +index d6db51c..8221d12 100644 +--- a/lib/sg_pt_iscsi.c +++ b/lib/sg_pt_iscsi.c -@@ -0,0 +1,392 @@ -+/* -+ * Copyright (c) 2010 Ronnie Sahlberg -+ * All rights reserved. -+ * Use of this source code is governed by a BSD-style -+ * license that can be found in the BSD_LICENSE file. -+ */ -+ -+#ifdef HAVE_CONFIG_H -+#include "config.h" -+#endif -+ -+#ifdef CONFIG_LIBISCSI -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+#include "sg_lib.h" -+#include "sg_pt.h" -+#include "sg_linux_inc.h" -+#include "sg_pt_iscsi.h" -+ -+struct sg_context { -+ struct iscsi_context *context; -+ int lun; -+}; -+struct sg_context *iscsi; -+ -+struct sg_pt_iscsi { -+ int os_err; -+ -+ int xferdir; -+ const unsigned char *cdb; -+ int cdb_len; -+ unsigned char *sense; -+ int sense_len; -+ int max_sense_len; -+ struct iscsi_data datain; -+ struct iscsi_data dataout; -+ int device_status; -+}; -+ -+struct sg_pt_base { -+ struct sg_pt_iscsi impl; -+}; -+ -+int -+do_iscsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ struct scsi_task *task; -+ struct iscsi_data *data = NULL; -+ -+ /* keep compiler happy */ -+ time_secs = time_secs; -+ verbose = verbose; -+ fd = fd; -+ -+ task = malloc(sizeof(struct scsi_task)); -+ bzero(task, sizeof(struct scsi_task)); -+ -+ ptp->os_err = 0; -+ -+ task->cdb_size = ptp->cdb_len; -+ memcpy(&task->cdb[0], ptp->cdb, task->cdb_size); -+ -+ task->xfer_dir = ptp->xferdir; -+ switch (task->xfer_dir) { -+ case SCSI_XFER_NONE: -+ task->expxferlen = 0; -+ break; -+ case SCSI_XFER_READ: -+ task->expxferlen = ptp->datain.size; -+ break; -+ case SCSI_XFER_WRITE: -+ task->expxferlen = ptp->dataout.size; -+ data = &ptp->dataout; -+ break; -+ } -+ -+ if (iscsi_scsi_command_sync(iscsi->context, iscsi->lun, task, data) == NULL) { -+ printf("error\n"); -+ scsi_free_scsi_task(task); -+ ptp->os_err = -1; -+ return -1; -+ } -+ -+ ptp->device_status = task->status; -+ if (task->status == SCSI_STATUS_GOOD) { -+ memcpy(ptp->datain.data, task->datain.data, -+ task->datain.sizedatain.size? -+ task->datain.size:ptp->datain.size); -+ scsi_free_scsi_task(task); -+ return 0; -+ } -+ -+ if (task->status == SCSI_STATUS_CHECK_CONDITION) { -+ /* +2 is to strip off the initial "length" and just copy the sense blob itself */ -+ ptp->sense_len = (ptp->max_sense_len<(task->datain.size-2))?ptp->max_sense_len:(task->datain.size-2); -+ memcpy(ptp->sense, task->datain.data+2, ptp->sense_len); -+ scsi_free_scsi_task(task); -+ return 0; -+ } -+ return -1; -+} -+ -+ -+struct sg_pt_base * -+construct_iscsi_pt_obj(void) -+{ -+ struct sg_pt_iscsi * ptp; -+ -+ ptp = (struct sg_pt_iscsi *) -+ calloc(1, sizeof(struct sg_pt_iscsi)); -+ ptp->xferdir = SCSI_XFER_NONE; -+ return (struct sg_pt_base *)ptp; -+} -+ -+void -+clear_iscsi_pt_obj(struct sg_pt_base * vp) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ if (ptp) { -+ memset(ptp, 0, sizeof(struct sg_pt_iscsi)); -+ ptp->xferdir = SCSI_XFER_READ; -+ } -+} -+ -+void -+destruct_iscsi_pt_obj(struct sg_pt_base * vp) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ if (ptp) -+ free(ptp); -+} -+ -+void -+set_iscsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, -+ int cdb_len) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ ptp->cdb = cdb; -+ ptp->cdb_len = cdb_len; -+} -+ -+void -+set_iscsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, -+ int max_sense_len) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ memset(sense, 0, max_sense_len); -+ ptp->sense = sense; -+ ptp->max_sense_len = max_sense_len; -+} -+ -+void -+set_iscsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, -+ int dxfer_len) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ if (dxfer_len > 0) { -+ ptp->datain.data = dxferp; -+ ptp->datain.size = dxfer_len; -+ ptp->xferdir = SCSI_XFER_READ; -+ } -+} -+ -+void -+set_iscsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, -+ int dxfer_len) -+{ -+ struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ if (dxfer_len > 0) { -+ ptp->dataout.data = (unsigned char *)dxferp; -+ ptp->dataout.size = dxfer_len; -+ ptp->xferdir = SCSI_XFER_WRITE; -+ } -+} -+ -+int -+get_iscsi_pt_resid(const struct sg_pt_base * vp) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ -+ return 0; -+} -+ -+int -+get_iscsi_pt_result_category(const struct sg_pt_base * vp) -+{ -+ const struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ if (ptp->os_err) -+ return SCSI_PT_RESULT_OS_ERR; -+ -+ if (ptp->device_status) -+ return SCSI_PT_RESULT_SENSE; -+ else -+ return SCSI_PT_RESULT_GOOD; -+} -+ -+int -+get_iscsi_pt_os_err(const struct sg_pt_base * vp) -+{ -+ const struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ return ptp->os_err; -+} -+ -+int -+get_iscsi_pt_sense_len(const struct sg_pt_base * vp) -+{ -+ const struct sg_pt_iscsi * ptp = &vp->impl; -+ -+ return ptp->sense_len; -+} -+ -+void -+set_iscsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ pack_id = pack_id; -+} -+ -+int -+iscsi_pt_close_device(int device_fd) -+{ -+ /* keep compiler happy */ -+ device_fd = device_fd; -+ -+ iscsi_logout_sync(iscsi->context); -+ iscsi_destroy_context(iscsi->context); -+ free(iscsi); -+ iscsi = NULL; -+ return 0; -+} -+ -+char * -+get_iscsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) -+{ -+ const struct sg_pt_iscsi * ptp = &vp->impl; -+ const char * cp; -+ -+ cp = safe_strerror(ptp->os_err); -+ strncpy(b, cp, max_b_len); -+ if ((int)strlen(cp) >= max_b_len) -+ b[max_b_len - 1] = '\0'; -+ return b; -+} -+ -+int -+get_iscsi_pt_transport_err(const struct sg_pt_base * vp) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ -+ return 0; -+} -+ -+char * -+get_iscsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, -+ char * b) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ max_b_len = max_b_len; -+ b = b; -+ -+ return ""; -+} -+ -+void -+set_iscsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ tag = tag; -+} -+ -+void -+set_iscsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ tmf_code = tmf_code; -+} -+ -+void -+set_iscsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ attribute = attribute; -+ priority = priority; -+} -+ -+int -+get_iscsi_pt_duration_ms(const struct sg_pt_base * vp) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ -+ return 0; -+} -+ -+ -+int -+get_iscsi_pt_status_response(const struct sg_pt_base * vp) -+{ -+ /* keep compiler happy */ -+ vp = vp; -+ -+ return 0; -+} -+ -+int -+iscsi_pt_open_device(const char *device_name, int read_only, int verbose) -+{ -+ char *tmpstr = NULL, *portal, *target, *lun; -+ -+ /* keep compiler happy */ -+ read_only = read_only; -+ verbose = verbose; -+ -+ if (strncmp(device_name, "iscsi://", 8)) { -+ return -1; -+ } -+ -+ tmpstr = strdup(device_name); -+ portal = tmpstr+8; -+ target = index(portal, '/'); -+ if (!target) { -+ fprintf(stderr, "Invalid iscsi url : %s\n", device_name); -+ free(tmpstr); -+ return -1; -+ } -+ *target++ = 0; -+ lun = index(target, '/'); -+ if (!lun) { -+ fprintf(stderr, "Invalid iscsi url : %s\n", device_name); -+ free(tmpstr); -+ return -1; -+ } -+ *lun++ = 0; -+ -+ iscsi = malloc(sizeof(struct sg_context)); -+ iscsi->context = iscsi_create_context("iqn.2010-12.org.sg3utils"); -+ if (!iscsi->context) { -+ fprintf(stderr, "Failed to create iscsi context for url %s\n", device_name); -+ free(tmpstr); -+ free(iscsi); -+ iscsi = NULL; -+ return -1; -+ } -+ -+ iscsi->lun = atoi(lun); -+ iscsi_set_targetname(iscsi->context, target); -+ iscsi_set_session_type(iscsi->context, ISCSI_SESSION_NORMAL); -+ iscsi_set_header_digest(iscsi->context, ISCSI_HEADER_DIGEST_NONE_CRC32C); -+ -+ if (iscsi_full_connect_sync(iscsi->context, portal, iscsi->lun) != 0) { -+ fprintf(stderr, "iSCSI login failed: %s\n", iscsi_get_error(iscsi->context)); -+ free(tmpstr); +@@ -266,57 +266,62 @@ get_iscsi_pt_transport_err_str(const struct sg_pt_iscsi *iscsi, int max_b_len, + int + iscsi_pt_open_device(const char *device_name, int read_only, int verbose) + { +- char *tmpstr = NULL, *portal, *target, *lun; + static int context_num = 0; + struct iscsi_lun_context *iscsi; ++ struct iscsi_url *iscsi_url = NULL; + + /* keep compiler happy */ + read_only = read_only; + verbose = verbose; + + if (strncmp(device_name, "iscsi://", 8)) { +- return -1; ++ return -EINVAL; + } + +- tmpstr = strdup(device_name); +- portal = tmpstr+8; +- target = index(portal, '/'); +- if (!target) { +- fprintf(stderr, "Invalid iscsi url : %s\n", device_name); +- free(tmpstr); +- return -1; +- } +- *target++ = 0; +- lun = index(target, '/'); +- if (!lun) { +- fprintf(stderr, "Invalid iscsi url : %s\n", device_name); +- free(tmpstr); +- return -1; +- } +- *lun++ = 0; +- + iscsi = malloc(sizeof(struct iscsi_lun_context)); + iscsi->context = iscsi_create_context("iqn.2010-12.org.sg3utils"); + if (!iscsi->context) { +- fprintf(stderr, "Failed to create iscsi context for url %s\n", device_name); +- free(tmpstr); ++ fprintf(stderr, "Failed to create iscsi context for url %s\n%s\n", ++ device_name, iscsi_get_error(iscsi->context)); + free(iscsi); +- iscsi = NULL; +- return -1; ++ iscsi = NULL; ++ return -EINVAL; + } + +- iscsi->lun = atoi(lun); +- iscsi_set_targetname(iscsi->context, target); ++ iscsi_url = iscsi_parse_full_url(iscsi->context, device_name); ++ if (iscsi_url == NULL) { ++ fprintf(stderr, "Failed to parse URL: %s\n", ++ iscsi_get_error(iscsi->context)); + iscsi_destroy_context(iscsi->context); + free(iscsi); -+ iscsi = NULL; -+ return -1; ++ iscsi = NULL; ++ return -EINVAL; + } + -+ return ISCSI_FAKE_FD; -+} -+ -+#endif -diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c -index 3ce4cf6..4e5221b 100644 ---- a/lib/sg_pt_linux.c -+++ b/lib/sg_pt_linux.c -@@ -27,6 +27,10 @@ - #include "sg_lib.h" - #include "sg_linux_inc.h" ++ iscsi->lun = iscsi_url->lun; ++ iscsi_set_targetname(iscsi->context, iscsi_url->target); + iscsi_set_session_type(iscsi->context, ISCSI_SESSION_NORMAL); + iscsi_set_header_digest(iscsi->context, ISCSI_HEADER_DIGEST_NONE_CRC32C); -+#ifdef CONFIG_LIBISCSI -+#include "sg_pt_iscsi.h" -+#endif -+ - #define DEF_TIMEOUT 60000 /* 60,000 millisecs (60 seconds) */ - - static const char * linux_host_bytes[] = { -@@ -117,6 +121,12 @@ scsi_pt_open_flags(const char * device_name, int flags, int verbose) - { - int fd; - -+#ifdef CONFIG_LIBISCSI -+ if (!strncmp(device_name, "iscsi://", 8)) { -+ return iscsi_pt_open_device(device_name, flags, verbose); +- if (iscsi_full_connect_sync(iscsi->context, portal, iscsi->lun) != 0) { +- fprintf(stderr, "iSCSI login failed: %s\n", iscsi_get_error(iscsi->context)); +- free(tmpstr); ++ if (iscsi_url->user != NULL) { ++ if (iscsi_set_initiator_username_pwd(iscsi->context, iscsi_url->user, iscsi_url->passwd) != 0) { ++ fprintf(stderr, "Failed to set initiator username and password\n%s\n", ++ iscsi_get_error(iscsi->context)); ++ iscsi_destroy_url(iscsi_url); ++ iscsi_destroy_context(iscsi->context); ++ free(iscsi); ++ iscsi = NULL; ++ return -EINVAL; ++ } + } -+#endif + - if (verbose > 1) { - if (NULL == sg_warnings_strm) - sg_warnings_strm = stderr; -@@ -135,6 +145,12 @@ scsi_pt_close_device(int device_fd) - { - int res; ++ if (iscsi_full_connect_sync(iscsi->context, iscsi_url->portal, iscsi->lun) != 0) { ++ fprintf(stderr, "iSCSI login failed: %s\n", ++ iscsi_get_error(iscsi->context)); + iscsi_destroy_context(iscsi->context); + free(iscsi); +- iscsi = NULL; +- return -1; ++ iscsi = NULL; ++ return -EINVAL; + } -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return iscsi_pt_close_device(device_fd); -+ } -+#endif -+ - res = close(device_fd); - if (res < 0) - res = -errno; -@@ -147,6 +163,12 @@ construct_scsi_pt_obj() - { - struct sg_pt_linux_scsi * ptp; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return construct_iscsi_pt_obj(); -+ } -+#endif -+ - ptp = (struct sg_pt_linux_scsi *) - calloc(1, sizeof(struct sg_pt_linux_scsi)); - if (ptp) { -@@ -161,6 +183,12 @@ destruct_scsi_pt_obj(struct sg_pt_base * vp) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return destruct_iscsi_pt_obj(vp); -+ } -+#endif -+ - if (ptp) - free(ptp); - } -@@ -170,6 +198,12 @@ clear_scsi_pt_obj(struct sg_pt_base * vp) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return clear_iscsi_pt_obj(vp); -+ } -+#endif -+ - if (ptp) { - memset(ptp, 0, sizeof(struct sg_pt_linux_scsi)); - ptp->io_hdr.interface_id = 'S'; -@@ -183,6 +217,12 @@ set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_cdb(vp, cdb, cdb_len); -+ } -+#endif -+ - if (ptp->io_hdr.cmdp) - ++ptp->in_err; - ptp->io_hdr.cmdp = (unsigned char *)cdb; -@@ -195,6 +235,12 @@ set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_sense(vp, sense, max_sense_len); -+ } -+#endif -+ - if (ptp->io_hdr.sbp) - ++ptp->in_err; - memset(sense, 0, max_sense_len); -@@ -209,6 +255,12 @@ set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_data_in(vp, dxferp, dxfer_len); -+ } -+#endif -+ - if (ptp->io_hdr.dxferp) - ++ptp->in_err; - if (dxfer_len > 0) { -@@ -225,6 +277,12 @@ set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_data_out(vp, dxferp, dxfer_len); -+ } -+#endif -+ - if (ptp->io_hdr.dxferp) - ++ptp->in_err; - if (dxfer_len > 0) { -@@ -239,6 +297,13 @@ set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_packet_id(vp, pack_id); -+ return; -+ } -+#endif -+ - ptp->io_hdr.pack_id = pack_id; - } - -@@ -247,6 +312,13 @@ set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_tag(vp, tag); -+ return; -+ } -+#endif -+ - ++ptp->in_err; - tag = tag; /* dummy to silence compiler */ - } -@@ -257,6 +329,13 @@ set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_task_management(vp, tmf_code); -+ return; -+ } -+#endif -+ - ++ptp->in_err; - tmf_code = tmf_code; /* dummy to silence compiler */ - } -@@ -266,6 +345,13 @@ set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_task_attr(vp, attribute, priority); -+ return; -+ } -+#endif -+ - ++ptp->in_err; - attribute = attribute; /* dummy to silence compiler */ - priority = priority; /* dummy to silence compiler */ -@@ -303,6 +389,12 @@ do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return do_iscsi_pt(vp, fd, time_secs, verbose); -+ } -+#endif -+ - if (NULL == sg_warnings_strm) - sg_warnings_strm = stderr; - ptp->os_err = 0; -@@ -339,6 +431,12 @@ get_scsi_pt_result_category(const struct sg_pt_base * vp) - int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK; - int scsi_st = ptp->io_hdr.status & 0x7e; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_result_category(vp); -+ } -+#endif -+ - if (ptp->os_err) - return SCSI_PT_RESULT_OS_ERR; - else if (ptp->io_hdr.host_status) -@@ -360,6 +458,12 @@ get_scsi_pt_resid(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_resid(vp); -+ } -+#endif -+ - return ptp->io_hdr.resid; - } - -@@ -368,6 +472,12 @@ get_scsi_pt_status_response(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_status_response(vp); -+ } -+#endif -+ - return ptp->io_hdr.status; - } - -@@ -376,6 +486,12 @@ get_scsi_pt_sense_len(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_sense_len(vp); -+ } -+#endif -+ - return ptp->io_hdr.sb_len_wr; - } - -@@ -384,6 +500,12 @@ get_scsi_pt_duration_ms(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_duration_ms(vp); -+ } -+#endif -+ - return ptp->io_hdr.duration; - } - -@@ -392,6 +514,12 @@ get_scsi_pt_transport_err(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_transport_err(vp); -+ } -+#endif -+ - return (ptp->io_hdr.host_status << 8) + ptp->io_hdr.driver_status; - } - -@@ -400,6 +528,12 @@ get_scsi_pt_os_err(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_os_err(vp); -+ } -+#endif -+ - return ptp->os_err; - } - -@@ -416,6 +550,12 @@ get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, - const char * driv_cp = "invalid"; - const char * sugg_cp = "invalid"; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_transport_err_str(vp, max_b_len, b); -+ } -+#endif -+ - m = max_b_len; - n = 0; - if (hs) { -@@ -451,6 +591,12 @@ get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) - const struct sg_pt_linux_scsi * ptp = &vp->impl; - const char * cp; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_os_err_str(vp, max_b_len, b); -+ } -+#endif -+ - cp = safe_strerror(ptp->os_err); - strncpy(b, cp, max_b_len); - if ((int)strlen(cp) >= max_b_len) -@@ -567,6 +713,12 @@ scsi_pt_open_flags(const char * device_name, int flags, int verbose) - { - int fd; - -+#ifdef CONFIG_LIBISCSI -+ if (!strncmp(device_name, "iscsi://", 8)) { -+ return iscsi_pt_open_device(device_name, flags, verbose); -+ } -+#endif -+ - if (! bsg_major_checked) { - bsg_major_checked = 1; - find_bsg_major(verbose); -@@ -589,6 +741,12 @@ scsi_pt_close_device(int device_fd) - { - int res; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return iscsi_pt_close_device(device_fd); -+ } -+#endif -+ - res = close(device_fd); - if (res < 0) - res = -errno; -@@ -601,6 +759,12 @@ construct_scsi_pt_obj() - { - struct sg_pt_linux_scsi * ptp; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return construct_iscsi_pt_obj(); -+ } -+#endif -+ - ptp = (struct sg_pt_linux_scsi *) - calloc(1, sizeof(struct sg_pt_linux_scsi)); - if (ptp) { -@@ -620,6 +784,12 @@ destruct_scsi_pt_obj(struct sg_pt_base * vp) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return destruct_iscsi_pt_obj(vp); -+ } -+#endif -+ - if (ptp) - free(ptp); - } -@@ -629,6 +799,12 @@ clear_scsi_pt_obj(struct sg_pt_base * vp) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return clear_iscsi_pt_obj(vp); -+ } -+#endif -+ - if (ptp) { - memset(ptp, 0, sizeof(struct sg_pt_linux_scsi)); - ptp->io_hdr.guard = 'Q'; -@@ -647,6 +823,12 @@ set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_cdb(vp, cdb, cdb_len); -+ } -+#endif -+ - if (ptp->io_hdr.request) - ++ptp->in_err; - /* C99 has intptr_t instead of long */ -@@ -660,6 +842,12 @@ set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_sense(vp, sense, max_sense_len); -+ } -+#endif -+ - if (ptp->io_hdr.response) - ++ptp->in_err; - memset(sense, 0, max_sense_len); -@@ -674,6 +862,12 @@ set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_data_in(vp, dxferp, dxfer_len); -+ } -+#endif -+ - if (ptp->io_hdr.din_xferp) - ++ptp->in_err; - if (dxfer_len > 0) { -@@ -689,6 +883,12 @@ set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return set_iscsi_pt_data_out(vp, dxferp, dxfer_len); -+ } -+#endif -+ - if (ptp->io_hdr.dout_xferp) - ++ptp->in_err; - if (dxfer_len > 0) { -@@ -702,6 +902,13 @@ set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_packet_id(vp, pack_id); -+ return; -+ } -+#endif -+ - ptp->io_hdr.spare_in = pack_id; - } - -@@ -710,6 +917,13 @@ set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_tag(vp, tag); -+ return; -+ } -+#endif -+ - ptp->io_hdr.request_tag = tag; - } - -@@ -719,6 +933,13 @@ set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_task_management(vp, tmf_code); -+ return; -+ } -+#endif -+ - ptp->io_hdr.subprotocol = 1; /* SCSI task management function */ - ptp->tmf_request[0] = (unsigned char)tmf_code; /* assume it fits */ - ptp->io_hdr.request = (__u64)(long)(&(ptp->tmf_request[0])); -@@ -730,6 +951,12 @@ set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority) - { - struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ set_iscsi_pt_task_attr(vp, attribute, priority); -+ return; -+ } -+#endif - ptp->io_hdr.request_attr = attribute; - ptp->io_hdr.request_priority = priority; - } -@@ -756,6 +983,12 @@ get_scsi_pt_resid(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_resid(vp); -+ } -+#endif -+ - return ptp->io_hdr.din_resid; - } - -@@ -764,6 +997,12 @@ get_scsi_pt_status_response(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_status_response(vp); -+ } -+#endif -+ - return ptp->io_hdr.device_status; - } - -@@ -772,6 +1011,12 @@ get_scsi_pt_sense_len(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_sense_len(vp); -+ } -+#endif -+ - return ptp->io_hdr.response_len; - } - -@@ -780,6 +1025,12 @@ get_scsi_pt_duration_ms(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_duration_ms(vp); -+ } -+#endif -+ - return ptp->io_hdr.duration; - } - -@@ -788,6 +1039,12 @@ get_scsi_pt_transport_err(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_transport_err(vp); -+ } -+#endif -+ - return ptp->io_hdr.transport_status; - } - -@@ -805,6 +1062,12 @@ get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, - const char * driv_cp = "invalid"; - const char * sugg_cp = "invalid"; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_transport_err_str(vp, max_b_len, b); -+ } -+#endif -+ - m = max_b_len; - n = 0; - if (hs) { -@@ -841,6 +1104,12 @@ get_scsi_pt_result_category(const struct sg_pt_base * vp) - int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK; - int scsi_st = ptp->io_hdr.device_status & 0x7e; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_result_category(vp); -+ } -+#endif -+ - if (ptp->os_err) - return SCSI_PT_RESULT_OS_ERR; - else if (ptp->io_hdr.transport_status) -@@ -862,6 +1131,12 @@ get_scsi_pt_os_err(const struct sg_pt_base * vp) - { - const struct sg_pt_linux_scsi * ptp = &vp->impl; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_os_err(vp); -+ } -+#endif -+ - return ptp->os_err; - } - -@@ -871,6 +1146,12 @@ get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) - const struct sg_pt_linux_scsi * ptp = &vp->impl; - const char * cp; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return get_iscsi_pt_os_err_str(vp, max_b_len, b); -+ } -+#endif -+ - cp = safe_strerror(ptp->os_err); - strncpy(b, cp, max_b_len); - if ((int)strlen(cp) >= max_b_len) -@@ -945,6 +1226,12 @@ do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose) - struct sg_pt_linux_scsi * ptp = &vp->impl; - void * p; - -+#ifdef CONFIG_LIBISCSI -+ if (iscsi) { -+ return do_iscsi_pt(vp, fd, time_secs, verbose); -+ } -+#endif -+ - if (! bsg_major_checked) { - bsg_major_checked = 1; - find_bsg_major(verbose); + iscsi_contexts[context_num] = iscsi;