sdparm-1.08/0000755000175000017500000000000012155115504011723 5ustar douggdouggsdparm-1.08/sdparm.spec0000664000175000017500000000721412154112737014077 0ustar douggdougg%define name sdparm %define version 1.08 %define release 1 Summary: List or change SCSI disk parameters Name: %{name} Version: %{version} Release: %{release} License: FreeBSD Group: Utilities/System URL: http://sg.danny.cz/sg/sdparm.html Source0: http://sg.danny.cz/sg/p/%{name}-%{version}.tgz BuildRoot: %{_tmppath}/%{name}-%{version}-root Packager: Douglas Gilbert %description SCSI disk parameters are held in mode pages. This utility lists or changes those parameters. Other SCSI devices (or devices that use the SCSI command set) such as CD/DVD and tape drives may also find parts of sdparm useful. Requires the linux kernel 2.4 series or later. In the 2.6 series any device node the understands a SCSI command set may be used (e.g. /dev/sda). In the 2.4 series SCSI device node may be used. Fetches Vital Product Data pages. Can send commands to start or stop the media and load or unload removable media. Warning: It is possible (but unlikely) to change SCSI disk settings such that the disk stops operating or is slowed down. Use with care. %prep %setup -q %build %configure %install if [ "$RPM_BUILD_ROOT" != "/" ]; then rm -rf $RPM_BUILD_ROOT fi make install \ DESTDIR=$RPM_BUILD_ROOT %clean if [ "$RPM_BUILD_ROOT" != "/" ]; then rm -rf $RPM_BUILD_ROOT fi %files %defattr(-,root,root) %doc ChangeLog INSTALL README CREDITS AUTHORS COPYING notes.txt %attr(0755,root,root) %{_bindir}/* # >> should that be %attr(0755,root,root) %{_sbindir}/* ?? %{_mandir}/man8/* %changelog * Thu Jun 06 2013 - dgilbert at interlog dot com - track recent spc4 and sbc3 drafts * sdparm-1.08 * Mon Mar 19 2012 - dgilbert at interlog dot com - track recent spc4 and sbc3 drafts * sdparm-1.07 * Sun Oct 31 2010 - dgilbert at interlog dot com - track recent spc4 and sbc3 drafts * sdparm-1.06 * Tue Apr 13 2010 - dgilbert at interlog dot com - update SAS Enhanced phy control mpage (spl-r04); add '--readonly' * sdparm-1.05 * Sun Sep 20 2009 - dgilbert at interlog dot com - linux bsg support, rework win32 device scan, thin provisioning * sdparm-1.04 * Mon Jun 23 2008 - dgilbert at interlog dot com - allow multiple devices to be given, profile and speed commands * sdparm-1.03 * Mon Oct 08 2007 - dgilbert at interlog dot com - add block device characteristics VPD page, descriptor based mpages * sdparm-1.02 * Thu Apr 05 2007 - dgilbert at interlog dot com - add element address assignment mode page (smc) * sdparm-1.01 * Mon Oct 16 2006 - dgilbert at interlog dot com - update Background control mode subpage, vendor specific mode pages * sdparm-1.00 * Sat Jul 08 2006 - dgilbert at interlog dot com - add old power condition page for disks * sdparm-0.99 * Thu May 18 2006 - dgilbert at interlog dot com - add medium configuration mode page * sdparm-0.98 * Wed Jan 25 2006 - dgilbert at interlog dot com - add SAT pATA control and medium partition mode (sub)pages * sdparm-0.97 * Fri Nov 18 2005 - dgilbert at interlog dot com - add capacity, ready and sync commands * sdparm-0.96 * Tue Sep 20 2005 - dgilbert at interlog dot com - add debian build directory, decode more VPD pages * sdparm-0.95 * Thu Jul 28 2005 - dgilbert at interlog dot com - add '--command=' option * sdparm-0.94 * Thu Jun 02 2005 - dgilbert at interlog dot com - add '--transport=' and '--dbd' options * sdparm-0.93 * Fri May 20 2005 - dgilbert at interlog dot com - add some tape, cd/dvd, disk, ses and rbc mode pages * sdparm-0.92 * Fri May 06 2005 - dgilbert at interlog dot com - if lk 2.4 detected, map non-sg SCSI device node to sg equivalent * sdparm-0.91 * Mon Apr 18 2005 - dgilbert at interlog dot com - initial version * sdparm-0.90 sdparm-1.08/lib/0000755000175000017500000000000012155115504012471 5ustar douggdouggsdparm-1.08/lib/Makefile.in0000664000175000017500000006420412153447426014557 0ustar douggdougg# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = lib DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__libsgutils2_la_SOURCES_DIST = sg_lib.c sg_lib_data.c \ sg_cmds_basic.c sg_cmds_basic2.c sg_cmds_extra.c sg_cmds_mmc.c \ sg_pt_common.c sg_pt_freebsd.c sg_pt_linux.c sg_io_linux.c \ sg_pt_osf1.c sg_pt_solaris.c sg_pt_win32.c @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@am_libsgutils2_la_OBJECTS = sg_lib.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_lib_data.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_basic.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_basic2.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_extra.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_cmds_mmc.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_pt_common.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_FALSE@@OS_WIN32_MINGW_TRUE@ sg_pt_win32.lo @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@am_libsgutils2_la_OBJECTS = sg_lib.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_lib_data.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic2.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_extra.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_cmds_mmc.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_pt_common.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_FALSE@@OS_WIN32_CYGWIN_TRUE@ sg_pt_win32.lo @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@am_libsgutils2_la_OBJECTS = sg_lib.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_lib_data.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_basic.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_basic2.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_extra.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_cmds_mmc.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_pt_common.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_FALSE@@OS_SOLARIS_TRUE@ sg_pt_solaris.lo @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@am_libsgutils2_la_OBJECTS = \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_lib.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_lib_data.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_basic.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_basic2.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_extra.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_cmds_mmc.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_pt_common.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_FALSE@@OS_OSF_TRUE@ sg_pt_osf1.lo @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@am_libsgutils2_la_OBJECTS = \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_lib.lo sg_lib_data.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_basic.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_basic2.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_extra.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_cmds_mmc.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_pt_common.lo \ @OS_FREEBSD_FALSE@@OS_LINUX_TRUE@ sg_pt_linux.lo sg_io_linux.lo @OS_FREEBSD_TRUE@am_libsgutils2_la_OBJECTS = sg_lib.lo sg_lib_data.lo \ @OS_FREEBSD_TRUE@ sg_cmds_basic.lo sg_cmds_basic2.lo \ @OS_FREEBSD_TRUE@ sg_cmds_extra.lo sg_cmds_mmc.lo \ @OS_FREEBSD_TRUE@ sg_pt_common.lo sg_pt_freebsd.lo am__EXTRA_libsgutils2_la_SOURCES_DIST = sg_pt_linux.c sg_io_linux.c \ sg_linux_inc.h sg_pt_osf1.c sg_pt_solaris.c sg_pt_win32.c \ getopt_long.c sg_pt_freebsd.c libsgutils2_la_OBJECTS = $(am_libsgutils2_la_OBJECTS) libsgutils2_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libsgutils2_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsgutils2_la_SOURCES) $(EXTRA_libsgutils2_la_SOURCES) DIST_SOURCES = $(am__libsgutils2_la_SOURCES_DIST) \ $(am__EXTRA_libsgutils2_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GETOPT_O_FILES = @GETOPT_O_FILES@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ 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@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @OS_FREEBSD_TRUE@libsgutils2_la_SOURCES = \ @OS_FREEBSD_TRUE@ sg_lib.c \ @OS_FREEBSD_TRUE@ sg_lib_data.c \ @OS_FREEBSD_TRUE@ sg_cmds_basic.c \ @OS_FREEBSD_TRUE@ sg_cmds_basic2.c \ @OS_FREEBSD_TRUE@ sg_cmds_extra.c \ @OS_FREEBSD_TRUE@ sg_cmds_mmc.c \ @OS_FREEBSD_TRUE@ sg_pt_common.c \ @OS_FREEBSD_TRUE@ sg_pt_freebsd.c @OS_LINUX_TRUE@libsgutils2_la_SOURCES = \ @OS_LINUX_TRUE@ sg_lib.c \ @OS_LINUX_TRUE@ sg_lib_data.c \ @OS_LINUX_TRUE@ sg_cmds_basic.c \ @OS_LINUX_TRUE@ sg_cmds_basic2.c \ @OS_LINUX_TRUE@ sg_cmds_extra.c \ @OS_LINUX_TRUE@ sg_cmds_mmc.c \ @OS_LINUX_TRUE@ sg_pt_common.c \ @OS_LINUX_TRUE@ sg_pt_linux.c \ @OS_LINUX_TRUE@ sg_io_linux.c @OS_OSF_TRUE@libsgutils2_la_SOURCES = \ @OS_OSF_TRUE@ sg_lib.c \ @OS_OSF_TRUE@ sg_lib_data.c \ @OS_OSF_TRUE@ sg_cmds_basic.c \ @OS_OSF_TRUE@ sg_cmds_basic2.c \ @OS_OSF_TRUE@ sg_cmds_extra.c \ @OS_OSF_TRUE@ sg_cmds_mmc.c \ @OS_OSF_TRUE@ sg_pt_common.c \ @OS_OSF_TRUE@ sg_pt_osf1.c @OS_SOLARIS_TRUE@libsgutils2_la_SOURCES = \ @OS_SOLARIS_TRUE@ sg_lib.c \ @OS_SOLARIS_TRUE@ sg_lib_data.c \ @OS_SOLARIS_TRUE@ sg_cmds_basic.c \ @OS_SOLARIS_TRUE@ sg_cmds_basic2.c \ @OS_SOLARIS_TRUE@ sg_cmds_extra.c \ @OS_SOLARIS_TRUE@ sg_cmds_mmc.c \ @OS_SOLARIS_TRUE@ sg_pt_common.c \ @OS_SOLARIS_TRUE@ sg_pt_solaris.c @OS_WIN32_CYGWIN_TRUE@libsgutils2_la_SOURCES = \ @OS_WIN32_CYGWIN_TRUE@ sg_lib.c \ @OS_WIN32_CYGWIN_TRUE@ sg_lib_data.c \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic.c \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic2.c \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_extra.c \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_mmc.c \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_common.c \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_win32.c @OS_WIN32_MINGW_TRUE@libsgutils2_la_SOURCES = \ @OS_WIN32_MINGW_TRUE@ sg_lib.c \ @OS_WIN32_MINGW_TRUE@ sg_lib_data.c \ @OS_WIN32_MINGW_TRUE@ sg_cmds_basic.c \ @OS_WIN32_MINGW_TRUE@ sg_cmds_basic2.c \ @OS_WIN32_MINGW_TRUE@ sg_cmds_extra.c \ @OS_WIN32_MINGW_TRUE@ sg_cmds_mmc.c \ @OS_WIN32_MINGW_TRUE@ sg_pt_common.c \ @OS_WIN32_MINGW_TRUE@ sg_pt_win32.c @OS_FREEBSD_TRUE@EXTRA_libsgutils2_la_SOURCES = \ @OS_FREEBSD_TRUE@ sg_pt_linux.c \ @OS_FREEBSD_TRUE@ sg_io_linux.c \ @OS_FREEBSD_TRUE@ sg_linux_inc.h \ @OS_FREEBSD_TRUE@ sg_pt_osf1.c \ @OS_FREEBSD_TRUE@ sg_pt_solaris.c \ @OS_FREEBSD_TRUE@ sg_pt_win32.c \ @OS_FREEBSD_TRUE@ getopt_long.c @OS_LINUX_TRUE@EXTRA_libsgutils2_la_SOURCES = \ @OS_LINUX_TRUE@ sg_pt_freebsd.c \ @OS_LINUX_TRUE@ sg_pt_osf1.c \ @OS_LINUX_TRUE@ sg_pt_solaris.c \ @OS_LINUX_TRUE@ sg_pt_win32.c \ @OS_LINUX_TRUE@ getopt_long.c @OS_OSF_TRUE@EXTRA_libsgutils2_la_SOURCES = \ @OS_OSF_TRUE@ sg_pt_linux.c \ @OS_OSF_TRUE@ sg_io_linux.c \ @OS_OSF_TRUE@ sg_pt_freebsd.c \ @OS_OSF_TRUE@ sg_pt_solaris.c \ @OS_OSF_TRUE@ sg_pt_win32.c \ @OS_OSF_TRUE@ getopt_long.c @OS_SOLARIS_TRUE@EXTRA_libsgutils2_la_SOURCES = \ @OS_SOLARIS_TRUE@ sg_pt_linux.c \ @OS_SOLARIS_TRUE@ sg_io_linux.c \ @OS_SOLARIS_TRUE@ sg_linux_inc.h \ @OS_SOLARIS_TRUE@ sg_pt_freebsd.c \ @OS_SOLARIS_TRUE@ sg_pt_osf1.c \ @OS_SOLARIS_TRUE@ sg_pt_win32.c \ @OS_SOLARIS_TRUE@ getopt_long.c @OS_WIN32_CYGWIN_TRUE@EXTRA_libsgutils2_la_SOURCES = \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_linux.c \ @OS_WIN32_CYGWIN_TRUE@ sg_io_linux.c \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_freebsd.c \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_osf1.c \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_solaris.c \ @OS_WIN32_CYGWIN_TRUE@ getopt_long.c @OS_WIN32_MINGW_TRUE@EXTRA_libsgutils2_la_SOURCES = \ @OS_WIN32_MINGW_TRUE@ sg_pt_linux.c \ @OS_WIN32_MINGW_TRUE@ sg_io_linux.c \ @OS_WIN32_MINGW_TRUE@ sg_pt_freebsd.c \ @OS_WIN32_MINGW_TRUE@ sg_pt_osf1.c \ @OS_WIN32_MINGW_TRUE@ sg_pt_solaris.c \ @OS_WIN32_MINGW_TRUE@ getopt_long.c # For C++/clang testing # -std= can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W # AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11 lib_LTLIBRARIES = libsgutils2.la libsgutils2_la_LDFLAGS = -version-info 2:0:0 libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@ libsgutils2_la_DEPENDENCIES = @GETOPT_O_FILES@ all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu lib/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsgutils2.la: $(libsgutils2_la_OBJECTS) $(libsgutils2_la_DEPENDENCIES) $(EXTRA_libsgutils2_la_DEPENDENCIES) $(libsgutils2_la_LINK) -rpath $(libdir) $(libsgutils2_la_OBJECTS) $(libsgutils2_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt_long.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_basic.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_basic2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_extra.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_mmc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_io_linux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_lib_data.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_common.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_freebsd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_linux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_osf1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_solaris.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_win32.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # 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. .NOEXPORT: sdparm-1.08/lib/sg_cmds_basic.c0000664000175000017500000004757312142450532015436 0ustar douggdougg/* * Copyright (c) 1999-2013 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. */ /* * CONTENTS * Some SCSI commands are executed in many contexts and hence began * to appear in several sg3_utils utilities. This files centralizes * some of the low level command execution code. In most cases the * interpretation of the command response is left to the each * utility. */ #include #include #include #include #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sg_pt.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif static const char * version_str = "1.61 20130507"; #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ #define EBUFF_SZ 256 #define DEF_PT_TIMEOUT 60 /* 60 seconds */ #define START_PT_TIMEOUT 120 /* 120 seconds == 2 minutes */ #define LONG_PT_TIMEOUT 7200 /* 7,200 seconds == 120 minutes */ #define INQUIRY_CMD 0x12 #define INQUIRY_CMDLEN 6 #define REQUEST_SENSE_CMD 0x3 #define REQUEST_SENSE_CMDLEN 6 #define REPORT_LUNS_CMD 0xa0 #define REPORT_LUNS_CMDLEN 12 #define TUR_CMD 0x0 #define TUR_CMDLEN 6 #define INQUIRY_RESP_INITIAL_LEN 36 const char * sg_cmds_version() { return version_str; } /* Returns file descriptor >= 0 if successful. If error in Unix returns negated errno. */ int sg_cmds_open_device(const char * device_name, int read_only, int verbose) { return scsi_pt_open_device(device_name, read_only, verbose); } /* Returns file descriptor >= 0 if successful. If error in Unix returns negated errno. */ int sg_cmds_open_flags(const char * device_name, int flags, int verbose) { return scsi_pt_open_flags(device_name, flags, verbose); } /* Returns 0 if successful. If error in Unix returns negated errno. */ int sg_cmds_close_device(int device_fd) { return scsi_pt_close_device(device_fd); } static int sg_cmds_process_helper(const char * leadin, int mx_di_len, int resid, const unsigned char * sbp, int slen, int noisy, int verbose, int * o_sense_cat) { int scat, got; int n = 0; int check_data_in = 0; char b[512]; scat = sg_err_category_sense(sbp, slen); switch (scat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: case SG_LIB_CAT_NO_SENSE: n = 0; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_MEDIUM_HARD: ++check_data_in; /* drop through */ case SG_LIB_CAT_UNIT_ATTENTION: default: n = noisy; break; } if (verbose || n) { sg_get_sense_str(leadin, sbp, slen, (verbose > 1), sizeof(b), b); fprintf(sg_warnings_strm, "%s", b); if ((mx_di_len > 0) && (resid > 0)) { got = mx_di_len - resid; if ((verbose > 2) || check_data_in || (got > 0)) fprintf(sg_warnings_strm, " pass-through requested " "%d bytes but got %d bytes\n", mx_di_len, got); } } if (o_sense_cat) *o_sense_cat = scat; return -2; } /* This is a helper function used by sg_cmds_* implementations after * the call to the pass-through. pt_res is returned from do_scsi_pt(). * If valid sense data is found it is decoded and output to sg_warnings_strm * (def: stderr); depending on the 'noisy' and 'verbose' settings. * Returns -2 for sense data (may not be fatal), -1 for failed, or the * number of data in bytes received. For data out (to device) or no data, * set 'mx_di_len' to 0 or less. If -2 returned then sense category * output via 'o_sense_cat' pointer (if not NULL). Note that several sense * categories also have data in bytes received; -2 is still returned. */ int sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin, int pt_res, int mx_di_len, const unsigned char * sbp, int noisy, int verbose, int * o_sense_cat) { int got, cat, duration, slen, resid, resp_code; char b[1024]; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (NULL == leadin) leadin = ""; if (pt_res < 0) { if (noisy || verbose) fprintf(sg_warnings_strm, "%s: pass through os error: %s\n", leadin, safe_strerror(-pt_res)); return -1; } else if (SCSI_PT_DO_BAD_PARAMS == pt_res) { fprintf(sg_warnings_strm, "%s: bad pass through setup\n", leadin); return -1; } else if (SCSI_PT_DO_TIMEOUT == pt_res) { fprintf(sg_warnings_strm, "%s: pass through timeout\n", leadin); return -1; } if ((verbose > 2) && ((duration = get_scsi_pt_duration_ms(ptvp)) >= 0)) fprintf(sg_warnings_strm, " duration=%d ms\n", duration); resid = (mx_di_len > 0) ? get_scsi_pt_resid(ptvp) : 0; slen = get_scsi_pt_sense_len(ptvp); switch ((cat = get_scsi_pt_result_category(ptvp))) { case SCSI_PT_RESULT_GOOD: if (slen > 7) { resp_code = sbp[0] & 0x7f; /* SBC referrals can have status=GOOD and sense_key=COMPLETED */ if (resp_code >= 0x70) { if (resp_code < 0x72) { if (SPC_SK_NO_SENSE != (0xf & sbp[2])) sg_err_category_sense(sbp, slen); } else if (resp_code < 0x74) { if (SPC_SK_NO_SENSE != (0xf & sbp[1])) sg_err_category_sense(sbp, slen); } } } if (mx_di_len > 0) { got = mx_di_len - resid; if (verbose && (resid > 0)) fprintf(sg_warnings_strm, " %s: pass-through requested " "%d bytes but got %d bytes\n", leadin, mx_di_len, got); return got; } else return 0; case SCSI_PT_RESULT_STATUS: /* other than GOOD and CHECK CONDITION */ if (verbose || noisy) { sg_get_scsi_status_str(get_scsi_pt_status_response(ptvp), sizeof(b), b); fprintf(sg_warnings_strm, "%s: scsi status: %s\n", leadin, b); } return -1; case SCSI_PT_RESULT_SENSE: return sg_cmds_process_helper(leadin, mx_di_len, resid, sbp, slen, noisy, verbose, o_sense_cat); case SCSI_PT_RESULT_TRANSPORT_ERR: if (verbose || noisy) { get_scsi_pt_transport_err_str(ptvp, sizeof(b), b); fprintf(sg_warnings_strm, "%s: transport: %s\n", leadin, b); } if ((SAM_STAT_CHECK_CONDITION == get_scsi_pt_status_response(ptvp)) && (slen > 0)) return sg_cmds_process_helper(leadin, mx_di_len, resid, sbp, slen, noisy, verbose, o_sense_cat); else return -1; case SCSI_PT_RESULT_OS_ERR: if (verbose || noisy) { get_scsi_pt_os_err_str(ptvp, sizeof(b), b); fprintf(sg_warnings_strm, "%s: os: %s\n", leadin, b); } return -1; default: fprintf(sg_warnings_strm, "%s: unknown pass through result " "category (%d)\n", leadin, cat); return -1; } } /* Invokes a SCSI INQUIRY command and yields the response * Returns 0 when successful, SG_LIB_CAT_INVALID_OP -> not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_MALFORMED -> bad response, -1 -> other errors */ int sg_ll_inquiry(int sg_fd, int cmddt, int evpd, int pg_op, void * resp, int mx_resp_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char inqCmdBlk[INQUIRY_CMDLEN] = {INQUIRY_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; unsigned char * up; struct sg_pt_base * ptvp; if (cmddt) inqCmdBlk[1] |= 2; if (evpd) inqCmdBlk[1] |= 1; inqCmdBlk[2] = (unsigned char)pg_op; /* 16 bit allocation length (was 8) is a recent SPC-3 addition */ inqCmdBlk[3] = (unsigned char)((mx_resp_len >> 8) & 0xff); inqCmdBlk[4] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " inquiry cdb: "); for (k = 0; k < INQUIRY_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", inqCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } if (resp && (mx_resp_len > 0)) { up = (unsigned char *)resp; up[0] = 0x7f; /* defensive prefill */ if (mx_resp_len > 4) up[4] = 0; } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "inquiry: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, inqCmdBlk, sizeof(inqCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "inquiry", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); destruct_scsi_pt_obj(ptvp); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else if (ret < 4) { if (verbose) fprintf(sg_warnings_strm, "inquiry: got too few " "bytes (%d)\n", ret); ret = SG_LIB_CAT_MALFORMED; } else ret = 0; return ret; } /* Yields most of first 36 bytes of a standard INQUIRY (evpd==0) response. * Returns 0 when successful, SG_LIB_CAT_INVALID_OP -> not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_MALFORMED -> bad response, -1 -> other errors */ int sg_simple_inquiry(int sg_fd, struct sg_simple_inquiry_resp * inq_data, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char inqCmdBlk[INQUIRY_CMDLEN] = {INQUIRY_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; unsigned char inq_resp[INQUIRY_RESP_INITIAL_LEN]; struct sg_pt_base * ptvp; if (inq_data) { memset(inq_data, 0, sizeof(* inq_data)); inq_data->peripheral_qualifier = 0x3; inq_data->peripheral_type = 0x1f; } inqCmdBlk[4] = (unsigned char)sizeof(inq_resp); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " inquiry cdb: "); for (k = 0; k < INQUIRY_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", inqCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } memset(inq_resp, 0, sizeof(inq_resp)); inq_resp[0] = 0x7f; /* defensive prefill */ ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "inquiry: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, inqCmdBlk, sizeof(inqCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, inq_resp, sizeof(inq_resp)); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "inquiry", res, sizeof(inq_resp), sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else if (ret < 4) { if (verbose) fprintf(sg_warnings_strm, "inquiry: got too few " "bytes (%d)\n", ret); ret = SG_LIB_CAT_MALFORMED; } else ret = 0; if (0 == ret) { inq_data->peripheral_qualifier = (inq_resp[0] >> 5) & 0x7; inq_data->peripheral_type = inq_resp[0] & 0x1f; inq_data->rmb = (inq_resp[1] & 0x80) ? 1 : 0; inq_data->version = inq_resp[2]; inq_data->byte_3 = inq_resp[3]; inq_data->byte_5 = inq_resp[5]; inq_data->byte_6 = inq_resp[6]; inq_data->byte_7 = inq_resp[7]; memcpy(inq_data->vendor, inq_resp + 8, 8); memcpy(inq_data->product, inq_resp + 16, 16); memcpy(inq_data->revision, inq_resp + 32, 4); } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI TEST UNIT READY command. * 'pack_id' is just for diagnostics, safe to set to 0. * Looks for progress indicator if 'progress' non-NULL; * if found writes value [0..65535] else write -1. * Return of 0 -> success, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_NOT_READY -> * device not ready, -1 -> other failure */ int sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char turCmdBlk[TUR_CMDLEN] = {TUR_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " test unit ready cdb: "); for (k = 0; k < TUR_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", turCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "test unit ready: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, turCmdBlk, sizeof(turCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_packet_id(ptvp, pack_id); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "test unit ready", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { if (progress) { int slen = get_scsi_pt_sense_len(ptvp); if (! sg_get_sense_progress_fld(sense_b, slen, progress)) *progress = -1; } switch (sense_cat) { case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI TEST UNIT READY command. * 'pack_id' is just for diagnostics, safe to set to 0. * Return of 0 -> success, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_NOT_READY -> * device not ready, -1 -> other failure */ int sg_ll_test_unit_ready(int sg_fd, int pack_id, int noisy, int verbose) { return sg_ll_test_unit_ready_progress(sg_fd, pack_id, NULL, noisy, verbose); } /* Invokes a SCSI REQUEST SENSE command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Request Sense not supported??, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */ int sg_ll_request_sense(int sg_fd, int desc, void * resp, int mx_resp_len, int noisy, int verbose) { int k, ret, res, sense_cat; unsigned char rsCmdBlk[REQUEST_SENSE_CMDLEN] = {REQUEST_SENSE_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (desc) rsCmdBlk[1] |= 0x1; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (mx_resp_len > 0xff) { fprintf(sg_warnings_strm, "mx_resp_len cannot exceed 255\n"); return -1; } rsCmdBlk[4] = mx_resp_len & 0xff; if (verbose) { fprintf(sg_warnings_strm, " Request Sense cmd: "); for (k = 0; k < REQUEST_SENSE_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rsCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "request sense: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rsCmdBlk, sizeof(rsCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "request sense", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_NOT_READY: /* shouldn't happen ?? */ default: ret = -1; break; } } else { if ((mx_resp_len >= 8) && (ret < 8)) { if (verbose) fprintf(sg_warnings_strm, " request sense: got %d " "bytes in response, too short\n", ret); ret = -1; } else ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI REPORT LUNS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Luns not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_NOT_READY (shouldn't happen), -1 -> other failure */ int sg_ll_report_luns(int sg_fd, int select_report, void * resp, int mx_resp_len, int noisy, int verbose) { int k, ret, res, sense_cat; unsigned char rlCmdBlk[REPORT_LUNS_CMDLEN] = {REPORT_LUNS_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; rlCmdBlk[2] = select_report & 0xff; rlCmdBlk[6] = (mx_resp_len >> 24) & 0xff; rlCmdBlk[7] = (mx_resp_len >> 16) & 0xff; rlCmdBlk[8] = (mx_resp_len >> 8) & 0xff; rlCmdBlk[9] = mx_resp_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " report luns cdb: "); for (k = 0; k < REPORT_LUNS_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rlCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "report luns: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rlCmdBlk, sizeof(rlCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "report luns", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: case SG_LIB_CAT_NOT_READY: /* shouldn't happen ?? */ ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } sdparm-1.08/lib/sg_pt_common.c0000664000175000017500000000062212061626602015325 0ustar douggdougg/* * Copyright (c) 2009-2012 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 "sg_pt.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif static const char * scsi_pt_version_str = "2.09 20120125"; const char * scsi_pt_version() { return scsi_pt_version_str; } sdparm-1.08/lib/sg_lib.c0000664000175000017500000020131012153447426014104 0ustar douggdougg/* * Copyright (c) 1999-2013 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. */ /* NOTICE: * On 5th October 2004 (v1.00) this file name was changed from sg_err.c * to sg_lib.c and the previous GPL was changed to a FreeBSD license. * The intention is to maintain this file and the related sg_lib.h file * as open source and encourage their unencumbered use. * * CONTRIBUTIONS: * This file started out as a copy of SCSI opcodes, sense keys and * additional sense codes (ASC/ASCQ) kept in the Linux SCSI subsystem * in the kernel source file: drivers/scsi/constant.c . That file * bore this notice: "Copyright (C) 1993, 1994, 1995 Eric Youngdale" * and a GPL notice. * * Much of the data in this file is derived from SCSI draft standards * found at http://www.t10.org with the "SCSI Primary Commands-4" (SPC-4) * being the central point of reference. * * Contributions: * sense key specific field decoding [Trent Piepho 20031116] * */ #include #include #include #include #include #define __STDC_FORMAT_MACROS 1 #include #include "sg_lib.h" #include "sg_lib_data.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif /* sg_lib_version_str (and datestamp) defined in sg_lib_data.c file */ #define ASCQ_ATA_PT_INFO_AVAILABLE 0x1d /* corresponding ASC is 0 */ FILE * sg_warnings_strm = NULL; /* would like to default to stderr */ static void dStrHexErr(const char* str, int len, int b_len, char * b); /* 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 my_snprintf(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); } /* Searches 'arr' for match on 'value' then 'peri_type'. If matches 'value' but not 'peri_type' then yields first 'value' match entry. Last element of 'arr' has NULL 'name'. If no match returns NULL. */ static const struct sg_lib_value_name_t * get_value_name(const struct sg_lib_value_name_t * arr, int value, int peri_type) { const struct sg_lib_value_name_t * vp = arr; const struct sg_lib_value_name_t * holdp; for (; vp->name; ++vp) { if (value == vp->value) { if (peri_type == vp->peri_dev_type) return vp; holdp = vp; while ((vp + 1)->name && (value == (vp + 1)->value)) { ++vp; if (peri_type == vp->peri_dev_type) return vp; } return holdp; } } return NULL; } void sg_set_warnings_strm(FILE * warnings_strm) { sg_warnings_strm = warnings_strm; } #define CMD_NAME_LEN 128 void sg_print_command(const unsigned char * command) { int k, sz; char buff[CMD_NAME_LEN]; sg_get_command_name(command, 0, CMD_NAME_LEN, buff); buff[CMD_NAME_LEN - 1] = '\0'; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "%s [", buff); if (SG_VARIABLE_LENGTH_CMD == command[0]) sz = command[7] + 8; else sz = sg_get_command_size(command[0]); for (k = 0; k < sz; ++k) fprintf(sg_warnings_strm, "%02x ", command[k]); fprintf(sg_warnings_strm, "]\n"); } void sg_get_scsi_status_str(int scsi_status, int buff_len, char * buff) { const char * ccp; if ((NULL == buff) || (buff_len < 1)) return; else if (1 == buff_len) { buff[0] = '\0'; return; } scsi_status &= 0x7e; /* sanitize as much as possible */ switch (scsi_status) { case 0: ccp = "Good"; break; case 0x2: ccp = "Check Condition"; break; case 0x4: ccp = "Condition Met"; break; case 0x8: ccp = "Busy"; break; case 0x10: ccp = "Intermediate (obsolete)"; break; case 0x14: ccp = "Intermediate-Condition Met (obs)"; break; case 0x18: ccp = "Reservation Conflict"; break; case 0x22: ccp = "Command Terminated (obsolete)"; break; case 0x28: ccp = "Task set Full"; break; case 0x30: ccp = "ACA Active"; break; case 0x40: ccp = "Task Aborted"; break; default: ccp = "Unknown status"; break; } my_snprintf(buff, buff_len, "%s", ccp); } void sg_print_scsi_status(int scsi_status) { char buff[128]; sg_get_scsi_status_str(scsi_status, sizeof(buff) - 1, buff); buff[sizeof(buff) - 1] = '\0'; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "%s ", buff); } char * sg_get_sense_key_str(int sense_key, int buff_len, char * buff) { if (1 == buff_len) { buff[0] = '\0'; return buff; } if ((sense_key >= 0) && (sense_key < 16)) my_snprintf(buff, buff_len, "%s", sg_lib_sense_key_desc[sense_key]); else my_snprintf(buff, buff_len, "invalid value: 0x%x", sense_key); return buff; } char * sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff) { int k, num, rlen; int found = 0; struct sg_lib_asc_ascq_t * eip; struct sg_lib_asc_ascq_range_t * ei2p; if (1 == buff_len) { buff[0] = '\0'; return buff; } for (k = 0; sg_lib_asc_ascq_range[k].text; ++k) { ei2p = &sg_lib_asc_ascq_range[k]; if ((ei2p->asc == asc) && (ascq >= ei2p->ascq_min) && (ascq <= ei2p->ascq_max)) { found = 1; num = my_snprintf(buff, buff_len, "Additional sense: "); rlen = buff_len - num; num += my_snprintf(buff + num, ((rlen > 0) ? rlen : 0), ei2p->text, ascq); } } if (found) return buff; for (k = 0; sg_lib_asc_ascq[k].text; ++k) { eip = &sg_lib_asc_ascq[k]; if (eip->asc == asc && eip->ascq == ascq) { found = 1; my_snprintf(buff, buff_len, "Additional sense: %s", eip->text); } } if (! found) { if (asc >= 0x80) my_snprintf(buff, buff_len, "vendor specific ASC=%02x, " "ASCQ=%02x (hex)", asc, ascq); else if (ascq >= 0x80) my_snprintf(buff, buff_len, "ASC=%02x, vendor specific " "qualification ASCQ=%02x (hex)", asc, ascq); else my_snprintf(buff, buff_len, "ASC=%02x, ASCQ=%02x (hex)", asc, ascq); } return buff; } const unsigned char * sg_scsi_sense_desc_find(const unsigned char * sensep, int sense_len, int desc_type) { int add_sb_len, add_d_len, desc_len, k; const unsigned char * descp; if ((sense_len < 8) || (0 == (add_sb_len = sensep[7]))) return NULL; if ((sensep[0] < 0x72) || (sensep[0] > 0x73)) return NULL; add_sb_len = (add_sb_len < (sense_len - 8)) ? add_sb_len : (sense_len - 8); descp = &sensep[8]; for (desc_len = 0, k = 0; k < add_sb_len; k += desc_len) { descp += desc_len; add_d_len = (k < (add_sb_len - 1)) ? descp[1]: -1; desc_len = add_d_len + 2; if (descp[0] == desc_type) return descp; if (add_d_len < 0) /* short descriptor ?? */ break; } return NULL; } int sg_get_sense_info_fld(const unsigned char * sensep, int sb_len, uint64_t * info_outp) { int j; const unsigned char * ucp; uint64_t ull; if (info_outp) *info_outp = 0; if (sb_len < 7) return 0; switch (sensep[0] & 0x7f) { case 0x70: case 0x71: if (info_outp) *info_outp = ((unsigned int)sensep[3] << 24) + (sensep[4] << 16) + (sensep[5] << 8) + sensep[6]; return (sensep[0] & 0x80) ? 1 : 0; case 0x72: case 0x73: ucp = sg_scsi_sense_desc_find(sensep, sb_len, 0 /* info desc */); if (ucp && (0xa == ucp[1])) { ull = 0; for (j = 0; j < 8; ++j) { if (j > 0) ull <<= 8; ull |= ucp[4 + j]; } if (info_outp) *info_outp = ull; return !!(ucp[2] & 0x80); /* since spc3r23 should be set */ } else return 0; default: return 0; } } int sg_get_sense_filemark_eom_ili(const unsigned char * sensep, int sb_len, int * filemark_p, int * eom_p, int * ili_p) { const unsigned char * ucp; if (sb_len < 7) return 0; switch (sensep[0] & 0x7f) { case 0x70: case 0x71: if (sensep[2] & 0xe0) { if (filemark_p) *filemark_p = !!(sensep[2] & 0x80); if (eom_p) *eom_p = !!(sensep[2] & 0x40); if (ili_p) *ili_p = !!(sensep[2] & 0x20); return 1; } else return 0; case 0x72: case 0x73: /* Look for stream commands sense data descriptor */ ucp = sg_scsi_sense_desc_find(sensep, sb_len, 4); if (ucp && (ucp[1] >= 2)) { if (ucp[3] & 0xe0) { if (filemark_p) *filemark_p = !!(ucp[3] & 0x80); if (eom_p) *eom_p = !!(ucp[3] & 0x40); if (ili_p) *ili_p = !!(ucp[3] & 0x20); return 1; } } return 0; default: return 0; } } /* Returns 1 if SKSV is set and sense key is NO_SENSE or NOT_READY. Also * returns 1 if progress indication sense data descriptor found. Places * progress field from sense data where progress_outp points. If progress * field is not available returns 0 and *progress_outp is unaltered. Handles * both fixed and descriptor sense formats. * Hint: if 1 is returned *progress_outp may be multiplied by 100 then * divided by 65536 to get the percentage completion. */ int sg_get_sense_progress_fld(const unsigned char * sensep, int sb_len, int * progress_outp) { const unsigned char * ucp; int sk, sk_pr; if (sb_len < 7) return 0; switch (sensep[0] & 0x7f) { case 0x70: case 0x71: sk = (sensep[2] & 0xf); if ((sb_len < 18) || ((SPC_SK_NO_SENSE != sk) && (SPC_SK_NOT_READY != sk))) return 0; if (sensep[15] & 0x80) { /* SKSV bit set */ if (progress_outp) *progress_outp = (sensep[16] << 8) + sensep[17]; return 1; } else return 0; case 0x72: case 0x73: /* sense key specific progress (0x2) or progress descriptor (0xa) */ sk = (sensep[1] & 0xf); sk_pr = (SPC_SK_NO_SENSE == sk) || (SPC_SK_NOT_READY == sk); if (sk_pr && ((ucp = sg_scsi_sense_desc_find(sensep, sb_len, 2))) && (0x6 == ucp[1]) && (0x80 & ucp[4])) { if (progress_outp) *progress_outp = (ucp[5] << 8) + ucp[6]; return 1; } else if (((ucp = sg_scsi_sense_desc_find(sensep, sb_len, 0xa))) && ((0x6 == ucp[1]))) { if (progress_outp) *progress_outp = (ucp[6] << 8) + ucp[7]; return 1; } else return 0; default: return 0; } } char * sg_get_pdt_str(int pdt, int buff_len, char * buff) { if ((pdt < 0) || (pdt > 31)) my_snprintf(buff, buff_len, "bad pdt"); else my_snprintf(buff, buff_len, "%s", sg_lib_pdt_strs[pdt]); return buff; } char * sg_get_trans_proto_str(int tpi, int buff_len, char * buff) { if ((tpi < 0) || (tpi > 15)) my_snprintf(buff, buff_len, "bad tpi"); else my_snprintf(buff, buff_len, "%s", sg_lib_transport_proto_strs[tpi]); return buff; } #define TPGS_STATE_OPTIMIZED 0x0 #define TPGS_STATE_NONOPTIMIZED 0x1 #define TPGS_STATE_STANDBY 0x2 #define TPGS_STATE_UNAVAILABLE 0x3 #define TPGS_STATE_OFFLINE 0xe #define TPGS_STATE_TRANSITIONING 0xf static int decode_tpgs_state(int st, char * b, int blen) { switch (st) { case TPGS_STATE_OPTIMIZED: return my_snprintf(b, blen, "active/optimized"); case TPGS_STATE_NONOPTIMIZED: return my_snprintf(b, blen, "active/non optimized"); case TPGS_STATE_STANDBY: return my_snprintf(b, blen, "standby"); case TPGS_STATE_UNAVAILABLE: return my_snprintf(b, blen, "unavailable"); case TPGS_STATE_OFFLINE: return my_snprintf(b, blen, "offline"); case TPGS_STATE_TRANSITIONING: return my_snprintf(b, blen, "transitioning between states"); default: return my_snprintf(b, blen, "unknown: 0x%x", st); } } static int uds_referral_descriptor_str(char * b, int blen, const unsigned char * dp, int alen) { int n = 0; int dlen = alen - 2; int k, j, g, f, tpgd; const unsigned char * tp; uint64_t ull; char c[40]; n += my_snprintf(b + n, blen - n, " Not all referrals: %d\n", !!(dp[2] & 0x1)); dp += 4; for (k = 0, f = 1; (k + 4) < dlen; k += g, dp += g, ++f) { tpgd = dp[3]; g = (tpgd * 4) + 20; n += my_snprintf(b + n, blen - n, " Descriptor %d\n", f); if ((k + g) > dlen) { n += my_snprintf(b + n, blen - n, " truncated descriptor, " "stop\n"); return n; } ull = 0; for (j = 0; j < 8; ++j) { if (j > 0) ull <<= 8; ull |= dp[4 + j]; } n += my_snprintf(b + n, blen - n, " first uds LBA: 0x%" PRIx64 "\n", ull); ull = 0; for (j = 0; j < 8; ++j) { if (j > 0) ull <<= 8; ull |= dp[12 + j]; } n += my_snprintf(b + n, blen - n, " last uds LBA: 0x%" PRIx64 "\n", ull); for (j = 0; j < tpgd; ++j) { tp = dp + 20 + (j * 4); decode_tpgs_state(tp[0] & 0xf, c, sizeof(c)); n += my_snprintf(b + n, blen - n, " tpg: %d state: %s\n", (tp[2] << 8) + tp[3], c); } } return n; } static const char * sdata_src[] = { "unknown", "Extended Copy command source device", "Extended Copy command destination device", }; /* Decode descriptor format sense descriptors (assumes sense buffer is in descriptor format) */ static void sg_get_sense_descriptors_str(const unsigned char * sense_buffer, int sb_len, int blen, char * b) { int add_sb_len, add_d_len, desc_len, k, j, sense_key, processed; int n, progress, pr, rem; const unsigned char * descp; const char * dtsp = " >> descriptor too short"; if ((NULL == b) || (blen <= 0)) return; b[0] = '\0'; if ((sb_len < 8) || (0 == (add_sb_len = sense_buffer[7]))) return; add_sb_len = (add_sb_len < (sb_len - 8)) ? add_sb_len : (sb_len - 8); sense_key = (sense_buffer[1] & 0xf); for (descp = (sense_buffer + 8), k = 0, n = 0; (k < add_sb_len) && (n < blen); k += desc_len, descp += desc_len) { add_d_len = (k < (add_sb_len - 1)) ? descp[1] : -1; if ((k + add_d_len + 2) > add_sb_len) add_d_len = add_sb_len - k - 2; desc_len = add_d_len + 2; n += my_snprintf(b + n, blen - n, " Descriptor type: "); processed = 1; switch (descp[0]) { case 0: n += my_snprintf(b + n, blen - n, "Information\n"); if ((add_d_len >= 10) && (0x80 & descp[2])) { n += my_snprintf(b + n, blen - n, " 0x"); for (j = 0; j < 8; ++j) n += my_snprintf(b + n, blen - n, "%02x", descp[4 + j]); n += my_snprintf(b + n, blen - n, "\n"); } else { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; } break; case 1: n += my_snprintf(b + n, blen - n, "Command specific\n"); if (add_d_len >= 10) { n += my_snprintf(b + n, blen - n, " 0x"); for (j = 0; j < 8; ++j) n += my_snprintf(b + n, blen - n, "%02x", descp[4 + j]); n += my_snprintf(b + n, blen - n, "\n"); } else { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; } break; case 2: n += my_snprintf(b + n, blen - n, "Sense key specific:"); switch (sense_key) { case SPC_SK_ILLEGAL_REQUEST: n += my_snprintf(b + n, blen - n, " Field pointer\n"); if (add_d_len < 6) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } n += my_snprintf(b + n, blen - n, " Error in %s byte %d", (descp[4] & 0x40) ? "Command" : "Data", (descp[5] << 8) | descp[6]); if (descp[4] & 0x08) { n += my_snprintf(b + n, blen - n, " bit %d\n", descp[4] & 0x07); } else n += my_snprintf(b + n, blen - n, "\n"); break; case SPC_SK_HARDWARE_ERROR: case SPC_SK_MEDIUM_ERROR: case SPC_SK_RECOVERED_ERROR: n += my_snprintf(b + n, blen - n, " Actual retry count\n"); if (add_d_len < 6) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } n += my_snprintf(b + n, blen - n," 0x%02x%02x\n", descp[5], descp[6]); break; case SPC_SK_NO_SENSE: case SPC_SK_NOT_READY: n += my_snprintf(b + n, blen - n, " Progress indication: "); if (add_d_len < 6) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } progress = (descp[5] << 8) + descp[6]; pr = (progress * 100) / 65536; rem = ((progress * 100) % 65536) / 656; n += my_snprintf(b + n, blen - n, "%d.%02d%%\n", pr, rem); break; case SPC_SK_COPY_ABORTED: n += my_snprintf(b + n, blen - n, " Segment pointer\n"); if (add_d_len < 6) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } n += my_snprintf(b + n, blen - n, " Relative to start of %s, " "byte %d", (descp[4] & 0x20) ? "segment descriptor" : "parameter list", (descp[5] << 8) | descp[6]); if (descp[4] & 0x08) n += my_snprintf(b + n, blen - n, " bit %d\n", descp[4] & 0x07); else n += my_snprintf(b + n, blen - n, "\n"); break; case SPC_SK_UNIT_ATTENTION: n += my_snprintf(b + n, blen - n, " Unit attention condition " "queue: "); n += my_snprintf(b + n, blen - n, "overflow flag is %d\n", !!(descp[4] & 0x1)); break; default: n += my_snprintf(b + n, blen - n, " Sense_key: 0x%x " "unexpected\n", sense_key); processed = 0; break; } break; case 3: n += my_snprintf(b + n, blen - n, "Field replaceable unit\n"); if (add_d_len >= 2) n += my_snprintf(b + n, blen - n, " code=0x%x\n", descp[3]); else { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; } break; case 4: n += my_snprintf(b + n, blen - n, "Stream commands\n"); if (add_d_len >= 2) { if (descp[3] & 0x80) n += my_snprintf(b + n, blen - n, " FILEMARK"); if (descp[3] & 0x40) n += my_snprintf(b + n, blen - n, " End Of Medium " "(EOM)"); if (descp[3] & 0x20) n += my_snprintf(b + n, blen - n, " Incorrect Length " "Indicator (ILI)"); n += my_snprintf(b + n, blen - n, "\n"); } else { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; } break; case 5: n += my_snprintf(b + n, blen - n, "Block commands\n"); if (add_d_len >= 2) n += my_snprintf(b + n, blen - n, " Incorrect Length " "Indicator (ILI) %s\n", (descp[3] & 0x20) ? "set" : "clear"); else { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; } break; case 6: n += my_snprintf(b + n, blen - n, "OSD object identification\n"); processed = 0; break; case 7: n += my_snprintf(b + n, blen - n, "OSD response integrity check " "value\n"); processed = 0; break; case 8: n += my_snprintf(b + n, blen - n, "OSD attribute " "identification\n"); processed = 0; break; case 9: /* this is defined in SAT (and SAT-2) */ n += my_snprintf(b + n, blen - n, "ATA Status Return\n"); if (add_d_len >= 12) { int extend, sector_count; extend = descp[2] & 1; sector_count = descp[5] + (extend ? (descp[4] << 8) : 0); n += my_snprintf(b + n, blen - n, " extend=%d error=0x%x " " sector_count=0x%x\n", extend, descp[3], sector_count); if (extend) n += my_snprintf(b + n, blen - n, " " "lba=0x%02x%02x%02x%02x%02x%02x\n", descp[10], descp[8], descp[6], descp[11], descp[9], descp[7]); else n += my_snprintf(b + n, blen - n, " " "lba=0x%02x%02x%02x\n", descp[11], descp[9], descp[7]); n += my_snprintf(b + n, blen - n, " device=0x%x " "status=0x%x\n", descp[12], descp[13]); } else { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; } break; case 0xa: /* Added in SPC-4 rev 17, became 'Another ...' in rev 34 */ n += my_snprintf(b + n, blen - n, "Another progress " "indication\n"); if (add_d_len < 6) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } progress = (descp[6] << 8) + descp[7]; pr = (progress * 100) / 65536; rem = ((progress * 100) % 65536) / 656; n += my_snprintf(b + n, blen - n, " %d.02%d%%", pr, rem); n += my_snprintf(b + n, blen - n, " [sense_key=0x%x " "asc,ascq=0x%x,0x%x]\n", descp[2], descp[3], descp[4]); break; case 0xb: /* Added in SPC-4 rev 23, defined in SBC-3 rev 22 */ n += my_snprintf(b + n, blen - n, "User data segment referral\n"); if (add_d_len < 2) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } n += uds_referral_descriptor_str(b + n, blen - n, descp, add_d_len); break; case 0xc: /* Added in SPC-4 rev 28 */ n += my_snprintf(b + n, blen - n, "Forwarded sense data\n"); if (add_d_len < 2) { n += my_snprintf(b + n, blen - n, "%s\n", dtsp); processed = 0; break; } n += my_snprintf(b + n, blen - n, " FSDT: %s\n", (descp[2] & 0x80) ? "set" : "clear"); j = descp[2] & 0xf; if (j < 3) n += my_snprintf(b + n, blen - n, " Sense data source: " "%s\n", sdata_src[j]); else n += my_snprintf(b + n, blen - n, " Sense data source: " "reserved [%d]\n", j); { char c[200]; sg_get_scsi_status_str(descp[3], sizeof(c) - 1, c); c[sizeof(c) - 1] = '\0'; n += my_snprintf(b + n, blen - n, " Forwarded status: " "%s\n", c); if (add_d_len > 2) { /* recursing; hope not to get carried away */ n += my_snprintf(b + n, blen - n, " vvvvvvvvvvvvvvvv\n"); sg_get_sense_str(NULL, descp + 4, add_d_len - 2, 0, sizeof(c), c); n += my_snprintf(b + n, blen - n, "%s", c); n += my_snprintf(b + n, blen - n, " ^^^^^^^^^^^^^^^^\n"); } } break; default: if (descp[0] >= 0x80) n += my_snprintf(b + n, blen - n, "Vendor specific [0x%x]\n", descp[0]); else n += my_snprintf(b + n, blen - n, "Unknown [0x%x]\n", descp[0]); processed = 0; break; } if (! processed) { if (add_d_len > 0) { n += my_snprintf(b + n, blen - n, " "); for (j = 0; j < add_d_len; ++j) { if ((j > 0) && (0 == (j % 24))) n += my_snprintf(b + n, blen - n, "\n "); n += my_snprintf(b + n, blen - n, "%02x ", descp[j + 2]); } n += my_snprintf(b + n, blen - n, "\n"); } } if (add_d_len < 0) n += my_snprintf(b + n, blen - n, " short descriptor\n"); } } /* Decode SAT ATA PASS-THROUGH fixed format sense */ static void sg_get_sense_sat_pt_fixed_str(const unsigned char * sp, int slen, int blen, char * b) { int n = 0; slen = slen; /* suppress warning */ if (blen < 1) return; if (SPC_SK_RECOVERED_ERROR != (0xf & sp[2])) n += my_snprintf(b + n, blen - n, " >> expected Sense key: " "Recovered Error ??\n"); n += my_snprintf(b + n, blen - n, " error=0x%x, status=0x%x, " "device=0x%x, sector_count(7:0)=0x%x%c\n", sp[3], sp[4], sp[5], sp[6], ((0x40 & sp[8]) ? '+' : ' ')); n += my_snprintf(b + n, blen - n, " extend=%d, log_index=0x%x, " "lba_high,mid,low(7:0)=0x%x,0x%x,0x%x%c\n", (!!(0x80 & sp[8])), (0xf & sp[8]), sp[9], sp[10], sp[11], ((0x20 & sp[8]) ? '+' : ' ')); } /* Fetch sense information */ void sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer, int sb_len, int raw_sinfo, int buff_len, char * buff) { int len, valid, progress, n, r, pr, rem, blen; unsigned int info; int descriptor_format = 0; int sdat_ovfl = 0; const char * ebp = NULL; char error_buff[64]; char b[256]; struct sg_scsi_sense_hdr ssh; if ((NULL == buff) || (buff_len <= 0)) return; else if (1 == buff_len) { buff[0] = '\0'; return; } blen = sizeof(b); n = 0; if (sb_len < 1) { my_snprintf(buff, buff_len, "sense buffer empty\n"); return; } if (leadin) n += my_snprintf(buff + n, buff_len - n, "%s: ", leadin); len = sb_len; if (sg_scsi_normalize_sense(sense_buffer, sb_len, &ssh)) { switch (ssh.response_code) { case 0x70: /* fixed, current */ ebp = "Fixed format, current"; len = (sb_len > 7) ? (sense_buffer[7] + 8) : sb_len; len = (len > sb_len) ? sb_len : len; sdat_ovfl = (len > 2) ? !!(sense_buffer[2] & 0x10) : 0; break; case 0x71: /* fixed, deferred */ /* error related to a previous command */ ebp = "Fixed format, <<>>"; len = (sb_len > 7) ? (sense_buffer[7] + 8) : sb_len; len = (len > sb_len) ? sb_len : len; sdat_ovfl = (len > 2) ? !!(sense_buffer[2] & 0x10) : 0; break; case 0x72: /* descriptor, current */ descriptor_format = 1; ebp = "Descriptor format, current"; sdat_ovfl = (sb_len > 4) ? !!(sense_buffer[4] & 0x80) : 0; break; case 0x73: /* descriptor, deferred */ descriptor_format = 1; ebp = "Descriptor format, <<>>"; sdat_ovfl = (sb_len > 4) ? !!(sense_buffer[4] & 0x80) : 0; break; case 0x0: ebp = "Response code: 0x0 (?)"; break; default: my_snprintf(error_buff, sizeof(error_buff), "Unknown response code: 0x%x", ssh.response_code); ebp = error_buff; break; } n += my_snprintf(buff + n, buff_len - n, " %s; Sense key: %s\n ", ebp, sg_lib_sense_key_desc[ssh.sense_key]); if (sdat_ovfl) n += my_snprintf(buff + n, buff_len - n, "<<>>\n"); if (descriptor_format) { n += my_snprintf(buff + n, buff_len - n, "%s\n", sg_get_asc_ascq_str(ssh.asc, ssh.ascq, sizeof(b), b)); sg_get_sense_descriptors_str(sense_buffer, len, buff_len - n, buff + n); n = strlen(buff); } else if ((len > 12) && (0 == ssh.asc) && (ASCQ_ATA_PT_INFO_AVAILABLE == ssh.ascq)) { /* SAT ATA PASS-THROUGH fixed format */ n += my_snprintf(buff + n, buff_len - n, "%s\n", sg_get_asc_ascq_str(ssh.asc, ssh.ascq, sizeof(b), b)); sg_get_sense_sat_pt_fixed_str(sense_buffer, len, buff_len - n, buff + n); n = strlen(buff); } else if (len > 2) { /* fixed format */ if (len > 12) n += my_snprintf(buff + n, buff_len - n, "%s\n", sg_get_asc_ascq_str(ssh.asc, ssh.ascq, sizeof(b), b)); r = 0; valid = sense_buffer[0] & 0x80; if (len > 6) { info = (unsigned int)((sense_buffer[3] << 24) | (sense_buffer[4] << 16) | (sense_buffer[5] << 8) | sense_buffer[6]); if (valid) r += my_snprintf(b + r, blen - r, " Info fld=0x%x [%u] ", info, info); else if (info > 0) r += my_snprintf(b + r, blen - r, " Valid=0, Info " "fld=0x%x [%u] ", info, info); } else info = 0; if (sense_buffer[2] & 0xe0) { if (sense_buffer[2] & 0x80) r += my_snprintf(b + r, blen - r, " FMK"); /* current command has read a filemark */ if (sense_buffer[2] & 0x40) r += my_snprintf(b + r, blen - r, " EOM"); /* end-of-medium condition exists */ if (sense_buffer[2] & 0x20) r += my_snprintf(b + r, blen - r, " ILI"); /* incorrect block length requested */ r += my_snprintf(b + r, blen - r, "\n"); } else if (valid || (info > 0)) r += my_snprintf(b + r, blen - r, "\n"); if ((len >= 14) && sense_buffer[14]) r += my_snprintf(b + r, blen - r, " Field replaceable unit " "code: %d\n", sense_buffer[14]); if ((len >= 18) && (sense_buffer[15] & 0x80)) { /* sense key specific decoding */ switch (ssh.sense_key) { case SPC_SK_ILLEGAL_REQUEST: r += my_snprintf(b + r, blen - r, " Sense Key Specific: " "Error in %s byte %d", ((sense_buffer[15] & 0x40) ? "Command" : "Data"), (sense_buffer[16] << 8) | sense_buffer[17]); if (sense_buffer[15] & 0x08) r += my_snprintf(b + r, blen - r, " bit %d\n", sense_buffer[15] & 0x07); else r += my_snprintf(b + r, blen - r, "\n"); break; case SPC_SK_NO_SENSE: case SPC_SK_NOT_READY: progress = (sense_buffer[16] << 8) + sense_buffer[17]; pr = (progress * 100) / 65536; rem = ((progress * 100) % 65536) / 656; r += my_snprintf(b + r, blen - r, " Progress " "indication: %d.%02d%%\n", pr, rem); break; case SPC_SK_HARDWARE_ERROR: case SPC_SK_MEDIUM_ERROR: case SPC_SK_RECOVERED_ERROR: r += my_snprintf(b + r, blen - r, " Actual retry count: " "0x%02x%02x\n", sense_buffer[16], sense_buffer[17]); break; case SPC_SK_COPY_ABORTED: r += my_snprintf(b + r, blen - r, " Segment pointer: "); r += my_snprintf(b + r, blen - r, "Relative to start of " "%s, byte %d", ((sense_buffer[15] & 0x20) ? "segment descriptor" : "parameter list"), ((sense_buffer[16] << 8) + sense_buffer[17])); if (sense_buffer[15] & 0x08) r += my_snprintf(b + r, blen - r, " bit %d\n", sense_buffer[15] & 0x07); else r += my_snprintf(b + r, blen - r, "\n"); break; case SPC_SK_UNIT_ATTENTION: r += my_snprintf(b + r, blen - r, " Unit attention " "condition queue: "); r += my_snprintf(b + r, blen - r, "overflow flag is %d\n", !!(sense_buffer[15] & 0x1)); break; default: r += my_snprintf(b + r, blen - r, " Sense_key: 0x%x " "unexpected\n", ssh.sense_key); break; } } if (r > 0) n += my_snprintf(buff + n, buff_len - n, "%s", b); } else n += my_snprintf(buff + n, buff_len - n, " fixed descriptor " "length too short, len=%d\n", len); } else { /* non-extended SCSI-1 sense data ?? */ if (sb_len < 4) { n += my_snprintf(buff + n, buff_len - n, "sense buffer too short " "(4 byte minimum)\n"); return; } r = 0; r += my_snprintf(b + r, blen - r, "Probably uninitialized data.\n " "Try to view as SCSI-1 non-extended sense:\n"); r += my_snprintf(b + r, blen - r, " AdValid=%d Error class=%d " "Error code=%d\n", !!(sense_buffer[0] & 0x80), ((sense_buffer[0] >> 4) & 0x7), (sense_buffer[0] & 0xf)); if (sense_buffer[0] & 0x80) r += my_snprintf(b + r, blen - r, " lba=0x%x\n", ((sense_buffer[1] & 0x1f) << 16) + (sense_buffer[2] << 8) + sense_buffer[3]); n += my_snprintf(buff + n, buff_len - n, "%s\n", b); len = sb_len; if (len > 32) len = 32; /* trim in case there is a lot of rubbish */ } if (raw_sinfo) { n += my_snprintf(buff + n, buff_len - n, " Raw sense data (in hex):" "\n"); if (n >= (buff_len - 1)) return; dStrHexErr((const char *)sense_buffer, len, buff_len - n, buff + n); } } /* Print sense information */ void sg_print_sense(const char * leadin, const unsigned char * sense_buffer, int sb_len, int raw_sinfo) { char b[2048]; sg_get_sense_str(leadin, sense_buffer, sb_len, raw_sinfo, sizeof(b), b); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "%s", b); } /* See description in sg_lib.h header file */ int sg_scsi_normalize_sense(const unsigned char * sensep, int sb_len, struct sg_scsi_sense_hdr * sshp) { if (sshp) memset(sshp, 0, sizeof(struct sg_scsi_sense_hdr)); if ((NULL == sensep) || (0 == sb_len) || (0x70 != (0x70 & sensep[0]))) return 0; if (sshp) { sshp->response_code = (0x7f & sensep[0]); if (sshp->response_code >= 0x72) { /* descriptor format */ if (sb_len > 1) sshp->sense_key = (0xf & sensep[1]); if (sb_len > 2) sshp->asc = sensep[2]; if (sb_len > 3) sshp->ascq = sensep[3]; if (sb_len > 7) sshp->additional_length = sensep[7]; } else { /* fixed format */ if (sb_len > 2) sshp->sense_key = (0xf & sensep[2]); if (sb_len > 7) { sb_len = (sb_len < (sensep[7] + 8)) ? sb_len : (sensep[7] + 8); if (sb_len > 12) sshp->asc = sensep[12]; if (sb_len > 13) sshp->ascq = sensep[13]; } } } return 1; } /* Returns a SG_LIB_CAT_* value. If cannot decode sense_buffer or a less * common sense key then return SG_LIB_CAT_SENSE .*/ int sg_err_category_sense(const unsigned char * sense_buffer, int sb_len) { struct sg_scsi_sense_hdr ssh; if ((sense_buffer && (sb_len > 2)) && (sg_scsi_normalize_sense(sense_buffer, sb_len, &ssh))) { switch (ssh.sense_key) { case SPC_SK_NO_SENSE: return SG_LIB_CAT_NO_SENSE; case SPC_SK_RECOVERED_ERROR: return SG_LIB_CAT_RECOVERED; case SPC_SK_NOT_READY: return SG_LIB_CAT_NOT_READY; case SPC_SK_MEDIUM_ERROR: case SPC_SK_HARDWARE_ERROR: case SPC_SK_BLANK_CHECK: return SG_LIB_CAT_MEDIUM_HARD; case SPC_SK_UNIT_ATTENTION: return SG_LIB_CAT_UNIT_ATTENTION; /* used to return SG_LIB_CAT_MEDIA_CHANGED when ssh.asc==0x28 */ case SPC_SK_ILLEGAL_REQUEST: if ((0x20 == ssh.asc) && (0x0 == ssh.ascq)) return SG_LIB_CAT_INVALID_OP; else return SG_LIB_CAT_ILLEGAL_REQ; break; case SPC_SK_ABORTED_COMMAND: return SG_LIB_CAT_ABORTED_COMMAND; default: ; /* drop through (SPC_SK_COMPLETED amongst others) */ } } return SG_LIB_CAT_SENSE; } /* gives wrong answer for variable length command (opcode=0x7f) */ int sg_get_command_size(unsigned char opcode) { switch ((opcode >> 5) & 0x7) { case 0: return 6; case 1: case 2: case 6: case 7: return 10; case 3: case 5: return 12; break; case 4: return 16; default: return 10; } } void sg_get_command_name(const unsigned char * cmdp, int peri_type, int buff_len, char * buff) { int service_action; if ((NULL == buff) || (buff_len < 1)) return; else if (1 == buff_len) { buff[0] = '\0'; return; } if (NULL == cmdp) { my_snprintf(buff, buff_len, "%s", " command pointer"); return; } service_action = (SG_VARIABLE_LENGTH_CMD == cmdp[0]) ? ((cmdp[8] << 8) | cmdp[9]) : (cmdp[1] & 0x1f); sg_get_opcode_sa_name(cmdp[0], service_action, peri_type, buff_len, buff); } void sg_get_opcode_sa_name(unsigned char cmd_byte0, int service_action, int peri_type, int buff_len, char * buff) { const struct sg_lib_value_name_t * vnp; if ((NULL == buff) || (buff_len < 1)) return; else if (1 == buff_len) { buff[0] = '\0'; return; } switch ((int)cmd_byte0) { case SG_VARIABLE_LENGTH_CMD: vnp = get_value_name(sg_lib_variable_length_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Variable length service action=0x%x", service_action); break; case SG_MAINTENANCE_IN: vnp = get_value_name(sg_lib_maint_in_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Maintenance in service action=0x%x", service_action); break; case SG_MAINTENANCE_OUT: vnp = get_value_name(sg_lib_maint_out_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Maintenance out service action=0x%x", service_action); break; case SG_SERVICE_ACTION_IN_12: vnp = get_value_name(sg_lib_serv_in12_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Service action in(12)=0x%x", service_action); break; case SG_SERVICE_ACTION_OUT_12: vnp = get_value_name(sg_lib_serv_out12_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Service action out(12)=0x%x", service_action); break; case SG_SERVICE_ACTION_IN_16: vnp = get_value_name(sg_lib_serv_in16_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Service action in(16)=0x%x", service_action); break; case SG_SERVICE_ACTION_OUT_16: vnp = get_value_name(sg_lib_serv_out16_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Service action out(16)=0x%x", service_action); break; case SG_PERSISTENT_RESERVE_IN: vnp = get_value_name(sg_lib_pr_in_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Persistent reserve in, service " "action=0x%x", service_action); break; case SG_PERSISTENT_RESERVE_OUT: vnp = get_value_name(sg_lib_pr_out_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Persistent reserve out, service " "action=0x%x", service_action); break; case SG_EXTENDED_COPY: vnp = get_value_name(sg_lib_xcopy_sa_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Extended copy, service action=0x%x", service_action); break; case SG_RECEIVE_COPY: vnp = get_value_name(sg_lib_rec_copy_sa_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Receive copy, service action=0x%x", service_action); break; case SG_READ_BUFFER: /* spc4r34 requested treating mode as service action */ vnp = get_value_name(sg_lib_read_buff_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "Read buffer (%s)\n", vnp->name); else my_snprintf(buff, buff_len, "Read buffer, mode=0x%x", service_action); break; case SG_WRITE_BUFFER: /* spc4r34 requested treating mode as service action */ vnp = get_value_name(sg_lib_write_buff_arr, service_action, peri_type); if (vnp) my_snprintf(buff, buff_len, "Write buffer (%s)\n", vnp->name); else my_snprintf(buff, buff_len, "Write buffer, mode=0x%x", service_action); break; default: sg_get_opcode_name(cmd_byte0, peri_type, buff_len, buff); break; } } void sg_get_opcode_name(unsigned char cmd_byte0, int peri_type, int buff_len, char * buff) { const struct sg_lib_value_name_t * vnp; int grp; if ((NULL == buff) || (buff_len < 1)) return; else if (1 == buff_len) { buff[0] = '\0'; return; } if (SG_VARIABLE_LENGTH_CMD == cmd_byte0) { my_snprintf(buff, buff_len, "%s", "Variable length"); return; } grp = (cmd_byte0 >> 5) & 0x7; switch (grp) { case 0: case 1: case 2: case 4: case 5: vnp = get_value_name(sg_lib_normal_opcodes, cmd_byte0, peri_type); if (vnp) my_snprintf(buff, buff_len, "%s", vnp->name); else my_snprintf(buff, buff_len, "Opcode=0x%x", (int)cmd_byte0); break; case 3: my_snprintf(buff, buff_len, "Reserved [0x%x]", (int)cmd_byte0); break; case 6: case 7: my_snprintf(buff, buff_len, "Vendor specific [0x%x]", (int)cmd_byte0); break; default: my_snprintf(buff, buff_len, "Opcode=0x%x", (int)cmd_byte0); break; } } /* Iterates to next designation descriptor in the device identification * VPD page. The 'initial_desig_desc' should point to start of first * descriptor with 'page_len' being the number of valid bytes in that * and following descriptors. To start, 'off' should point to a negative * value, thereafter it should point to the value yielded by the previous * call. If 0 returned then 'initial_desig_desc + *off' should be a valid * descriptor; returns -1 if normal end condition and -2 for an abnormal * 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, int * off, int m_assoc, int m_desig_type, int m_code_set) { const unsigned char * ucp; 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; } /* safe_strerror() contributed by Clayton Weaver Allows for situation in which strerror() is given a wild value (or the C library is incomplete) and returns NULL. Still not thread safe. */ static char safe_errbuf[64] = {'u', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'n', 'o', ':', ' ', 0}; char * safe_strerror(int errnum) { size_t len; char * errstr; if (errnum < 0) errnum = -errnum; errstr = strerror(errnum); if (NULL == errstr) { len = strlen(safe_errbuf); my_snprintf(safe_errbuf + len, sizeof(safe_errbuf) - len, "%i", errnum); return safe_errbuf; } return errstr; } /* Note the ASCII-hex output goes to stdout. [Most other output from functions in this file go to sg_warnings_strm (default stderr).] 'no_ascii' allows for 3 output types: > 0 each line has address then up to 16 ASCII-hex bytes = 0 in addition, the bytes are listed in ASCII to the right < 0 only the ASCII-hex bytes are listed (i.e. without address) */ void dStrHex(const char* str, int len, int no_ascii) { const char * p = str; const char * formatstr; unsigned char c; char buff[82]; int a = 0; const int bpstart = 5; const int cpstart = 60; int cpos = cpstart; int bpos = bpstart; int i, k, blen; if (len <= 0) return; blen = (int)sizeof(buff); formatstr = (0 == no_ascii) ? "%.76s\n" : "%.56s\n"; memset(buff, ' ', 80); buff[80] = '\0'; if (no_ascii < 0) { for (k = 0; k < len; k++) { c = *p++; bpos += 3; if (bpos == (bpstart + (9 * 3))) bpos++; my_snprintf(&buff[bpos], blen - bpos, "%.2x", (int)(unsigned char)c); buff[bpos + 2] = ' '; if ((k > 0) && (0 == ((k + 1) % 16))) { printf(formatstr, buff); bpos = bpstart; memset(buff, ' ', 80); } } if (bpos > bpstart) { buff[bpos + 2] = '\0'; printf("%s\n", buff); } return; } /* no_ascii>=0, start each line with address (offset) */ k = my_snprintf(buff + 1, blen - 1, "%.2x", a); buff[k + 1] = ' '; for (i = 0; i < len; i++) { c = *p++; bpos += 3; if (bpos == (bpstart + (9 * 3))) bpos++; my_snprintf(&buff[bpos], blen - bpos, "%.2x", (int)(unsigned char)c); buff[bpos + 2] = ' '; if (no_ascii) buff[cpos++] = ' '; else { if ((c < ' ') || (c >= 0x7f)) c = '.'; buff[cpos++] = c; } if (cpos > (cpstart + 15)) { printf(formatstr, buff); bpos = bpstart; cpos = cpstart; a += 16; memset(buff, ' ', 80); k = my_snprintf(buff + 1, blen - 1, "%.2x", a); buff[k + 1] = ' '; } } if (cpos > cpstart) { buff[cpos] = '\0'; printf("%s\n", buff); } } /* Output to ASCII-Hex bytes to 'b' not to exceed 'b_len' characters. * 16 bytes per line with an extra space between the 8th and 9th bytes */ static void dStrHexErr(const char* str, int len, int b_len, char * b) { const char * p = str; unsigned char c; char buff[82]; const int bpstart = 5; int bpos = bpstart; int k, n; if (len <= 0) return; n = 0; memset(buff, ' ', 80); buff[80] = '\0'; for (k = 0; k < len; k++) { c = *p++; bpos += 3; if (bpos == (bpstart + (9 * 3))) bpos++; my_snprintf(&buff[bpos], (int)sizeof(buff) - bpos, "%.2x", (int)(unsigned char)c); buff[bpos + 2] = ' '; if ((k > 0) && (0 == ((k + 1) % 16))) { n += my_snprintf(b + n, b_len - n, "%.60s\n", buff); if (n >= (b_len - 1)) return; bpos = bpstart; memset(buff, ' ', 80); } } if (bpos > bpstart) n += my_snprintf(b + n, b_len - n, "%.60s\n", buff); return; } /* Returns 1 when executed on big endian machine; else returns 0. Useful for displaying ATA identify words (which need swapping on a big endian machine). */ int sg_is_big_endian() { union u_t { unsigned short s; unsigned char c[sizeof(unsigned short)]; } u; u.s = 0x0102; return (u.c[0] == 0x01); /* The lowest address contains the most significant byte */ } static unsigned short swapb_ushort(unsigned short u) { unsigned short r; r = (u >> 8) & 0xff; r |= ((u & 0xff) << 8); return r; } /* Note the ASCII-hex output goes to stdout. [Most other output from functions in this file go to sg_warnings_strm (default stderr).] 'no_ascii' allows for 3 output types: > 0 each line has address then up to 8 ASCII-hex 16 bit words = 0 in addition, the ASCI bytes pairs are listed to the right = -1 only the ASCII-hex words are listed (i.e. without address) = -2 only the ASCII-hex words, formatted for "hdparm --Istdin" < -2 same as -1 If 'swapb' non-zero then bytes in each word swapped. Needs to be set for ATA IDENTIFY DEVICE response on big-endian machines. */ void dWordHex(const unsigned short* words, int num, int no_ascii, int swapb) { const unsigned short * p = words; unsigned short c; char buff[82]; unsigned char upp, low; int a = 0; const int bpstart = 3; const int cpstart = 52; int cpos = cpstart; int bpos = bpstart; int i, k, blen; if (num <= 0) return; blen = (int)sizeof(buff); memset(buff, ' ', 80); buff[80] = '\0'; if (no_ascii < 0) { for (k = 0; k < num; k++) { c = *p++; if (swapb) c = swapb_ushort(c); bpos += 5; my_snprintf(&buff[bpos], blen - bpos, "%.4x", (unsigned int)c); buff[bpos + 4] = ' '; if ((k > 0) && (0 == ((k + 1) % 8))) { if (-2 == no_ascii) printf("%.39s\n", buff +8); else printf("%.47s\n", buff); bpos = bpstart; memset(buff, ' ', 80); } } if (bpos > bpstart) { if (-2 == no_ascii) printf("%.39s\n", buff +8); else printf("%.47s\n", buff); } return; } /* no_ascii>=0, start each line with address (offset) */ k = my_snprintf(buff + 1, blen - 1, "%.2x", a); buff[k + 1] = ' '; for (i = 0; i < num; i++) { c = *p++; if (swapb) c = swapb_ushort(c); bpos += 5; my_snprintf(&buff[bpos], blen - bpos, "%.4x", (unsigned int)c); buff[bpos + 4] = ' '; if (no_ascii) { buff[cpos++] = ' '; buff[cpos++] = ' '; buff[cpos++] = ' '; } else { upp = (c >> 8) & 0xff; low = c & 0xff; if ((upp < 0x20) || (upp >= 0x7f)) upp = '.'; buff[cpos++] = upp; if ((low < 0x20) || (low >= 0x7f)) low = '.'; buff[cpos++] = low; buff[cpos++] = ' '; } if (cpos > (cpstart + 23)) { printf("%.76s\n", buff); bpos = bpstart; cpos = cpstart; a += 8; memset(buff, ' ', 80); k = my_snprintf(buff + 1, blen - 1, "%.2x", a); buff[k + 1] = ' '; } } if (cpos > cpstart) printf("%.76s\n", buff); } /* If the number in 'buf' can be decoded or the multiplier is unknown then -1 is returned. Accepts a hex prefix (0x or 0X) or a decimal multiplier suffix (as per GNU's dd (since 2002: SI and IEC 60027-2)). Main (SI) multipliers supported: K, M, G. */ int sg_get_num(const char * buf) { int res, num, n, len; unsigned int unum; char * cp; char c = 'c'; char c2, c3; if ((NULL == buf) || ('\0' == buf[0])) return -1; len = strlen(buf); if (('0' == buf[0]) && (('x' == buf[1]) || ('X' == buf[1]))) { res = sscanf(buf + 2, "%x", &unum); num = unum; } else if ('H' == toupper((int)buf[len - 1])) { res = sscanf(buf, "%x", &unum); num = unum; } else res = sscanf(buf, "%d%c%c%c", &num, &c, &c2, &c3); if (res < 1) return -1LL; else if (1 == res) return num; else { if (res > 2) c2 = toupper((int)c2); if (res > 3) c3 = toupper((int)c3); switch (toupper((int)c)) { case 'C': return num; case 'W': return num * 2; case 'B': return num * 512; case 'K': if (2 == res) return num * 1024; if (('B' == c2) || ('D' == c2)) return num * 1000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1024; return -1; case 'M': if (2 == res) return num * 1048576; if (('B' == c2) || ('D' == c2)) return num * 1000000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1048576; return -1; case 'G': if (2 == res) return num * 1073741824; if (('B' == c2) || ('D' == c2)) return num * 1000000000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1073741824; return -1; case 'X': cp = (char *)strchr(buf, 'x'); if (NULL == cp) cp = (char *)strchr(buf, 'X'); if (cp) { n = sg_get_num(cp + 1); if (-1 != n) return num * n; } return -1; default: if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "unrecognized multiplier\n"); return -1; } } } /* If the number in 'buf' can not be decoded then -1 is returned. Accepts a hex prefix (0x or 0X) or a 'h' (or 'H') suffix; otherwise decimal is assumed. Does not accept multipliers. Accept a comma (","), a whitespace or newline as terminator. */ int sg_get_num_nomult(const char * buf) { int res, len, num; unsigned int unum; char * commap; if ((NULL == buf) || ('\0' == buf[0])) return -1; len = strlen(buf); commap = (char *)strchr(buf + 1, ','); if (('0' == buf[0]) && (('x' == buf[1]) || ('X' == buf[1]))) { res = sscanf(buf + 2, "%x", &unum); num = unum; } else if (commap && ('H' == toupper((int)*(commap - 1)))) { res = sscanf(buf, "%x", &unum); num = unum; } else if ((NULL == commap) && ('H' == toupper((int)buf[len - 1]))) { res = sscanf(buf, "%x", &unum); num = unum; } else res = sscanf(buf, "%d", &num); if (1 == res) return num; else return -1; } /* If the number in 'buf' can be decoded or the multiplier is unknown then -1LL is returned. Accepts a hex prefix (0x or 0X) or a decimal multiplier suffix (as per GNU's dd (since 2002: SI and IEC 60027-2)). Main (SI) multipliers supported: K, M, G, T, P. */ int64_t sg_get_llnum(const char * buf) { int res, len; int64_t num, ll; uint64_t unum; char * cp; char c = 'c'; char c2, c3; if ((NULL == buf) || ('\0' == buf[0])) return -1LL; len = strlen(buf); if (('0' == buf[0]) && (('x' == buf[1]) || ('X' == buf[1]))) { res = sscanf(buf + 2, "%" SCNx64 "", &unum); num = unum; } else if ('H' == toupper((int)buf[len - 1])) { res = sscanf(buf, "%" SCNx64 "", &unum); num = unum; } else res = sscanf(buf, "%" SCNd64 "%c%c%c", &num, &c, &c2, &c3); if (res < 1) return -1LL; else if (1 == res) return num; else { if (res > 2) c2 = toupper((int)c2); if (res > 3) c3 = toupper((int)c3); switch (toupper((int)c)) { case 'C': return num; case 'W': return num * 2; case 'B': return num * 512; case 'K': if (2 == res) return num * 1024; if (('B' == c2) || ('D' == c2)) return num * 1000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1024; return -1LL; case 'M': if (2 == res) return num * 1048576; if (('B' == c2) || ('D' == c2)) return num * 1000000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1048576; return -1LL; case 'G': if (2 == res) return num * 1073741824; if (('B' == c2) || ('D' == c2)) return num * 1000000000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1073741824; return -1LL; case 'T': if (2 == res) return num * 1099511627776LL; if (('B' == c2) || ('D' == c2)) return num * 1000000000000LL; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1099511627776LL; return -1LL; case 'P': if (2 == res) return num * 1099511627776LL * 1024; if (('B' == c2) || ('D' == c2)) return num * 1000000000000LL * 1000; if (('I' == c2) && (4 == res) && ('B' == c3)) return num * 1099511627776LL * 1024; return -1LL; case 'X': cp = (char *)strchr(buf, 'x'); if (NULL == cp) cp = (char *)strchr(buf, 'X'); if (cp) { ll = sg_get_llnum(cp + 1); if (-1LL != ll) return num * ll; } return -1LL; default: if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "unrecognized multiplier\n"); return -1LL; } } } /* Extract character sequence from ATA words as in the model string in a IDENTIFY DEVICE response. Returns number of characters written to 'ochars' before 0 character is found or 'num' words are processed. */ int sg_ata_get_chars(const unsigned short * word_arr, int start_word, int num_words, int is_big_endian, char * ochars) { int k; unsigned short s; char a, b; char * op = ochars; for (k = start_word; k < (start_word + num_words); ++k) { s = word_arr[k]; if (is_big_endian) { a = s & 0xff; b = (s >> 8) & 0xff; } else { a = (s >> 8) & 0xff; b = s & 0xff; } if (a == 0) break; *op++ = a; if (b == 0) break; *op++ = b; } return op - ochars; } const char * sg_lib_version() { return sg_lib_version_str; } #ifdef SG_LIB_MINGW /* Non Unix OSes distinguish between text and binary files. Set text mode on fd. Does nothing in Unix. Returns negative number on failure. */ #include #include int sg_set_text_mode(int fd) { return setmode(fd, O_TEXT); } /* Set binary mode on fd. Does nothing in Unix. Returns negative number on failure. */ int sg_set_binary_mode(int fd) { return setmode(fd, O_BINARY); } #else /* For Unix the following functions are dummies. */ int sg_set_text_mode(int fd) { return fd; /* fd should be >= 0 */ } int sg_set_binary_mode(int fd) { return fd; } #endif sdparm-1.08/lib/sg_pt_freebsd.c0000664000175000017500000003217112061626602015453 0ustar douggdougg/* * Copyright (c) 2005-2010 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. */ /* sg_pt_freebsd version 1.10 20100321 */ #include #include #include #include #include #include #include #include #include #include // #include #include #include #include #include #include #include #include "sg_pt.h" #include "sg_lib.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #define FREEBSD_MAXDEV 64 #define FREEBSD_FDOFFSET 16; struct freebsd_dev_channel { char* devname; // the SCSI device name int unitnum; // the SCSI unit number struct cam_device* cam_dev; }; // Private table of open devices: guaranteed zero on startup since // part of static data. static struct freebsd_dev_channel *devicetable[FREEBSD_MAXDEV]; #define DEF_TIMEOUT 60000 /* 60,000 milliseconds (60 seconds) */ struct sg_pt_freebsd_scsi { struct cam_device* cam_dev; // copy held for error processing union ccb *ccb; unsigned char * cdb; int cdb_len; unsigned char * sense; int sense_len; unsigned char * dxferp; int dxfer_len; int dxfer_dir; int scsi_status; int resid; int sense_resid; int in_err; int os_err; int transport_err; }; struct sg_pt_base { struct sg_pt_freebsd_scsi impl; }; /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, int read_only, int verbose) { int oflags = 0 /* O_NONBLOCK*/ ; oflags |= (read_only ? O_RDONLY : O_RDWR); return scsi_pt_open_flags(device_name, oflags, verbose); } /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed * together. The 'flags' argument is ignored in FreeBSD. * Returns >= 0 if successful, otherwise returns negated errno. */ int scsi_pt_open_flags(const char * device_name, int flags __attribute__ ((unused)), int verbose) { struct freebsd_dev_channel *fdchan; struct cam_device* cam_dev; int k; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; // Search table for a free entry for (k = 0; k < FREEBSD_MAXDEV; k++) if (! devicetable[k]) break; // If no free entry found, return error. We have max allowed number // of "file descriptors" already allocated. if (k == FREEBSD_MAXDEV) { if (verbose) fprintf(sg_warnings_strm, "too many open file descriptors " "(%d)\n", FREEBSD_MAXDEV); errno = EMFILE; return -1; } fdchan = (struct freebsd_dev_channel *) calloc(1,sizeof(struct freebsd_dev_channel)); if (fdchan == NULL) { // errno already set by call to calloc() return -1; } if (! (fdchan->devname = (char *)calloc(1, DEV_IDLEN+1))) return -1; if (cam_get_device(device_name, fdchan->devname, DEV_IDLEN, &(fdchan->unitnum)) == -1) { if (verbose) fprintf(sg_warnings_strm, "bad device name structure\n"); errno = EINVAL; return -1; } if (! (cam_dev = cam_open_spec_device(fdchan->devname, fdchan->unitnum, O_RDWR, NULL))) { if (verbose) fprintf(sg_warnings_strm, "cam_open_spec_device: %s\n", cam_errbuf); errno = EPERM; /* permissions or no CAM */ return -1; } fdchan->cam_dev = cam_dev; // return pointer to "file descriptor" table entry, properly offset. devicetable[k] = fdchan; return k + FREEBSD_FDOFFSET; } /* Returns 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_close_device(int device_fd) { struct freebsd_dev_channel *fdchan; int fd = device_fd - FREEBSD_FDOFFSET; if ((fd < 0) || (fd >= FREEBSD_MAXDEV)) { errno = ENODEV; return -1; } fdchan = devicetable[fd]; if (NULL == fdchan) { errno = ENODEV; return -1; } if (fdchan->devname) free(fdchan->devname); if (fdchan->cam_dev) cam_close_device(fdchan->cam_dev); free(fdchan); devicetable[fd] = NULL; return 0; } struct sg_pt_base * construct_scsi_pt_obj() { struct sg_pt_freebsd_scsi * ptp; ptp = (struct sg_pt_freebsd_scsi *) calloc(1, sizeof(struct sg_pt_freebsd_scsi)); if (ptp) { memset(ptp, 0, sizeof(struct sg_pt_freebsd_scsi)); ptp->dxfer_dir = CAM_DIR_NONE; } return (struct sg_pt_base *)ptp; } void destruct_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp) { if (ptp->ccb) cam_freeccb(ptp->ccb); free(ptp); } } void clear_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp) { memset(ptp, 0, sizeof(struct sg_pt_freebsd_scsi)); ptp->dxfer_dir = CAM_DIR_NONE; } } void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp->cdb) ++ptp->in_err; ptp->cdb = (unsigned char *)cdb; ptp->cdb_len = cdb_len; } void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int max_sense_len) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp->sense) ++ptp->in_err; memset(sense, 0, max_sense_len); ptp->sense = sense; ptp->sense_len = max_sense_len; } /* Setup for data transfer from device */ void set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp->dxferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->dxferp = dxferp; ptp->dxfer_len = dxfer_len; ptp->dxfer_dir = CAM_DIR_IN; } } /* Setup for data transfer toward device */ void set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp->dxferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->dxferp = (unsigned char *)dxferp; ptp->dxfer_len = dxfer_len; ptp->dxfer_dir = CAM_DIR_OUT; } } void set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)), int pack_id __attribute__ ((unused))) { } void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag __attribute__ ((unused))) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; ++ptp->in_err; } void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code __attribute__ ((unused))) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; ++ptp->in_err; } void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attrib __attribute__ ((unused)), int priority __attribute__ ((unused))) { struct sg_pt_freebsd_scsi * ptp = &vp->impl; ++ptp->in_err; } void set_scsi_pt_flags(struct sg_pt_base * objp, int flags) { /* do nothing, suppress warnings */ objp = objp; flags = flags; } /* Executes SCSI command (or at least forwards it to lower layers). * Clears os_err field prior to active call (whose result may set it * again). */ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose) { int fd = device_fd - FREEBSD_FDOFFSET; struct sg_pt_freebsd_scsi * ptp = &vp->impl; struct freebsd_dev_channel *fdchan; union ccb *ccb; int len, timout_ms; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; ptp->os_err = 0; if (ptp->in_err) { if (verbose) fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt...\n"); return SCSI_PT_DO_BAD_PARAMS; } if (NULL == ptp->cdb) { if (verbose) fprintf(sg_warnings_strm, "No command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } if ((fd < 0) || (fd >= FREEBSD_MAXDEV)) { if (verbose) fprintf(sg_warnings_strm, "Bad file descriptor\n"); ptp->os_err = ENODEV; return -ptp->os_err; } fdchan = devicetable[fd]; if (NULL == fdchan) { if (verbose) fprintf(sg_warnings_strm, "File descriptor closed??\n"); ptp->os_err = ENODEV; return -ptp->os_err; } if (NULL == fdchan->cam_dev) { if (verbose) fprintf(sg_warnings_strm, "No open CAM device\n"); return SCSI_PT_DO_BAD_PARAMS; } if (! (ccb = cam_getccb(fdchan->cam_dev))) { if (verbose) fprintf(sg_warnings_strm, "cam_getccb: failed\n"); ptp->os_err = ENOMEM; return -ptp->os_err; } ptp->ccb = ccb; // clear out structure, except for header that was filled in for us bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); timout_ms = (time_secs > 0) ? (time_secs * 1000) : DEF_TIMEOUT; cam_fill_csio(&ccb->csio, /* retries */ 1, /* cbfcnp */ NULL, /* flags */ ptp->dxfer_dir, /* tagaction */ MSG_SIMPLE_Q_TAG, /* dataptr */ ptp->dxferp, /* datalen */ ptp->dxfer_len, /* senselen */ ptp->sense_len, /* cdblen */ ptp->cdb_len, /* timeout (millisecs) */ timout_ms); memcpy(ccb->csio.cdb_io.cdb_bytes, ptp->cdb, ptp->cdb_len); if (cam_send_ccb(fdchan->cam_dev, ccb) < 0) { if (verbose) { warn("error sending SCSI ccb"); #if __FreeBSD_version > 500000 cam_error_print(fdchan->cam_dev, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); #endif } cam_freeccb(ptp->ccb); ptp->ccb = NULL; ptp->os_err = EIO; return -ptp->os_err; } if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) || ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR)) { ptp->scsi_status = ccb->csio.scsi_status; ptp->resid = ccb->csio.resid; ptp->sense_resid = ccb->csio.sense_resid; if ((SAM_STAT_CHECK_CONDITION == ptp->scsi_status) || (SAM_STAT_COMMAND_TERMINATED == ptp->scsi_status)) { len = ptp->sense_len - ptp->sense_resid; if (len) memcpy(ptp->sense, &(ccb->csio.sense_data), len); } } else ptp->transport_err = 1; ptp->cam_dev = fdchan->cam_dev; // for error processing return 0; } int get_scsi_pt_result_category(const struct sg_pt_base * vp) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (ptp->os_err) return SCSI_PT_RESULT_OS_ERR; else if (ptp->transport_err) return SCSI_PT_RESULT_TRANSPORT_ERR; else if ((SAM_STAT_CHECK_CONDITION == ptp->scsi_status) || (SAM_STAT_COMMAND_TERMINATED == ptp->scsi_status)) return SCSI_PT_RESULT_SENSE; else if (ptp->scsi_status) return SCSI_PT_RESULT_STATUS; else return SCSI_PT_RESULT_GOOD; } int get_scsi_pt_resid(const struct sg_pt_base * vp) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; return ptp->resid; } int get_scsi_pt_status_response(const struct sg_pt_base * vp) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; return ptp->scsi_status; } int get_scsi_pt_sense_len(const struct sg_pt_base * vp) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; int len; len = ptp->sense_len - ptp->sense_resid; return (len > 0) ? len : 0; } int get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused))) { // const struct sg_pt_freebsd_scsi * ptp = &vp->impl; return -1; } int get_scsi_pt_transport_err(const struct sg_pt_base * vp) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; return ptp->transport_err; } int get_scsi_pt_os_err(const struct sg_pt_base * vp) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; return ptp->os_err; } char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_freebsd_scsi * ptp = &vp->impl; if (0 == ptp->transport_err) { strncpy(b, "no transport error available", max_b_len); b[max_b_len - 1] = '\0'; return b; } #if __FreeBSD_version > 500000 if (ptp->cam_dev) cam_error_string(ptp->cam_dev, ptp->ccb, b, max_b_len, CAM_ESF_ALL, CAM_EPF_ALL); else { strncpy(b, "no transport error available", max_b_len); b[max_b_len - 1] = '\0'; } #else strncpy(b, "no transport error available", max_b_len); b[max_b_len - 1] = '\0'; #endif return b; } char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_freebsd_scsi * 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; } sdparm-1.08/lib/sg_pt_solaris.c0000664000175000017500000002146511351460102015511 0ustar douggdougg/* * Copyright (c) 2007-2010 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. */ /* sg_pt_solaris version 1.03 20100321 */ #include #include #include #include #include #include #include #include /* Solaris headers */ #include #include #include #include #include "sg_pt.h" #include "sg_lib.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #define DEF_TIMEOUT 60 /* 60 seconds */ struct sg_pt_solaris_scsi { struct uscsi_cmd uscsi; int max_sense_len; int in_err; int os_err; }; struct sg_pt_base { struct sg_pt_solaris_scsi impl; }; /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, int read_only, int verbose) { int oflags = 0 /* O_NONBLOCK*/ ; oflags |= (read_only ? O_RDONLY : O_RDWR); return scsi_pt_open_flags(device_name, oflags, verbose); } /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed * together. The 'flags' argument is ignored in Solaris. * Returns >= 0 if successful, otherwise returns negated errno. */ int scsi_pt_open_flags(const char * device_name, int flags_arg, int verbose) { int oflags = O_NONBLOCK | O_RDWR; int fd; flags_arg = flags_arg; /* ignore flags argument, suppress warning */ if (verbose > 1) { fprintf(stderr, "open %s with flags=0x%x\n", device_name, oflags); } fd = open(device_name, oflags); if (fd < 0) fd = -errno; return fd; } /* Returns 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_close_device(int device_fd) { int res; res = close(device_fd); if (res < 0) res = -errno; return res; } struct sg_pt_base * construct_scsi_pt_obj() { struct sg_pt_solaris_scsi * ptp; ptp = (struct sg_pt_solaris_scsi *) calloc(1, sizeof(struct sg_pt_solaris_scsi)); if (ptp) { ptp->uscsi.uscsi_timeout = DEF_TIMEOUT; ptp->uscsi.uscsi_flags = USCSI_READ | USCSI_ISOLATE | USCSI_RQENABLE; ptp->uscsi.uscsi_timeout = DEF_TIMEOUT; } return (struct sg_pt_base *)ptp; } void destruct_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_solaris_scsi * ptp = &vp->impl; if (ptp) free(ptp); } void clear_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_solaris_scsi * ptp = &vp->impl; if (ptp) { memset(ptp, 0, sizeof(struct sg_pt_solaris_scsi)); ptp->uscsi.uscsi_timeout = DEF_TIMEOUT; ptp->uscsi.uscsi_flags = USCSI_READ | USCSI_ISOLATE | USCSI_RQENABLE; ptp->uscsi.uscsi_timeout = DEF_TIMEOUT; } } void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len) { struct sg_pt_solaris_scsi * ptp = &vp->impl; if (ptp->uscsi.uscsi_cdb) ++ptp->in_err; ptp->uscsi.uscsi_cdb = (char *)cdb; ptp->uscsi.uscsi_cdblen = cdb_len; } void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int max_sense_len) { struct sg_pt_solaris_scsi * ptp = &vp->impl; if (ptp->uscsi.uscsi_rqbuf) ++ptp->in_err; memset(sense, 0, max_sense_len); ptp->uscsi.uscsi_rqbuf = (char *)sense; ptp->uscsi.uscsi_rqlen = max_sense_len; ptp->max_sense_len = max_sense_len; } /* from device */ void set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len) { struct sg_pt_solaris_scsi * ptp = &vp->impl; if (ptp->uscsi.uscsi_bufaddr) ++ptp->in_err; if (dxfer_len > 0) { ptp->uscsi.uscsi_bufaddr = (char *)dxferp; ptp->uscsi.uscsi_buflen = dxfer_len; ptp->uscsi.uscsi_flags = USCSI_READ | USCSI_ISOLATE | USCSI_RQENABLE; } } /* to device */ void set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len) { struct sg_pt_solaris_scsi * ptp = &vp->impl; if (ptp->uscsi.uscsi_bufaddr) ++ptp->in_err; if (dxfer_len > 0) { ptp->uscsi.uscsi_bufaddr = (char *)dxferp; ptp->uscsi.uscsi_buflen = dxfer_len; ptp->uscsi.uscsi_flags = USCSI_WRITE | USCSI_ISOLATE | USCSI_RQENABLE; } } void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) { // struct sg_pt_solaris_scsi * ptp = &vp->impl; vp = vp; /* ignore and suppress warning */ pack_id = pack_id; /* ignore and suppress warning */ } void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) { // struct sg_pt_solaris_scsi * ptp = &vp->impl; vp = vp; /* ignore and suppress warning */ tag = tag; /* ignore and suppress warning */ } /* Note that task management function codes are transport specific */ void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) { struct sg_pt_solaris_scsi * ptp = &vp->impl; ++ptp->in_err; tmf_code = tmf_code; /* dummy to silence compiler */ } void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority) { struct sg_pt_solaris_scsi * ptp = &vp->impl; ++ptp->in_err; attribute = attribute; /* dummy to silence compiler */ priority = priority; /* dummy to silence compiler */ } void set_scsi_pt_flags(struct sg_pt_base * objp, int flags) { /* do nothing, suppress warnings */ objp = objp; flags = flags; } /* Executes SCSI command (or at least forwards it to lower layers). * Clears os_err field prior to active call (whose result may set it * again). */ int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose) { struct sg_pt_solaris_scsi * ptp = &vp->impl; ptp->os_err = 0; if (ptp->in_err) { if (verbose) fprintf(stderr, "Replicated or unused set_scsi_pt... " "functions\n"); return SCSI_PT_DO_BAD_PARAMS; } if (NULL == ptp->uscsi.uscsi_cdb) { if (verbose) fprintf(stderr, "No SCSI command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } if (time_secs > 0) ptp->uscsi.uscsi_timeout = time_secs; if (ioctl(fd, USCSICMD, &ptp->uscsi)) { ptp->os_err = errno; if ((EIO == ptp->os_err) && ptp->uscsi.uscsi_status) { ptp->os_err = 0; return 0; } if (verbose) fprintf(stderr, "ioctl(USCSICMD) failed with os_err " "(errno) = %d\n", ptp->os_err); return -ptp->os_err; } return 0; } int get_scsi_pt_result_category(const struct sg_pt_base * vp) { const struct sg_pt_solaris_scsi * ptp = &vp->impl; int scsi_st = ptp->uscsi.uscsi_status; if (ptp->os_err) return SCSI_PT_RESULT_OS_ERR; else if ((SAM_STAT_CHECK_CONDITION == scsi_st) || (SAM_STAT_COMMAND_TERMINATED == scsi_st)) return SCSI_PT_RESULT_SENSE; else if (scsi_st) return SCSI_PT_RESULT_STATUS; else return SCSI_PT_RESULT_GOOD; } int get_scsi_pt_resid(const struct sg_pt_base * vp) { const struct sg_pt_solaris_scsi * ptp = &vp->impl; return ptp->uscsi.uscsi_resid; } int get_scsi_pt_status_response(const struct sg_pt_base * vp) { const struct sg_pt_solaris_scsi * ptp = &vp->impl; return ptp->uscsi.uscsi_status; } int get_scsi_pt_sense_len(const struct sg_pt_base * vp) { const struct sg_pt_solaris_scsi * ptp = &vp->impl; int res; if (ptp->max_sense_len > 0) { res = ptp->max_sense_len - ptp->uscsi.uscsi_rqresid; return (res > 0) ? res : 0; } return 0; } int get_scsi_pt_duration_ms(const struct sg_pt_base * vp) { // const struct sg_pt_solaris_scsi * ptp = &vp->impl; vp = vp; /* ignore and suppress warning */ return -1; /* not available */ } int get_scsi_pt_transport_err(const struct sg_pt_base * vp) { // const struct sg_pt_solaris_scsi * ptp = &vp->impl; vp = vp; /* ignore and suppress warning */ return 0; } int get_scsi_pt_os_err(const struct sg_pt_base * vp) { const struct sg_pt_solaris_scsi * ptp = &vp->impl; return ptp->os_err; } char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { // const struct sg_pt_solaris_scsi * ptp = &vp->impl; vp = vp; /* ignore and suppress warning */ if (max_b_len > 0) b[0] = '\0'; return b; } char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_solaris_scsi * 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; } sdparm-1.08/lib/sg_lib_data.c0000664000175000017500000016330712153447426015112 0ustar douggdougg/* * Copyright (c) 2007-2013 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 "sg_lib.h" #include "sg_lib_data.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif const char * sg_lib_version_str = "1.84 20130603"; /* spc4r36, sbc3r32 */ #ifdef SG_SCSI_STRINGS struct sg_lib_value_name_t sg_lib_normal_opcodes[] = { {0, 0, "Test Unit Ready"}, {0x1, 0, "Rezero Unit"}, {0x1, PDT_TAPE, "Rewind"}, {0x3, 0, "Request Sense"}, {0x4, 0, "Format Unit"}, {0x4, PDT_TAPE, "Format medium"}, {0x4, PDT_PRINTER, "Format"}, {0x5, 0, "Read Block Limits"}, {0x7, 0, "Reassign Blocks"}, {0x7, PDT_MCHANGER, "Initialize element status"}, {0x8, 0, "Read(6)"}, /* obsolete in sbc3r30 */ {0x8, PDT_PROCESSOR, "Receive"}, {0xa, 0, "Write(6)"}, /* obsolete in sbc3r30 */ {0xa, PDT_PRINTER, "Print"}, {0xa, PDT_PROCESSOR, "Send"}, {0xb, 0, "Seek(6)"}, {0xb, PDT_TAPE, "Set capacity"}, {0xb, PDT_PRINTER, "Slew and print"}, {0xf, 0, "Read reverse(6)"}, {0x10, 0, "Write filemarks(6)"}, {0x10, PDT_PRINTER, "Synchronize buffer"}, {0x11, 0, "Space(6)"}, {0x12, 0, "Inquiry"}, {0x13, 0, "Verify(6)"}, /* SSC */ {0x14, 0, "Recover buffered data"}, {0x15, 0, "Mode select(6)"}, /* SBC-3 r31 recommends Mode select(10) */ {0x16, 0, "Reserve(6)"}, /* obsolete in SPC-4 r11 */ {0x16, PDT_MCHANGER, "Reserve element(6)"}, {0x17, 0, "Release(6)"}, /* obsolete in SPC-4 r11 */ {0x17, PDT_MCHANGER, "Release element(6)"}, {0x18, 0, "Copy"}, /* obsolete in SPC-4 r11 */ {0x19, 0, "Erase(6)"}, {0x1a, 0, "Mode sense(6)"}, /* SBC-3 r31 recommends Mode sense(10) */ {0x1b, 0, "Start stop unit"}, {0x1b, PDT_TAPE, "Load unload"}, {0x1b, PDT_ADC, "Load unload"}, {0x1b, PDT_PRINTER, "Stop print"}, {0x1c, 0, "Receive diagnostic results"}, {0x1d, 0, "Send diagnostic"}, {0x1e, 0, "Prevent allow medium removal"}, {0x23, 0, "Read Format capacities"}, {0x24, 0, "Set window"}, {0x25, 0, "Read capacity(10)"}, /* SBC-3 r31 recommends Read capacity(16) */ {0x25, PDT_OCRW, "Read card capacity"}, {0x28, 0, "Read(10)"}, /* SBC-3 r31 recommends Read(16) */ {0x29, 0, "Read generation"}, {0x2a, 0, "Write(10)"}, /* SBC-3 r31 recommends Write(16) */ {0x2b, 0, "Seek(10)"}, {0x2b, PDT_TAPE, "Locate(10)"}, {0x2b, PDT_MCHANGER, "Position to element"}, {0x2c, 0, "Erase(10)"}, {0x2d, 0, "Read updated block"}, {0x2e, 0, "Write and verify(10)"}, /* SBC-3 r31 recommends Write and verify(16) */ {0x2f, 0, "Verify(10)"}, /* SBC-3 r31 recommends Verify(16) */ {0x30, 0, "Search data high(10)"}, {0x31, 0, "Search data equal(10)"}, {0x32, 0, "Search data low(10)"}, {0x33, 0, "Set limits(10)"}, {0x34, 0, "Pre-fetch(10)"}, /* SBC-3 r31 recommends Pre-fetch(16) */ {0x34, PDT_TAPE, "Read position"}, {0x35, 0, "Synchronize cache(10)"}, /* SBC-3 r31 recommends Synchronize cache(16) */ {0x36, 0, "Lock unlock cache(10)"}, {0x37, 0, "Read defect data(10)"}, /* SBC-3 r31 recommends Read defect data(12) */ {0x37, PDT_MCHANGER, "Initialize element status with range"}, {0x38, 0, "Medium scan"}, {0x39, 0, "Compare"}, /* obsolete in SPC-4 r11 */ {0x3a, 0, "Copy and verify"}, /* obsolete in SPC-4 r11 */ {0x3b, 0, "Write buffer"}, {0x3c, 0, "Read buffer"}, {0x3d, 0, "Update block"}, {0x3e, 0, "Read long(10)"}, /* SBC-3 r31 recommends Read long(16) */ {0x3f, 0, "Write long(10)"}, /* SBC-3 r31 recommends Write long(16) */ {0x40, 0, "Change definition"}, /* obsolete in SPC-4 r11 */ {0x41, 0, "Write same(10)"}, /* SBC-3 r31 recommends Write same(16) */ {0x42, 0, "Unmap"}, /* added SPC-4 rev 18 */ {0x42, PDT_MMC, "Read sub-channel"}, {0x43, PDT_MMC, "Read TOC/PMA/ATIP"}, {0x44, 0, "Report density support"}, {0x45, PDT_MMC, "Play audio(10)"}, {0x46, PDT_MMC, "Get configuration"}, {0x47, PDT_MMC, "Play audio msf"}, {0x48, 0, "Sanitize"}, {0x4a, PDT_MMC, "Get event status notification"}, {0x4b, PDT_MMC, "Pause/resume"}, {0x4c, 0, "Log select"}, {0x4d, 0, "Log sense"}, {0x4e, 0, "Stop play/scan"}, {0x50, 0, "Xdwrite(10)"}, /* obsolete in SBC-3 r31 */ {0x51, 0, "Xpwrite(10)"}, {0x51, PDT_MMC, "Read disk information"}, {0x52, 0, "Xdread(10)"}, /* obsolete in SBC-3 r31 */ {0x52, PDT_MMC, "Read track information"}, {0x53, 0, "Reserve track"}, {0x54, 0, "Send OPC information"}, {0x55, 0, "Mode select(10)"}, {0x56, 0, "Reserve(10)"}, /* obsolete in SPC-4 r11 */ {0x56, PDT_MCHANGER, "Reserve element(10)"}, {0x57, 0, "Release(10)"}, /* obsolete in SPC-4 r11 */ {0x57, PDT_MCHANGER, "Release element(10)"}, {0x58, 0, "Repair track"}, {0x5a, 0, "Mode sense(10)"}, {0x5b, 0, "Close track/session"}, {0x5c, 0, "Read buffer capacity"}, {0x5d, 0, "Send cue sheet"}, {0x5e, 0, "Persistent reserve in"}, {0x5f, 0, "Persistent reserve out"}, {0x7e, 0, "Extended cdb (XCBD)"}, /* added in SPC-4 r12 */ {0x80, 0, "Xdwrite extended(16)"}, {0x80, PDT_TAPE, "Write filemarks(16)"}, {0x81, 0, "Rebuild(16)"}, {0x81, PDT_TAPE, "Read reverse(16)"}, {0x82, 0, "Regenerate(16)"}, {0x83, 0, "Extended copy"}, {0x84, 0, "Receive copy results"}, {0x85, 0, "ATA command pass through(16)"}, /* was 0x98 in spc3 rev21c */ {0x86, 0, "Access control in"}, {0x87, 0, "Access control out"}, {0x88, 0, "Read(16)"}, {0x89, 0, "Compare and write"}, {0x8a, 0, "Write(16)"}, {0x8b, 0, "Orwrite(16)"}, {0x8c, 0, "Read attribute"}, {0x8d, 0, "Write attribute"}, {0x8e, 0, "Write and verify(16)"}, {0x8f, 0, "Verify(16)"}, {0x90, 0, "Pre-fetch(16)"}, {0x91, 0, "Synchronize cache(16)"}, {0x91, PDT_TAPE, "Space(16)"}, {0x92, 0, "Lock unlock cache(16)"}, {0x92, PDT_TAPE, "Locate(16)"}, {0x93, 0, "Write same(16)"}, {0x93, PDT_TAPE, "Erase(16)"}, {0x9d, 0, "Service action bidirectional"}, /* added spc4r35 */ {0x9e, 0, "Service action in(16)"}, {0x9f, 0, "Service action out(16)"}, {0xa0, 0, "Report luns"}, {0xa1, 0, "ATA command pass through(12)"}, {0xa1, PDT_MMC, "Blank"}, {0xa2, 0, "Security protocol in"}, {0xa3, 0, "Maintenance in"}, {0xa3, PDT_MMC, "Send key"}, {0xa4, 0, "Maintenance out"}, {0xa4, PDT_MMC, "Report key"}, {0xa5, 0, "Move medium"}, {0xa5, PDT_MMC, "Play audio(12)"}, {0xa6, 0, "Exchange medium"}, {0xa6, PDT_MMC, "Load/unload medium"}, {0xa7, 0, "Move medium attached"}, {0xa7, PDT_MMC, "Set read ahead"}, {0xa8, 0, "Read(12)"}, /* SBC-3 r31 recommends Read(16) */ {0xa9, 0, "Service action out(12)"}, {0xaa, 0, "Write(12)"}, /* SBC-3 r31 recommends Write(16) */ {0xab, 0, "Service action in(12)"}, {0xac, 0, "erase(12)"}, {0xac, PDT_MMC, "Get performance"}, {0xad, PDT_MMC, "Read DVD/BD structure"}, {0xae, 0, "Write and verify(12)"}, /* SBC-3 r31 recommends Write and verify(16) */ {0xaf, 0, "Verify(12)"}, /* SBC-3 r31 recommends Verify(16) */ {0xb0, 0, "Search data high(12)"}, {0xb1, 0, "Search data equal(12)"}, {0xb1, PDT_MCHANGER, "Open/close import/export element"}, {0xb2, 0, "Search data low(12)"}, {0xb3, 0, "Set limits(12)"}, {0xb4, 0, "Read element status attached"}, {0xb5, 0, "Security protocol out"}, {0xb5, PDT_MCHANGER, "Request volume element address"}, {0xb6, 0, "Send volume tag"}, {0xb6, PDT_MMC, "Set streaming"}, {0xb7, 0, "Read defect data(12)"}, {0xb8, 0, "Read element status"}, {0xb9, 0, "Read CD msf"}, {0xba, 0, "Redundancy group in"}, {0xba, PDT_MMC, "Scan"}, {0xbb, 0, "Redundancy group out"}, {0xbb, PDT_MMC, "Set CD speed"}, {0xbc, 0, "Spare in"}, {0xbd, 0, "Spare out"}, {0xbd, PDT_MMC, "Mechanism status"}, {0xbe, 0, "Volume set in"}, {0xbe, PDT_MMC, "Read CD"}, {0xbf, 0, "Volume set out"}, {0xbf, PDT_MMC, "Send DVD/BD structure"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_read_buff_arr[] = { /* opcode 0x3c */ {0x0, 0, "combined header and data [or multiple modes]"}, {0x2, 0, "data"}, {0x3, 0, "descriptor"}, {0xa, 0, "read data from echo buffer"}, {0xb, 0, "echo buffer descriptor"}, {0x1a, 0, "enable expander comms protocol and echo buffer"}, {0x1c, 0, "error history"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_write_buff_arr[] = { /* opcode 0x3b */ {0x0, 0, "combined header and data [or multiple modes]"}, {0x2, 0, "data"}, {0x4, 0, "download microcode and activate"}, {0x5, 0, "download microcode, save, and activate"}, {0x6, 0, "download microcode with offsets and activate"}, {0x7, 0, "download microcode with offsets, save, and activate"}, {0xa, 0, "write data to echo buffer"}, {0xd, 0, "download microcode with offsets, select activation events, " " save and defer activate"}, {0xe, 0, "download microcode with offsets, save and defer activate"}, {0xf, 0, "activate deferred microcode"}, {0x1a, 0, "enable expander comms protocol and echo buffer"}, {0x1b, 0, "disable expander comms protocol"}, {0x1c, 0, "download application client error history"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_maint_in_arr[] = { /* opcode 0xa3 */ {0x5, 0, "Report identifying information"}, /* was "Report device identifier" prior to spc4r07 */ {0xa, 0, "Report target port groups"}, {0xb, 0, "Report aliases"}, {0xc, 0, "Report supported operation codes"}, {0xd, 0, "Report supported task management functions"}, {0xe, 0, "Report priority"}, {0xf, 0, "Report timestamp"}, {0x10, 0, "Management protocol in"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_maint_out_arr[] = { /* opcode 0xa4 */ {0x6, 0, "Set identifying information"}, /* was "Set device identifier" prior to spc4r07 */ {0xa, 0, "Set target port groups"}, {0xb, 0, "Change aliases"}, {0xc, 0, "Remove I_T nexus"}, {0xe, 0, "Set priority"}, {0xf, 0, "Set timestamp"}, {0x10, 0, "Management protocol out"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_in12_arr[] = { /* opcode 0xab */ {0x1, 0, "Read media serial number"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_out12_arr[] = { /* opcode 0xa9 */ {0xff, 0, "Impossible command name"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_in16_arr[] = { /* opcode 0x9e */ {0x10, 0, "Read capacity(16)"}, {0x11, 0, "Read long(16)"}, {0x12, 0, "Get LBA status"}, {0x13, 0, "Report referrals"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_out16_arr[] = { /* opcode 0x9f */ {0x11, 0, "Write long(16)"}, {0x1f, PDT_ADC, "Notify data transfer device(16)"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_bidi_arr[] = { /* opcode 0x9d */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_pr_in_arr[] = { /* opcode 0x5e */ {0x0, 0, "Persistent reserve in, read keys"}, {0x1, 0, "Persistent reserve in, read reservation"}, {0x2, 0, "Persistent reserve in, report capabilities"}, {0x3, 0, "Persistent reserve in, read full status"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_pr_out_arr[] = { /* opcode 0x5f */ {0x0, 0, "Persistent reserve out, register"}, {0x1, 0, "Persistent reserve out, reserve"}, {0x2, 0, "Persistent reserve out, release"}, {0x3, 0, "Persistent reserve out, clear"}, {0x4, 0, "Persistent reserve out, preempt"}, {0x5, 0, "Persistent reserve out, preempt and abort"}, {0x6, 0, "Persistent reserve out, register and ignore existing key"}, {0x7, 0, "Persistent reserve out, register and move"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_xcopy_sa_arr[] = { /* opcode 0x83 */ {0x0, 0, "Extended copy(lid1)"}, {0x1, 0, "Extended copy(lid4)"}, {0x10, 0, "Populate token"}, {0x11, 0, "Write using token"}, {0x1c, 0, "Extended copy abort"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_rec_copy_sa_arr[] = { /* opcode 0x84 */ {0x0, 0, "Receive copy status(lid1)"}, {0x1, 0, "Receive copy data(lid1)"}, {0x3, 0, "Receive copy operating parameters"}, {0x4, 0, "Receive copy failure details(lid1)"}, {0x5, 0, "Receive copy status(lid4)"}, {0x6, 0, "Receive copy data(lid4)"}, {0x7, 0, "Receive ROD token information"}, {0x8, 0, "Report all ROD tokens"}, {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_variable_length_arr[] = { {0x1, 0, "Rebuild(32)"}, {0x2, 0, "Regenerate(32)"}, {0x3, 0, "Xdread(32)"}, /* obsolete in SBC-3 r31 */ {0x4, 0, "Xdwrite(32)"}, /* obsolete in SBC-3 r31 */ {0x5, 0, "Xdwrite extended(32)"}, {0x6, 0, "Xpwrite(32)"}, {0x7, 0, "Xdwriteread(32)"}, {0x8, 0, "Xdwrite extended(64)"}, {0x9, 0, "Read(32)"}, {0xa, 0, "Verify(32)"}, {0xb, 0, "Write(32)"}, {0xc, 0, "Write an verify(32)"}, {0xd, 0, "Write same(32)"}, {0xe, 0, "Orwrite(32)"}, /* added sbc3r25 */ {0x1800, 0, "Receive credential"}, {0x8801, 0, "Format OSD (osd)"}, {0x8802, 0, "Create (osd)"}, {0x8803, 0, "List (osd)"}, {0x8805, 0, "Read (osd)"}, {0x8806, 0, "Write (osd)"}, {0x8807, 0, "Append (osd)"}, {0x8808, 0, "Flush (osd)"}, {0x880a, 0, "Remove (osd)"}, {0x880b, 0, "Create partition (osd)"}, {0x880c, 0, "Remove partition (osd)"}, {0x880e, 0, "Get attributes (osd)"}, {0x880f, 0, "Set attributes (osd)"}, {0x8812, 0, "Create and write (osd)"}, {0x8815, 0, "Create collection (osd)"}, {0x8816, 0, "Remove collection (osd)"}, {0x8817, 0, "List collection (osd)"}, {0x8818, 0, "Set key (osd)"}, {0x8819, 0, "Set master key (osd)"}, {0x881a, 0, "Flush collection (osd)"}, {0x881b, 0, "Flush partition (osd)"}, {0x881c, 0, "Flush OSD (osd)"}, {0x8880, 0, "Object structure check (osd-2)"}, {0x8881, 0, "Format OSD (osd-2)"}, {0x8882, 0, "Create (osd-2)"}, {0x8883, 0, "List (osd-2)"}, {0x8884, 0, "Punch (osd-2)"}, {0x8885, 0, "Read (osd-2)"}, {0x8886, 0, "Write (osd-2)"}, {0x8887, 0, "Append (osd-2)"}, {0x8888, 0, "Flush (osd-2)"}, {0x8889, 0, "Clear (osd-2)"}, {0x888a, 0, "Remove (osd-2)"}, {0x888b, 0, "Create partition (osd-2)"}, {0x888c, 0, "Remove partition (osd-2)"}, {0x888e, 0, "Get attributes (osd-2)"}, {0x888f, 0, "Set attributes (osd-2)"}, {0x8892, 0, "Create and write (osd-2)"}, {0x8895, 0, "Create collection (osd-2)"}, {0x8896, 0, "Remove collection (osd-2)"}, {0x8897, 0, "List collection (osd-2)"}, {0x8898, 0, "Set key (osd-2)"}, {0x8899, 0, "Set master key (osd-2)"}, {0x889a, 0, "Flush collection (osd-2)"}, {0x889b, 0, "Flush partition (osd-2)"}, {0x889c, 0, "Flush OSD (osd-2)"}, {0x88a0, 0, "Query (osd-2)"}, {0x88a1, 0, "Remove member objects (osd-2)"}, {0x88a2, 0, "Get member attributes (osd-2)"}, {0x88a3, 0, "Set member attributes (osd-2)"}, {0x88b1, 0, "Read map (osd-2)"}, {0x8f7c, 0, "Perform SCSI command (osd-2)"}, {0x8f7d, 0, "Perform task management function (osd-2)"}, {0x8f7e, 0, "Perform SCSI command (osd)"}, {0x8f7f, 0, "Perform task management function (osd)"}, {0xffff, 0, NULL}, }; #else struct sg_lib_value_name_t sg_lib_normal_opcodes[] = { {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_read_buff_arr[] = { /* opcode 0x3c */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_write_buff_arr[] = { /* opcode 0x3b */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_maint_in_arr[] = { /* opcode 0xa3 */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_maint_out_arr[] = { /* opcode 0xa4 */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_in12_arr[] = { /* opcode 0xab */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_out12_arr[] = { /* opcode 0xa9 */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_in16_arr[] = { /* opcode 0x9e */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_out16_arr[] = { /* opcode 0x9f */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_serv_bidi_arr[] = { /* opcode 0x9d */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_pr_in_arr[] = { /* opcode 0x5e */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_pr_out_arr[] = { /* opcode 0x5f */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_xcopy_sa_arr[] = { /* opcode 0x83 */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_rec_copy_sa_arr[] = { /* opcode 0x84 */ {0xffff, 0, NULL}, }; struct sg_lib_value_name_t sg_lib_variable_length_arr[] = { {0xffff, 0, NULL}, }; #endif /* A conveniently formatted list of SCSI ASC/ASCQ codes and their * corresponding text can be found at: www.t10.org/lists/asc-num.txt * The following should match asc-num.txt dated 20111222 */ #ifdef SG_SCSI_STRINGS struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[] = { {0x40,0x01,0x7f,"Ram failure [0x%x]"}, {0x40,0x80,0xff,"Diagnostic failure on component [0x%x]"}, {0x41,0x01,0xff,"Data path failure [0x%x]"}, {0x42,0x01,0xff,"Power-on or self-test failure [0x%x]"}, {0x4d,0x00,0xff,"Tagged overlapped commands [0x%x]"}, {0x70,0x00,0xff,"Decompression exception short algorithm id of 0x%x"}, {0, 0, 0, NULL} }; struct sg_lib_asc_ascq_t sg_lib_asc_ascq[] = { {0x00,0x00,"No additional sense information"}, {0x00,0x01,"Filemark detected"}, {0x00,0x02,"End-of-partition/medium detected"}, {0x00,0x03,"Setmark detected"}, {0x00,0x04,"Beginning-of-partition/medium detected"}, {0x00,0x05,"End-of-data detected"}, {0x00,0x06,"I/O process terminated"}, {0x00,0x07,"Programmable early warning detected"}, {0x00,0x11,"Audio play operation in progress"}, {0x00,0x12,"Audio play operation paused"}, {0x00,0x13,"Audio play operation successfully completed"}, {0x00,0x14,"Audio play operation stopped due to error"}, {0x00,0x15,"No current audio status to return"}, {0x00,0x16,"operation in progress"}, {0x00,0x17,"Cleaning requested"}, {0x00,0x18,"Erase operation in progress"}, {0x00,0x19,"Locate operation in progress"}, {0x00,0x1a,"Rewind operation in progress"}, {0x00,0x1b,"Set capacity operation in progress"}, {0x00,0x1c,"Verify operation in progress"}, {0x00,0x1d,"ATA pass through information available"}, {0x00,0x1e,"Conflicting SA creation request"}, {0x00,0x1f,"Logical unit transitioning to another power condition"}, {0x00,0x20,"Extended copy information available"}, {0x01,0x00,"No index/sector signal"}, {0x02,0x00,"No seek complete"}, {0x03,0x00,"Peripheral device write fault"}, {0x03,0x01,"No write current"}, {0x03,0x02,"Excessive write errors"}, {0x04,0x00,"Logical unit not ready, cause not reportable"}, {0x04,0x01,"Logical unit is in process of becoming ready"}, {0x04,0x02,"Logical unit not ready, " "initializing command required"}, {0x04,0x03,"Logical unit not ready, " "manual intervention required"}, {0x04,0x04,"Logical unit not ready, format in progress"}, {0x04,0x05,"Logical unit not ready, rebuild in progress"}, {0x04,0x06,"Logical unit not ready, recalculation in progress"}, {0x04,0x07,"Logical unit not ready, operation in progress"}, {0x04,0x08,"Logical unit not ready, long write in progress"}, {0x04,0x09,"Logical unit not ready, self-test in progress"}, {0x04,0x0a,"Logical unit " "not accessible, asymmetric access state transition"}, {0x04,0x0b,"Logical unit " "not accessible, target port in standby state"}, {0x04,0x0c,"Logical unit " "not accessible, target port in unavailable state"}, {0x04,0x0d,"Logical unit not ready, structure check required"}, {0x04,0x10,"Logical unit not ready, " "auxiliary memory not accessible"}, {0x04,0x11,"Logical unit not ready, " "notify (enable spinup) required"}, {0x04,0x12,"Logical unit not ready, offline"}, {0x04,0x13,"Logical unit not ready, SA creation in progress"}, {0x04,0x14,"Logical unit not ready, space allocation in progress"}, {0x04,0x15,"Logical unit not ready, robotics disabled"}, {0x04,0x16,"Logical unit not ready, configuration required"}, {0x04,0x17,"Logical unit not ready, calibration required"}, {0x04,0x18,"Logical unit not ready, a door is open"}, {0x04,0x19,"Logical unit not ready, operating in sequential mode"}, {0x04,0x1a,"Logical unit not ready, start stop unit command in progress"}, {0x04,0x1b,"Logical unit not ready, sanitize in progress"}, {0x04,0x1c,"Logical unit not ready, additional power use not yet " "granted"}, {0x04,0x1d,"Logical unit not ready, configuration in progress"}, {0x05,0x00,"Logical unit does not respond to selection"}, {0x06,0x00,"No reference position found"}, {0x07,0x00,"Multiple peripheral devices selected"}, {0x08,0x00,"Logical unit communication failure"}, {0x08,0x01,"Logical unit communication time-out"}, {0x08,0x02,"Logical unit communication parity error"}, {0x08,0x03,"Logical unit communication CRC error (Ultra-DMA/32)"}, {0x08,0x04,"Unreachable copy target"}, {0x09,0x00,"Track following error"}, {0x09,0x01,"Tracking servo failure"}, {0x09,0x02,"Focus servo failure"}, {0x09,0x03,"Spindle servo failure"}, {0x09,0x04,"Head select fault"}, {0x0A,0x00,"Error log overflow"}, {0x0B,0x00,"Warning"}, {0x0B,0x01,"Warning - specified temperature exceeded"}, {0x0B,0x02,"Warning - enclosure degraded"}, {0x0B,0x03,"Warning - background self-test failed"}, {0x0B,0x04,"Warning - background pre-scan detected medium error"}, {0x0B,0x05,"Warning - background medium scan detected medium error"}, {0x0B,0x06,"Warning - non-volatile cache now volatile"}, {0x0B,0x07,"Warning - degraded power to non-volatile cache"}, {0x0B,0x08,"Warning - power loss expected"}, {0x0B,0x09,"Warning - device statistics notification active"}, {0x0C,0x00,"Write error"}, {0x0C,0x01,"Write error - recovered with auto reallocation"}, {0x0C,0x02,"Write error - auto reallocation failed"}, {0x0C,0x03,"Write error - recommend reassignment"}, {0x0C,0x04,"Compression check miscompare error"}, {0x0C,0x05,"Data expansion occurred during compression"}, {0x0C,0x06,"Block not compressible"}, {0x0C,0x07,"Write error - recovery needed"}, {0x0C,0x08,"Write error - recovery failed"}, {0x0C,0x09,"Write error - loss of streaming"}, {0x0C,0x0A,"Write error - padding blocks added"}, {0x0C,0x0B,"Auxiliary memory write error"}, {0x0C,0x0C,"Write error - unexpected unsolicited data"}, {0x0C,0x0D,"Write error - not enough unsolicited data"}, {0x0C,0x0E,"Multiple write errors"}, {0x0C,0x0F,"Defects in error window"}, {0x0D,0x00,"Error detected by third party temporary initiator"}, {0x0D,0x01,"Third party device failure"}, {0x0D,0x02,"Copy target device not reachable"}, {0x0D,0x03,"Incorrect copy target device type"}, {0x0D,0x04,"Copy target device data underrun"}, {0x0D,0x05,"Copy target device data overrun"}, {0x0E,0x00,"Invalid information unit"}, {0x0E,0x01,"Information unit too short"}, {0x0E,0x02,"Information unit too long"}, {0x0E,0x03,"Invalid field in command information unit"}, {0x10,0x00,"Id CRC or ECC error"}, {0x10,0x01,"Logical block guard check failed"}, {0x10,0x02,"Logical block application tag check failed"}, {0x10,0x03,"Logical block reference tag check failed"}, {0x10,0x04,"Logical block protection error on recover buffered data"}, {0x10,0x05,"Logical block protection method error"}, {0x11,0x00,"Unrecovered read error"}, {0x11,0x01,"Read retries exhausted"}, {0x11,0x02,"Error too long to correct"}, {0x11,0x03,"Multiple read errors"}, {0x11,0x04,"Unrecovered read error - auto reallocate failed"}, {0x11,0x05,"L-EC uncorrectable error"}, {0x11,0x06,"CIRC unrecovered error"}, {0x11,0x07,"Data re-synchronization error"}, {0x11,0x08,"Incomplete block read"}, {0x11,0x09,"No gap found"}, {0x11,0x0A,"Miscorrected error"}, {0x11,0x0B,"Unrecovered read error - recommend reassignment"}, {0x11,0x0C,"Unrecovered read error - recommend rewrite the data"}, {0x11,0x0D,"De-compression CRC error"}, {0x11,0x0E,"Cannot decompress using declared algorithm"}, {0x11,0x0F,"Error reading UPC/EAN number"}, {0x11,0x10,"Error reading ISRC number"}, {0x11,0x11,"Read error - loss of streaming"}, {0x11,0x12,"Auxiliary memory read error"}, {0x11,0x13,"Read error - failed retransmission request"}, {0x11,0x14,"Read error - LBA marked bad by application client"}, {0x12,0x00,"Address mark not found for id field"}, {0x13,0x00,"Address mark not found for data field"}, {0x14,0x00,"Recorded entity not found"}, {0x14,0x01,"Record not found"}, {0x14,0x02,"Filemark or setmark not found"}, {0x14,0x03,"End-of-data not found"}, {0x14,0x04,"Block sequence error"}, {0x14,0x05,"Record not found - recommend reassignment"}, {0x14,0x06,"Record not found - data auto-reallocated"}, {0x14,0x07,"Locate operation failure"}, {0x15,0x00,"Random positioning error"}, {0x15,0x01,"Mechanical positioning error"}, {0x15,0x02,"Positioning error detected by read of medium"}, {0x16,0x00,"Data synchronization mark error"}, {0x16,0x01,"Data sync error - data rewritten"}, {0x16,0x02,"Data sync error - recommend rewrite"}, {0x16,0x03,"Data sync error - data auto-reallocated"}, {0x16,0x04,"Data sync error - recommend reassignment"}, {0x17,0x00,"Recovered data with no error correction applied"}, {0x17,0x01,"Recovered data with retries"}, {0x17,0x02,"Recovered data with positive head offset"}, {0x17,0x03,"Recovered data with negative head offset"}, {0x17,0x04,"Recovered data with retries and/or circ applied"}, {0x17,0x05,"Recovered data using previous sector id"}, {0x17,0x06,"Recovered data without ECC - data auto-reallocated"}, {0x17,0x07,"Recovered data without ECC - recommend reassignment"}, {0x17,0x08,"Recovered data without ECC - recommend rewrite"}, {0x17,0x09,"Recovered data without ECC - data rewritten"}, {0x18,0x00,"Recovered data with error correction applied"}, {0x18,0x01,"Recovered data with error corr. & retries applied"}, {0x18,0x02,"Recovered data - data auto-reallocated"}, {0x18,0x03,"Recovered data with CIRC"}, {0x18,0x04,"Recovered data with L-EC"}, {0x18,0x05,"Recovered data - recommend reassignment"}, {0x18,0x06,"Recovered data - recommend rewrite"}, {0x18,0x07,"Recovered data with ECC - data rewritten"}, {0x18,0x08,"Recovered data with linking"}, {0x19,0x00,"Defect list error"}, {0x19,0x01,"Defect list not available"}, {0x19,0x02,"Defect list error in primary list"}, {0x19,0x03,"Defect list error in grown list"}, {0x1A,0x00,"Parameter list length error"}, {0x1B,0x00,"Synchronous data transfer error"}, {0x1C,0x00,"Defect list not found"}, {0x1C,0x01,"Primary defect list not found"}, {0x1C,0x02,"Grown defect list not found"}, {0x1D,0x00,"Miscompare during verify operation"}, {0x1D,0x01,"Miscompare verify of unmapped lba"}, {0x1E,0x00,"Recovered id with ECC correction"}, {0x1F,0x00,"Partial defect list transfer"}, {0x20,0x00,"Invalid command operation code"}, {0x20,0x01,"Access denied - initiator pending-enrolled"}, {0x20,0x02,"Access denied - no access rights"}, {0x20,0x03,"Access denied - invalid mgmt id key"}, {0x20,0x04,"Illegal command while in write capable state"}, {0x20,0x05,"Write type operation while in read capable state (obs)"}, {0x20,0x06,"Illegal command while in explicit address mode"}, {0x20,0x07,"Illegal command while in implicit address mode"}, {0x20,0x08,"Access denied - enrollment conflict"}, {0x20,0x09,"Access denied - invalid LU identifier"}, {0x20,0x0A,"Access denied - invalid proxy token"}, {0x20,0x0B,"Access denied - ACL LUN conflict"}, {0x20,0x0C,"Illegal command when not in append-only mode"}, {0x21,0x00,"Logical block address out of range"}, {0x21,0x01,"Invalid element address"}, {0x21,0x02,"Invalid address for write"}, {0x21,0x03,"Invalid write crossing layer jump"}, {0x22,0x00,"Illegal function (use 20 00, 24 00, or 26 00)"}, {0x23,0x00,"Invalid token operation, cause not reportable"}, {0x23,0x01,"Invalid token operation, unsupported token type"}, {0x23,0x02,"Invalid token operation, remote token usage not supported"}, {0x23,0x03,"invalid token operation, remote rod token creation not " "supported"}, {0x23,0x04,"Invalid token operation, token unknown"}, {0x23,0x05,"Invalid token operation, token corrupt"}, {0x23,0x06,"Invalid token operation, token revoked"}, {0x23,0x07,"Invalid token operation, token expired"}, {0x23,0x08,"Invalid token operation, token cancelled"}, {0x23,0x09,"Invalid token operation, token deleted"}, {0x23,0x0a,"Invalid token operation, invalid token length"}, {0x24,0x00,"Invalid field in cdb"}, {0x24,0x01,"CDB decryption error"}, {0x24,0x02,"Invalid cdb field while in explicit block model (obs)"}, {0x24,0x03,"Invalid cdb field while in implicit block model (obs)"}, {0x24,0x04,"Security audit value frozen"}, {0x24,0x05,"Security working key frozen"}, {0x24,0x06,"Nonce not unique"}, {0x24,0x07,"Nonce timestamp out of range"}, {0x24,0x08,"Invalid xcdb"}, {0x25,0x00,"Logical unit not supported"}, {0x26,0x00,"Invalid field in parameter list"}, {0x26,0x01,"Parameter not supported"}, {0x26,0x02,"Parameter value invalid"}, {0x26,0x03,"Threshold parameters not supported"}, {0x26,0x04,"Invalid release of persistent reservation"}, {0x26,0x05,"Data decryption error"}, {0x26,0x06,"Too many target descriptors"}, {0x26,0x07,"Unsupported target descriptor type code"}, {0x26,0x08,"Too many segment descriptors"}, {0x26,0x09,"Unsupported segment descriptor type code"}, {0x26,0x0A,"Unexpected inexact segment"}, {0x26,0x0B,"Inline data length exceeded"}, {0x26,0x0C,"Invalid operation for copy source or destination"}, {0x26,0x0D,"Copy segment granularity violation"}, {0x26,0x0E,"Invalid parameter while port is enabled"}, {0x26,0x0F,"Invalid data-out buffer integrity check value"}, {0x26,0x10,"Data decryption key fail limit reached"}, {0x26,0x11,"Incomplete key-associated data set"}, {0x26,0x12,"Vendor specific key reference not found"}, {0x27,0x00,"Write protected"}, {0x27,0x01,"Hardware write protected"}, {0x27,0x02,"Logical unit software write protected"}, {0x27,0x03,"Associated write protect"}, {0x27,0x04,"Persistent write protect"}, {0x27,0x05,"Permanent write protect"}, {0x27,0x06,"Conditional write protect"}, {0x27,0x07,"Space allocation failed write protect"}, {0x28,0x00,"Not ready to ready change, medium may have changed"}, {0x28,0x01,"Import or export element accessed"}, {0x28,0x02,"Format-layer may have changed"}, {0x28,0x03,"Import/export element accessed, medium changed"}, {0x29,0x00,"Power on, reset, or bus device reset occurred"}, {0x29,0x01,"Power on occurred"}, {0x29,0x02,"SCSI bus reset occurred"}, {0x29,0x03,"Bus device reset function occurred"}, {0x29,0x04,"Device internal reset"}, {0x29,0x05,"Transceiver mode changed to single-ended"}, {0x29,0x06,"Transceiver mode changed to lvd"}, {0x29,0x07,"I_T nexus loss occurred"}, {0x2A,0x00,"Parameters changed"}, {0x2A,0x01,"Mode parameters changed"}, {0x2A,0x02,"Log parameters changed"}, {0x2A,0x03,"Reservations preempted"}, {0x2A,0x04,"Reservations released"}, {0x2A,0x05,"Registrations preempted"}, {0x2A,0x06,"Asymmetric access state changed"}, {0x2A,0x07,"Implicit asymmetric access state transition failed"}, {0x2A,0x08,"Priority changed"}, {0x2A,0x09,"Capacity data has changed"}, {0x2A,0x0c, "Error recovery attributes have changed"}, {0x2A,0x0d, "Data encryption capabilities changed"}, {0x2A,0x10,"Timestamp changed"}, {0x2A,0x11,"Data encryption parameters changed by another i_t nexus"}, {0x2A,0x12,"Data encryption parameters changed by vendor specific event"}, {0x2A,0x13,"Data encryption key instance counter has changed"}, {0x2A,0x0a,"Error history i_t nexus cleared"}, {0x2A,0x0b,"Error history snapshot released"}, {0x2A,0x14,"SA creation capabilities data has changed"}, {0x2A,0x15,"Medium removal prevention preempted"}, {0x2B,0x00,"Copy cannot execute since host cannot disconnect"}, {0x2C,0x00,"Command sequence error"}, {0x2C,0x01,"Too many windows specified"}, {0x2C,0x02,"Invalid combination of windows specified"}, {0x2C,0x03,"Current program area is not empty"}, {0x2C,0x04,"Current program area is empty"}, {0x2C,0x05,"Illegal power condition request"}, {0x2C,0x06,"Persistent prevent conflict"}, {0x2C,0x07,"Previous busy status"}, {0x2C,0x08,"Previous task set full status"}, {0x2C,0x09,"Previous reservation conflict status"}, {0x2C,0x0A,"Partition or collection contains user objects"}, {0x2C,0x0B,"Not reserved"}, {0x2C,0x0C,"ORWRITE generation does not match"}, {0x2D,0x00,"Overwrite error on update in place"}, {0x2E,0x00,"Insufficient time for operation"}, {0x2F,0x00,"Commands cleared by another initiator"}, {0x2F,0x01,"Commands cleared by power loss notification"}, {0x2F,0x02,"Commands cleared by device server"}, {0x2F,0x03,"Some commands cleared by queuing layer event"}, {0x30,0x00,"Incompatible medium installed"}, {0x30,0x01,"Cannot read medium - unknown format"}, {0x30,0x02,"Cannot read medium - incompatible format"}, {0x30,0x03,"Cleaning cartridge installed"}, {0x30,0x04,"Cannot write medium - unknown format"}, {0x30,0x05,"Cannot write medium - incompatible format"}, {0x30,0x06,"Cannot format medium - incompatible medium"}, {0x30,0x07,"Cleaning failure"}, {0x30,0x08,"Cannot write - application code mismatch"}, {0x30,0x09,"Current session not fixated for append"}, {0x30,0x0A,"Cleaning request rejected"}, {0x30,0x0B,"Cleaning tape expired"}, {0x30,0x0C,"WORM medium - overwrite attempted"}, {0x30,0x0D,"WORM medium - integrity check"}, {0x30,0x10,"Medium not formatted"}, {0x30,0x11,"Incompatible volume type"}, {0x30,0x12,"Incompatible volume qualifier"}, {0x30,0x13,"Cleaning volume expired"}, {0x31,0x00,"Medium format corrupted"}, {0x31,0x01,"Format command failed"}, {0x31,0x02,"Zoned formatting failed due to spare linking"}, {0x31,0x03,"Sanitize command failed"}, {0x32,0x00,"No defect spare location available"}, {0x32,0x01,"Defect list update failure"}, {0x33,0x00,"Tape length error"}, {0x34,0x00,"Enclosure failure"}, {0x35,0x00,"Enclosure services failure"}, {0x35,0x01,"Unsupported enclosure function"}, {0x35,0x02,"Enclosure services unavailable"}, {0x35,0x03,"Enclosure services transfer failure"}, {0x35,0x04,"Enclosure services transfer refused"}, {0x35,0x05,"Enclosure services checksum error"}, {0x36,0x00,"Ribbon, ink, or toner failure"}, {0x37,0x00,"Rounded parameter"}, {0x38,0x00,"Event status notification"}, {0x38,0x02,"Esn - power management class event"}, {0x38,0x04,"Esn - media class event"}, {0x38,0x06,"Esn - device busy class event"}, {0x38,0x07,"Thin provisioning soft threshold reached"}, {0x39,0x00,"Saving parameters not supported"}, {0x3A,0x00,"Medium not present"}, {0x3A,0x01,"Medium not present - tray closed"}, {0x3A,0x02,"Medium not present - tray open"}, {0x3A,0x03,"Medium not present - loadable"}, {0x3A,0x04,"Medium not present - medium auxiliary memory accessible"}, {0x3B,0x00,"Sequential positioning error"}, {0x3B,0x01,"Tape position error at beginning-of-medium"}, {0x3B,0x02,"Tape position error at end-of-medium"}, {0x3B,0x03,"Tape or electronic vertical forms unit not ready"}, {0x3B,0x04,"Slew failure"}, {0x3B,0x05,"Paper jam"}, {0x3B,0x06,"Failed to sense top-of-form"}, {0x3B,0x07,"Failed to sense bottom-of-form"}, {0x3B,0x08,"Reposition error"}, {0x3B,0x09,"Read past end of medium"}, {0x3B,0x0A,"Read past beginning of medium"}, {0x3B,0x0B,"Position past end of medium"}, {0x3B,0x0C,"Position past beginning of medium"}, {0x3B,0x0D,"Medium destination element full"}, {0x3B,0x0E,"Medium source element empty"}, {0x3B,0x0F,"End of medium reached"}, {0x3B,0x11,"Medium magazine not accessible"}, {0x3B,0x12,"Medium magazine removed"}, {0x3B,0x13,"Medium magazine inserted"}, {0x3B,0x14,"Medium magazine locked"}, {0x3B,0x15,"Medium magazine unlocked"}, {0x3B,0x16,"Mechanical positioning or changer error"}, {0x3B,0x17,"Read past end of user object"}, {0x3B,0x18,"Element disabled"}, {0x3B,0x19,"Element enabled"}, {0x3B,0x1a,"Data transfer device removed"}, {0x3B,0x1b,"Data transfer device inserted"}, {0x3B,0x1c,"Too many logical objects on partition to support operation"}, {0x3D,0x00,"Invalid bits in identify message"}, {0x3E,0x00,"Logical unit has not self-configured yet"}, {0x3E,0x01,"Logical unit failure"}, {0x3E,0x02,"Timeout on logical unit"}, {0x3E,0x03,"Logical unit failed self-test"}, {0x3E,0x04,"Logical unit unable to update self-test log"}, {0x3F,0x00,"Target operating conditions have changed"}, {0x3F,0x01,"Microcode has been changed"}, {0x3F,0x02,"Changed operating definition"}, {0x3F,0x03,"Inquiry data has changed"}, {0x3F,0x04,"Component device attached"}, {0x3F,0x05,"Device identifier changed"}, {0x3F,0x06,"Redundancy group created or modified"}, {0x3F,0x07,"Redundancy group deleted"}, {0x3F,0x08,"Spare created or modified"}, {0x3F,0x09,"Spare deleted"}, {0x3F,0x0A,"Volume set created or modified"}, {0x3F,0x0B,"Volume set deleted"}, {0x3F,0x0C,"Volume set deassigned"}, {0x3F,0x0D,"Volume set reassigned"}, {0x3F,0x0E,"Reported luns data has changed"}, {0x3F,0x0F,"Echo buffer overwritten"}, {0x3F,0x10,"Medium loadable"}, {0x3F,0x11,"Medium auxiliary memory accessible"}, {0x3F,0x12,"iSCSI IP address added"}, {0x3F,0x13,"iSCSI IP address removed"}, {0x3F,0x14,"iSCSI IP address changed"}, /* * ASC 0x40, 0x41 and 0x42 overridden by "additional2" array entries * for ascq > 1. Preferred error message for this group is * "Diagnostic failure on component nn (80h-ffh)". */ {0x40,0x00,"Ram failure (should use 40 nn)"}, {0x41,0x00,"Data path failure (should use 40 nn)"}, {0x42,0x00,"Power-on or self-test failure (should use 40 nn)"}, {0x43,0x00,"Message error"}, {0x44,0x00,"Internal target failure"}, {0x44,0x01,"Persistent reservation information lost"}, {0x44,0x71,"ATA device failed Set Features"}, {0x45,0x00,"Select or reselect failure"}, {0x46,0x00,"Unsuccessful soft reset"}, {0x47,0x00,"SCSI parity error"}, {0x47,0x01,"Data phase CRC error detected"}, {0x47,0x02,"SCSI parity error detected during st data phase"}, {0x47,0x03,"Information unit iuCRC error detected"}, {0x47,0x04,"Asynchronous information protection error detected"}, {0x47,0x05,"Protocol service CRC error"}, {0x47,0x06,"Phy test function in progress"}, {0x47,0x7F,"Some commands cleared by iSCSI protocol event"}, {0x48,0x00,"Initiator detected error message received"}, {0x49,0x00,"Invalid message error"}, {0x4A,0x00,"Command phase error"}, {0x4B,0x00,"Data phase error"}, {0x4B,0x01,"Invalid target port transfer tag received"}, {0x4B,0x02,"Too much write data"}, {0x4B,0x03,"Ack/nak timeout"}, {0x4B,0x04,"Nak received"}, {0x4B,0x05,"Data offset error"}, {0x4B,0x06,"Initiator response timeout"}, {0x4B,0x07,"Connection lost"}, {0x4B,0x08,"Data-in buffer overflow - data buffer size"}, {0x4B,0x09,"Data-in buffer overflow - data buffer descriptor area"}, {0x4B,0x0A,"Data-in buffer error"}, {0x4B,0x0B,"Data-out buffer overflow - data buffer size"}, {0x4B,0x0C,"Data-out buffer overflow - data buffer descriptor area"}, {0x4B,0x0D,"Data-out buffer error"}, {0x4B,0x0E,"PCIe fabric error"}, {0x4B,0x0f,"PCIe completion timeout"}, {0x4B,0x10,"PCIe completer abort"}, {0x4B,0x11,"PCIe poisoned tlp received"}, {0x4B,0x12,"PCIe ecrc check failed"}, {0x4B,0x13,"PCIe unsupported request"}, {0x4B,0x14,"PCIe acs violation"}, {0x4B,0x15,"PCIe tlp prefix blocked"}, {0x4C,0x00,"Logical unit failed self-configuration"}, /* * ASC 0x4D overridden by an "additional2" array entry * so there is no need to have them here. */ /* {0x4D,0x00,"Tagged overlapped commands (nn = queue tag)"}, */ {0x4E,0x00,"Overlapped commands attempted"}, {0x50,0x00,"Write append error"}, {0x50,0x01,"Write append position error"}, {0x50,0x02,"Position error related to timing"}, {0x51,0x00,"Erase failure"}, {0x51,0x01,"Erase failure - incomplete erase operation detected"}, {0x52,0x00,"Cartridge fault"}, {0x53,0x00,"Media load or eject failed"}, {0x53,0x01,"Unload tape failure"}, {0x53,0x02,"Medium removal prevented"}, {0x53,0x03,"Medium removal prevented by data transfer element"}, {0x53,0x04,"Medium thread or unthread failure"}, {0x53,0x05,"Volume identifier invalid"}, {0x53,0x06,"Volume identifier missing"}, {0x53,0x07,"Duplicate volume identifier"}, {0x53,0x08,"Element status unknown"}, {0x54,0x00,"SCSI to host system interface failure"}, {0x55,0x00,"System resource failure"}, {0x55,0x01,"System buffer full"}, {0x55,0x02,"Insufficient reservation resources"}, {0x55,0x03,"Insufficient resources"}, {0x55,0x04,"Insufficient registration resources"}, {0x55,0x05,"Insufficient access control resources"}, {0x55,0x06,"Auxiliary memory out of space"}, {0x55,0x07,"Quota error"}, {0x55,0x08,"Maximum number of supplemental decryption keys exceeded"}, {0x55,0x09,"Medium auxiliary memory not accessible"}, {0x55,0x0a,"Data currently unavailable"}, {0x55,0x0b,"Insufficient power for operation"}, {0x55,0x0c,"Insufficient resources to create rod"}, {0x55,0x0d,"Insufficient resources to create rod token"}, {0x57,0x00,"Unable to recover table-of-contents"}, {0x58,0x00,"Generation does not exist"}, {0x59,0x00,"Updated block read"}, {0x5A,0x00,"Operator request or state change input"}, {0x5A,0x01,"Operator medium removal request"}, {0x5A,0x02,"Operator selected write protect"}, {0x5A,0x03,"Operator selected write permit"}, {0x5B,0x00,"Log exception"}, {0x5B,0x01,"Threshold condition met"}, {0x5B,0x02,"Log counter at maximum"}, {0x5B,0x03,"Log list codes exhausted"}, {0x5C,0x00,"Rpl status change"}, {0x5C,0x01,"Spindles synchronized"}, {0x5C,0x02,"Spindles not synchronized"}, {0x5D,0x00,"Failure prediction threshold exceeded"}, {0x5D,0x01,"Media failure prediction threshold exceeded"}, {0x5D,0x02,"Logical unit failure prediction threshold exceeded"}, {0x5D,0x03,"spare area exhaustion prediction threshold exceeded"}, {0x5D,0x10,"Hardware impending failure general hard drive failure"}, {0x5D,0x11,"Hardware impending failure drive error rate too high" }, {0x5D,0x12,"Hardware impending failure data error rate too high" }, {0x5D,0x13,"Hardware impending failure seek error rate too high" }, {0x5D,0x14,"Hardware impending failure too many block reassigns"}, {0x5D,0x15,"Hardware impending failure access times too high" }, {0x5D,0x16,"Hardware impending failure start unit times too high" }, {0x5D,0x17,"Hardware impending failure channel parametrics"}, {0x5D,0x18,"Hardware impending failure controller detected"}, {0x5D,0x19,"Hardware impending failure throughput performance"}, {0x5D,0x1A,"Hardware impending failure seek time performance"}, {0x5D,0x1B,"Hardware impending failure spin-up retry count"}, {0x5D,0x1C,"Hardware impending failure drive calibration retry count"}, {0x5D,0x20,"Controller impending failure general hard drive failure"}, {0x5D,0x21,"Controller impending failure drive error rate too high" }, {0x5D,0x22,"Controller impending failure data error rate too high" }, {0x5D,0x23,"Controller impending failure seek error rate too high" }, {0x5D,0x24,"Controller impending failure too many block reassigns"}, {0x5D,0x25,"Controller impending failure access times too high" }, {0x5D,0x26,"Controller impending failure start unit times too high" }, {0x5D,0x27,"Controller impending failure channel parametrics"}, {0x5D,0x28,"Controller impending failure controller detected"}, {0x5D,0x29,"Controller impending failure throughput performance"}, {0x5D,0x2A,"Controller impending failure seek time performance"}, {0x5D,0x2B,"Controller impending failure spin-up retry count"}, {0x5D,0x2C,"Controller impending failure drive calibration retry count"}, {0x5D,0x30,"Data channel impending failure general hard drive failure"}, {0x5D,0x31,"Data channel impending failure drive error rate too high" }, {0x5D,0x32,"Data channel impending failure data error rate too high" }, {0x5D,0x33,"Data channel impending failure seek error rate too high" }, {0x5D,0x34,"Data channel impending failure too many block reassigns"}, {0x5D,0x35,"Data channel impending failure access times too high" }, {0x5D,0x36,"Data channel impending failure start unit times too high" }, {0x5D,0x37,"Data channel impending failure channel parametrics"}, {0x5D,0x38,"Data channel impending failure controller detected"}, {0x5D,0x39,"Data channel impending failure throughput performance"}, {0x5D,0x3A,"Data channel impending failure seek time performance"}, {0x5D,0x3B,"Data channel impending failure spin-up retry count"}, {0x5D,0x3C,"Data channel impending failure drive calibration retry count"}, {0x5D,0x40,"Servo impending failure general hard drive failure"}, {0x5D,0x41,"Servo impending failure drive error rate too high" }, {0x5D,0x42,"Servo impending failure data error rate too high" }, {0x5D,0x43,"Servo impending failure seek error rate too high" }, {0x5D,0x44,"Servo impending failure too many block reassigns"}, {0x5D,0x45,"Servo impending failure access times too high" }, {0x5D,0x46,"Servo impending failure start unit times too high" }, {0x5D,0x47,"Servo impending failure channel parametrics"}, {0x5D,0x48,"Servo impending failure controller detected"}, {0x5D,0x49,"Servo impending failure throughput performance"}, {0x5D,0x4A,"Servo impending failure seek time performance"}, {0x5D,0x4B,"Servo impending failure spin-up retry count"}, {0x5D,0x4C,"Servo impending failure drive calibration retry count"}, {0x5D,0x50,"Spindle impending failure general hard drive failure"}, {0x5D,0x51,"Spindle impending failure drive error rate too high" }, {0x5D,0x52,"Spindle impending failure data error rate too high" }, {0x5D,0x53,"Spindle impending failure seek error rate too high" }, {0x5D,0x54,"Spindle impending failure too many block reassigns"}, {0x5D,0x55,"Spindle impending failure access times too high" }, {0x5D,0x56,"Spindle impending failure start unit times too high" }, {0x5D,0x57,"Spindle impending failure channel parametrics"}, {0x5D,0x58,"Spindle impending failure controller detected"}, {0x5D,0x59,"Spindle impending failure throughput performance"}, {0x5D,0x5A,"Spindle impending failure seek time performance"}, {0x5D,0x5B,"Spindle impending failure spin-up retry count"}, {0x5D,0x5C,"Spindle impending failure drive calibration retry count"}, {0x5D,0x60,"Firmware impending failure general hard drive failure"}, {0x5D,0x61,"Firmware impending failure drive error rate too high" }, {0x5D,0x62,"Firmware impending failure data error rate too high" }, {0x5D,0x63,"Firmware impending failure seek error rate too high" }, {0x5D,0x64,"Firmware impending failure too many block reassigns"}, {0x5D,0x65,"Firmware impending failure access times too high" }, {0x5D,0x66,"Firmware impending failure start unit times too high" }, {0x5D,0x67,"Firmware impending failure channel parametrics"}, {0x5D,0x68,"Firmware impending failure controller detected"}, {0x5D,0x69,"Firmware impending failure throughput performance"}, {0x5D,0x6A,"Firmware impending failure seek time performance"}, {0x5D,0x6B,"Firmware impending failure spin-up retry count"}, {0x5D,0x6C,"Firmware impending failure drive calibration retry count"}, {0x5D,0xFF,"Failure prediction threshold exceeded (false)"}, {0x5E,0x00,"Low power condition on"}, {0x5E,0x01,"Idle condition activated by timer"}, {0x5E,0x02,"Standby condition activated by timer"}, {0x5E,0x03,"Idle condition activated by command"}, {0x5E,0x04,"Standby condition activated by command"}, {0x5E,0x05,"Idle_b condition activated by timer"}, {0x5E,0x06,"Idle_b condition activated by command"}, {0x5E,0x07,"Idle_c condition activated by timer"}, {0x5E,0x08,"Idle_c condition activated by command"}, {0x5E,0x09,"Standby_y condition activated by timer"}, {0x5E,0x0a,"Standby_y condition activated by command"}, {0x5E,0x41,"Power state change to active"}, {0x5E,0x42,"Power state change to idle"}, {0x5E,0x43,"Power state change to standby"}, {0x5E,0x45,"Power state change to sleep"}, {0x5E,0x47,"Power state change to device control"}, {0x60,0x00,"Lamp failure"}, {0x61,0x00,"Video acquisition error"}, {0x61,0x01,"Unable to acquire video"}, {0x61,0x02,"Out of focus"}, {0x62,0x00,"Scan head positioning error"}, {0x63,0x00,"End of user area encountered on this track"}, {0x63,0x01,"Packet does not fit in available space"}, {0x64,0x00,"Illegal mode for this track"}, {0x64,0x01,"Invalid packet size"}, {0x65,0x00,"Voltage fault"}, {0x66,0x00,"Automatic document feeder cover up"}, {0x66,0x01,"Automatic document feeder lift up"}, {0x66,0x02,"Document jam in automatic document feeder"}, {0x66,0x03,"Document miss feed automatic in document feeder"}, {0x67,0x00,"Configuration failure"}, {0x67,0x01,"Configuration of incapable logical units failed"}, {0x67,0x02,"Add logical unit failed"}, {0x67,0x03,"Modification of logical unit failed"}, {0x67,0x04,"Exchange of logical unit failed"}, {0x67,0x05,"Remove of logical unit failed"}, {0x67,0x06,"Attachment of logical unit failed"}, {0x67,0x07,"Creation of logical unit failed"}, {0x67,0x08,"Assign failure occurred"}, {0x67,0x09,"Multiply assigned logical unit"}, {0x67,0x0A,"Set target port groups command failed"}, {0x67,0x0B,"ATA device feature not enabled"}, {0x68,0x00,"Logical unit not configured"}, {0x68,0x01,"Subsidiary logical unit not configured"}, {0x69,0x00,"Data loss on logical unit"}, {0x69,0x01,"Multiple logical unit failures"}, {0x69,0x02,"Parity/data mismatch"}, {0x6A,0x00,"Informational, refer to log"}, {0x6B,0x00,"State change has occurred"}, {0x6B,0x01,"Redundancy level got better"}, {0x6B,0x02,"Redundancy level got worse"}, {0x6C,0x00,"Rebuild failure occurred"}, {0x6D,0x00,"Recalculate failure occurred"}, {0x6E,0x00,"Command to logical unit failed"}, {0x6F,0x00,"Copy protection key exchange failure - authentication " "failure"}, {0x6F,0x01,"Copy protection key exchange failure - key not present"}, {0x6F,0x02,"Copy protection key exchange failure - key not established"}, {0x6F,0x03,"Read of scrambled sector without authentication"}, {0x6F,0x04,"Media region code is mismatched to logical unit region"}, {0x6F,0x05,"Drive region must be permanent/region reset count error"}, {0x6F,0x06,"Insufficient block count for binding nonce recording"}, {0x6F,0x07,"Conflict in binding nonce recording"}, /* * ASC 0x70 overridden by an "additional2" array entry * so there is no need to have them here. */ /* {0x70,0x00,"Decompression exception short algorithm id of nn"}, */ {0x71,0x00,"Decompression exception long algorithm id"}, {0x72,0x00,"Session fixation error"}, {0x72,0x01,"Session fixation error writing lead-in"}, {0x72,0x02,"Session fixation error writing lead-out"}, {0x72,0x03,"Session fixation error - incomplete track in session"}, {0x72,0x04,"Empty or partially written reserved track"}, {0x72,0x05,"No more track reservations allowed"}, {0x72,0x06,"RMZ extension is not allowed"}, {0x72,0x07,"No more test zone extensions are allowed"}, {0x73,0x00,"CD control error"}, {0x73,0x01,"Power calibration area almost full"}, {0x73,0x02,"Power calibration area is full"}, {0x73,0x03,"Power calibration area error"}, {0x73,0x04,"Program memory area update failure"}, {0x73,0x05,"Program memory area is full"}, {0x73,0x06,"RMA/PMA is almost full"}, {0x73,0x10,"Current power calibration area almost full"}, {0x73,0x11,"Current power calibration area is full"}, {0x73,0x17,"RDZ is full"}, {0x74,0x00,"Security error"}, {0x74,0x01,"Unable to decrypt data"}, {0x74,0x02,"Unencrypted data encountered while decrypting"}, {0x74,0x03,"Incorrect data encryption key"}, {0x74,0x04,"Cryptographic integrity validation failed"}, {0x74,0x05,"Error decrypting data"}, {0x74,0x06,"Unknown signature verification key"}, {0x74,0x07,"Encryption parameters not useable"}, {0x74,0x08,"Digital signature validation failure"}, {0x74,0x09,"Encryption mode mismatch on read"}, {0x74,0x0a,"Encrypted block not raw read enabled"}, {0x74,0x0b,"Incorrect Encryption parameters"}, {0x74,0x0c,"Unable to decrypt parameter list"}, {0x74,0x0d,"Encryption algorithm disabled"}, {0x74,0x10,"SA creation parameter value invalid"}, {0x74,0x11,"SA creation parameter value rejected"}, {0x74,0x12,"Invalid SA usage"}, {0x74,0x21,"Data encryption configuration prevented"}, {0x74,0x30,"SA creation parameter not supported"}, {0x74,0x40,"Authentication failed"}, {0x74,0x61,"External data encryption key manager access error"}, {0x74,0x62,"External data encryption key manager error"}, {0x74,0x63,"External data encryption key not found"}, {0x74,0x64,"External data encryption request not authorized"}, {0x74,0x6e,"External data encryption control timeout"}, {0x74,0x6f,"External data encryption control error"}, {0x74,0x71,"Logical unit access not authorized"}, {0x74,0x79,"Security conflict in translated device"}, {0, 0, NULL} }; #else struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[] = { {0, 0, 0, NULL} }; struct sg_lib_asc_ascq_t sg_lib_asc_ascq[] = { {0, 0, NULL} }; #endif /* SG_SCSI_STRINGS */ const char * sg_lib_sense_key_desc[] = { "No Sense", /* Filemark, ILI and/or EOM; progress indication (during FORMAT); power condition sensing (REQUEST SENSE) */ "Recovered Error", /* The last command completed successfully but used error correction */ "Not Ready", /* The addressed target is not ready */ "Medium Error", /* Data error detected on the medium */ "Hardware Error", /* Controller or device failure */ "Illegal Request", "Unit Attention", /* Removable medium was changed, or the target has been reset */ "Data Protect", /* Access to the data is blocked */ "Blank Check", /* Reached unexpected written or unwritten region of the medium */ "Key=9", /* Vendor specific */ "Copy Aborted", /* COPY or COMPARE was aborted */ "Aborted Command", /* The target aborted the command */ "Equal", /* SEARCH DATA found data equal (obsolete) */ "Volume Overflow", /* Medium full with data to be written */ "Miscompare", /* Source data and data on the medium do not agree */ "Completed" /* may occur for successful cmd (spc4r23) */ }; const char * sg_lib_pdt_strs[] = { /* 0 */ "disk", "tape", "printer", "processor", /* often SAF-TE (seldom scanner) device */ "write once optical disk", /* 5 */ "cd/dvd", "scanner", /* obsolete */ "optical memory device", "medium changer", "communications", /* obsolete */ /* 0xa */ "graphics [0xa]", /* obsolete */ "graphics [0xb]", /* obsolete */ "storage array controller", "enclosure services device", "simplified direct access device", "optical card reader/writer device", /* 0x10 */ "bridge controller commands", "object based storage", "automation/driver interface", "security manager device", "0x14", "0x15", "0x16", "0x17", "0x18", "0x19", "0x1a", "0x1b", "0x1c", "0x1d", "well known logical unit", "no physical device on this lu", }; const char * sg_lib_transport_proto_strs[] = { "Fibre Channel Protocol for SCSI (FCP-4)", "SCSI Parallel Interface (SPI-5)", "Serial Storage Architecture SCSI-3 Protocol (SSA-S3P)", "Serial Bus Protocol for IEEE 1394 (SBP-3)", "SCSI RDMA Protocol (SRP)", "Internet SCSI (iSCSI)", "Serial Attached SCSI Protocol (SPL-2)", "Automation/Drive Interface Transport (ADT-2)", "AT Attachment Interface (ACS-2)", /* 0x8 */ "USB Attached SCSI (UAS-2)", "SCSI over PCI Express (SOP)", "Oxb", "Oxc", "Oxd", "Oxe", "No specific protocol" }; sdparm-1.08/lib/sg_cmds_mmc.c0000664000175000017500000003001412145557174015124 0ustar douggdougg/* * Copyright (c) 2008-2013 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 #include #include #define __STDC_FORMAT_MACROS 1 #include #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sg_cmds_mmc.h" #include "sg_pt.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ #define DEF_PT_TIMEOUT 60 /* 60 seconds */ #define GET_CONFIG_CMD 0x46 #define GET_CONFIG_CMD_LEN 10 #define GET_PERFORMANCE_CMD 0xac #define GET_PERFORMANCE_CMD_LEN 12 #define SET_CD_SPEED_CMD 0xbb #define SET_CD_SPEED_CMDLEN 12 #define SET_STREAMING_CMD 0xb6 #define SET_STREAMING_CMDLEN 12 /* Invokes a SCSI SET CD SPEED command (MMC). * Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> command not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed, int drv_write_speed, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char scsCmdBlk[SET_CD_SPEED_CMDLEN] = {SET_CD_SPEED_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; scsCmdBlk[1] |= (rot_control & 0x3); scsCmdBlk[2] = (drv_read_speed >> 8) & 0xff; scsCmdBlk[3] = drv_read_speed & 0xff; scsCmdBlk[4] = (drv_write_speed >> 8) & 0xff; scsCmdBlk[5] = drv_write_speed & 0xff; if (verbose) { fprintf(sg_warnings_strm, " set cd speed cdb: "); for (k = 0; k < SET_CD_SPEED_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", scsCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "set cd speed: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, scsCmdBlk, sizeof(scsCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "set cd speed", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI GET CONFIGURATION command (MMC-3,4,5). * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ int sg_ll_get_config(int sg_fd, int rt, int starting, void * resp, int mx_resp_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char gcCmdBlk[GET_CONFIG_CMD_LEN] = {GET_CONFIG_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if ((rt < 0) || (rt > 3)) { fprintf(sg_warnings_strm, "Bad rt value: %d\n", rt); return -1; } gcCmdBlk[1] = (rt & 0x3); if ((starting < 0) || (starting > 0xffff)) { fprintf(sg_warnings_strm, "Bad starting field number: 0x%x\n", starting); return -1; } gcCmdBlk[2] = (unsigned char)((starting >> 8) & 0xff); gcCmdBlk[3] = (unsigned char)(starting & 0xff); if ((mx_resp_len < 0) || (mx_resp_len > 0xffff)) { fprintf(sg_warnings_strm, "Bad mx_resp_len: 0x%x\n", starting); return -1; } gcCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff); gcCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff); if (verbose) { fprintf(sg_warnings_strm, " Get Configuration cdb: "); for (k = 0; k < GET_CONFIG_CMD_LEN; ++k) fprintf(sg_warnings_strm, "%02x ", gcCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "get configuration: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, gcCmdBlk, sizeof(gcCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "get configuration", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 3)) { unsigned char * ucp; int len; ucp = (unsigned char *)resp; len = (ucp[0] << 24) + (ucp[1] << 16) + (ucp[2] << 8) + ucp[3] + 4; if (len < 0) len = 0; len = (ret < len) ? ret : len; fprintf(sg_warnings_strm, " get configuration: response%s\n", (len > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (len > 256 ? 256 : len), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI GET PERFORMANCE command (MMC-3...6). * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ int sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba, int max_num_desc, int ttype, void * resp, int mx_resp_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char gpCmdBlk[GET_PERFORMANCE_CMD_LEN] = {GET_PERFORMANCE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if ((data_type < 0) || (data_type > 0x1f)) { fprintf(sg_warnings_strm, "Bad data_type value: %d\n", data_type); return -1; } gpCmdBlk[1] = (data_type & 0x1f); gpCmdBlk[2] = (unsigned char)((starting_lba >> 24) & 0xff); gpCmdBlk[3] = (unsigned char)((starting_lba >> 16) & 0xff); gpCmdBlk[4] = (unsigned char)((starting_lba >> 8) & 0xff); gpCmdBlk[3] = (unsigned char)(starting_lba & 0xff); if ((max_num_desc < 0) || (max_num_desc > 0xffff)) { fprintf(sg_warnings_strm, "Bad max_num_desc: 0x%x\n", max_num_desc); return -1; } gpCmdBlk[8] = (unsigned char)((max_num_desc >> 8) & 0xff); gpCmdBlk[9] = (unsigned char)(max_num_desc & 0xff); if ((ttype < 0) || (ttype > 0xff)) { fprintf(sg_warnings_strm, "Bad type: 0x%x\n", ttype); return -1; } gpCmdBlk[10] = (unsigned char)ttype; if (verbose) { fprintf(sg_warnings_strm, " Get Performance cdb: "); for (k = 0; k < GET_PERFORMANCE_CMD_LEN; ++k) fprintf(sg_warnings_strm, "%02x ", gpCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "get performance: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, gpCmdBlk, sizeof(gpCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "get performance", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 3)) { unsigned char * ucp; int len; ucp = (unsigned char *)resp; len = (ucp[0] << 24) + (ucp[1] << 16) + (ucp[2] << 8) + ucp[3] + 4; if (len < 0) len = 0; len = (ret < len) ? ret : len; fprintf(sg_warnings_strm, " get performance:: response%s\n", (len > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (len > 256 ? 256 : len), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI SET STREAMING command (MMC). Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Set Streaming not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_NOT_READY -> device not ready, * -1 -> other failure */ int sg_ll_set_streaming(int sg_fd, int type, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char ssCmdBlk[SET_STREAMING_CMDLEN] = {SET_STREAMING_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; ssCmdBlk[8] = type; ssCmdBlk[9] = (param_len >> 8) & 0xff; ssCmdBlk[10] = param_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " set streaming cdb: "); for (k = 0; k < SET_STREAMING_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", ssCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 1) && paramp && param_len) { fprintf(sg_warnings_strm, " set streaming " "parameter list:\n"); dStrHex((const char *)paramp, param_len, -1); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "set streaming: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, ssCmdBlk, sizeof(ssCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "set streaming", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } sdparm-1.08/lib/sg_cmds_basic2.c0000664000175000017500000011057112113731552015507 0ustar douggdougg/* * Copyright (c) 1999-2013 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. */ /* * CONTENTS * Some SCSI commands are executed in many contexts and hence began * to appear in several sg3_utils utilities. This files centralizes * some of the low level command execution code. In most cases the * interpretation of the command response is left to the each * utility. */ #include #include #include #include #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sg_pt.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ #define EBUFF_SZ 256 #define DEF_PT_TIMEOUT 60 /* 60 seconds */ #define START_PT_TIMEOUT 120 /* 120 seconds == 2 minutes */ #define LONG_PT_TIMEOUT 7200 /* 7,200 seconds == 120 minutes */ #define SYNCHRONIZE_CACHE_CMD 0x35 #define SYNCHRONIZE_CACHE_CMDLEN 10 #define SERVICE_ACTION_IN_16_CMD 0x9e #define SERVICE_ACTION_IN_16_CMDLEN 16 #define READ_CAPACITY_16_SA 0x10 #define READ_CAPACITY_10_CMD 0x25 #define READ_CAPACITY_10_CMDLEN 10 #define MODE_SENSE6_CMD 0x1a #define MODE_SENSE6_CMDLEN 6 #define MODE_SENSE10_CMD 0x5a #define MODE_SENSE10_CMDLEN 10 #define MODE_SELECT6_CMD 0x15 #define MODE_SELECT6_CMDLEN 6 #define MODE_SELECT10_CMD 0x55 #define MODE_SELECT10_CMDLEN 10 #define LOG_SENSE_CMD 0x4d #define LOG_SENSE_CMDLEN 10 #define LOG_SELECT_CMD 0x4c #define LOG_SELECT_CMDLEN 10 #define START_STOP_CMD 0x1b #define START_STOP_CMDLEN 6 #define PREVENT_ALLOW_CMD 0x1e #define PREVENT_ALLOW_CMDLEN 6 #define MODE6_RESP_HDR_LEN 4 #define MODE10_RESP_HDR_LEN 8 #define MODE_RESP_ARB_LEN 1024 #define INQUIRY_RESP_INITIAL_LEN 36 /* Invokes a SCSI SYNCHRONIZE CACHE (10) command. Return of 0 -> success, * SG_LIB_CAT_UNIT_ATTENTION -> repeat, * SG_LIB_CAT_INVALID_OP -> cdb not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ int sg_ll_sync_cache_10(int sg_fd, int sync_nv, int immed, int group, unsigned int lba, unsigned int count, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char scCmdBlk[SYNCHRONIZE_CACHE_CMDLEN] = {SYNCHRONIZE_CACHE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (sync_nv) scCmdBlk[1] |= 4; if (immed) scCmdBlk[1] |= 2; scCmdBlk[2] = (lba >> 24) & 0xff; scCmdBlk[3] = (lba >> 16) & 0xff; scCmdBlk[4] = (lba >> 8) & 0xff; scCmdBlk[5] = lba & 0xff; scCmdBlk[6] = group & 0x1f; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (count > 0xffff) { fprintf(sg_warnings_strm, "count too big\n"); return -1; } scCmdBlk[7] = (count >> 8) & 0xff; scCmdBlk[8] = count & 0xff; if (verbose) { fprintf(sg_warnings_strm, " synchronize cache(10) cdb: "); for (k = 0; k < SYNCHRONIZE_CACHE_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", scCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "synchronize cache(10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, scCmdBlk, sizeof(scCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "synchronize cache(10)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ CAPACITY (16) command. Returns 0 -> success, * SG_LIB_CAT_UNIT_ATTENTION -> media changed??, SG_LIB_CAT_INVALID_OP * -> cdb not supported, SG_LIB_CAT_IlLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_NOT_READY -> device not ready, * -1 -> other failure */ int sg_ll_readcap_16(int sg_fd, int pmi, uint64_t llba, void * resp, int mx_resp_len, int noisy, int verbose) { int k, ret, res, sense_cat; unsigned char rcCmdBlk[SERVICE_ACTION_IN_16_CMDLEN] = {SERVICE_ACTION_IN_16_CMD, READ_CAPACITY_16_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (pmi) { /* lbs only valid when pmi set */ rcCmdBlk[14] |= 1; rcCmdBlk[2] = (llba >> 56) & 0xff; rcCmdBlk[3] = (llba >> 48) & 0xff; rcCmdBlk[4] = (llba >> 40) & 0xff; rcCmdBlk[5] = (llba >> 32) & 0xff; rcCmdBlk[6] = (llba >> 24) & 0xff; rcCmdBlk[7] = (llba >> 16) & 0xff; rcCmdBlk[8] = (llba >> 8) & 0xff; rcCmdBlk[9] = llba & 0xff; } /* Allocation length, no guidance in SBC-2 rev 15b */ rcCmdBlk[10] = (mx_resp_len >> 24) & 0xff; rcCmdBlk[11] = (mx_resp_len >> 16) & 0xff; rcCmdBlk[12] = (mx_resp_len >> 8) & 0xff; rcCmdBlk[13] = mx_resp_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " read capacity (16) cdb: "); for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rcCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read capacity (16): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rcCmdBlk, sizeof(rcCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read capacity (16)", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ CAPACITY (10) command. Returns 0 -> success, * SG_LIB_CAT_UNIT_ATTENTION -> media changed??, SG_LIB_CAT_INVALID_OP * -> cdb not supported, SG_LIB_CAT_IlLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_NOT_READY -> device not ready, * -1 -> other failure */ int sg_ll_readcap_10(int sg_fd, int pmi, unsigned int lba, void * resp, int mx_resp_len, int noisy, int verbose) { int k, ret, res, sense_cat; unsigned char rcCmdBlk[READ_CAPACITY_10_CMDLEN] = {READ_CAPACITY_10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (pmi) { /* lbs only valid when pmi set */ rcCmdBlk[8] |= 1; rcCmdBlk[2] = (lba >> 24) & 0xff; rcCmdBlk[3] = (lba >> 16) & 0xff; rcCmdBlk[4] = (lba >> 8) & 0xff; rcCmdBlk[5] = lba & 0xff; } if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " read capacity (10) cdb: "); for (k = 0; k < READ_CAPACITY_10_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rcCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read capacity (10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rcCmdBlk, sizeof(rcCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read capacity (10)", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI MODE SENSE (6) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_UNIT_ATTENTION, * -1 -> other failure */ int sg_ll_mode_sense6(int sg_fd, int dbd, int pc, int pg_code, int sub_pg_code, void * resp, int mx_resp_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char modesCmdBlk[MODE_SENSE6_CMDLEN] = {MODE_SENSE6_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; modesCmdBlk[1] = (unsigned char)(dbd ? 0x8 : 0); modesCmdBlk[2] = (unsigned char)(((pc << 6) & 0xc0) | (pg_code & 0x3f)); modesCmdBlk[3] = (unsigned char)(sub_pg_code & 0xff); modesCmdBlk[4] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (mx_resp_len > 0xff) { fprintf(sg_warnings_strm, "mx_resp_len too big\n"); return -1; } if (verbose) { fprintf(sg_warnings_strm, " mode sense (6) cdb: "); for (k = 0; k < MODE_SENSE6_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", modesCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "mode sense (6): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, modesCmdBlk, sizeof(modesCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "mode sense (6)", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " mode sense (6): response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI MODE SENSE (10) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_UNIT_ATTENTION, * -1 -> other failure */ int sg_ll_mode_sense10(int sg_fd, int llbaa, int dbd, int pc, int pg_code, int sub_pg_code, void * resp, int mx_resp_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char modesCmdBlk[MODE_SENSE10_CMDLEN] = {MODE_SENSE10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; modesCmdBlk[1] = (unsigned char)((dbd ? 0x8 : 0) | (llbaa ? 0x10 : 0)); modesCmdBlk[2] = (unsigned char)(((pc << 6) & 0xc0) | (pg_code & 0x3f)); modesCmdBlk[3] = (unsigned char)(sub_pg_code & 0xff); modesCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff); modesCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (mx_resp_len > 0xffff) { fprintf(sg_warnings_strm, "mx_resp_len too big\n"); return -1; } if (verbose) { fprintf(sg_warnings_strm, " mode sense (10) cdb: "); for (k = 0; k < MODE_SENSE10_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", modesCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "mode sense (10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, modesCmdBlk, sizeof(modesCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "mode sense (10)", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " mode sense (10): response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI MODE SELECT (6) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_UNIT_ATTENTION, * -1 -> other failure */ int sg_ll_mode_select6(int sg_fd, int pf, int sp, void * paramp, int param_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char modesCmdBlk[MODE_SELECT6_CMDLEN] = {MODE_SELECT6_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; modesCmdBlk[1] = (unsigned char)(((pf << 4) & 0x10) | (sp & 0x1)); modesCmdBlk[4] = (unsigned char)(param_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (param_len > 0xff) { fprintf(sg_warnings_strm, "mode select (6): param_len too big\n"); return -1; } if (verbose) { fprintf(sg_warnings_strm, " mode select (6) cdb: "); for (k = 0; k < MODE_SELECT6_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", modesCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } if (verbose > 1) { fprintf(sg_warnings_strm, " mode select (6) parameter list\n"); dStrHex((const char *)paramp, param_len, -1); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "mode select (6): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, modesCmdBlk, sizeof(modesCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "mode select (6)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI MODE SELECT (10) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_UNIT_ATTENTION, * -1 -> other failure */ int sg_ll_mode_select10(int sg_fd, int pf, int sp, void * paramp, int param_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char modesCmdBlk[MODE_SELECT10_CMDLEN] = {MODE_SELECT10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; modesCmdBlk[1] = (unsigned char)(((pf << 4) & 0x10) | (sp & 0x1)); modesCmdBlk[7] = (unsigned char)((param_len >> 8) & 0xff); modesCmdBlk[8] = (unsigned char)(param_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (param_len > 0xffff) { fprintf(sg_warnings_strm, "mode select (10): param_len too big\n"); return -1; } if (verbose) { fprintf(sg_warnings_strm, " mode select (10) cdb: "); for (k = 0; k < MODE_SELECT10_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", modesCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } if (verbose > 1) { fprintf(sg_warnings_strm, " mode select (10) parameter list\n"); dStrHex((const char *)paramp, param_len, -1); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "mode select (10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, modesCmdBlk, sizeof(modesCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "mode select (10)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* MODE SENSE commands yield a response that has block descriptors followed * by mode pages. In most cases users are interested in the first mode page. * This function returns the (byte) offset of the start of the first mode * page. Set mode_sense_6 to 1 for MODE SENSE (6) and 0 for MODE SENSE (10). * Returns >= 0 is successful or -1 if failure. If there is a failure * a message is written to err_buff. */ int sg_mode_page_offset(const unsigned char * resp, int resp_len, int mode_sense_6, char * err_buff, int err_buff_len) { int bd_len; int calc_len; int offset; if ((NULL == resp) || (resp_len < 4) || ((! mode_sense_6) && (resp_len < 8))) { if (err_buff_len > 0) snprintf(err_buff, err_buff_len, "given response length too " "short: %d\n", resp_len); return -1; } if (mode_sense_6) { calc_len = resp[0] + 1; bd_len = resp[3]; offset = bd_len + MODE6_RESP_HDR_LEN; } else { calc_len = (resp[0] << 8) + resp[1] + 2; bd_len = (resp[6] << 8) + resp[7]; /* LongLBA doesn't change this calculation */ offset = bd_len + MODE10_RESP_HDR_LEN; } if ((offset + 2) > resp_len) { if (err_buff_len > 0) snprintf(err_buff, err_buff_len, "given response length " "too small, offset=%d given_len=%d bd_len=%d\n", offset, resp_len, bd_len); offset = -1; } else if ((offset + 2) > calc_len) { if (err_buff_len > 0) snprintf(err_buff, err_buff_len, "calculated response " "length too small, offset=%d calc_len=%d bd_len=%d\n", offset, calc_len, bd_len); offset = -1; } return offset; } /* Fetches current, changeable, default and/or saveable modes pages as * indicated by pcontrol_arr for given pg_code and sub_pg_code. If * mode6==0 then use MODE SENSE (10) else use MODE SENSE (6). If * flexible set and mode data length seems wrong then try and * fix (compensating hack for bad device or driver). pcontrol_arr * should have 4 elements for output of current, changeable, default * and saved values respectively. Each element should be NULL or * at least mx_mpage_len bytes long. * Return of 0 -> overall success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_MALFORMED -> bad response, -1 -> other failure. * If success_mask pointer is not NULL then first zeros it. Then set bits * 0, 1, 2 and/or 3 if the current, changeable, default and saved values * respectively have been fetched. If error on current page * then stops and returns that error; otherwise continues if an error is * detected but returns the first error encountered. */ int sg_get_mode_page_controls(int sg_fd, int mode6, int pg_code, int sub_pg_code, int dbd, int flexible, int mx_mpage_len, int * success_mask, void * pcontrol_arr[], int * reported_len, int verbose) { int k, n, res, offset, calc_len, xfer_len, resp_mode6; unsigned char buff[MODE_RESP_ARB_LEN]; char ebuff[EBUFF_SZ]; int first_err = 0; if (success_mask) *success_mask = 0; if (reported_len) *reported_len = 0; if (mx_mpage_len < 4) return 0; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; memset(ebuff, 0, sizeof(ebuff)); /* first try to find length of current page response */ memset(buff, 0, MODE10_RESP_HDR_LEN); if (mode6) /* want first 8 bytes just in case */ res = sg_ll_mode_sense6(sg_fd, dbd, 0 /* pc */, pg_code, sub_pg_code, buff, MODE10_RESP_HDR_LEN, 1, verbose); else res = sg_ll_mode_sense10(sg_fd, 0 /* llbaa */, dbd, 0 /* pc */, pg_code, sub_pg_code, buff, MODE10_RESP_HDR_LEN, 1, verbose); if (0 != res) return res; n = buff[0]; if (reported_len) *reported_len = mode6 ? (n + 1) : ((n << 8) + buff[1] + 2); resp_mode6 = mode6; if (flexible) { if (mode6 && (n < 3)) { resp_mode6 = 0; if (verbose) fprintf(sg_warnings_strm, ">>> msense(6) but resp[0]=%d so " "try msense(10) response processing\n", n); } if ((0 == mode6) && (n > 5)) { if ((n > 11) && (0 == (n % 2)) && (0 == buff[4]) && (0 == buff[5]) && (0 == buff[6])) { buff[1] = n; buff[0] = 0; if (verbose) fprintf(sg_warnings_strm, ">>> msense(10) but resp[0]=%d " "and not msense(6) response so fix length\n", n); } else resp_mode6 = 1; } } if (verbose && (resp_mode6 != mode6)) fprintf(sg_warnings_strm, ">>> msense(%d) but resp[0]=%d " "so switch response processing\n", (mode6 ? 6 : 10), buff[0]); calc_len = resp_mode6 ? (buff[0] + 1) : ((buff[0] << 8) + buff[1] + 2); if (calc_len > MODE_RESP_ARB_LEN) calc_len = MODE_RESP_ARB_LEN; offset = sg_mode_page_offset(buff, calc_len, resp_mode6, ebuff, EBUFF_SZ); if (offset < 0) { if (('\0' != ebuff[0]) && (verbose > 0)) fprintf(sg_warnings_strm, "sg_get_mode_page_controls: %s\n", ebuff); return SG_LIB_CAT_MALFORMED; } xfer_len = calc_len - offset; if (xfer_len > mx_mpage_len) xfer_len = mx_mpage_len; for (k = 0; k < 4; ++k) { if (NULL == pcontrol_arr[k]) continue; memset(pcontrol_arr[k], 0, mx_mpage_len); if (mode6) res = sg_ll_mode_sense6(sg_fd, dbd, k /* pc */, pg_code, sub_pg_code, buff, calc_len, 1, verbose); else res = sg_ll_mode_sense10(sg_fd, 0 /* llbaa */, dbd, k /* pc */, pg_code, sub_pg_code, buff, calc_len, 1, verbose); if (0 != res) { if (0 == first_err) first_err = res; if (0 == k) break; /* if problem on current page, it won't improve */ else continue; } if (xfer_len > 0) memcpy(pcontrol_arr[k], buff + offset, xfer_len); if (success_mask) *success_mask |= (1 << k); } return first_err; } /* Invokes a SCSI LOG SENSE command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Log Sense not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_log_sense(int sg_fd, int ppc, int sp, int pc, int pg_code, int subpg_code, int paramp, unsigned char * resp, int mx_resp_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char logsCmdBlk[LOG_SENSE_CMDLEN] = {LOG_SENSE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (mx_resp_len > 0xffff) { fprintf(sg_warnings_strm, "mx_resp_len too big\n"); return -1; } logsCmdBlk[1] = (unsigned char)((ppc ? 2 : 0) | (sp ? 1 : 0)); logsCmdBlk[2] = (unsigned char)(((pc << 6) & 0xc0) | (pg_code & 0x3f)); logsCmdBlk[3] = (unsigned char)(subpg_code & 0xff); logsCmdBlk[5] = (unsigned char)((paramp >> 8) & 0xff); logsCmdBlk[6] = (unsigned char)(paramp & 0xff); logsCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff); logsCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff); if (verbose) { fprintf(sg_warnings_strm, " log sense cdb: "); for (k = 0; k < LOG_SENSE_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", logsCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "log sense: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, logsCmdBlk, sizeof(logsCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "log sense", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((mx_resp_len > 3) && (ret < 4)) { /* resid indicates LOG SENSE response length bad, so zero it */ resp[2] = 0; resp[3] = 0; } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI LOG SELECT command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Log Select not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_log_select(int sg_fd, int pcr, int sp, int pc, int pg_code, int subpg_code, unsigned char * paramp, int param_len, int noisy, int verbose) { int res, ret, k, sense_cat; unsigned char logsCmdBlk[LOG_SELECT_CMDLEN] = {LOG_SELECT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (param_len > 0xffff) { fprintf(sg_warnings_strm, "log select: param_len too big\n"); return -1; } logsCmdBlk[1] = (unsigned char)((pcr ? 2 : 0) | (sp ? 1 : 0)); logsCmdBlk[2] = (unsigned char)(((pc << 6) & 0xc0) | (pg_code & 0x3f)); logsCmdBlk[3] = (unsigned char)(subpg_code & 0xff); logsCmdBlk[7] = (unsigned char)((param_len >> 8) & 0xff); logsCmdBlk[8] = (unsigned char)(param_len & 0xff); if (verbose) { fprintf(sg_warnings_strm, " log select cdb: "); for (k = 0; k < LOG_SELECT_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", logsCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } if ((verbose > 1) && (param_len > 0)) { fprintf(sg_warnings_strm, " log select parameter list\n"); dStrHex((const char *)paramp, param_len, -1); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "log select: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, logsCmdBlk, sizeof(logsCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "log select", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI START STOP UNIT command (SBC + MMC). * Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Start stop unit not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure * SBC-3 and MMC partially overlap on the power_condition_modifier(sbc) and * format_layer_number(mmc) fields. They also overlap on the noflush(sbc) * and fl(mmc) one bit field. This is the cause of the awkardly named * pc_mod__fl_num and noflush__fl arguments to this function. * */ int sg_ll_start_stop_unit(int sg_fd, int immed, int pc_mod__fl_num, int power_cond, int noflush__fl, int loej, int start, int noisy, int verbose) { unsigned char ssuBlk[START_STOP_CMDLEN] = {START_STOP_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; int k, res, ret, sense_cat; struct sg_pt_base * ptvp; ssuBlk[1] = immed & 1; ssuBlk[3] = pc_mod__fl_num & 0xf; /* bits 2 and 3 are reserved in MMC */ ssuBlk[4] = ((power_cond & 0xf) << 4) | (noflush__fl ? 0x4 : 0) | (loej ? 0x2 : 0) | (start ? 0x1 : 0); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Start stop unit command:"); for (k = 0; k < (int)sizeof(ssuBlk); ++k) fprintf (sg_warnings_strm, " %02x", ssuBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "start stop unit: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, ssuBlk, sizeof(ssuBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); res = do_scsi_pt(ptvp, sg_fd, START_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "start stop unit", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI PREVENT ALLOW MEDIUM REMOVAL command * [was in SPC-3 but displaced from SPC-4 into SBC-3, MMC-5, SSC-3] * prevent==0 allows removal, prevent==1 prevents removal ... * Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> command not supported * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_prevent_allow(int sg_fd, int prevent, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char pCmdBlk[PREVENT_ALLOW_CMDLEN] = {PREVENT_ALLOW_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if ((prevent < 0) || (prevent > 3)) { fprintf(sg_warnings_strm, "prevent argument should be 0, 1, 2 or 3\n"); return -1; } pCmdBlk[4] |= (prevent & 0x3); if (verbose) { fprintf(sg_warnings_strm, " Prevent allow medium removal cdb: "); for (k = 0; k < PREVENT_ALLOW_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", pCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "prevent allow medium removal: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, pCmdBlk, sizeof(pCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "prevent allow medium removal", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } sdparm-1.08/lib/sg_cmds_extra.c0000664000175000017500000024767212061626602015505 0ustar douggdougg/* * Copyright (c) 1999-2012 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 #include #include #define __STDC_FORMAT_MACROS 1 #include #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sg_cmds_extra.h" #include "sg_pt.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ #define DEF_PT_TIMEOUT 60 /* 60 seconds */ #define LONG_PT_TIMEOUT 7200 /* 7,200 seconds == 120 minutes */ #define SERVICE_ACTION_IN_16_CMD 0x9e #define SERVICE_ACTION_IN_16_CMDLEN 16 #define SERVICE_ACTION_OUT_16_CMD 0x9f #define SERVICE_ACTION_OUT_16_CMDLEN 16 #define MAINTENANCE_IN_CMD 0xa3 #define MAINTENANCE_IN_CMDLEN 12 #define MAINTENANCE_OUT_CMD 0xa4 #define MAINTENANCE_OUT_CMDLEN 12 #define ATA_PT_12_CMD 0xa1 #define ATA_PT_12_CMDLEN 12 #define ATA_PT_16_CMD 0x85 #define ATA_PT_16_CMDLEN 16 #define FORMAT_UNIT_CMD 0x4 #define FORMAT_UNIT_CMDLEN 6 #define PERSISTENT_RESERVE_IN_CMD 0x5e #define PERSISTENT_RESERVE_IN_CMDLEN 10 #define PERSISTENT_RESERVE_OUT_CMD 0x5f #define PERSISTENT_RESERVE_OUT_CMDLEN 10 #define READ_BLOCK_LIMITS_CMD 0x5 #define READ_BLOCK_LIMITS_CMDLEN 6 #define READ_BUFFER_CMD 0x3c #define READ_BUFFER_CMDLEN 10 #define READ_DEFECT10_CMD 0x37 #define READ_DEFECT10_CMDLEN 10 #define REASSIGN_BLKS_CMD 0x7 #define REASSIGN_BLKS_CMDLEN 6 #define RECEIVE_DIAGNOSTICS_CMD 0x1c #define RECEIVE_DIAGNOSTICS_CMDLEN 6 #define EXTENDED_COPY_CMD 0x83 #define EXTENDED_COPY_CMDLEN 16 #define RECEIVE_COPY_RESULTS_CMD 0x84 #define RECEIVE_COPY_RESULTS_CMDLEN 16 #define SEND_DIAGNOSTIC_CMD 0x1d #define SEND_DIAGNOSTIC_CMDLEN 6 #define SERVICE_ACTION_IN_12_CMD 0xab #define SERVICE_ACTION_IN_12_CMDLEN 12 #define READ_LONG10_CMD 0x3e #define READ_LONG10_CMDLEN 10 #define UNMAP_CMD 0x42 #define UNMAP_CMDLEN 10 #define VERIFY10_CMD 0x2f #define VERIFY10_CMDLEN 10 #define VERIFY16_CMD 0x8f #define VERIFY16_CMDLEN 16 #define WRITE_LONG10_CMD 0x3f #define WRITE_LONG10_CMDLEN 10 #define WRITE_BUFFER_CMD 0x3b #define WRITE_BUFFER_CMDLEN 10 #define GET_LBA_STATUS_SA 0x12 #define READ_LONG_16_SA 0x11 #define READ_MEDIA_SERIAL_NUM_SA 0x1 #define REPORT_IDENTIFYING_INFORMATION_SA 0x5 #define REPORT_TGT_PRT_GRP_SA 0xa #define RECEIVE_COPY_RES_COPY_STATUS_SA 0x00 #define RECEIVE_COPY_RES_RECEIVE_DATA_SA 0x01 #define RECEIVE_COPY_RES_OPERATING_PARMS_SA 0x03 #define RECEIVE_COPY_RES_FAILED_SEGMENT_DETAILS_SA 0x04 #define SET_IDENTIFYING_INFORMATION_SA 0x6 #define SET_TGT_PRT_GRP_SA 0xa #define WRITE_LONG_16_SA 0x11 #define REPORT_REFERRALS_SA 0x13 /* Invokes a SCSI GET LBA STATUS command (SBC). Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> GET LBA STATUS not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ int sg_ll_get_lba_status(int sg_fd, uint64_t start_llba, void * resp, int alloc_len, int noisy, int verbose) { int k, res, sense_cat, ret; unsigned char getLbaStatCmd[SERVICE_ACTION_IN_16_CMDLEN]; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; memset(getLbaStatCmd, 0, sizeof(getLbaStatCmd)); getLbaStatCmd[0] = SERVICE_ACTION_IN_16_CMD; getLbaStatCmd[1] = GET_LBA_STATUS_SA; getLbaStatCmd[2] = (start_llba >> 56) & 0xff; getLbaStatCmd[3] = (start_llba >> 48) & 0xff; getLbaStatCmd[4] = (start_llba >> 40) & 0xff; getLbaStatCmd[5] = (start_llba >> 32) & 0xff; getLbaStatCmd[6] = (start_llba >> 24) & 0xff; getLbaStatCmd[7] = (start_llba >> 16) & 0xff; getLbaStatCmd[8] = (start_llba >> 8) & 0xff; getLbaStatCmd[9] = start_llba & 0xff; getLbaStatCmd[10] = (alloc_len >> 24) & 0xff; getLbaStatCmd[11] = (alloc_len >> 16) & 0xff; getLbaStatCmd[12] = (alloc_len >> 8) & 0xff; getLbaStatCmd[13] = alloc_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Get LBA status cmd: "); for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", getLbaStatCmd[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "get LBA status: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, getLbaStatCmd, sizeof(getLbaStatCmd)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, alloc_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "get LBA status", res, alloc_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " get LBA status: response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } int sg_ll_report_tgt_prt_grp(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose) { return sg_ll_report_tgt_prt_grp2(sg_fd, resp, mx_resp_len, 0, noisy, verbose); } /* Invokes a SCSI REPORT TARGET PORT GROUPS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Target Port Groups not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ int sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len, int extended, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char rtpgCmdBlk[MAINTENANCE_IN_CMDLEN] = {MAINTENANCE_IN_CMD, REPORT_TGT_PRT_GRP_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (extended) { rtpgCmdBlk[1] |= 0x20; } rtpgCmdBlk[6] = (mx_resp_len >> 24) & 0xff; rtpgCmdBlk[7] = (mx_resp_len >> 16) & 0xff; rtpgCmdBlk[8] = (mx_resp_len >> 8) & 0xff; rtpgCmdBlk[9] = mx_resp_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " report target port groups cdb: "); for (k = 0; k < MAINTENANCE_IN_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rtpgCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "report target port groups: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rtpgCmdBlk, sizeof(rtpgCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "report target port group", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " report target port group: " "response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI SET TARGET PORT GROUPS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Set Target Port Groups not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ int sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char stpgCmdBlk[MAINTENANCE_OUT_CMDLEN] = {MAINTENANCE_OUT_CMD, SET_TGT_PRT_GRP_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; stpgCmdBlk[6] = (param_len >> 24) & 0xff; stpgCmdBlk[7] = (param_len >> 16) & 0xff; stpgCmdBlk[8] = (param_len >> 8) & 0xff; stpgCmdBlk[9] = param_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " set target port groups cdb: "); for (k = 0; k < MAINTENANCE_OUT_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", stpgCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 1) && paramp && param_len) { fprintf(sg_warnings_strm, " set target port groups " "parameter list:\n"); dStrHex((const char *)paramp, param_len, -1); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "set target port groups: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, stpgCmdBlk, sizeof(stpgCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "set target port group", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI REPORT REFERRALS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Referrals not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ int sg_ll_report_referrals(int sg_fd, uint64_t start_llba, int one_seg, void * resp, int mx_resp_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char repRefCmdBlk[SERVICE_ACTION_IN_16_CMDLEN] = {SERVICE_ACTION_IN_16_CMD, REPORT_REFERRALS_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; repRefCmdBlk[2] = (start_llba >> 56) & 0xff; repRefCmdBlk[3] = (start_llba >> 48) & 0xff; repRefCmdBlk[4] = (start_llba >> 40) & 0xff; repRefCmdBlk[5] = (start_llba >> 32) & 0xff; repRefCmdBlk[6] = (start_llba >> 24) & 0xff; repRefCmdBlk[7] = (start_llba >> 16) & 0xff; repRefCmdBlk[8] = (start_llba >> 8) & 0xff; repRefCmdBlk[9] = start_llba & 0xff; repRefCmdBlk[10] = (mx_resp_len >> 24) & 0xff; repRefCmdBlk[11] = (mx_resp_len >> 16) & 0xff; repRefCmdBlk[12] = (mx_resp_len >> 8) & 0xff; repRefCmdBlk[13] = mx_resp_len & 0xff; repRefCmdBlk[14] = one_seg & 0x1; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " report referrals cdb: "); for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", repRefCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "report target port groups: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, repRefCmdBlk, sizeof(repRefCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "report referrals", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " report referrals: response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI SEND DIAGNOSTIC command. Foreground, extended self tests can * take a long time, if so set long_duration flag. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Send diagnostic not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_send_diag(int sg_fd, int sf_code, int pf_bit, int sf_bit, int devofl_bit, int unitofl_bit, int long_duration, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char senddiagCmdBlk[SEND_DIAGNOSTIC_CMDLEN] = {SEND_DIAGNOSTIC_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; senddiagCmdBlk[1] = (unsigned char)((sf_code << 5) | (pf_bit << 4) | (sf_bit << 2) | (devofl_bit << 1) | unitofl_bit); senddiagCmdBlk[3] = (unsigned char)((param_len >> 8) & 0xff); senddiagCmdBlk[4] = (unsigned char)(param_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Send diagnostic cmd: "); for (k = 0; k < SEND_DIAGNOSTIC_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", senddiagCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 1) && paramp && param_len) { fprintf(sg_warnings_strm, " Send diagnostic parameter " "list:\n"); dStrHex((const char *)paramp, param_len, -1); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "send diagnostic: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, senddiagCmdBlk, sizeof(senddiagCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, (long_duration ? LONG_PT_TIMEOUT : DEF_PT_TIMEOUT), verbose); ret = sg_cmds_process_resp(ptvp, "send diagnostic", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Receive diagnostic results not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_receive_diag(int sg_fd, int pcv, int pg_code, void * resp, int mx_resp_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char rcvdiagCmdBlk[RECEIVE_DIAGNOSTICS_CMDLEN] = {RECEIVE_DIAGNOSTICS_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; rcvdiagCmdBlk[1] = (unsigned char)(pcv ? 0x1 : 0); rcvdiagCmdBlk[2] = (unsigned char)(pg_code); rcvdiagCmdBlk[3] = (unsigned char)((mx_resp_len >> 8) & 0xff); rcvdiagCmdBlk[4] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Receive diagnostic results cmd: "); for (k = 0; k < RECEIVE_DIAGNOSTICS_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rcvdiagCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "receive diagnostic results: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rcvdiagCmdBlk, sizeof(rcvdiagCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "receive diagnostic results", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " receive diagnostic results: " "response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ DEFECT DATA (10) command (SBC). Return of 0 -> * success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_read_defect10(int sg_fd, int req_plist, int req_glist, int dl_format, void * resp, int mx_resp_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char rdefCmdBlk[READ_DEFECT10_CMDLEN] = {READ_DEFECT10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; rdefCmdBlk[2] = (unsigned char)(((req_plist << 4) & 0x10) | ((req_glist << 3) & 0x8) | (dl_format & 0x7)); rdefCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff); rdefCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (mx_resp_len > 0xffff) { fprintf(sg_warnings_strm, "mx_resp_len too big\n"); return -1; } if (verbose) { fprintf(sg_warnings_strm, " read defect (10) cdb: "); for (k = 0; k < READ_DEFECT10_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rdefCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read defect (10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rdefCmdBlk, sizeof(rdefCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read defect (10)", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " read defect (10): response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ MEDIA SERIAL NUMBER command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Read media serial number not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char rmsnCmdBlk[SERVICE_ACTION_IN_12_CMDLEN] = {SERVICE_ACTION_IN_12_CMD, READ_MEDIA_SERIAL_NUM_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; rmsnCmdBlk[6] = (mx_resp_len >> 24) & 0xff; rmsnCmdBlk[7] = (mx_resp_len >> 16) & 0xff; rmsnCmdBlk[8] = (mx_resp_len >> 8) & 0xff; rmsnCmdBlk[9] = mx_resp_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " read media serial number cdb: "); for (k = 0; k < SERVICE_ACTION_IN_12_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rmsnCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read media serial number: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rmsnCmdBlk, sizeof(rmsnCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read media serial number", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " read media serial number: respon" "se%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI REPORT IDENTIFYING INFORMATION command. This command was * called REPORT DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report identifying information not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char riiCmdBlk[MAINTENANCE_IN_CMDLEN] = {MAINTENANCE_IN_CMD, REPORT_IDENTIFYING_INFORMATION_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; riiCmdBlk[6] = (max_resp_len >> 24) & 0xff; riiCmdBlk[7] = (max_resp_len >> 16) & 0xff; riiCmdBlk[8] = (max_resp_len >> 8) & 0xff; riiCmdBlk[9] = max_resp_len & 0xff; riiCmdBlk[10] |= (itype << 1) & 0xfe; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Report identifying information cdb: "); for (k = 0; k < MAINTENANCE_IN_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", riiCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "report identifying information: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, riiCmdBlk, sizeof(riiCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, max_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "report identifying information", res, max_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " report identifying information: " "response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was * called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Set identifying information not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char siiCmdBlk[MAINTENANCE_OUT_CMDLEN] = {MAINTENANCE_OUT_CMD, SET_IDENTIFYING_INFORMATION_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; siiCmdBlk[6] = (param_len >> 24) & 0xff; siiCmdBlk[7] = (param_len >> 16) & 0xff; siiCmdBlk[8] = (param_len >> 8) & 0xff; siiCmdBlk[9] = param_len & 0xff; siiCmdBlk[10] |= (itype << 1) & 0xfe; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Set identifying information cdb: "); for (k = 0; k < MAINTENANCE_OUT_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", siiCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 1) && paramp && param_len) { fprintf(sg_warnings_strm, " Set identifying information " "parameter list:\n"); dStrHex((const char *)paramp, param_len, -1); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "Set identifying information: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, siiCmdBlk, sizeof(siiCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "set identifying information", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a FORMAT UNIT (SBC-3) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Format unit not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_format_unit(int sg_fd, int fmtpinfo, int longlist, int fmtdata, int cmplst, int dlist_format, int timeout_secs, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat, tmout; unsigned char fuCmdBlk[FORMAT_UNIT_CMDLEN] = {FORMAT_UNIT_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (fmtpinfo) fuCmdBlk[1] |= (fmtpinfo << 6); if (longlist) fuCmdBlk[1] |= 0x20; if (fmtdata) fuCmdBlk[1] |= 0x10; if (cmplst) fuCmdBlk[1] |= 0x8; if (dlist_format) fuCmdBlk[1] |= (dlist_format & 0x7); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; tmout = (timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT; if (verbose) { fprintf(sg_warnings_strm, " format cdb: "); for (k = 0; k < 6; ++k) fprintf(sg_warnings_strm, "%02x ", fuCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } if ((verbose > 1) && (param_len > 0)) { fprintf(sg_warnings_strm, " format parameter list:\n"); dStrHex((const char *)paramp, param_len, -1); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "format unit: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, fuCmdBlk, sizeof(fuCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, tmout, verbose); ret = sg_cmds_process_resp(ptvp, "format unit", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI REASSIGN BLOCKS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ int sg_ll_reassign_blocks(int sg_fd, int longlba, int longlist, void * paramp, int param_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char reassCmdBlk[REASSIGN_BLKS_CMDLEN] = {REASSIGN_BLKS_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; reassCmdBlk[1] = (unsigned char)(((longlba << 1) & 0x2) | (longlist & 0x1)); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " reassign blocks cdb: "); for (k = 0; k < REASSIGN_BLKS_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", reassCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } if (verbose > 1) { fprintf(sg_warnings_strm, " reassign blocks parameter list\n"); dStrHex((const char *)paramp, param_len, -1); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "reassign blocks: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, reassCmdBlk, sizeof(reassCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "reassign blocks", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI PERSISTENT RESERVE IN command (SPC). Returns 0 * when successful, SG_LIB_CAT_INVALID_OP if command not supported, * SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ int sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp, int mx_resp_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char prinCmdBlk[PERSISTENT_RESERVE_IN_CMDLEN] = {PERSISTENT_RESERVE_IN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (rq_servact > 0) prinCmdBlk[1] = (unsigned char)(rq_servact & 0x1f); prinCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff); prinCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Persistent Reservation In cmd: "); for (k = 0; k < PERSISTENT_RESERVE_IN_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", prinCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "persistent reservation in: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, prinCmdBlk, sizeof(prinCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "persistent reservation in", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " persistent reserve in: " "response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI PERSISTENT RESERVE OUT command (SPC). Returns 0 * when successful, SG_LIB_CAT_INVALID_OP if command not supported, * SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ int sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope, unsigned int rq_type, void * paramp, int param_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char proutCmdBlk[PERSISTENT_RESERVE_OUT_CMDLEN] = {PERSISTENT_RESERVE_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (rq_servact > 0) proutCmdBlk[1] = (unsigned char)(rq_servact & 0x1f); proutCmdBlk[2] = (((rq_scope & 0xf) << 4) | (rq_type & 0xf)); proutCmdBlk[7] = (unsigned char)((param_len >> 8) & 0xff); proutCmdBlk[8] = (unsigned char)(param_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Persistent Reservation Out cmd: "); for (k = 0; k < PERSISTENT_RESERVE_OUT_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", proutCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if (verbose > 1) { fprintf(sg_warnings_strm, " Persistent Reservation Out " "parameters:\n"); dStrHex((const char *)paramp, param_len, 0); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "persistent reserve out: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, proutCmdBlk, sizeof(proutCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "persistent reserve out", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } static int has_blk_ili(unsigned char * sensep, int sb_len) { int resp_code; const unsigned char * cup; if (sb_len < 8) return 0; resp_code = (0x7f & sensep[0]); if (resp_code >= 0x72) { /* descriptor format */ /* find block command descriptor */ if ((cup = sg_scsi_sense_desc_find(sensep, sb_len, 0x5))) return ((cup[3] & 0x20) ? 1 : 0); } else /* fixed */ return ((sensep[2] & 0x20) ? 1 : 0); return 0; } /* Invokes a SCSI READ LONG (10) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> READ LONG(10) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ int sg_ll_read_long10(int sg_fd, int pblock, int correct, unsigned int lba, void * resp, int xfer_len, int * offsetp, int noisy, int verbose) { int k, res, sense_cat, ret; unsigned char readLongCmdBlk[READ_LONG10_CMDLEN]; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; memset(readLongCmdBlk, 0, READ_LONG10_CMDLEN); readLongCmdBlk[0] = READ_LONG10_CMD; if (pblock) readLongCmdBlk[1] |= 0x4; if (correct) readLongCmdBlk[1] |= 0x2; readLongCmdBlk[2] = (lba >> 24) & 0xff; readLongCmdBlk[3] = (lba >> 16) & 0xff; readLongCmdBlk[4] = (lba >> 8) & 0xff; readLongCmdBlk[5] = lba & 0xff; readLongCmdBlk[7] = (xfer_len >> 8) & 0xff; readLongCmdBlk[8] = xfer_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Read Long (10) cmd: "); for (k = 0; k < READ_LONG10_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", readLongCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read long (10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, readLongCmdBlk, sizeof(readLongCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, xfer_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read long (10)", res, xfer_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_ILLEGAL_REQ: { int valid, slen, ili; uint64_t ull = 0; slen = get_scsi_pt_sense_len(ptvp); valid = sg_get_sense_info_fld(sense_b, slen, &ull); ili = has_blk_ili(sense_b, slen); if (valid && ili) { if (offsetp) *offsetp = (int)(int64_t)ull; ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO; } else { if (verbose > 1) fprintf(sg_warnings_strm, " info field: 0x%" PRIx64 ", valid: %d, ili: %d\n", ull, valid, ili); ret = SG_LIB_CAT_ILLEGAL_REQ; } } break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " read long(10): response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ LONG (16) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> READ LONG(16) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ int sg_ll_read_long16(int sg_fd, int pblock, int correct, uint64_t llba, void * resp, int xfer_len, int * offsetp, int noisy, int verbose) { int k, res, sense_cat, ret; unsigned char readLongCmdBlk[SERVICE_ACTION_IN_16_CMDLEN]; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; memset(readLongCmdBlk, 0, sizeof(readLongCmdBlk)); readLongCmdBlk[0] = SERVICE_ACTION_IN_16_CMD; readLongCmdBlk[1] = READ_LONG_16_SA; if (pblock) readLongCmdBlk[14] |= 0x2; if (correct) readLongCmdBlk[14] |= 0x1; readLongCmdBlk[2] = (llba >> 56) & 0xff; readLongCmdBlk[3] = (llba >> 48) & 0xff; readLongCmdBlk[4] = (llba >> 40) & 0xff; readLongCmdBlk[5] = (llba >> 32) & 0xff; readLongCmdBlk[6] = (llba >> 24) & 0xff; readLongCmdBlk[7] = (llba >> 16) & 0xff; readLongCmdBlk[8] = (llba >> 8) & 0xff; readLongCmdBlk[9] = llba & 0xff; readLongCmdBlk[12] = (xfer_len >> 8) & 0xff; readLongCmdBlk[13] = xfer_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Read Long (16) cmd: "); for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", readLongCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read long (16): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, readLongCmdBlk, sizeof(readLongCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, xfer_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read long (16)", res, xfer_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_ILLEGAL_REQ: { int valid, slen, ili; uint64_t ull = 0; slen = get_scsi_pt_sense_len(ptvp); valid = sg_get_sense_info_fld(sense_b, slen, &ull); ili = has_blk_ili(sense_b, slen); if (valid && ili) { if (offsetp) *offsetp = (int)(int64_t)ull; ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO; } else { if (verbose > 1) fprintf(sg_warnings_strm, " info field: 0x%" PRIx64 ", valid: %d, ili: %d\n", ull, valid, ili); ret = SG_LIB_CAT_ILLEGAL_REQ; } } break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " read long(16): response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI WRITE LONG (10) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> WRITE LONG(10) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */ int sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock, unsigned int lba, void * data_out, int xfer_len, int * offsetp, int noisy, int verbose) { int k, res, sense_cat, ret; unsigned char writeLongCmdBlk[WRITE_LONG10_CMDLEN]; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; memset(writeLongCmdBlk, 0, WRITE_LONG10_CMDLEN); writeLongCmdBlk[0] = WRITE_LONG10_CMD; if (cor_dis) writeLongCmdBlk[1] |= 0x80; if (wr_uncor) writeLongCmdBlk[1] |= 0x40; if (pblock) writeLongCmdBlk[1] |= 0x20; writeLongCmdBlk[2] = (lba >> 24) & 0xff; writeLongCmdBlk[3] = (lba >> 16) & 0xff; writeLongCmdBlk[4] = (lba >> 8) & 0xff; writeLongCmdBlk[5] = lba & 0xff; writeLongCmdBlk[7] = (xfer_len >> 8) & 0xff; writeLongCmdBlk[8] = xfer_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Write Long (10) cmd: "); for (k = 0; k < (int)sizeof(writeLongCmdBlk); ++k) fprintf(sg_warnings_strm, "%02x ", writeLongCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "write long(10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, writeLongCmdBlk, sizeof(writeLongCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)data_out, xfer_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "write long(10)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_ILLEGAL_REQ: { int valid, slen, ili; uint64_t ull = 0; slen = get_scsi_pt_sense_len(ptvp); valid = sg_get_sense_info_fld(sense_b, slen, &ull); ili = has_blk_ili(sense_b, slen); if (valid && ili) { if (offsetp) *offsetp = (int)(int64_t)ull; ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO; } else { if (verbose > 1) fprintf(sg_warnings_strm, " info field: 0x%" PRIx64 ", valid: %d, ili: %d\n", ull, valid, ili); ret = SG_LIB_CAT_ILLEGAL_REQ; } } break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI WRITE LONG (16) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> WRITE LONG(16) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */ int sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock, uint64_t llba, void * data_out, int xfer_len, int * offsetp, int noisy, int verbose) { int k, res, sense_cat, ret; unsigned char writeLongCmdBlk[SERVICE_ACTION_OUT_16_CMDLEN]; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; memset(writeLongCmdBlk, 0, sizeof(writeLongCmdBlk)); writeLongCmdBlk[0] = SERVICE_ACTION_OUT_16_CMD; writeLongCmdBlk[1] = WRITE_LONG_16_SA; if (cor_dis) writeLongCmdBlk[1] |= 0x80; if (wr_uncor) writeLongCmdBlk[1] |= 0x40; if (pblock) writeLongCmdBlk[1] |= 0x20; writeLongCmdBlk[2] = (llba >> 56) & 0xff; writeLongCmdBlk[3] = (llba >> 48) & 0xff; writeLongCmdBlk[4] = (llba >> 40) & 0xff; writeLongCmdBlk[5] = (llba >> 32) & 0xff; writeLongCmdBlk[6] = (llba >> 24) & 0xff; writeLongCmdBlk[7] = (llba >> 16) & 0xff; writeLongCmdBlk[8] = (llba >> 8) & 0xff; writeLongCmdBlk[9] = llba & 0xff; writeLongCmdBlk[12] = (xfer_len >> 8) & 0xff; writeLongCmdBlk[13] = xfer_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Write Long (16) cmd: "); for (k = 0; k < SERVICE_ACTION_OUT_16_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", writeLongCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "write long(16): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, writeLongCmdBlk, sizeof(writeLongCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)data_out, xfer_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "write long(16)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_ILLEGAL_REQ: { int valid, slen, ili; uint64_t ull = 0; slen = get_scsi_pt_sense_len(ptvp); valid = sg_get_sense_info_fld(sense_b, slen, &ull); ili = has_blk_ili(sense_b, slen); if (valid && ili) { if (offsetp) *offsetp = (int)(int64_t)ull; ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO; } else { if (verbose > 1) fprintf(sg_warnings_strm, " info field: 0x%" PRIx64 ", valid: %d, ili: %d\n", ull, valid, ili); ret = SG_LIB_CAT_ILLEGAL_REQ; } } break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI VERIFY (10) command (SBC and MMC). * Note that 'veri_len' is in blocks while 'data_out_len' is in bytes. * Returns of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Verify(10) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_MEDIUM_HARD -> medium or hardware error, no valid info, * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> as previous, with valid info, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_verify10(int sg_fd, int vrprotect, int dpo, int bytchk, unsigned int lba, int veri_len, void * data_out, int data_out_len, unsigned int * infop, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char vCmdBlk[VERIFY10_CMDLEN] = {VERIFY10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; /* N.B. BYTCHK field expanded to 2 bits sbc3r34 */ vCmdBlk[1] = ((vrprotect & 0x7) << 5) | ((dpo & 0x1) << 4) | ((bytchk & 0x3) << 1) ; vCmdBlk[2] = (unsigned char)((lba >> 24) & 0xff); vCmdBlk[3] = (unsigned char)((lba >> 16) & 0xff); vCmdBlk[4] = (unsigned char)((lba >> 8) & 0xff); vCmdBlk[5] = (unsigned char)(lba & 0xff); vCmdBlk[7] = (unsigned char)((veri_len >> 8) & 0xff); vCmdBlk[8] = (unsigned char)(veri_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose > 1) { fprintf(sg_warnings_strm, " Verify(10) cdb: "); for (k = 0; k < VERIFY10_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", vCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 3) && bytchk && data_out && (data_out_len > 0)) { k = data_out_len > 4104 ? 4104 : data_out_len; fprintf(sg_warnings_strm, " data_out buffer%s\n", (data_out_len > 4104 ? ", first 4104 bytes" : "")); dStrHex((const char *)data_out, k, verbose < 5); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "verify (10): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, vCmdBlk, sizeof(vCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); if (data_out_len > 0) set_scsi_pt_data_out(ptvp, (unsigned char *)data_out, data_out_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "verify (10)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_MEDIUM_HARD: { int valid, slen; uint64_t ull = 0; slen = get_scsi_pt_sense_len(ptvp); valid = sg_get_sense_info_fld(sense_b, slen, &ull); if (valid) { if (infop) *infop = (unsigned int)ull; ret = SG_LIB_CAT_MEDIUM_HARD_WITH_INFO; } else ret = SG_LIB_CAT_MEDIUM_HARD; } break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI VERIFY (16) command (SBC and MMC). * Note that 'veri_len' is in blocks while 'data_out_len' is in bytes. * Returns of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Verify(16) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_MEDIUM_HARD -> medium or hardware error, no valid info, * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> as previous, with valid info, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_verify16(int sg_fd, int vrprotect, int dpo, int bytchk, uint64_t llba, int veri_len, int group_num, void * data_out, int data_out_len, uint64_t * infop, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char vCmdBlk[VERIFY16_CMDLEN] = {VERIFY16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; /* N.B. BYTCHK field expanded to 2 bits sbc3r34 */ vCmdBlk[1] = ((vrprotect & 0x7) << 5) | ((dpo & 0x1) << 4) | ((bytchk & 0x3) << 1) ; vCmdBlk[2] = (llba >> 56) & 0xff; vCmdBlk[3] = (llba >> 48) & 0xff; vCmdBlk[4] = (llba >> 40) & 0xff; vCmdBlk[5] = (llba >> 32) & 0xff; vCmdBlk[6] = (llba >> 24) & 0xff; vCmdBlk[7] = (llba >> 16) & 0xff; vCmdBlk[8] = (llba >> 8) & 0xff; vCmdBlk[9] = llba & 0xff; vCmdBlk[10] = (veri_len >> 24) & 0xff; vCmdBlk[11] = (veri_len >> 16) & 0xff; vCmdBlk[12] = (veri_len >> 8) & 0xff; vCmdBlk[13] = veri_len & 0xff; vCmdBlk[14] = group_num & 0x1f; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose > 1) { fprintf(sg_warnings_strm, " Verify(16) cdb: "); for (k = 0; k < VERIFY16_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", vCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 3) && bytchk && data_out && (data_out_len > 0)) { k = data_out_len > 4104 ? 4104 : data_out_len; fprintf(sg_warnings_strm, " data_out buffer%s\n", (data_out_len > 4104 ? ", first 4104 bytes" : "")); dStrHex((const char *)data_out, k, verbose < 5); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "verify (16): out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, vCmdBlk, sizeof(vCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); if (data_out_len > 0) set_scsi_pt_data_out(ptvp, (unsigned char *)data_out, data_out_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "verify (16)", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; case SG_LIB_CAT_MEDIUM_HARD: { int valid, slen; uint64_t ull = 0; slen = get_scsi_pt_sense_len(ptvp); valid = sg_get_sense_info_fld(sense_b, slen, &ull); if (valid) { if (infop) *infop = ull; ret = SG_LIB_CAT_MEDIUM_HARD_WITH_INFO; } else ret = SG_LIB_CAT_MEDIUM_HARD; } break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a ATA PASS-THROUGH (12 or 16) SCSI command (SAT). If cdb_len * is 12 then a ATA PASS-THROUGH (12) command is called. If cdb_len is 16 * then a ATA PASS-THROUGH (16) command is called. If cdb_len is any other * value -1 is returned. After copying from cdbp to an internal buffer, * the first byte (i.e. offset 0) is set to 0xa1 if cdb_len is 12; or is * set to 0x85 if cdb_len is 16. The last byte (offset 11 or offset 15) is * set to 0x0 in the internal buffer. If timeout_secs <= 0 then the timeout * is set to 60 seconds. For data in or out transfers set dinp or doutp, * and dlen to the number of bytes to transfer. If dlen is zero then no data * transfer is assumed. If sense buffer obtained then it is written to * sensep, else sensep[0] is set to 0x0. If ATA return descriptor is obtained * then written to ata_return_dp, else ata_return_dp[0] is set to 0x0. Either * sensep or ata_return_dp (or both) may be NULL pointers. Returns SCSI * status value (>= 0) or -1 if other error. Users are expected to check the * sense buffer themselves. If available the data in resid is written to * residp. Note in SAT-2 and later, fixed format sense data may be placed in * *sensep in which case sensep[0]==0x70 . */ int sg_ll_ata_pt(int sg_fd, const unsigned char * cdbp, int cdb_len, int timeout_secs, void * dinp, void * doutp, int dlen, unsigned char * sensep, int max_sense_len, unsigned char * ata_return_dp, int max_ata_return_len, int * residp, int verbose) { int k, res, slen, duration; unsigned char aptCmdBlk[ATA_PT_16_CMDLEN] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; unsigned char * sp; const unsigned char * ucp; struct sg_pt_base * ptvp; const char * cnamep; char b[256]; int ret = -1; b[0] = '\0'; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; cnamep = (12 == cdb_len) ? "ATA pass through (12)" : "ATA pass through (16)"; if ((NULL == cdbp) || ((12 != cdb_len) && (16 != cdb_len))) { if (verbose) { if (NULL == cdbp) fprintf(sg_warnings_strm, "%s NULL cdb pointer\n", cnamep); else fprintf(sg_warnings_strm, "cdb_len must be 12 or 16\n"); } return -1; } aptCmdBlk[0] = (12 == cdb_len) ? ATA_PT_12_CMD : ATA_PT_16_CMD; if (sensep && (max_sense_len >= (int)sizeof(sense_b))) { sp = sensep; slen = max_sense_len; } else { sp = sense_b; slen = sizeof(sense_b); } if (12 == cdb_len) memcpy(aptCmdBlk + 1, cdbp + 1, ((cdb_len > 11) ? 10 : (cdb_len - 1))); else memcpy(aptCmdBlk + 1, cdbp + 1, ((cdb_len > 15) ? 14 : (cdb_len - 1))); if (verbose) { fprintf(sg_warnings_strm, " %s cdb: ", cnamep); for (k = 0; k < cdb_len; ++k) fprintf(sg_warnings_strm, "%02x ", aptCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "%s: out of memory\n", cnamep); return -1; } set_scsi_pt_cdb(ptvp, aptCmdBlk, cdb_len); set_scsi_pt_sense(ptvp, sp, slen); if (dlen > 0) { if (dinp) set_scsi_pt_data_in(ptvp, (unsigned char *)dinp, dlen); else if (doutp) set_scsi_pt_data_out(ptvp, (unsigned char *)doutp, dlen); } res = do_scsi_pt(ptvp, sg_fd, ((timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT), verbose); if (SCSI_PT_DO_BAD_PARAMS == res) { if (verbose) fprintf(sg_warnings_strm, "%s: bad parameters\n", cnamep); goto out; } else if (SCSI_PT_DO_TIMEOUT == res) { if (verbose) fprintf(sg_warnings_strm, "%s: timeout\n", cnamep); goto out; } else if (res > 2) { if (verbose) fprintf(sg_warnings_strm, "%s: do_scsi_pt: errno=%d\n", cnamep, -res); } if ((verbose > 2) && ((duration = get_scsi_pt_duration_ms(ptvp)) >= 0)) fprintf(sg_warnings_strm, " duration=%d ms\n", duration); switch (get_scsi_pt_result_category(ptvp)) { case SCSI_PT_RESULT_GOOD: if ((sensep) && (max_sense_len > 0)) *sensep = 0; if ((ata_return_dp) && (max_ata_return_len > 0)) *ata_return_dp = 0; if (residp && (dlen > 0)) *residp = get_scsi_pt_resid(ptvp); ret = 0; break; case SCSI_PT_RESULT_STATUS: /* other than GOOD + CHECK CONDITION */ if ((sensep) && (max_sense_len > 0)) *sensep = 0; if ((ata_return_dp) && (max_ata_return_len > 0)) *ata_return_dp = 0; ret = get_scsi_pt_status_response(ptvp); break; case SCSI_PT_RESULT_SENSE: if (sensep && (sp != sensep)) { k = get_scsi_pt_sense_len(ptvp); k = (k > max_sense_len) ? max_sense_len : k; memcpy(sensep, sp, k); } if (ata_return_dp && (max_ata_return_len > 0)) { /* search for ATA return descriptor */ ucp = sg_scsi_sense_desc_find(sp, slen, 0x9); if (ucp) { k = ucp[1] + 2; k = (k > max_ata_return_len) ? max_ata_return_len : k; memcpy(ata_return_dp, ucp, k); } else ata_return_dp[0] = 0x0; } if (residp && (dlen > 0)) *residp = get_scsi_pt_resid(ptvp); ret = get_scsi_pt_status_response(ptvp); break; case SCSI_PT_RESULT_TRANSPORT_ERR: if (verbose) fprintf(sg_warnings_strm, "%s: transport error: %s\n", cnamep, get_scsi_pt_transport_err_str(ptvp, sizeof(b) , b)); break; case SCSI_PT_RESULT_OS_ERR: if (verbose) fprintf(sg_warnings_strm, "%s: os error: %s\n", cnamep, get_scsi_pt_os_err_str(ptvp, sizeof(b) , b)); break; default: if (verbose) fprintf(sg_warnings_strm, "%s: unknown pt_result_category=%d\n", cnamep, get_scsi_pt_result_category(ptvp)); break; } out: destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ BUFFER command (SPC). Return of 0 -> * success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset, void * resp, int mx_resp_len, int noisy, int verbose) { int res, k, ret, sense_cat; unsigned char rbufCmdBlk[READ_BUFFER_CMDLEN] = {READ_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; rbufCmdBlk[1] = (unsigned char)(mode & 0x1f); rbufCmdBlk[2] = (unsigned char)(buffer_id & 0xff); rbufCmdBlk[3] = (unsigned char)((buffer_offset >> 16) & 0xff); rbufCmdBlk[4] = (unsigned char)((buffer_offset >> 8) & 0xff); rbufCmdBlk[5] = (unsigned char)(buffer_offset & 0xff); rbufCmdBlk[6] = (unsigned char)((mx_resp_len >> 16) & 0xff); rbufCmdBlk[7] = (unsigned char)((mx_resp_len >> 8) & 0xff); rbufCmdBlk[8] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " read buffer cdb: "); for (k = 0; k < READ_BUFFER_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rbufCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read buffer: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rbufCmdBlk, sizeof(rbufCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read buffer", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " read buffer: response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI WRITE BUFFER command (SPC). Return of 0 -> * success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char wbufCmdBlk[WRITE_BUFFER_CMDLEN] = {WRITE_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; wbufCmdBlk[1] = (unsigned char)(mode & 0x1f); wbufCmdBlk[2] = (unsigned char)(buffer_id & 0xff); wbufCmdBlk[3] = (unsigned char)((buffer_offset >> 16) & 0xff); wbufCmdBlk[4] = (unsigned char)((buffer_offset >> 8) & 0xff); wbufCmdBlk[5] = (unsigned char)(buffer_offset & 0xff); wbufCmdBlk[6] = (unsigned char)((param_len >> 16) & 0xff); wbufCmdBlk[7] = (unsigned char)((param_len >> 8) & 0xff); wbufCmdBlk[8] = (unsigned char)(param_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Write buffer cmd: "); for (k = 0; k < WRITE_BUFFER_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", wbufCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 1) && paramp && param_len) { fprintf(sg_warnings_strm, " Write buffer parameter list%s:\n", ((param_len > 256) ? " (first 256 bytes)" : "")); dStrHex((const char *)paramp, ((param_len > 256) ? 256 : param_len), -1); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "write buffer: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, wbufCmdBlk, sizeof(wbufCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "write buffer", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI UNMAP command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> command not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ int sg_ll_unmap(int sg_fd, int group_num, int timeout_secs, void * paramp, int param_len, int noisy, int verbose) { return sg_ll_unmap_v2(sg_fd, 0, group_num, timeout_secs, paramp, param_len, noisy, verbose); } /* Invokes a SCSI UNMAP (SBC-3) command. Version 2 adds anchor field * (sbc3r22). Otherwise same as sg_ll_unmap() . */ int sg_ll_unmap_v2(int sg_fd, int anchor, int group_num, int timeout_secs, void * paramp, int param_len, int noisy, int verbose) { int k, res, ret, sense_cat, tmout; unsigned char uCmdBlk[UNMAP_CMDLEN] = {UNMAP_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (anchor) uCmdBlk[1] |= 0x1; tmout = (timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT; uCmdBlk[7] = group_num & 0x1f; uCmdBlk[7] = (param_len >> 8) & 0xff; uCmdBlk[8] = param_len & 0xff; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " unmap cdb: "); for (k = 0; k < UNMAP_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", uCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); if ((verbose > 1) && paramp && param_len) { fprintf(sg_warnings_strm, " unmap parameter list:\n"); dStrHex((const char *)paramp, param_len, -1); } } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "unmap: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, uCmdBlk, sizeof(uCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len); res = do_scsi_pt(ptvp, sg_fd, tmout, verbose); ret = sg_cmds_process_resp(ptvp, "unmap", res, 0, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI READ BLOCK LIMITS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Read block limits not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_NOT_READY (shouldn't happen), -1 -> other failure */ int sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose) { int k, ret, res, sense_cat; unsigned char rlCmdBlk[READ_BLOCK_LIMITS_CMDLEN] = {READ_BLOCK_LIMITS_CMD, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " read block limits cdb: "); for (k = 0; k < READ_BLOCK_LIMITS_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rlCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "read block limits: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rlCmdBlk, sizeof(rlCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "read block limits", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_ABORTED_COMMAND: case SG_LIB_CAT_NOT_READY: /* shouldn't happen ?? */ ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else { if ((verbose > 2) && (ret > 0)) { fprintf(sg_warnings_strm, " read block limits: response%s\n", (ret > 256 ? ", first 256 bytes" : "")); dStrHex((const char *)resp, (ret > 256 ? 256 : ret), -1); } ret = 0; } destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI RECEIVE COPY RESULTS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Receive copy results not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp, int mx_resp_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char rcvcopyresCmdBlk[RECEIVE_COPY_RESULTS_CMDLEN] = {RECEIVE_COPY_RESULTS_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; rcvcopyresCmdBlk[1] = (unsigned char)(sa & 0x1f); rcvcopyresCmdBlk[2] = (unsigned char)(list_id); rcvcopyresCmdBlk[10] = (unsigned char)((mx_resp_len >> 24) & 0xff); rcvcopyresCmdBlk[11] = (unsigned char)((mx_resp_len >> 16) & 0xff); rcvcopyresCmdBlk[12] = (unsigned char)((mx_resp_len >> 8) & 0xff); rcvcopyresCmdBlk[13] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Receive copy results cmd: "); for (k = 0; k < RECEIVE_COPY_RESULTS_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", rcvcopyresCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "receive copy results: out of " "memory\n"); return -1; } set_scsi_pt_cdb(ptvp, rcvcopyresCmdBlk, sizeof(rcvcopyresCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "receive copy results", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } /* Invokes a SCSI RECEIVE COPY RESULTS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Receive copy results not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ int sg_ll_extended_copy(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose) { int k, res, ret, sense_cat; unsigned char xcopyCmdBlk[EXTENDED_COPY_CMDLEN] = {EXTENDED_COPY_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char sense_b[SENSE_BUFF_LEN]; struct sg_pt_base * ptvp; xcopyCmdBlk[10] = (unsigned char)((mx_resp_len >> 24) & 0xff); xcopyCmdBlk[11] = (unsigned char)((mx_resp_len >> 16) & 0xff); xcopyCmdBlk[12] = (unsigned char)((mx_resp_len >> 8) & 0xff); xcopyCmdBlk[13] = (unsigned char)(mx_resp_len & 0xff); if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) { fprintf(sg_warnings_strm, " Extended copy cmd: "); for (k = 0; k < EXTENDED_COPY_CMDLEN; ++k) fprintf(sg_warnings_strm, "%02x ", xcopyCmdBlk[k]); fprintf(sg_warnings_strm, "\n"); } ptvp = construct_scsi_pt_obj(); if (NULL == ptvp) { fprintf(sg_warnings_strm, "extended copy: out of memory\n"); return -1; } set_scsi_pt_cdb(ptvp, xcopyCmdBlk, sizeof(xcopyCmdBlk)); set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); set_scsi_pt_data_out(ptvp, (unsigned char *)resp, mx_resp_len); res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); ret = sg_cmds_process_resp(ptvp, "extended copy", res, mx_resp_len, sense_b, noisy, verbose, &sense_cat); if (-1 == ret) ; else if (-2 == ret) { switch (sense_cat) { case SG_LIB_CAT_NOT_READY: case SG_LIB_CAT_INVALID_OP: case SG_LIB_CAT_ILLEGAL_REQ: case SG_LIB_CAT_UNIT_ATTENTION: case SG_LIB_CAT_ABORTED_COMMAND: ret = sense_cat; break; case SG_LIB_CAT_RECOVERED: case SG_LIB_CAT_NO_SENSE: ret = 0; break; default: ret = -1; break; } } else ret = 0; destruct_scsi_pt_obj(ptvp); return ret; } sdparm-1.08/lib/sg_pt_win32.c0000664000175000017500000005724712042611120015002 0ustar douggdougg/* * Copyright (c) 2006-2012 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. */ /* sg_pt_win32 version 1.14 20121026 */ #include #include #include #include #include #include #include "sg_pt.h" #include "sg_lib.h" #include "sg_pt_win32.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif /* Use the Microsoft SCSI Pass Through (SPT) interface. It has two * variants: "SPT" where data is double buffered; and "SPTD" where data * pointers to the user space are passed to the OS. Only Windows * 2000 and later (i.e. not 95,98 or ME). * There is no ASPI interface which relies on a dll from adaptec. * This code uses cygwin facilities and is built in a cygwin * shell. It can be run in a normal DOS shell if the cygwin1.dll * file is put in an appropriate place. * This code can build in a MinGW environment. * * N.B. MSDN says that the "SPT" interface (i.e. double buffered) * should be used for small amounts of data (it says "< 16 KB"). * The direct variant (i.e. IOCTL_SCSI_PASS_THROUGH_DIRECT) should * be used for larger amounts of data but the buffer needs to be * "cache aligned". Is that 16 byte alignment or greater? * * This code will default to indirect (i.e. double buffered) access * unless the WIN32_SPT_DIRECT preprocessor constant is defined in * config.h . In version 1.12 runtime selection of direct and indirect * access was added; the default is still determined by the * WIN32_SPT_DIRECT preprocessor constant. */ #define DEF_TIMEOUT 60 /* 60 seconds */ #define MAX_OPEN_SIMULT 8 #define WIN32_FDOFFSET 32 struct sg_pt_handle { int in_use; HANDLE fh; char adapter[32]; int bus; int target; int lun; }; struct sg_pt_handle handle_arr[MAX_OPEN_SIMULT]; struct sg_pt_win32_scsi { unsigned char * dxferp; int dxfer_len; unsigned char * sensep; int sense_len; int scsi_status; int resid; int sense_resid; int in_err; int os_err; /* pseudo unix error */ int transport_err; /* windows error number */ union { SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER swb_d; /* Last entry in structure so data buffer can be extended */ SCSI_PASS_THROUGH_WITH_BUFFERS swb_i; }; }; /* embed pointer so can change on fly if (non-direct) data buffer * is not big enough */ struct sg_pt_base { struct sg_pt_win32_scsi * implp; }; #ifdef WIN32_SPT_DIRECT static int spt_direct = 1; #else static int spt_direct = 0; #endif /* Request SPT direct interface when state_direct is 1, state_direct set * to 0 for the SPT indirect interface. */ void scsi_pt_win32_direct(int state_direct) { spt_direct = state_direct; } /* Returns current SPT interface state, 1 for direct, 0 for indirect */ int scsi_pt_win32_spt_state(void) { return spt_direct; } /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, int read_only, int verbose) { int oflags = 0 /* O_NONBLOCK*/ ; oflags |= (read_only ? 0 : 0); /* was ... ? O_RDONLY : O_RDWR) */ return scsi_pt_open_flags(device_name, oflags, verbose); } /* * Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed * together. The 'flags' argument is ignored in Windows. * Returns >= 0 if successful, otherwise returns negated errno. * Optionally accept leading "\\.\". If given something of the form * "SCSI:,," where the values in angle brackets * are integers, then will attempt to open "\\.\SCSI:" and save the * other three values for the DeviceIoControl call. The trailing "." * is optionally and if not given 0 is assumed. Since "PhysicalDrive" * is a lot of keystrokes, "PD" is accepted and converted to the longer * form. */ int scsi_pt_open_flags(const char * device_name, int flags __attribute__ ((unused)), int verbose) { int len, k, adapter_num, bus, target, lun, off, got_scsi_name; int index, num, got_pd_name, pd_num; struct sg_pt_handle * shp; char buff[8]; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; /* lock */ for (k = 0; k < MAX_OPEN_SIMULT; k++) if (0 == handle_arr[k].in_use) break; if (k == MAX_OPEN_SIMULT) { if (verbose) fprintf(sg_warnings_strm, "too many open handles " "(%d)\n", MAX_OPEN_SIMULT); return -EMFILE; } else handle_arr[k].in_use = 1; /* unlock */ index = k; shp = handle_arr + index; adapter_num = 0; bus = 0; /* also known as 'PathId' in MS docs */ target = 0; lun = 0; got_pd_name = 0; got_scsi_name = 0; len = strlen(device_name); if ((len > 4) && (0 == strncmp("\\\\.\\", device_name, 4))) off = 4; else off = 0; if (len > (off + 2)) { buff[0] = toupper((int)device_name[off + 0]); buff[1] = toupper((int)device_name[off + 1]); if (0 == strncmp("PD", buff, 2)) { num = sscanf(device_name + off + 2, "%d", &pd_num); if (1 == num) got_pd_name = 1; } if (0 == got_pd_name) { buff[2] = toupper((int)device_name[off + 2]); buff[3] = toupper((int)device_name[off + 3]); if (0 == strncmp("SCSI", buff, 4)) { num = sscanf(device_name + off + 4, "%d:%d,%d,%d", &adapter_num, &bus, &target, &lun); if (num < 3) { if (verbose) fprintf(sg_warnings_strm, "expected format like: " "'SCSI:.[.]'\n"); shp->in_use = 0; return -EINVAL; } got_scsi_name = 1; } } } shp->bus = bus; shp->target = target; shp->lun = lun; memset(shp->adapter, 0, sizeof(shp->adapter)); strncpy(shp->adapter, "\\\\.\\", 4); if (got_pd_name) snprintf(shp->adapter + 4, sizeof(shp->adapter) - 5, "PhysicalDrive%d", pd_num); else if (got_scsi_name) snprintf(shp->adapter + 4, sizeof(shp->adapter) - 5, "SCSI%d:", adapter_num); else snprintf(shp->adapter + 4, sizeof(shp->adapter) - 5, "%s", device_name + off); shp->fh = CreateFile(shp->adapter, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (shp->fh == INVALID_HANDLE_VALUE) { if (verbose) fprintf(sg_warnings_strm, "Windows CreateFile error=%ld\n", GetLastError()); shp->in_use = 0; return -ENODEV; } return index + WIN32_FDOFFSET; } /* Returns 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_close_device(int device_fd) { struct sg_pt_handle * shp; int index; index = device_fd - WIN32_FDOFFSET; if ((index < 0) || (index >= WIN32_FDOFFSET)) return -ENODEV; shp = handle_arr + index; CloseHandle(shp->fh); shp->bus = 0; shp->target = 0; shp->lun = 0; memset(shp->adapter, 0, sizeof(shp->adapter)); shp->in_use = 0; return 0; } struct sg_pt_base * construct_scsi_pt_obj() { struct sg_pt_win32_scsi * psp; struct sg_pt_base * vp = NULL; psp = (struct sg_pt_win32_scsi *)calloc(sizeof(struct sg_pt_win32_scsi), 1); if (psp) { if (spt_direct) { psp->swb_d.spt.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; psp->swb_d.spt.SenseInfoLength = SCSI_MAX_SENSE_LEN; psp->swb_d.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf); psp->swb_d.spt.TimeOutValue = DEF_TIMEOUT; } else { psp->swb_i.spt.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; psp->swb_i.spt.SenseInfoLength = SCSI_MAX_SENSE_LEN; psp->swb_i.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf); psp->swb_i.spt.TimeOutValue = DEF_TIMEOUT; } vp = malloc(sizeof(struct sg_pt_win32_scsi *)); // yes a pointer if (vp) vp->implp = psp; else free(psp); } return vp; } void destruct_scsi_pt_obj(struct sg_pt_base * vp) { if (vp) { struct sg_pt_win32_scsi * psp = vp->implp; if (psp) { free(psp); } free(vp); } } void clear_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_win32_scsi * psp = vp->implp; if (psp) { memset(psp, 0, sizeof(struct sg_pt_win32_scsi)); if (spt_direct) { psp->swb_d.spt.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; psp->swb_d.spt.SenseInfoLength = SCSI_MAX_SENSE_LEN; psp->swb_d.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf); psp->swb_d.spt.TimeOutValue = DEF_TIMEOUT; } else { psp->swb_i.spt.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; psp->swb_i.spt.SenseInfoLength = SCSI_MAX_SENSE_LEN; psp->swb_i.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf); psp->swb_i.spt.TimeOutValue = DEF_TIMEOUT; } } } void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len) { struct sg_pt_win32_scsi * psp = vp->implp; if (spt_direct) { if (psp->swb_d.spt.CdbLength > 0) ++psp->in_err; if (cdb_len > (int)sizeof(psp->swb_d.spt.Cdb)) { ++psp->in_err; return; } memcpy(psp->swb_d.spt.Cdb, cdb, cdb_len); psp->swb_d.spt.CdbLength = cdb_len; } else { if (psp->swb_i.spt.CdbLength > 0) ++psp->in_err; if (cdb_len > (int)sizeof(psp->swb_i.spt.Cdb)) { ++psp->in_err; return; } memcpy(psp->swb_i.spt.Cdb, cdb, cdb_len); psp->swb_i.spt.CdbLength = cdb_len; } } void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int sense_len) { struct sg_pt_win32_scsi * psp = vp->implp; if (psp->sensep) ++psp->in_err; memset(sense, 0, sense_len); psp->sensep = sense; psp->sense_len = sense_len; } /* from device */ void set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len) { struct sg_pt_win32_scsi * psp = vp->implp; if (psp->dxferp) ++psp->in_err; if (dxfer_len > 0) { psp->dxferp = dxferp; psp->dxfer_len = dxfer_len; if (spt_direct) psp->swb_d.spt.DataIn = SCSI_IOCTL_DATA_IN; else psp->swb_i.spt.DataIn = SCSI_IOCTL_DATA_IN; } } /* to device */ void set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len) { struct sg_pt_win32_scsi * psp = vp->implp; if (psp->dxferp) ++psp->in_err; if (dxfer_len > 0) { psp->dxferp = (unsigned char *)dxferp; psp->dxfer_len = dxfer_len; if (spt_direct) psp->swb_d.spt.DataIn = SCSI_IOCTL_DATA_OUT; else psp->swb_i.spt.DataIn = SCSI_IOCTL_DATA_OUT; } } void set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)), int pack_id __attribute__ ((unused))) { } void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag __attribute__ ((unused))) { struct sg_pt_win32_scsi * psp = vp->implp; ++psp->in_err; } void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code __attribute__ ((unused))) { struct sg_pt_win32_scsi * psp = vp->implp; ++psp->in_err; } void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attrib __attribute__ ((unused)), int priority __attribute__ ((unused))) { struct sg_pt_win32_scsi * psp = vp->implp; ++psp->in_err; } void set_scsi_pt_flags(struct sg_pt_base * objp, int flags) { /* do nothing, suppress warnings */ objp = objp; flags = flags; } /* Executes SCSI command (or at least forwards it to lower layers) * using direct interface. Clears os_err field prior to active call (whose * result may set it again). */ int do_scsi_pt_direct(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose) { int index = device_fd - WIN32_FDOFFSET; struct sg_pt_win32_scsi * psp = vp->implp; struct sg_pt_handle * shp; BOOL status; ULONG returned; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; psp->os_err = 0; if (psp->in_err) { if (verbose) fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt...\n"); return SCSI_PT_DO_BAD_PARAMS; } if (0 == psp->swb_d.spt.CdbLength) { if (verbose) fprintf(sg_warnings_strm, "No command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } index = device_fd - WIN32_FDOFFSET; if ((index < 0) || (index >= WIN32_FDOFFSET)) { if (verbose) fprintf(sg_warnings_strm, "Bad file descriptor\n"); psp->os_err = ENODEV; return -psp->os_err; } shp = handle_arr + index; if (0 == shp->in_use) { if (verbose) fprintf(sg_warnings_strm, "File descriptor closed??\n"); psp->os_err = ENODEV; return -psp->os_err; } psp->swb_d.spt.Length = sizeof (SCSI_PASS_THROUGH_DIRECT); psp->swb_d.spt.PathId = shp->bus; psp->swb_d.spt.TargetId = shp->target; psp->swb_d.spt.Lun = shp->lun; psp->swb_d.spt.TimeOutValue = time_secs; psp->swb_d.spt.DataTransferLength = psp->dxfer_len; if (verbose > 4) { fprintf(stderr, " spt_direct, adapter: %s Length=%d ScsiStatus=%d " "PathId=%d TargetId=%d Lun=%d\n", shp->adapter, (int)psp->swb_d.spt.Length, (int)psp->swb_d.spt.ScsiStatus, (int)psp->swb_d.spt.PathId, (int)psp->swb_d.spt.TargetId, (int)psp->swb_d.spt.Lun); fprintf(stderr, " CdbLength=%d SenseInfoLength=%d DataIn=%d " "DataTransferLength=%lu\n", (int)psp->swb_d.spt.CdbLength, (int)psp->swb_d.spt.SenseInfoLength, (int)psp->swb_d.spt.DataIn, psp->swb_d.spt.DataTransferLength); fprintf(stderr, " TimeOutValue=%lu SenseInfoOffset=%lu\n", psp->swb_d.spt.TimeOutValue, psp->swb_d.spt.SenseInfoOffset); } psp->swb_d.spt.DataBuffer = psp->dxferp; status = DeviceIoControl(shp->fh, IOCTL_SCSI_PASS_THROUGH_DIRECT, &psp->swb_d, sizeof(psp->swb_d), &psp->swb_d, sizeof(psp->swb_d), &returned, NULL); if (! status) { psp->transport_err = GetLastError(); if (verbose) fprintf(sg_warnings_strm, "Windows DeviceIoControl error=%d\n", psp->transport_err); psp->os_err = EIO; return 0; /* let app find transport error */ } psp->scsi_status = psp->swb_d.spt.ScsiStatus; if ((SAM_STAT_CHECK_CONDITION == psp->scsi_status) || (SAM_STAT_COMMAND_TERMINATED == psp->scsi_status)) memcpy(psp->sensep, psp->swb_d.ucSenseBuf, psp->sense_len); else psp->sense_len = 0; psp->sense_resid = 0; if ((psp->dxfer_len > 0) && (psp->swb_d.spt.DataTransferLength > 0)) psp->resid = psp->dxfer_len - psp->swb_d.spt.DataTransferLength; else psp->resid = 0; return 0; } /* Executes SCSI command (or at least forwards it to lower layers) using * indirect interface. Clears os_err field prior to active call (whose * result may set it again). */ static int do_scsi_pt_indirect(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose) { int index = device_fd - WIN32_FDOFFSET; struct sg_pt_win32_scsi * psp = vp->implp; struct sg_pt_handle * shp; BOOL status; ULONG returned; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; psp->os_err = 0; if (psp->in_err) { if (verbose) fprintf(sg_warnings_strm, "Replicated or unused " "set_scsi_pt...\n"); return SCSI_PT_DO_BAD_PARAMS; } if (0 == psp->swb_i.spt.CdbLength) { if (verbose) fprintf(sg_warnings_strm, "No command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } index = device_fd - WIN32_FDOFFSET; if ((index < 0) || (index >= WIN32_FDOFFSET)) { if (verbose) fprintf(sg_warnings_strm, "Bad file descriptor\n"); psp->os_err = ENODEV; return -psp->os_err; } shp = handle_arr + index; if (0 == shp->in_use) { if (verbose) fprintf(sg_warnings_strm, "File descriptor closed??\n"); psp->os_err = ENODEV; return -psp->os_err; } if (psp->dxfer_len > (int)sizeof(psp->swb_i.ucDataBuf)) { int extra = psp->dxfer_len - (int)sizeof(psp->swb_i.ucDataBuf); struct sg_pt_win32_scsi * epsp; if (verbose > 4) fprintf(sg_warnings_strm, "spt_indirect: dxfer_len (%d) too " "large for initial data\n buffer (%d bytes), try " "enlarging\n", psp->dxfer_len, sizeof(psp->swb_i.ucDataBuf)); epsp = (struct sg_pt_win32_scsi *) calloc(sizeof(struct sg_pt_win32_scsi) + extra, 1); if (NULL == epsp) { fprintf(sg_warnings_strm, "do_scsi_pt: failed to enlarge data " "buffer to %d bytes\n", psp->dxfer_len); psp->os_err = ENOMEM; return -psp->os_err; } memcpy(epsp, psp, sizeof(struct sg_pt_win32_scsi)); free(psp); vp->implp = epsp; psp = epsp; } psp->swb_i.spt.Length = sizeof (SCSI_PASS_THROUGH); psp->swb_i.spt.DataBufferOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf); psp->swb_i.spt.PathId = shp->bus; psp->swb_i.spt.TargetId = shp->target; psp->swb_i.spt.Lun = shp->lun; psp->swb_i.spt.TimeOutValue = time_secs; psp->swb_i.spt.DataTransferLength = psp->dxfer_len; if (verbose > 4) { fprintf(stderr, " spt_indirect, adapter: %s Length=%d ScsiStatus=%d " "PathId=%d TargetId=%d Lun=%d\n", shp->adapter, (int)psp->swb_i.spt.Length, (int)psp->swb_i.spt.ScsiStatus, (int)psp->swb_i.spt.PathId, (int)psp->swb_i.spt.TargetId, (int)psp->swb_i.spt.Lun); fprintf(stderr, " CdbLength=%d SenseInfoLength=%d DataIn=%d " "DataTransferLength=%lu\n", (int)psp->swb_i.spt.CdbLength, (int)psp->swb_i.spt.SenseInfoLength, (int)psp->swb_i.spt.DataIn, psp->swb_i.spt.DataTransferLength); fprintf(stderr, " TimeOutValue=%lu DataBufferOffset=%lu " "SenseInfoOffset=%lu\n", psp->swb_i.spt.TimeOutValue, psp->swb_i.spt.DataBufferOffset, psp->swb_i.spt.SenseInfoOffset); } if ((psp->dxfer_len > 0) && (SCSI_IOCTL_DATA_OUT == psp->swb_i.spt.DataIn)) memcpy(psp->swb_i.ucDataBuf, psp->dxferp, psp->dxfer_len); status = DeviceIoControl(shp->fh, IOCTL_SCSI_PASS_THROUGH, &psp->swb_i, sizeof(psp->swb_i), &psp->swb_i, sizeof(psp->swb_i), &returned, NULL); if (! status) { psp->transport_err = GetLastError(); if (verbose) fprintf(sg_warnings_strm, "Windows DeviceIoControl error=%d\n", psp->transport_err); psp->os_err = EIO; return 0; /* let app find transport error */ } if ((psp->dxfer_len > 0) && (SCSI_IOCTL_DATA_IN == psp->swb_i.spt.DataIn)) memcpy(psp->dxferp, psp->swb_i.ucDataBuf, psp->dxfer_len); psp->scsi_status = psp->swb_i.spt.ScsiStatus; if ((SAM_STAT_CHECK_CONDITION == psp->scsi_status) || (SAM_STAT_COMMAND_TERMINATED == psp->scsi_status)) memcpy(psp->sensep, psp->swb_i.ucSenseBuf, psp->sense_len); else psp->sense_len = 0; psp->sense_resid = 0; if ((psp->dxfer_len > 0) && (psp->swb_i.spt.DataTransferLength > 0)) psp->resid = psp->dxfer_len - psp->swb_i.spt.DataTransferLength; else psp->resid = 0; return 0; } /* Executes SCSI command (or at least forwards it to lower layers). * Clears os_err field prior to active call (whose result may set it * again). */ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose) { if (spt_direct) return do_scsi_pt_direct(vp, device_fd, time_secs, verbose); else return do_scsi_pt_indirect(vp, device_fd, time_secs, verbose); } int get_scsi_pt_result_category(const struct sg_pt_base * vp) { const struct sg_pt_win32_scsi * psp = vp->implp; if (psp->transport_err) /* give transport error highest priority */ return SCSI_PT_RESULT_TRANSPORT_ERR; else if (psp->os_err) return SCSI_PT_RESULT_OS_ERR; else if ((SAM_STAT_CHECK_CONDITION == psp->scsi_status) || (SAM_STAT_COMMAND_TERMINATED == psp->scsi_status)) return SCSI_PT_RESULT_SENSE; else if (psp->scsi_status) return SCSI_PT_RESULT_STATUS; else return SCSI_PT_RESULT_GOOD; } int get_scsi_pt_resid(const struct sg_pt_base * vp) { const struct sg_pt_win32_scsi * psp = vp->implp; return psp->resid; } int get_scsi_pt_status_response(const struct sg_pt_base * vp) { const struct sg_pt_win32_scsi * psp = vp->implp; return psp->scsi_status; } int get_scsi_pt_sense_len(const struct sg_pt_base * vp) { const struct sg_pt_win32_scsi * psp = vp->implp; int len; len = psp->sense_len - psp->sense_resid; return (len > 0) ? len : 0; } int get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused))) { // const struct sg_pt_freebsd_scsi * psp = vp->implp; return -1; } int get_scsi_pt_transport_err(const struct sg_pt_base * vp) { const struct sg_pt_win32_scsi * psp = vp->implp; return psp->transport_err; } int get_scsi_pt_os_err(const struct sg_pt_base * vp) { const struct sg_pt_win32_scsi * psp = vp->implp; return psp->os_err; } char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { struct sg_pt_win32_scsi * psp = (struct sg_pt_win32_scsi *)vp->implp; LPVOID lpMsgBuf; int k, num, ch; if (max_b_len < 2) { if (1 == max_b_len) b[0] = '\0'; return b; } memset(b, 0, max_b_len); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, psp->transport_err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); num = lstrlen((LPCTSTR)lpMsgBuf); if (num < 1) return b; num = (num < max_b_len) ? num : (max_b_len - 1); for (k = 0; k < num; ++k) { ch = *((LPCTSTR)lpMsgBuf + k); if ((ch >= 0x0) && (ch < 0x7f)) b[k] = ch & 0x7f; else b[k] = '?'; } return b; } char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_win32_scsi * psp = vp->implp; const char * cp; cp = safe_strerror(psp->os_err); strncpy(b, cp, max_b_len); if ((int)strlen(cp) >= max_b_len) b[max_b_len - 1] = '\0'; return b; } sdparm-1.08/lib/sg_pt_linux.c0000664000175000017500000006745512142450532015212 0ustar douggdougg/* * Copyright (c) 2005-2013 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. */ /* sg_pt_linux version 1.19 20130507 */ #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "sg_pt.h" #include "sg_lib.h" #include "sg_linux_inc.h" #define DEF_TIMEOUT 60000 /* 60,000 millisecs (60 seconds) */ static const char * linux_host_bytes[] = { "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE" /* 0xd */, "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE" /* 0x10 */, "DID_NEXUS_FAILURE (reservation conflict)", }; #define LINUX_HOST_BYTES_SZ \ (int)(sizeof(linux_host_bytes) / sizeof(linux_host_bytes[0])) static const char * linux_driver_bytes[] = { "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE" }; #define LINUX_DRIVER_BYTES_SZ \ (int)(sizeof(linux_driver_bytes) / sizeof(linux_driver_bytes[0])) static const char * linux_driver_suggests[] = { "SUGGEST_OK", "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", "UNKNOWN","UNKNOWN","UNKNOWN", "SUGGEST_SENSE" }; #define LINUX_DRIVER_SUGGESTS_SZ \ (int)(sizeof(linux_driver_suggests) / sizeof(linux_driver_suggests[0])) /* * These defines are for constants that should be visible in the * /usr/include/scsi directory (brought in by sg_linux_inc.h). * Redefined and aliased here to decouple this code from * sg_io_linux.h */ #ifndef DRIVER_MASK #define DRIVER_MASK 0x0f #endif #ifndef SUGGEST_MASK #define SUGGEST_MASK 0xf0 #endif #ifndef DRIVER_SENSE #define DRIVER_SENSE 0x08 #endif #define SG_LIB_DRIVER_MASK DRIVER_MASK #define SG_LIB_SUGGEST_MASK SUGGEST_MASK #define SG_LIB_DRIVER_SENSE DRIVER_SENSE // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #if defined(IGNORE_LINUX_BSG) || ! defined(HAVE_LINUX_BSG_H) /* * sg(v3) via SG_IO ioctl on a sg node or other node that accepts that ioctl. * Decision has been made at compile time because either: * a) no /usr/include/linux/bsg.h header file was found, or * b) the builder gave the '--enable-no-linux-bsg' option to ./configure */ struct sg_pt_linux_scsi { struct sg_io_hdr io_hdr; int in_err; int os_err; }; struct sg_pt_base { struct sg_pt_linux_scsi impl; }; /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, int read_only, int verbose) { int oflags = O_NONBLOCK; oflags |= (read_only ? O_RDONLY : O_RDWR); return scsi_pt_open_flags(device_name, oflags, verbose); } /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed */ /* together. The 'flags' argument is advisory and may be ignored. */ /* Returns >= 0 if successful, otherwise returns negated errno. */ int scsi_pt_open_flags(const char * device_name, int flags, int verbose) { int fd; if (verbose > 1) { if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "open %s with flags=0x%x\n", device_name, flags); } fd = open(device_name, flags); if (fd < 0) fd = -errno; return fd; } /* Returns 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_close_device(int device_fd) { int res; res = close(device_fd); if (res < 0) res = -errno; return res; } struct sg_pt_base * construct_scsi_pt_obj() { struct sg_pt_linux_scsi * ptp; ptp = (struct sg_pt_linux_scsi *) calloc(1, sizeof(struct sg_pt_linux_scsi)); if (ptp) { ptp->io_hdr.interface_id = 'S'; ptp->io_hdr.dxfer_direction = SG_DXFER_NONE; } return (struct sg_pt_base *)ptp; } void destruct_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp) free(ptp); } void clear_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp) { memset(ptp, 0, sizeof(struct sg_pt_linux_scsi)); ptp->io_hdr.interface_id = 'S'; ptp->io_hdr.dxfer_direction = SG_DXFER_NONE; } } void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.cmdp) ++ptp->in_err; ptp->io_hdr.cmdp = (unsigned char *)cdb; ptp->io_hdr.cmd_len = cdb_len; } void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int max_sense_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.sbp) ++ptp->in_err; memset(sense, 0, max_sense_len); ptp->io_hdr.sbp = sense; ptp->io_hdr.mx_sb_len = max_sense_len; } /* Setup for data transfer from device */ void set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.dxferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->io_hdr.dxferp = dxferp; ptp->io_hdr.dxfer_len = dxfer_len; ptp->io_hdr.dxfer_direction = SG_DXFER_FROM_DEV; } } /* Setup for data transfer toward device */ void set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.dxferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->io_hdr.dxferp = (unsigned char *)dxferp; ptp->io_hdr.dxfer_len = dxfer_len; ptp->io_hdr.dxfer_direction = SG_DXFER_TO_DEV; } } void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) { struct sg_pt_linux_scsi * ptp = &vp->impl; ptp->io_hdr.pack_id = pack_id; } void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) { struct sg_pt_linux_scsi * ptp = &vp->impl; ++ptp->in_err; tag = tag; /* dummy to silence compiler */ } /* Note that task management function codes are transport specific */ void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) { struct sg_pt_linux_scsi * ptp = &vp->impl; ++ptp->in_err; tmf_code = tmf_code; /* dummy to silence compiler */ } void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority) { struct sg_pt_linux_scsi * ptp = &vp->impl; ++ptp->in_err; attribute = attribute; /* dummy to silence compiler */ priority = priority; /* dummy to silence compiler */ } #ifndef SG_FLAG_Q_AT_TAIL #define SG_FLAG_Q_AT_TAIL 0x10 #endif #ifndef SG_FLAG_Q_AT_HEAD #define SG_FLAG_Q_AT_HEAD 0x20 #endif void set_scsi_pt_flags(struct sg_pt_base * vp, int flags) { struct sg_pt_linux_scsi * ptp = &vp->impl; /* default action of SG (v3) is QUEUE_AT_HEAD */ /* default action of block layer SG_IO ioctl is QUEUE_AT_TAIL */ if (SCSI_PT_FLAGS_QUEUE_AT_TAIL & flags) { ptp->io_hdr.flags |= SG_FLAG_Q_AT_TAIL; ptp->io_hdr.flags &= ~SG_FLAG_Q_AT_HEAD; } if (SCSI_PT_FLAGS_QUEUE_AT_HEAD & flags) { ptp->io_hdr.flags |= SG_FLAG_Q_AT_HEAD; ptp->io_hdr.flags &= ~SG_FLAG_Q_AT_TAIL; } } /* Executes SCSI command (or at least forwards it to lower layers). * Clears os_err field prior to active call (whose result may set it * again). */ int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; ptp->os_err = 0; if (ptp->in_err) { if (verbose) fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt... " "functions\n"); return SCSI_PT_DO_BAD_PARAMS; } if (NULL == ptp->io_hdr.cmdp) { if (verbose) fprintf(sg_warnings_strm, "No SCSI command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } /* io_hdr.timeout is in milliseconds */ ptp->io_hdr.timeout = ((time_secs > 0) ? (time_secs * 1000) : DEF_TIMEOUT); if (ptp->io_hdr.sbp && (ptp->io_hdr.mx_sb_len > 0)) memset(ptp->io_hdr.sbp, 0, ptp->io_hdr.mx_sb_len); if (ioctl(fd, SG_IO, &ptp->io_hdr) < 0) { ptp->os_err = errno; if (verbose > 1) fprintf(sg_warnings_strm, "ioctl(SG_IO) failed: %s (errno=%d)\n", strerror(ptp->os_err), ptp->os_err); return -ptp->os_err; } return 0; } int get_scsi_pt_result_category(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK; int scsi_st = ptp->io_hdr.status & 0x7e; if (ptp->os_err) return SCSI_PT_RESULT_OS_ERR; else if (ptp->io_hdr.host_status) return SCSI_PT_RESULT_TRANSPORT_ERR; else if (dr_st && (SG_LIB_DRIVER_SENSE != dr_st)) return SCSI_PT_RESULT_TRANSPORT_ERR; else if ((SG_LIB_DRIVER_SENSE == dr_st) || (SAM_STAT_CHECK_CONDITION == scsi_st) || (SAM_STAT_COMMAND_TERMINATED == scsi_st)) return SCSI_PT_RESULT_SENSE; else if (scsi_st) return SCSI_PT_RESULT_STATUS; else return SCSI_PT_RESULT_GOOD; } int get_scsi_pt_resid(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.resid; } int get_scsi_pt_status_response(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.status; } int get_scsi_pt_sense_len(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.sb_len_wr; } int get_scsi_pt_duration_ms(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.duration; } int get_scsi_pt_transport_err(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return (ptp->io_hdr.host_status << 8) + ptp->io_hdr.driver_status; } int get_scsi_pt_os_err(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->os_err; } /* Returns b which will contain a null char terminated string (if * max_b_len > 0). That string should decode Linux driver and host * status values. */ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_linux_scsi * ptp = &vp->impl; int ds = ptp->io_hdr.driver_status; int hs = ptp->io_hdr.host_status; int n, m; char * cp = b; int driv, sugg; const char * driv_cp = "unknown"; const char * sugg_cp = "unknown"; if (max_b_len < 1) return b; m = max_b_len; n = 0; if (hs) { if ((hs < 0) || (hs >= LINUX_HOST_BYTES_SZ)) n = snprintf(cp, m, "Host_status=0x%02x is unknown\n", hs); else n = snprintf(cp, m, "Host_status=0x%02x [%s]\n", hs, linux_host_bytes[hs]); } m -= n; if (m < 1) { b[max_b_len - 1] = '\0'; return b; } cp += n; driv = ds & SG_LIB_DRIVER_MASK; if (driv < LINUX_DRIVER_BYTES_SZ) driv_cp = linux_driver_bytes[driv]; sugg = (ds & SG_LIB_SUGGEST_MASK) >> 4; if (sugg < LINUX_DRIVER_SUGGESTS_SZ) sugg_cp = linux_driver_suggests[sugg]; n = snprintf(cp, m, "Driver_status=0x%02x [%s, %s]\n", ds, driv_cp, sugg_cp); m -= n; if (m < 1) b[max_b_len - 1] = '\0'; return b; } char * 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; 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; } // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #else /* allow for runtime selection of sg v3 or v4 (via bsg) */ // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /* * So bsg is an option. Thus we make a runtime decision. If all the following * are true we use sg v4 which is only currently supported on bsg device * nodes: * a) there is a bsg entry in the /proc/devices file * b) the device node given to scsi_pt_open() is a char device * c) the char major number of the device node given to scsi_pt_open() * matches the char major number of the bsg entry in /proc/devices * Otherwise the sg v3 interface is used. * * Note that in either case we prepare the data in a sg v4 structure. If * the runtime tests indicate that the v3 interface is needed then * do_scsi_pt_v3() transfers the input data into a v3 structure and * then the output data is transferred back into a sg v4 structure. * That implementation detail could change in the future. * * [20120806] Only use MAJOR() macro in kdev_t.h if that header file is * available and major() macro [N.B. lower case] is not available. */ #include #include #ifdef major #define SG_DEV_MAJOR major #else #ifdef HAVE_LINUX_KDEV_T_H #include #endif #define SG_DEV_MAJOR MAJOR /* MAJOR() macro faulty if > 255 minors */ #endif struct sg_pt_linux_scsi { struct sg_io_v4 io_hdr; /* use v4 header as it is more general */ int in_err; int os_err; unsigned char tmf_request[4]; }; struct sg_pt_base { struct sg_pt_linux_scsi impl; }; static int bsg_major_checked = 0; static int bsg_major = 0; static void find_bsg_major(int verbose) { const char * proc_devices = "/proc/devices"; FILE *fp; char a[128]; char b[128]; char * cp; int n; if (NULL == (fp = fopen(proc_devices, "r"))) { if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (verbose) fprintf(sg_warnings_strm, "fopen %s failed: %s\n", proc_devices, strerror(errno)); return; } while ((cp = fgets(b, sizeof(b), fp))) { if ((1 == sscanf(b, "%s", a)) && (0 == memcmp(a, "Character", 9))) break; } while (cp && (cp = fgets(b, sizeof(b), fp))) { if (2 == sscanf(b, "%d %s", &n, a)) { if (0 == strcmp("bsg", a)) { bsg_major = n; break; } } else break; } if (verbose > 3) { if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (cp) fprintf(sg_warnings_strm, "found bsg_major=%d\n", bsg_major); else fprintf(sg_warnings_strm, "found no bsg char device in %s\n", proc_devices); } fclose(fp); } /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, int read_only, int verbose) { int oflags = O_NONBLOCK; oflags |= (read_only ? O_RDONLY : O_RDWR); return scsi_pt_open_flags(device_name, oflags, verbose); } /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed */ /* together. The 'flags' argument is advisory and may be ignored. */ /* Returns >= 0 if successful, otherwise returns negated errno. */ int scsi_pt_open_flags(const char * device_name, int flags, int verbose) { int fd; if (! bsg_major_checked) { bsg_major_checked = 1; find_bsg_major(verbose); } if (verbose > 1) { if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "open %s with flags=0x%x\n", device_name, flags); } fd = open(device_name, flags); if (fd < 0) fd = -errno; return fd; } /* Returns 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_close_device(int device_fd) { int res; res = close(device_fd); if (res < 0) res = -errno; return res; } struct sg_pt_base * construct_scsi_pt_obj() { struct sg_pt_linux_scsi * ptp; ptp = (struct sg_pt_linux_scsi *) calloc(1, sizeof(struct sg_pt_linux_scsi)); if (ptp) { ptp->io_hdr.guard = 'Q'; #ifdef BSG_PROTOCOL_SCSI ptp->io_hdr.protocol = BSG_PROTOCOL_SCSI; #endif #ifdef BSG_SUB_PROTOCOL_SCSI_CMD ptp->io_hdr.subprotocol = BSG_SUB_PROTOCOL_SCSI_CMD; #endif } return (struct sg_pt_base *)ptp; } void destruct_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp) free(ptp); } void clear_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp) { memset(ptp, 0, sizeof(struct sg_pt_linux_scsi)); ptp->io_hdr.guard = 'Q'; #ifdef BSG_PROTOCOL_SCSI ptp->io_hdr.protocol = BSG_PROTOCOL_SCSI; #endif #ifdef BSG_SUB_PROTOCOL_SCSI_CMD ptp->io_hdr.subprotocol = BSG_SUB_PROTOCOL_SCSI_CMD; #endif } } void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.request) ++ptp->in_err; /* C99 has intptr_t instead of long */ ptp->io_hdr.request = (__u64)(long)cdb; ptp->io_hdr.request_len = cdb_len; } void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int max_sense_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.response) ++ptp->in_err; memset(sense, 0, max_sense_len); ptp->io_hdr.response = (__u64)(long)sense; ptp->io_hdr.max_response_len = max_sense_len; } /* Setup for data transfer from device */ void set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.din_xferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->io_hdr.din_xferp = (__u64)(long)dxferp; ptp->io_hdr.din_xfer_len = dxfer_len; } } /* Setup for data transfer toward device */ void set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (ptp->io_hdr.dout_xferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->io_hdr.dout_xferp = (__u64)(long)dxferp; ptp->io_hdr.dout_xfer_len = dxfer_len; } } void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) { struct sg_pt_linux_scsi * ptp = &vp->impl; ptp->io_hdr.spare_in = pack_id; } void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) { struct sg_pt_linux_scsi * ptp = &vp->impl; ptp->io_hdr.request_tag = tag; } /* Note that task management function codes are transport specific */ void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) { struct sg_pt_linux_scsi * ptp = &vp->impl; 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])); ptp->io_hdr.request_len = 1; } void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority) { struct sg_pt_linux_scsi * ptp = &vp->impl; ptp->io_hdr.request_attr = attribute; ptp->io_hdr.request_priority = priority; } #ifndef BSG_FLAG_Q_AT_TAIL #define BSG_FLAG_Q_AT_TAIL 0x10 #endif void set_scsi_pt_flags(struct sg_pt_base * vp, int flags) { struct sg_pt_linux_scsi * ptp = &vp->impl; /* default action of bsg (sg v4) is QUEUE_AT_HEAD */ if (SCSI_PT_FLAGS_QUEUE_AT_TAIL & flags) ptp->io_hdr.flags |= BSG_FLAG_Q_AT_TAIL; if (SCSI_PT_FLAGS_QUEUE_AT_HEAD & flags) ptp->io_hdr.flags &= ~BSG_FLAG_Q_AT_TAIL; } /* N.B. Returns din_resid and ignores dout_resid */ int get_scsi_pt_resid(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.din_resid; } int get_scsi_pt_status_response(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.device_status; } int get_scsi_pt_sense_len(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.response_len; } int get_scsi_pt_duration_ms(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.duration; } int get_scsi_pt_transport_err(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->io_hdr.transport_status; } /* Returns b which will contain a null char terminated string (if * max_b_len > 0). Combined driver and transport (called "host" in Linux * kernel) statuses */ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_linux_scsi * ptp = &vp->impl; int ds = ptp->io_hdr.driver_status; int hs = ptp->io_hdr.transport_status; int n, m; char * cp = b; int driv, sugg; const char * driv_cp = "invalid"; const char * sugg_cp = "invalid"; if (max_b_len < 1) return b; m = max_b_len; n = 0; if (hs) { if ((hs < 0) || (hs >= LINUX_HOST_BYTES_SZ)) n = snprintf(cp, m, "Host_status=0x%02x is invalid\n", hs); else n = snprintf(cp, m, "Host_status=0x%02x [%s]\n", hs, linux_host_bytes[hs]); } m -= n; if (m < 1) { b[max_b_len - 1] = '\0'; return b; } cp += n; driv = ds & SG_LIB_DRIVER_MASK; if (driv < LINUX_DRIVER_BYTES_SZ) driv_cp = linux_driver_bytes[driv]; sugg = (ds & SG_LIB_SUGGEST_MASK) >> 4; if (sugg < LINUX_DRIVER_SUGGESTS_SZ) sugg_cp = linux_driver_suggests[sugg]; n = snprintf(cp, m, "Driver_status=0x%02x [%s, %s]\n", ds, driv_cp, sugg_cp); m -= n; if (m < 1) b[max_b_len - 1] = '\0'; return b; } int get_scsi_pt_result_category(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK; int scsi_st = ptp->io_hdr.device_status & 0x7e; if (ptp->os_err) return SCSI_PT_RESULT_OS_ERR; else if (ptp->io_hdr.transport_status) return SCSI_PT_RESULT_TRANSPORT_ERR; else if (dr_st && (SG_LIB_DRIVER_SENSE != dr_st)) return SCSI_PT_RESULT_TRANSPORT_ERR; else if ((SG_LIB_DRIVER_SENSE == dr_st) || (SAM_STAT_CHECK_CONDITION == scsi_st) || (SAM_STAT_COMMAND_TERMINATED == scsi_st)) return SCSI_PT_RESULT_SENSE; else if (scsi_st) return SCSI_PT_RESULT_STATUS; else return SCSI_PT_RESULT_GOOD; } int get_scsi_pt_os_err(const struct sg_pt_base * vp) { const struct sg_pt_linux_scsi * ptp = &vp->impl; return ptp->os_err; } char * 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; 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; } /* Executes SCSI command using sg v3 interface */ static int do_scsi_pt_v3(struct sg_pt_linux_scsi * ptp, int fd, int time_secs, int verbose) { struct sg_io_hdr v3_hdr; memset(&v3_hdr, 0, sizeof(v3_hdr)); /* convert v4 to v3 header */ v3_hdr.interface_id = 'S'; v3_hdr.dxfer_direction = SG_DXFER_NONE; v3_hdr.cmdp = (unsigned char *)(long)ptp->io_hdr.request; v3_hdr.cmd_len = (unsigned char)ptp->io_hdr.request_len; if (ptp->io_hdr.din_xfer_len > 0) { if (ptp->io_hdr.dout_xfer_len > 0) { if (verbose) fprintf(sg_warnings_strm, "sgv3 doesn't support bidi\n"); return SCSI_PT_DO_BAD_PARAMS; } v3_hdr.dxferp = (void *)(long)ptp->io_hdr.din_xferp; v3_hdr.dxfer_len = (unsigned int)ptp->io_hdr.din_xfer_len; v3_hdr.dxfer_direction = SG_DXFER_FROM_DEV; } else if (ptp->io_hdr.dout_xfer_len > 0) { v3_hdr.dxferp = (void *)(long)ptp->io_hdr.dout_xferp; v3_hdr.dxfer_len = (unsigned int)ptp->io_hdr.dout_xfer_len; v3_hdr.dxfer_direction = SG_DXFER_TO_DEV; } if (ptp->io_hdr.response && (ptp->io_hdr.max_response_len > 0)) { v3_hdr.sbp = (unsigned char *)(long)ptp->io_hdr.response; v3_hdr.mx_sb_len = (unsigned char)ptp->io_hdr.max_response_len; } v3_hdr.pack_id = (int)ptp->io_hdr.spare_in; if (NULL == v3_hdr.cmdp) { if (verbose) fprintf(sg_warnings_strm, "No SCSI command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } /* io_hdr.timeout is in milliseconds, if greater than zero */ v3_hdr.timeout = ((time_secs > 0) ? (time_secs * 1000) : DEF_TIMEOUT); /* Finally do the v3 SG_IO ioctl */ if (ioctl(fd, SG_IO, &v3_hdr) < 0) { ptp->os_err = errno; if (verbose > 1) fprintf(sg_warnings_strm, "ioctl(SG_IO v3) failed: %s " "(errno=%d)\n", strerror(ptp->os_err), ptp->os_err); return -ptp->os_err; } ptp->io_hdr.device_status = (__u32)v3_hdr.status; ptp->io_hdr.driver_status = (__u32)v3_hdr.driver_status; ptp->io_hdr.transport_status = (__u32)v3_hdr.host_status; ptp->io_hdr.response_len = (__u32)v3_hdr.sb_len_wr; ptp->io_hdr.duration = (__u32)v3_hdr.duration; ptp->io_hdr.din_resid = (__s32)v3_hdr.resid; /* v3_hdr.info not passed back since no mapping defined (yet) */ return 0; } /* Executes SCSI command (or at least forwards it to lower layers). * Clears os_err field prior to active call (whose result may set it * again). */ int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose) { struct sg_pt_linux_scsi * ptp = &vp->impl; if (! bsg_major_checked) { bsg_major_checked = 1; find_bsg_major(verbose); } if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; ptp->os_err = 0; if (ptp->in_err) { if (verbose) fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt... " "functions\n"); return SCSI_PT_DO_BAD_PARAMS; } if (bsg_major <= 0) return do_scsi_pt_v3(ptp, fd, time_secs, verbose); else { struct stat a_stat; if (fstat(fd, &a_stat) < 0) { ptp->os_err = errno; if (verbose > 1) fprintf(sg_warnings_strm, "fstat() failed: %s (errno=%d)\n", strerror(ptp->os_err), ptp->os_err); return -ptp->os_err; } if (! S_ISCHR(a_stat.st_mode) || (bsg_major != (int)SG_DEV_MAJOR(a_stat.st_rdev))) return do_scsi_pt_v3(ptp, fd, time_secs, verbose); } if (! ptp->io_hdr.request) { if (verbose) fprintf(sg_warnings_strm, "No SCSI command (cdb) given (v4)\n"); return SCSI_PT_DO_BAD_PARAMS; } /* io_hdr.timeout is in milliseconds */ ptp->io_hdr.timeout = ((time_secs > 0) ? (time_secs * 1000) : DEF_TIMEOUT); #if 0 /* sense buffer already zeroed */ if (ptp->io_hdr.response && (ptp->io_hdr.max_response_len > 0)) { void * p; p = (void *)(long)ptp->io_hdr.response; memset(p, 0, ptp->io_hdr.max_response_len); } #endif if (ioctl(fd, SG_IO, &ptp->io_hdr) < 0) { ptp->os_err = errno; if (verbose > 1) fprintf(sg_warnings_strm, "ioctl(SG_IO v4) failed: %s " "(errno=%d)\n", strerror(ptp->os_err), ptp->os_err); return -ptp->os_err; } return 0; } #endif // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< sdparm-1.08/lib/sg_pt_osf1.c0000664000175000017500000003033412061626602014710 0ustar douggdougg/* * Copyright (c) 2005-2010 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "sg_pt.h" #include "sg_lib.h" /* Changed to use struct sg_pt_base 20070403 */ #define OSF1_MAXDEV 64 struct osf1_dev_channel { int bus; int tgt; int lun; }; // Private table of open devices: guaranteed zero on startup since // part of static data. static struct osf1_dev_channel *devicetable[OSF1_MAXDEV] = {0}; static char *cam_dev = "/dev/cam"; static int camfd; static int camopened = 0; struct sg_pt_osf1_scsi { unsigned char * cdb; int cdb_len; unsigned char * sense; int sense_len; unsigned char * dxferp; int dxfer_len; int dxfer_dir; int scsi_status; int resid; int sense_resid; int in_err; int os_err; int transport_err; }; struct sg_pt_base { struct sg_pt_osf1_scsi impl; }; /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, int read_only, int verbose) { int oflags = 0 /* O_NONBLOCK*/ ; oflags |= (read_only ? O_RDONLY : O_RDWR); return scsi_pt_open_flags(device_name, oflags, verbose); } /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed * together. The 'flags' argument is ignored in OSF-1. * Returns >= 0 if successful, otherwise returns negated errno. */ int scsi_pt_open_flags(const char * device_name, int flags, int verbose) { struct osf1_dev_channel *fdchan; int fd, k; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; if (!camopened) { camfd = open(cam_dev, O_RDWR, 0); if (camfd < 0) return -1; camopened++; } // Search table for a free entry for (k = 0; k < OSF1_MAXDEV; k++) if (! devicetable[k]) break; if (k == OSF1_MAXDEV) { if (verbose) fprintf(sg_warnings_strm, "too many open devices " "(%d)\n", OSF1_MAXDEV); errno=EMFILE; return -1; } fdchan = (struct osf1_dev_channel *)calloc(1, sizeof(struct osf1_dev_channel)); if (fdchan == NULL) { // errno already set by call to malloc() return -1; } fd = open(device_name, O_RDONLY|O_NONBLOCK); if (fd > 0) { device_info_t devinfo; bzero(&devinfo, sizeof(devinfo)); if (ioctl(fd, DEVGETINFO, &devinfo) == 0) { fdchan->bus = devinfo.v1.businfo.bus.scsi.bus_num; fdchan->tgt = devinfo.v1.businfo.bus.scsi.tgt_id; fdchan->lun = devinfo.v1.businfo.bus.scsi.lun; } close (fd); } else { free(fdchan); return -1; } devicetable[k] = fdchan; return k; } /* Returns 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_close_device(int device_fd) { struct osf1_dev_channel *fdchan; int i; if ((device_fd < 0) || (device_fd >= OSF1_MAXDEV)) { errno = ENODEV; return -1; } fdchan = devicetable[device_fd]; if (NULL == fdchan) { errno = ENODEV; return -1; } free(fdchan); devicetable[device_fd] = NULL; for (i = 0; i < OSF1_MAXDEV; i++) { if (devicetable[i]) break; } if (i == OSF1_MAXDEV) { close(camfd); camopened = 0; } return 0; } struct sg_pt_base * construct_scsi_pt_obj() { struct sg_pt_osf1_scsi * ptp; ptp = (struct sg_pt_osf1_scsi *)malloc(sizeof(struct sg_pt_osf1_scsi)); if (ptp) { bzero(ptp, sizeof(struct sg_pt_osf1_scsi)); ptp->dxfer_dir = CAM_DIR_NONE; } return (struct sg_pt_base *)ptp; } void destruct_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp) free(ptp); } void clear_scsi_pt_obj(struct sg_pt_base * vp) { struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp) { bzero(ptp, sizeof(struct sg_pt_osf1_scsi)); ptp->dxfer_dir = CAM_DIR_NONE; } } void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len) { struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp->cdb) ++ptp->in_err; ptp->cdb = (unsigned char *)cdb; ptp->cdb_len = cdb_len; } void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense, int max_sense_len) { struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp->sense) ++ptp->in_err; bzero(sense, max_sense_len); ptp->sense = sense; ptp->sense_len = max_sense_len; } /* from device */ void set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp, int dxfer_len) { struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp->dxferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->dxferp = dxferp; ptp->dxfer_len = dxfer_len; ptp->dxfer_dir = CAM_DIR_IN; } } /* to device */ void set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp, int dxfer_len) { struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp->dxferp) ++ptp->in_err; if (dxfer_len > 0) { ptp->dxferp = (unsigned char *)dxferp; ptp->dxfer_len = dxfer_len; ptp->dxfer_dir = CAM_DIR_OUT; } } void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id) { } void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag) { struct sg_pt_osf1_scsi * ptp = &vp->impl; ++ptp->in_err; } void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code) { struct sg_pt_osf1_scsi * ptp = &vp->impl; ++ptp->in_err; } void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attrib, int priority) { struct sg_pt_osf1_scsi * ptp = &vp->impl; ++ptp->in_err; } void set_scsi_pt_flags(struct sg_pt_base * objp, int flags) { /* do nothing, suppress warnings */ objp = objp; flags = flags; } static int release_sim(struct sg_pt_base *vp, int device_fd, int verbose) { struct sg_pt_osf1_scsi * ptp = &vp->impl; struct osf1_dev_channel *fdchan = devicetable[device_fd]; UAGT_CAM_CCB uagt; CCB_RELSIM relsim; int retval; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; bzero(&uagt, sizeof(uagt)); bzero(&relsim, sizeof(relsim)); uagt.uagt_ccb = (CCB_HEADER *) &relsim; uagt.uagt_ccblen = sizeof(relsim); relsim.cam_ch.cam_ccb_len = sizeof(relsim); relsim.cam_ch.cam_func_code = XPT_REL_SIMQ; relsim.cam_ch.cam_flags = CAM_DIR_IN | CAM_DIS_CALLBACK; relsim.cam_ch.cam_path_id = fdchan->bus; relsim.cam_ch.cam_target_id = fdchan->tgt; relsim.cam_ch.cam_target_lun = fdchan->lun; retval = ioctl(camfd, UAGT_CAM_IO, &uagt); if (retval < 0) { if (verbose) fprintf(sg_warnings_strm, "CAM ioctl error (Release SIM Queue)\n"); } return retval; } int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose) { struct sg_pt_osf1_scsi * ptp = &vp->impl; struct osf1_dev_channel *fdchan; int len, retval; CCB_SCSIIO ccb; UAGT_CAM_CCB uagt; unsigned char sensep[ADDL_SENSE_LENGTH]; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; ptp->os_err = 0; if (ptp->in_err) { if (verbose) fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt...\n"); return SCSI_PT_DO_BAD_PARAMS; } if (NULL == ptp->cdb) { if (verbose) fprintf(sg_warnings_strm, "No command (cdb) given\n"); return SCSI_PT_DO_BAD_PARAMS; } if ((device_fd < 0) || (device_fd >= OSF1_MAXDEV)) { if (verbose) fprintf(sg_warnings_strm, "Bad file descriptor\n"); ptp->os_err = ENODEV; return -ptp->os_err; } fdchan = devicetable[device_fd]; if (NULL == fdchan) { if (verbose) fprintf(sg_warnings_strm, "File descriptor closed??\n"); ptp->os_err = ENODEV; return -ptp->os_err; } if (0 == camopened) { if (verbose) fprintf(sg_warnings_strm, "No open CAM device\n"); return SCSI_PT_DO_BAD_PARAMS; } bzero(&uagt, sizeof(uagt)); bzero(&ccb, sizeof(ccb)); uagt.uagt_ccb = (CCB_HEADER *) &ccb; uagt.uagt_ccblen = sizeof(ccb); uagt.uagt_snsbuf = ccb.cam_sense_ptr = ptp->sense ? ptp->sense : sensep; uagt.uagt_snslen = ccb.cam_sense_len = ptp->sense ? ptp->sense_len : sizeof sensep; uagt.uagt_buffer = ccb.cam_data_ptr = ptp->dxferp; uagt.uagt_buflen = ccb.cam_dxfer_len = ptp->dxfer_len; ccb.cam_timeout = time_secs; ccb.cam_ch.my_addr = (CCB_HEADER *) &ccb; ccb.cam_ch.cam_ccb_len = sizeof(ccb); ccb.cam_ch.cam_func_code = XPT_SCSI_IO; ccb.cam_ch.cam_flags = ptp->dxfer_dir; ccb.cam_cdb_len = ptp->cdb_len; memcpy(ccb.cam_cdb_io.cam_cdb_bytes, ptp->cdb, ptp->cdb_len); ccb.cam_ch.cam_path_id = fdchan->bus; ccb.cam_ch.cam_target_id = fdchan->tgt; ccb.cam_ch.cam_target_lun = fdchan->lun; if (ioctl(camfd, UAGT_CAM_IO, &uagt) < 0) { if (verbose) fprintf(sg_warnings_strm, "CAN I/O Error\n"); ptp->os_err = EIO; return -ptp->os_err; } if (((ccb.cam_ch.cam_status & CAM_STATUS_MASK) == CAM_REQ_CMP) || ((ccb.cam_ch.cam_status & CAM_STATUS_MASK) == CAM_REQ_CMP_ERR)) { ptp->scsi_status = ccb.cam_scsi_status; ptp->resid = ccb.cam_resid; if (ptp->sense) ptp->sense_resid = ccb.cam_sense_resid; } else { ptp->transport_err = 1; } /* If the SIM queue is frozen, release SIM queue. */ if (ccb.cam_ch.cam_status & CAM_SIM_QFRZN) release_sim(vp, device_fd, verbose); return 0; } int get_scsi_pt_result_category(const struct sg_pt_base * vp) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; if (ptp->os_err) return SCSI_PT_RESULT_OS_ERR; else if (ptp->transport_err) return SCSI_PT_RESULT_TRANSPORT_ERR; else if ((SAM_STAT_CHECK_CONDITION == ptp->scsi_status) || (SAM_STAT_COMMAND_TERMINATED == ptp->scsi_status)) return SCSI_PT_RESULT_SENSE; else if (ptp->scsi_status) return SCSI_PT_RESULT_STATUS; else return SCSI_PT_RESULT_GOOD; } int get_scsi_pt_resid(const struct sg_pt_base * vp) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; return ptp->resid; } int get_scsi_pt_status_response(const struct sg_pt_base * vp) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; return ptp->scsi_status; } int get_scsi_pt_sense_len(const struct sg_pt_base * vp) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; int len; len = ptp->sense_len - ptp->sense_resid; return (len > 0) ? len : 0; } int get_scsi_pt_duration_ms(const struct sg_pt_base * vp) { // const struct sg_pt_osf1_scsi * ptp = &vp->impl; return -1; } int get_scsi_pt_transport_err(const struct sg_pt_base * vp) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; return ptp->transport_err; } int get_scsi_pt_os_err(const struct sg_pt_base * vp) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; return ptp->os_err; } char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_osf1_scsi * ptp = &vp->impl; if (0 == ptp->transport_err) { strncpy(b, "no transport error available", max_b_len); b[max_b_len - 1] = '\0'; return b; } strncpy(b, "no transport error available", max_b_len); b[max_b_len - 1] = '\0'; return b; } char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b) { const struct sg_pt_osf1_scsi * 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; } sdparm-1.08/lib/Makefile.am0000664000175000017500000000470612153447426014547 0ustar douggdougg if OS_LINUX libsgutils2_la_SOURCES = \ sg_lib.c \ sg_lib_data.c \ sg_cmds_basic.c \ sg_cmds_basic2.c \ sg_cmds_extra.c \ sg_cmds_mmc.c \ sg_pt_common.c \ sg_pt_linux.c \ sg_io_linux.c EXTRA_libsgutils2_la_SOURCES = \ sg_pt_freebsd.c \ sg_pt_osf1.c \ sg_pt_solaris.c \ sg_pt_win32.c \ getopt_long.c endif if OS_WIN32_MINGW libsgutils2_la_SOURCES = \ sg_lib.c \ sg_lib_data.c \ sg_cmds_basic.c \ sg_cmds_basic2.c \ sg_cmds_extra.c \ sg_cmds_mmc.c \ sg_pt_common.c \ sg_pt_win32.c EXTRA_libsgutils2_la_SOURCES = \ sg_pt_linux.c \ sg_io_linux.c \ sg_pt_freebsd.c \ sg_pt_osf1.c \ sg_pt_solaris.c \ getopt_long.c endif if OS_WIN32_CYGWIN libsgutils2_la_SOURCES = \ sg_lib.c \ sg_lib_data.c \ sg_cmds_basic.c \ sg_cmds_basic2.c \ sg_cmds_extra.c \ sg_cmds_mmc.c \ sg_pt_common.c \ sg_pt_win32.c EXTRA_libsgutils2_la_SOURCES = \ sg_pt_linux.c \ sg_io_linux.c \ sg_pt_freebsd.c \ sg_pt_osf1.c \ sg_pt_solaris.c \ getopt_long.c endif if OS_FREEBSD libsgutils2_la_SOURCES = \ sg_lib.c \ sg_lib_data.c \ sg_cmds_basic.c \ sg_cmds_basic2.c \ sg_cmds_extra.c \ sg_cmds_mmc.c \ sg_pt_common.c \ sg_pt_freebsd.c EXTRA_libsgutils2_la_SOURCES = \ sg_pt_linux.c \ sg_io_linux.c \ sg_linux_inc.h \ sg_pt_osf1.c \ sg_pt_solaris.c \ sg_pt_win32.c \ getopt_long.c endif if OS_SOLARIS libsgutils2_la_SOURCES = \ sg_lib.c \ sg_lib_data.c \ sg_cmds_basic.c \ sg_cmds_basic2.c \ sg_cmds_extra.c \ sg_cmds_mmc.c \ sg_pt_common.c \ sg_pt_solaris.c EXTRA_libsgutils2_la_SOURCES = \ sg_pt_linux.c \ sg_io_linux.c \ sg_linux_inc.h \ sg_pt_freebsd.c \ sg_pt_osf1.c \ sg_pt_win32.c \ getopt_long.c endif if OS_OSF libsgutils2_la_SOURCES = \ sg_lib.c \ sg_lib_data.c \ sg_cmds_basic.c \ sg_cmds_basic2.c \ sg_cmds_extra.c \ sg_cmds_mmc.c \ sg_pt_common.c \ sg_pt_osf1.c EXTRA_libsgutils2_la_SOURCES = \ sg_pt_linux.c \ sg_io_linux.c \ sg_pt_freebsd.c \ sg_pt_solaris.c \ sg_pt_win32.c \ getopt_long.c endif # For C++/clang testing ## CC = g++ -std=c++11 ## CC = g++ ## CC = clang # -std= can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W # AM_CFLAGS = -I ../include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -pedantic -std=c11 lib_LTLIBRARIES = libsgutils2.la libsgutils2_la_LDFLAGS = -version-info 2:0:0 libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@ libsgutils2_la_DEPENDENCIES = @GETOPT_O_FILES@ sdparm-1.08/lib/BSD_LICENSE0000664000175000017500000000275211346470114014200 0ustar douggdougg/* * Copyright (c) 1999-2010 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ sdparm-1.08/lib/sg_io_linux.c0000664000175000017500000001672112024633456015173 0ustar douggdougg/* * Copyright (c) 1999-2012 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 #include #include // need to include the file in the build when sg_scan is built for Win32. // Hence the following guard ... // #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef SG_LIB_LINUX #include "sg_io_linux.h" /* Version 1.04 20120914 */ void sg_print_masked_status(int masked_status) { int scsi_status = (masked_status << 1) & 0x7e; sg_print_scsi_status(scsi_status); } static const char * linux_host_bytes[] = { "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE", "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", "DID_NEXUS_FAILURE", }; #define LINUX_HOST_BYTES_SZ \ (int)(sizeof(linux_host_bytes) / sizeof(linux_host_bytes[0])) void sg_print_host_status(int host_status) { if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "Host_status=0x%02x ", host_status); if ((host_status < 0) || (host_status >= LINUX_HOST_BYTES_SZ)) fprintf(sg_warnings_strm, "is invalid "); else fprintf(sg_warnings_strm, "[%s] ", linux_host_bytes[host_status]); } static const char * linux_driver_bytes[] = { "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE" }; #define LINUX_DRIVER_BYTES_SZ \ (int)(sizeof(linux_driver_bytes) / sizeof(linux_driver_bytes[0])) static const char * linux_driver_suggests[] = { "SUGGEST_OK", "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", "UNKNOWN","UNKNOWN","UNKNOWN", "SUGGEST_SENSE" }; #define LINUX_DRIVER_SUGGESTS_SZ \ (int)(sizeof(linux_driver_suggests) / sizeof(linux_driver_suggests[0])) void sg_print_driver_status(int driver_status) { int driv, sugg; const char * driv_cp = "invalid"; const char * sugg_cp = "invalid"; driv = driver_status & SG_LIB_DRIVER_MASK; if (driv < LINUX_DRIVER_BYTES_SZ) driv_cp = linux_driver_bytes[driv]; sugg = (driver_status & SG_LIB_SUGGEST_MASK) >> 4; if (sugg < LINUX_DRIVER_SUGGESTS_SZ) sugg_cp = linux_driver_suggests[sugg]; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; fprintf(sg_warnings_strm, "Driver_status=0x%02x", driver_status); fprintf(sg_warnings_strm, " [%s, %s] ", driv_cp, sugg_cp); } /* Returns 1 if no errors found and thus nothing printed; otherwise prints error/warning (prefix by 'leadin') and returns 0. */ static int sg_linux_sense_print(const char * leadin, int scsi_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len, int raw_sinfo) { int done_leadin = 0; int done_sense = 0; if (NULL == sg_warnings_strm) sg_warnings_strm = stderr; scsi_status &= 0x7e; /*sanity */ if ((0 == scsi_status) && (0 == host_status) && (0 == driver_status)) return 1; /* No problems */ if (0 != scsi_status) { if (leadin) fprintf(sg_warnings_strm, "%s: ", leadin); done_leadin = 1; fprintf(sg_warnings_strm, "SCSI status: "); sg_print_scsi_status(scsi_status); fprintf(sg_warnings_strm, "\n"); if (sense_buffer && ((scsi_status == SAM_STAT_CHECK_CONDITION) || (scsi_status == SAM_STAT_COMMAND_TERMINATED))) { /* SAM_STAT_COMMAND_TERMINATED is obsolete */ sg_print_sense(0, sense_buffer, sb_len, raw_sinfo); done_sense = 1; } } if (0 != host_status) { if (leadin && (! done_leadin)) fprintf(sg_warnings_strm, "%s: ", leadin); if (done_leadin) fprintf(sg_warnings_strm, "plus...: "); else done_leadin = 1; sg_print_host_status(host_status); fprintf(sg_warnings_strm, "\n"); } if (0 != driver_status) { if (done_sense && (SG_LIB_DRIVER_SENSE == (SG_LIB_DRIVER_MASK & driver_status))) return 0; if (leadin && (! done_leadin)) fprintf(sg_warnings_strm, "%s: ", leadin); if (done_leadin) fprintf(sg_warnings_strm, "plus...: "); else done_leadin = 1; sg_print_driver_status(driver_status); fprintf(sg_warnings_strm, "\n"); if (sense_buffer && (! done_sense) && (SG_LIB_DRIVER_SENSE == (SG_LIB_DRIVER_MASK & driver_status))) sg_print_sense(0, sense_buffer, sb_len, raw_sinfo); } return 0; } #ifdef SG_IO int sg_normalize_sense(const struct sg_io_hdr * hp, struct sg_scsi_sense_hdr * sshp) { if ((NULL == hp) || (0 == hp->sb_len_wr)) { if (sshp) memset(sshp, 0, sizeof(struct sg_scsi_sense_hdr)); return 0; } return sg_scsi_normalize_sense(hp->sbp, hp->sb_len_wr, sshp); } /* Returns 1 if no errors found and thus nothing printed; otherwise returns 0. */ int sg_chk_n_print3(const char * leadin, struct sg_io_hdr * hp, int raw_sinfo) { return sg_linux_sense_print(leadin, hp->status, hp->host_status, hp->driver_status, hp->sbp, hp->sb_len_wr, raw_sinfo); } #endif /* Returns 1 if no errors found and thus nothing printed; otherwise returns 0. */ int sg_chk_n_print(const char * leadin, int masked_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len, int raw_sinfo) { int scsi_status = (masked_status << 1) & 0x7e; return sg_linux_sense_print(leadin, scsi_status, host_status, driver_status, sense_buffer, sb_len, raw_sinfo); } #ifdef SG_IO int sg_err_category3(struct sg_io_hdr * hp) { return sg_err_category_new(hp->status, hp->host_status, hp->driver_status, hp->sbp, hp->sb_len_wr); } #endif int sg_err_category(int masked_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len) { int scsi_status = (masked_status << 1) & 0x7e; return sg_err_category_new(scsi_status, host_status, driver_status, sense_buffer, sb_len); } int sg_err_category_new(int scsi_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len) { int masked_driver_status = (SG_LIB_DRIVER_MASK & driver_status); scsi_status &= 0x7e; if ((0 == scsi_status) && (0 == host_status) && (0 == masked_driver_status)) return SG_LIB_CAT_CLEAN; if ((SAM_STAT_CHECK_CONDITION == scsi_status) || (SAM_STAT_COMMAND_TERMINATED == scsi_status) || (SG_LIB_DRIVER_SENSE == masked_driver_status)) return sg_err_category_sense(sense_buffer, sb_len); if (0 != host_status) { if ((SG_LIB_DID_NO_CONNECT == host_status) || (SG_LIB_DID_BUS_BUSY == host_status) || (SG_LIB_DID_TIME_OUT == host_status)) return SG_LIB_CAT_TIMEOUT; } if (SG_LIB_DRIVER_TIMEOUT == masked_driver_status) return SG_LIB_CAT_TIMEOUT; return SG_LIB_CAT_OTHER; } #endif sdparm-1.08/Makefile.in0000664000175000017500000005561512144501012013775 0ustar douggdougg# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ 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) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETOPT_O_FILES = @GETOPT_O_FILES@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SGUTILS_LIBS = @SGUTILS_LIBS@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ os_deps = @os_deps@ os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src doc scripts EXTRA_DIST = autogen.sh all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -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 $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(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 --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr distclean-local \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-generic distclean-hdr \ distclean-local distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ tags-recursive uninstall uninstall-am distclean-local: rm -rf autom4te.cache # 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. .NOEXPORT: sdparm-1.08/debian/0000755000175000017500000000000012155115504013145 5ustar douggdouggsdparm-1.08/debian/copyright0000664000175000017500000000236711101162103015075 0ustar douggdouggThis package was debianized by Tomas Fasth on Wed, 8 Jun 2005 23:48:13 +0000. It was downloaded from http://sg.danny.cz/sg/p/sdparm-0.93.tgz Copyright Holder: Douglas Gilbert License: Redistribution and use in source and binary forms, with or without modification, are permitted under the terms of the BSD License. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. On Debian systems, the complete text of the BSD License can be found in `/usr/share/common-licenses/BSD'. sdparm-1.08/debian/docs0000664000175000017500000000006611361072431014023 0ustar douggdouggAUTHORS COPYING CREDITS INSTALL NEWS README ChangeLog sdparm-1.08/debian/control0000664000175000017500000000116511477341055014565 0ustar douggdouggSource: sdparm Section: admin Priority: optional Maintainer: Tomas Fasth Build-Depends: cdbs (>= 0.4.15), debhelper (>= 4.0.0), autotools-dev Standards-Version: 3.9.1 Package: sdparm Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Output and modify SCSI device parameters The sdparm utility outputs and in some cases modifies SCSI device parameters. It can be used to output and modify parameters on any device that uses a SCSI command set. Apart from SCSI disks, such devices include CD/DVD drives (irrespective of transport), SCSI and ATAPI tape drives and SCSI enclosures. sdparm-1.08/debian/changelog0000664000175000017500000000735612154112737015040 0ustar douggdouggsdparm (1.08-0.1) unstable; urgency=low * see ChangeLog -- Douglas Gilbert Thu, 06 Jun 2013 11:00:00 -0400 sdparm (1.07-0.1) unstable; urgency=low * see ChangeLog -- Douglas Gilbert Sun, 21 Jan 2012 14:00:00 -0500 sdparm (1.06-1) unstable; urgency=low * New upstream release. * Updated Standards-Version to 3.9.1. -- Tomas Fasth Sun, 28 Nov 2010 22:07:35 +0000 sdparm (1.06-0.1) unstable; urgency=low * see ChangeLog -- Douglas Gilbert Sun, 31 Oct 2010 15:00:00 -0400 sdparm (1.05-0.1) unstable; urgency=low * see ChangeLog -- Douglas Gilbert Tue, 13 Apr 2010 09:50:00 -0400 sdparm (1.04-0.1) unstable; urgency=low * add SAT ATA Power condition mode page, thin provisioning -- Douglas Gilbert Sun, 20 Sep 2009 18:00:00 +0200 sdparm (1.03-0.1) unstable; urgency=low * allow multiple devices to be given -- Douglas Gilbert Mon, 23 Jun 2008 15:00:00 -0400 sdparm (1.02-1) unstable; urgency=low * New upstream release, maintainer upload to Debian archive. -- Tomas Fasth Mon, 15 Oct 2007 15:19:44 +0000 sdparm (1.02-0.1) unstable; urgency=low * add block device characteristics VPD page -- Douglas Gilbert Mon, 08 Oct 2007 10:00:00 -0400 sdparm (1.01-1) unstable; urgency=low * New upstream release, maintainer upload to Debian archive. -- Tomas Fasth Wed, 23 May 2007 17:47:17 +0000 sdparm (1.01-0.1) unstable; urgency=low * add element address assignment mode page (smc) -- Douglas Gilbert Thu, 05 Apr 2007 23:00:00 -0400 sdparm (1.00-1) unstable; urgency=low * New upstream release, maintainer upload to Debian archive. -- Tomas Fasth Wed, 24 Jan 2007 17:38:59 +0000 sdparm (1.00-0.1) unstable; urgency=low * update Background control mode subpage, vendor specific mode pages -- Douglas Gilbert Mon, 16 Oct 2006 11:00:00 -0400 sdparm (0.99-0.1) unstable; urgency=low * add old power condition page for disks -- Douglas Gilbert Sat, 08 Jul 2006 12:00:00 -0400 sdparm (0.98-1) unstable; urgency=low * New upstream release. -- Tomas Fasth Sun, 14 May 2006 12:20:28 +0000 sdparm (0.98-0.1) unstable; urgency=low * add medium configuration mode page -- Douglas Gilbert Thu, 18 May 2006 22:00:00 -0400 sdparm (0.97-0.1) unstable; urgency=low * add SAT pATA control mode subpage -- Douglas Gilbert Wed, 25 Jan 2006 20:00:00 +1000 sdparm (0.96-1) unstable; urgency=low * New upstream version. * Now building with cdbs (Common Debian Build System). -- Tomas Fasth Sun, 18 Dec 2005 22:48:53 +0000 sdparm (0.96-0.1) unstable; urgency=low * restructure sdparm.c; add capacity, sense and sync commands -- Douglas Gilbert Sat, 19 Nov 2005 15:00:00 +1000 sdparm (0.95-1) unstable; urgency=low * New upstream version. -- Tomas Fasth Tue, 20 Sep 2005 17:17:39 +0000 sdparm (0.95-0.1) unstable; urgency=low * Add debian directory in original sdparm-0.95 -- Douglas Gilbert Tue, 20 Sep 2005 11:00:00 +1000 sdparm (0.94-1) unstable; urgency=low * New upstream version. -- Tomas Fasth Fri, 29 Jul 2005 13:31:13 +0000 sdparm (0.94-0.1) unstable; urgency=low * Track sdparm-0.94 original -- Douglas Gilbert Thu, 28 Jul 2005 22:00:00 +1000 sdparm (0.93-1) unstable; urgency=low * Initial Release. -- Tomas Fasth Wed, 8 Jun 2005 23:48:13 +0000 sdparm-1.08/debian/compat0000664000175000017500000000000211505200742014342 0ustar douggdougg7 sdparm-1.08/debian/rules0000664000175000017500000000031610713740514014227 0ustar douggdougg#!/usr/bin/make -f include /usr/share/cdbs/1/rules/buildcore.mk include /usr/share/cdbs/1/class/autotools.mk include /usr/share/cdbs/1/rules/debhelper.mk #include /usr/share/cdbs/1/rules/simple-patchsys.mk sdparm-1.08/build_debian.sh0000775000175000017500000000057712144501012014665 0ustar douggdougg#!/bin/sh echo "chmod +x debian/rules" chmod +x debian/rules # in some environments the '-rfakeroot' can cause a failure (e.g. when # building as root). If so, remove that argument from the following: echo "dpkg-buildpackage -b -rfakeroot -us -uc" dpkg-buildpackage -b -rfakeroot -us -uc # If the above succeeds then the ".deb" binary package is placed in the # parent directory. sdparm-1.08/config.sub0000775000175000017500000010532712062455663013732 0ustar douggdougg#! /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, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-04-18' # 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 # (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. # Please send patches to . Submit a context # diff and a properly formatted GNU 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. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit 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, 2011, 2012 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." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | 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 \ | 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 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; 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 ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; 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 ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; 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 ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -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. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -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* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -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 ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: sdparm-1.08/doc/0000755000175000017500000000000012155115504012470 5ustar douggdouggsdparm-1.08/doc/Makefile.in0000664000175000017500000003316712145473377014567 0ustar douggdougg# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = doc DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man8dir = $(mandir)/man8 am__installdirs = "$(DESTDIR)$(man8dir)" NROFF = nroff MANS = $(man_MANS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETOPT_O_FILES = @GETOPT_O_FILES@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SGUTILS_LIBS = @SGUTILS_LIBS@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ os_deps = @os_deps@ os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @OS_FREEBSD_TRUE@man_MANS = sdparm.8 sas_disk_blink.8 @OS_LINUX_TRUE@man_MANS = sdparm.8 sas_disk_blink.8 scsi_ch_swp.8 @OS_OSF_TRUE@man_MANS = sdparm.8 sas_disk_blink.8 @OS_SOLARIS_TRUE@man_MANS = sdparm.8 sas_disk_blink.8 @OS_WIN32_CYGWIN_TRUE@man_MANS = sdparm.8 sas_disk_blink.8 @OS_WIN32_MINGW_TRUE@man_MANS = sdparm.8 sas_disk_blink.8 all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-man8: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man8dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.8[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \ done; } uninstall-man8: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man8dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.8[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(MANS) installdirs: for dir in "$(DESTDIR)$(man8dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man8 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man8 .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-man8 install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ uninstall-am uninstall-man uninstall-man8 # 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. .NOEXPORT: sdparm-1.08/doc/scsi_ch_swp.80000664000175000017500000000560612145473377015114 0ustar douggdougg.TH SCSI_CH_SWP "8" "May 2013" "sdparm\-1.08" SDPARM .SH NAME scsi_ch_swp \- change SCSI Software WRITE Protect and block device settings .SH SYNOPSIS .B scsi_ch_swp [\fI\-\-help\fR] [\fI\-\-set 0|1\fR] [\fI\-\-verbose\fR] [\fI\-\-wr\fR] \fIBLK_DEVICE\fR .SH DESCRIPTION .\" Add any additional description here .PP This bash shell script attempts to read or change the Software Write Protect (SWP) bit in the SCSI Control mode page using the sdparm utility. If that change is successful then it uses the blockdev utility to change \fIBLK_DEVICE\fR's read\-write or read\-only setting in sympathy. This script is only available in Linux since the blockdev utility is Linux specific. .PP If changing the SWP bit is supported, setting the SWP bit makes \fIBLK_DEVICE\fR read\-only at the device (disk) itself. Clearing the SWP bit makes \fIBLK_DEVICE\fR read\-write which is usually the default setting at device (disk) power up. .PP If no options are given then the current state of the SWP bit is printed out (using sdparm) together with blockdev's RO bit. If they are both 1 then \fIBLK_DEVICE\fR is in read\-only mode; if they are both 0 then \fIBLK_DEVICE\fR is in read\-write mode. .SH OPTIONS Arguments to long options are mandatory for short options as well. .TP \fB\-h\fR, \fB\-\-help\fR print out the usage message then exit. .TP \fB\-s\fR, \fB\-\-set\fR \fI0|1\fR when 0 is given then the SWP bit in the Control mode page is cleared (i.e. set that bit to 0) using sdparm; and blockdev is used to set \fIBLK_DEVICE\fR to read\-write mode. When 1 is given then the SWP bit in the Control mode page is set using sdparm; and blockdev is used to set \fIBLK_DEVICE\fR to read\-only mode. The default (i.e. when this option is not given) is to read the state of the SWP bit and \fIBLK_DEVICE\fR's read\-only mode and print those values out. .TP \fB\-v\fR, \fB\-\-verbose\fR increase level or verbosity. .TP \fB\-w\fR, \fB\-\-wr\fR when the \fIBLK_DEVICE\fR is in read\-only mode, Linux will not typically allow \fIBLK_DEVICE\fR to be opened read\-write by sdparm, so the default action of this script is to use the sdparm \fI\-\-readonly\fR option when \fI\-\-set 0\fR has been invoked. It is possible that \fIBLK_DEVICE\fR could be a generic device (e.g. /dev/sg3) which has a different interpretation of the read\-only open flag and may fail. For such rare cases the \fI\-\-wr\fR option makes sdparm open \fIBLK_DEVICE\fR read\-write when \fI\-\-set 0\fR is invoked. .SH EXIT STATUS The exit status of this script is 0 when it is successful. Otherwise the exit status is that of the sdparm or the blockdev utility, whichever is called last. See the sdparm(8) man page. .SH AUTHORS Written by D. Gilbert .SH COPYRIGHT Copyright \(co 2013 Douglas Gilbert .br This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH "SEE ALSO" .B sdparm(sdparm), blockdev(8) sdparm-1.08/doc/sdparm.80000664000175000017500000010574412154112737014070 0ustar douggdougg.TH SDPARM "8" "June 2013" "sdparm\-1.08" SDPARM .SH NAME sdparm \- access SCSI modes pages; read VPD pages; send simple SCSI commands. .SH SYNOPSIS .B sdparm [\fI\-\-all\fR] [\fI\-\-clear=STR\fR] [\fI\-\-command=CMD\fR] [\fI\-\-dbd\fR] [\fI\-\-defaults\fR] [\fI\-\-dummy\fR] [\fI\-\-flexible\fR] [\fI\-\-get=STR\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-inquiry\fR] [\fI\-\-long\fR] [\fI\-\-num\-desc\fR] [\fI\-\-page=PG[,SPG]\fR] [\fI\-\-quiet\fR] [\fI\-\-readonly\fR] [\fI\-\-save\fR] [\fI\-\-set=STR\fR] [\fI\-\-six\fR] [\fI\-\-transport=TN\fR] [\fI\-\-vendor=VN\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR [\fIDEVICE\fR...] .PP .B sdparm \fI\-\-enumerate\fR [\fI\-\-all\fR] [\fI\-\-inquiry\fR] [\fI\-\-long\fR] [\fI\-\-page=PG[,SPG]\fR] [\fI\-\-transport=TN\fR] [\fI\-\-vendor=VN\fR] .PP .B sdparm \fI\-\-wscan\fR [\fI\-\-verbose\fR] .SH DESCRIPTION .\" Add any additional description here .PP This utility fetches and potentially changes SCSI device (e.g. disk) mode pages. Inquiry data including Vital Product Data (VPD) pages can also be displayed. Commands associated with starting and stopping the medium; loading and unloading the medium; and other housekeeping function may also be issued by this utility. .PP Of the three invocations shown in the synopsis, the first is the most general. The second variant that uses \fI\-\-enumerate\fR is for dumping information held in sdparm's internal tables. The last variant is for Windows only and lists the available device names; see the OPTIONS entry for \fI\-\-wscan\fR. .PP If no options (other than \fIDEVICE\fR) are given then a selection of common mode page fields for that device are listed. If the \fI\-\-long\fR option is also given then a description of the fields is placed on the right of each line. If the \fI\-\-all\fR option is given then all known mode page fields for that device are listed. Individual fields can be displayed with the \fI\-\-get=STR\fR option (e.g. '\-\-get=WCE' to fetch the state of the Writeback Cache Enable field). .PP This utility completes with an exit status of 0 when successful. For other values see the EXIT STATUS section below. .PP One or more \fIDEVICE\fR arguments can be given. The utility will essentially apply the given options to each \fIDEVICE\fR in the list. If an error is detected, it is noted and the utility continues. Error value 5 (file open or close problem) is treated as lower priority when other errors are detected. The exit status is the most recently detected error value (excluding error value 5 if other errors have been detected). If all actions succeed the exit status is zero. .PP By default this utility shows mode pages that are common to all transport protocols. These are termed as "generic" mode pages. If there is no match on a generic mode page name or field then those pages specific to the SAS transport are checked. Transport protocol specific mode pages are selected with the \fI\-\-transport=TN\fR option. See the TRANSPORT section below. Vendor specific mode pages are selected with the \fI\-\-vendor=VN\fR option. See the VENDORS section below. .PP Although originally for SCSI disks (or storage devices that appear to the OS as SCSI disks) many of the mode pages are for other SCSI device types. These include CD/DVD players that use the ATAPI (or any other) transport, SCSI tapes drives and SCSI enclosures. .PP When the \fI\-\-inquiry\fR option is given without a page number then the Device Identification VPD page (page number 0x83) is requested and if found it is decoded and output. If no page number is given and the \fI\-\-all\fR option is given then a list of VPD page names (but not their contents) supported by the \fIDEVICE\fR is output. When both the \fI\-\-inquiry\fR and \fI\-\-page=PG\fR options are given then the VPD page can be specified as an abbreviation (e.g. "sp" for the SCSI ports VPD page) or numerically (e.g. "0x88"). If a VPD page is returned by the \fIDEVICE\fR but sdparm cannot decode it or the \fI\-\-hex\fR option is given then it is output in hex. .SH OPTIONS Mandatory arguments to long options are mandatory for short options as well. If an option takes a numeric argument then that argument is assumed to be decimal unless otherwise indicated (e.g. with a leading "0x" or a trailing "h"). The options are in alphabetical order, based on the long option name. .TP \fB\-a\fR, \fB\-\-all\fR output all recognized fields for the device type (e.g. disk) of the \fIDEVICE\fR. Without this option (or the \fI\-\-page=PG[,SPG]\fR option) the default action is to output a relatively small number of commonly used fields from different pages. When a specific (mode) page number is given with the \fI\-\-page=PG[,SPG]\fR option then all the fields of that page are output (irrespective of the setting of this option). For this option's action when used with the \fI\-\-enumerate\fR option see the ENUMERATE section below. .TP \fB\-c\fR, \fB\-\-clear\fR=\fISTR\fR In its simplest form \fISTR\fR contains a field acronym_name or a field numerical descriptor. In the absence of an explicit value argument (e.g. '\-\-clear=WCE=1'), the field has its value cleared to zero. See the PARAMETERS section below. .TP \fB\-C\fR, \fB\-\-command\fR=\fICMD\fR Perform given \fICMD\fR. See section below on COMMANDS. To enumerate supported commands use '\-e \-C x' (using any CMD name, valid or otherwise). .TP \fB\-B\fR, \fB\-\-dbd\fR disable block descriptors. This is a bit in MODE SENSE cdbs that rarely needs to be set. One known case is a MODE SENSE 6 issued to a Reduced Block Commands (RBC) device where the RBC standard says it shall be set. .TP \fB\-D\fR, \fB\-\-defaults\fR sets the given mode page to its default values. Requires the \fI\-\-page=PG[,SPG]\fR option to be given to specify the mode page. To make the default mode page values also the saved mode page values, use the \fI\-\-save\fR option as well. .TP \fB\-d\fR, \fB\-\-dummy\fR when set inhibits changes being placed in the \fIDEVICE\fR's mode page. Instead the mode data that would have been sent to a MODE SELECT command, is output in ASCII hex to the console. This option is mainly for testing. .TP \fB\-e\fR, \fB\-\-enumerate\fR lists out descriptive information about the pages and fields known to this utility. Ignores the \fIDEVICE\fR argument and other options apart from the \fI\-\-all\fR, \fI\-\-inquiry\fR, \fI\-\-long\fR, \fI\-\-page=PG[,SPG]\fR, \fI\-\-transport=TN\fR and \fI\-\-vendor=VN\fR. If \fI\-\-enumerate\fR is given without other options then the known (generic) mode pages are listed. See the ENUMERATE section below. .TP \fB\-f\fR, \fB\-\-flexible\fR Some devices, bridges and/or drivers attempt crude transformations between mode sense 6 and 10 byte commands without correctly rebuilding the response. This will cause the response to be mis\-interpreted (usually with an error saying the response is malformed). With this option, the length of the response is checked, and if it looks wrong, various corrections are attempted. This option will also allow mode pages that don't belong to the current device's peripheral type to be listed. .TP \fB\-g\fR, \fB\-\-get\fR=\fISTR\fR In its simplest form \fISTR\fR contains a field acronym_name or a field numerical descriptor. The field is fetched from mode page. See the PARAMETERS section below. The \fI\-\-long\fR and \fI\-\-hex\fR options effect the output format. Also if a value of "1" is given (e.g. '\-\-get=WCE=1') only the current value is output (i.e. not the change mask, the default value and the saved value). .TP \fB\-h\fR, \fB\-\-help\fR output the usage message then exit. .TP \fB\-H\fR, \fB\-\-hex\fR rather than trying to decode mode (or VPD) pages, print them out in hex. When used with the \fI\-\-get=STR\fR option the corresponding current, changeable, default and saved values are output in hex, prefixed by "0x" and space separated. If a value of "1" is given with the \fI\-\-get=STR\fR option (e.g. '\-\-get=WCE=1') then only the current value is output in hex, prefixed by "0x". If a value of "2" is given with the \fI\-\-get=STR\fR option then only the current value is output as a (signed) integer. This option can be used multiple times (e.g. '\-HH'). Useful with the ATA Information VPD page which usually outputs its IDENTIFY (PACKET) DEVICE response in 16 bit hex words; with '\-HH' outputs that response in hex bytes; with '\-HHH' outputs the same response in a format suitable for 'hdparm \-\-Istdin' to decode. .TP \fB\-i\fR, \fB\-\-inquiry\fR output INQUIRY VPD pages. In the absence of this option the default action is to output mode pages. If the \fI\-\-inquiry\fR option is given without the \fI\-\-page=PG[,SPG]\fR option then the device identification VPD page (0x83) is decoded and output. If this option and the \fI\-\-all\fR option are given then the supported VPD pages page (0x0) is decoded and output. .TP \fB\-l\fR, \fB\-\-long\fR output extra information. In the case of mode page fields a description (with units if applicable) is output to the right. If used twice, then for some fields more information about its values is given on one or more following lines, each prefixed by a tab character. For usage with \fI\-\-enumerate\fR see the ENUMERATE section below. .TP \fB\-n\fR, \fB\-\-num\-desc\fR for a mode page that can have descriptors, the number of descriptors for the given page on the \fIDEVICE\fR is output. Otherwise 0 is output. .TP \fB\-p\fR, \fB\-\-page\fR=\fIPG[,SPG]\fR supply the page number (\fIPG\fR) and optionally the sub page number (\fISPG\fR) of the mode (or VPD) page to fetch. These numbers are interpreted as decimal unless prefixed with "0x" or a trailing. Sub page numbers are only valid for mode pages (not VPD pages). Alternatively an abbreviation for a page can be given (see next entry). .TP \fB\-p\fR, \fB\-\-page\fR=\fISTR\fR a two or three letter abbreviation for a page can be given. Known mode page abbreviations are checked first followed by known VPD page abbreviations. For example '\-\-page=ca' matches the caching mode page. If no match is found then an error is issued and a list of possibilities in the current context is given (so '\-p x' can be quite useful). If the \fISTR\fR matches a known VPD page abbreviation then the \fI\-\-inquiry\fR option is assumed. For usage with \fI\-\-enumerate\fR see the ENUMERATE section below. .TP \fB\-q\fR, \fB\-\-quiet\fR suppress output of device name followed by the vendor, product and revision strings fetched from an INQUIRY response. Without this option such a line is typically the first line output by sdparm. Reduces output from the device identification VPD page, typically to one line (or none) for each of di_lu, di_port, di_target and di_asis. .TP \fB\-r\fR, \fB\-\-readonly\fR override other logic to open \fIDEVICE\fR in read\-only mode. The default setting of the open read\-only/read\-write mode depends on the operation requested (e.g. a \fI\-\-set=STR\fR operation by default will try a read\-write mode open on \fIDEVICE\fR). This option may be useful if a command is being sent to an ATA disk via a SCSI command set. For example in Linux '\-C stop' may require this option to stop an ATA disk being restarted immediately. .TP \fB\-S\fR, \fB\-\-save\fR when a mode page is being modified (by using the \fI\-\-clear=STR\fR and/or \fI\-\-set=STR\fR options) then the default action is to modify only the current values mode page. When this option is given then the corresponding value(s) in the saved values mode page is also changed. The next time the device is power cycled (or reset) the saved values mode page becomes (i.e. is copied to) the current values mode page. See NOTES section below. .TP \fB\-s\fR, \fB\-\-set\fR=\fISTR\fR in its simplest form \fISTR\fR contains a field acronym_name or a field numerical descriptor. In the absence of an explicit value, each acronym_name has its value set to (all) ones. This means a 16 bit field will be set to 0xffff which is 65535 in decimal. Alternatively each acronym_name or numerical descriptor may be followed by "=" where is the value to set that field to. See the PARAMETERS section below. .TP \fB\-6\fR, \fB\-\-six\fR The default action of this utility is to issue MODE SENSE and MODE SELECT SCSI commands with 10 byte cdbs. When this option is given the 6 byte cdb variants are used. RBC and old SCSI devices may need this option. This utility outputs a suggestion to use this option if the SCSI status indicates that the 10 byte cdb variant is not supported. .TP \fB\-t\fR, \fB\-\-transport\fR=\fITN\fR Specifies the transport protocol where \fITN\fR is either a number in the range 0 to 15 (inclusive) or an abbreviation (e.g. "fcp" for the Fibre Channel Protocol). One way to list available transport protocols numbers and their associated abbreviations is to give an invalid transport protocol number such as '\-t x'; another way is '\-e \-l'. .TP \fB\-M\fR, \fB\-\-vendor\fR=\fIVN\fR Specifies the vendor (i.e. manufacturer) where \fIVN\fR is either a number (0 or more) or an abbreviation (e.g. "sea" for Seagate disk vendor specific). One way to list available vendor numbers and their associated abbreviations is to give an invalid vendor number such as '\-M x'; another way is '\-e \-l'. .TP \fB\-v\fR, \fB\-\-verbose\fR increase the level of verbosity, (i.e. debug output). In some cases more decoding is done (e.g. fields within a standard INQUIRY response). .TP \fB\-V\fR, \fB\-\-version\fR print the version string and then exit. .TP \fB\-w\fR, \fB\-\-wscan\fR this option is available in Windows only. It lists storage device names and the corresponding volumes, if any. When used twice it adds the "bus type" of the closest transport (e.g. a SATA disk in a USB connected enclosure has bus type Usb). When used three times a SCSI adapter scan is added. When used four times only a SCSI adapter scan is shown. See examples below and the "Win32 port" section in the README file. .SH NOTES The reference document used for interpreting mode and VPD pages (and the INQUIRY standard response) is T10/1713\-D Revision 36e (SPC\-4, 24 August 2012) found at http://www.t10.org . Obsolete and reserved items in the standard INQUIRY response output are displayed in brackets. .PP A mode page for which no abbreviation is known (e.g. a vendor specific mode page) can be listed in hexadecimal by using the option combination '\-\-page=PG \-\-hex'. .PP Numbers input to sdparm (e.g. in the command line arguments) are assumed to be in decimal unless there is a hexadecimal indicator. A hexadecimal indicator is either a leading '0x' or '0X' (i.e. the C language convention) or a trailing 'h' or 'H' (i.e. the convention used at www.t10.org ). In the case of \fI\-\-page\fR= either a string or number is expected, so hex numbers like 'ch' (12) should be prefixed by a zero (e.g. '0ch'). .PP The SPC\-4 draft (rev 2) says that devices that implement no distinction between current and saved pages can return an error (ILLEGAL REQUEST, invalid field in cdb) if the SP bit (which corresponds to the \fI\-\-save\fR option) is _not_ set. In such cases the \fI\-\-save\fR option needs to be given. .PP If the \fI\-\-save\fR option is given but the existing mode page indicates (via its PS bit) that the page is not savable, then this utility generates an error message. That message suggests to try again without the \fI\-\-save\fR option. .PP Since the device identification VPD page (acronym_name "di") potentially contains a lot of diverse designators, several associated acronyms are available. They are "di_lu" for designators associated with the addressed logical unit, "di_port" for designators associated with the target port (which the command arrived via) and "di_target" for designators associated with the target device. When "di" is used designators are grouped by lu, then port and then target device. To see all designators decoded in the order that they appear in the VPD page use "di_asis". .PP Only those VPD pages defined by t10.org are decoded by this utility. SPC\-4 sets aside VPD pages codes from 0xc0 to 0xff (inclusive) for vendor specific pages some of which are decoded in the sg_vpd utility. .PP In the linux kernel 2.6 series any device node that understands a SCSI command set (e.g. SCSI disks and CD/DVD drives) may be specified. More precisely the driver that "owns" the device node must support the SG_IO ioctl. In the lk 2.4 series only SCSI generic (sg) device nodes support the SG_IO ioctl. However in the lk 2.4 series other SCSI device nodes are mapped within this utility to their corresponding sg device nodes. So if there is a SCSI disk at /dev/sda then 'sdparm /dev/sda' will work in both the lk 2.6 and lk 2.4 series. However if there is an ATAPI cd/dvd drive at /dev/hdc then 'sdparm /dev/hdc' will only work in the lk 2.6 series. .PP In the Linux 2.6 series, especially with ATA disks, using sdparm to stop (spin down) a disk may not be sufficient and other mechanisms will start the disk again some time later. The user might additionally mark the disk as "offline" with 'echo offline > /sys/block/sda/device/state' where sda is the block name of the disk. To restart the disk "offline" can be replaced with "running". .SH PARAMETERS In their simplest form the \fI\-\-clear\fR=, \fI\-\-get\fR= and \fI\-\-set\fR= options (or their short forms) take an acronym_name such as "WCE". In the case of '\-\-get=WCE' the value of "Writeback Cache Enable" in the caching mode page will be fetched. In the case of '\-\-set=WCE' that bit will be set (to one). In the case of '\-\-clear=WCE' that bit will be cleared (to zero). When an acronym_name is given then the mode page is imputed from that acronym_name (e.g. WCE is in the caching mode page). .PP Instead of an acronym_name a field within a mode page can be described numerically with a :: tuple. These are the (origin 0) within the mode page, a (0 to 7 inclusive) and (1 to 64 inclusive). For example, the low level representation of the RCD bit (the "Read Cache Disable bit in the caching mode page) is "2:0:1". The can optionally be given in hex (e.g. '\-\-set=0x2:0:1' or '\-\-set=2h:0:1'). With this form the \fI\-\-page\fR= option is required to establish which mode page is to be used. .PP Either form can optionally be followed by "=". By default is decimal but can be given in hex in the normal fashion. Here are some examples: '\-\-set=2h:0:1=1h' and '\-s MRIE=0x3'. When the acronym_name or numeric form following \fI\-\-clear\fR= is not given an explicit '=' then the value defaults to zero. When the acronym_name or numeric form following \fI\-\-set\fR= is not given an explicit '=' then the value defaults to "all ones" (i.e. as many as permits). For example '\-\-clear=WCE' and '\-\-clear=WCE=0' have the same meaning: clear Writeback Cache Enable or, put more simply: turn off the writeback cache. .PP Multiple fields within the same mode page can be changed by giving a comma separated list of acronym_names and/or the numerical form. For example: '\-\-set=TEST,MRIE=6'. .PP Some mode page have multiple descriptors. They typically have a fixed header section at the start of the mode page that includes a field containing the number of descriptors that follow. Following the header is a variable number of descriptors. An example is the SAS Phy Control and Discover mode page. An acronym_name may include a trailing '.' where "" is a descriptor number (origin 0). For example '\-t sas \-g PHID.0' and '\-t sas \-g PHID' will yield the phy identifier of the first descriptor of the above mode page; '\-t sas \-g PHID.1' will yield the phy identifier of the second descriptor. .SH ENUMERATE The \fI\-\-enumerate\fR option essentially dumps out static information held by this utility. A list of \fI\-\-enumerate\fR variants and their actions follows. For brevity subsequent examples of options are shown in their shorter form. .PP \-\-enumerate list generic mode page information .br \-e \-\-all list generic mode page contents .br (i.e. parameters) .br \-e \-\-page=rw list contents of read write error .br recovery mode page .br \-e \-\-inquiry list VPD pages this utility can decode .br \-e \-\-long list generic mode pages, transport .br protocols, mode pages for each .br supported transport protocol and .br supported commands .br \-e \-l \-\-all additionally list the contents of .br each mode page .br \-e \-\-transport=fcp list mode pages for the fcp .br transport protocol .br \-e \-t fcp \-\-all additionally list the contents of .br each mode page .br \-e \-\-vendor=sea list vendor specific mode pages for .br "sea" (Seagate) .br \-e \-M sea \-\-all additionally list the contents of vendor .br specific mode pages for "sea" (Seagate) .br \-e \-p pcd \-l list contents of SAS phy control and .br discovery mode page plus (due to "\-l") .br some descfriptor format information .PP When known mode pages are listed (via the \fI\-\-enumerate \fR option) each line starts with a two or three letter abbreviation. This is followed by the page number (in hex prefixed by "0x") optionally followed by a comma and the subpage number. Finally the descriptive name of the mode page (e.g. as found in SPC\-4) is output. .PP When known parameters (fields) of a mode page are listed, each line starts with an acronym (indented a few spaces). This will match (or be an acronym for) the description for that field found in the (draft) standards. Next are three numbers, separated by colons, surrounded by brackets. These are the start byte (in hex, prefixed by "0x") of the beginning of the field within the mode page; the starting bit (0 through 7 inclusive) and then the number of bits. The descriptive name of the parameter (field) is then given. If appropriate the descriptive name includes units (e.g. "(ms)" means the units are milliseconds). Adding the '\-ll' option will list information about possible field values for selected mode page parameters. .PP Mode parameters for which the num_bits is greater than 1 can be viewed as unsigned integers. Often 16 and 32 bit fields are set to 0xffff and 0xffffffff respectively (all ones) which usually has a special meaning (see drafts). This utility outputs such values as "\-1" to save space (rather than their unsigned integer equivalents). "\-1" can also be given as the value to a mode page field acronym (e.g. '\-\-set=INTT=\-1' sets the interval timer field in the Informational Exceptions control mode page to 0xffffffff). .SH TRANSPORTS SCSI transport protocols are a relatively specialized area that can be safely ignored by the majority of users. .PP Some transport protocols have protocol specific mode pages. These are usually the disconnect\-reconnect (0x2), the protocol specific logical unit (0x18) and the protocol specific port (0x19) mode pages. In some cases the latter mode page has several subpages. The most common transport protocol abbreviations likely to be used are "fcp", "spi" and "sas". .PP Many of the field names are re\-used in the same position so the acronym_name namespaces have been divided between generic mode pages (i.e. when the \fI\-\-transport\fR= option is _not_ given) and a namespace for each transport protocol. A LUPID field from the protocol specific logical unit (0x18) mode page and the PPID field from protocol specific port (0x19) mode page are included in the generic modes pages; this is so the respective (transport) protocol identifiers can be seen. In most cases the user will know what the "port" transport is (i.e. the same transport as the HBA in the computer) but the logical unit's transport could be different. .SH VENDORS SCSI leaves a lot of space for vendor specific information. Often this is described in product manuals. The \fI\-\-vendor=VN\fR (or \fI\-M=VN\fR) option allows known vendor specific mode pages to be examined and/or modified by acronym. .PP In this utility the syntax and semantics of vendor specific mode pages is very similar to those of transport protocol specific mode pages. Both cannot be specified together. Vendor specific modes pages can still be accessed numerically (as shown at the end of the EXAMPLES section). .SH COMMANDS The command option sends a SCSI command to the \fIDEVICE\fR. If the command fails then this is reflected in the non\-zero exit status. To obtain more information about the error use the \fI\-v\fR option. .TP capacity sends a READ CAPACITY command (valid for disks and cd/dvd media). If successful yields "blocks: " [the number of blocks], "block_length: " [typically either 512 or 2048] and "capacity_mib: " [capacity in MibiBytes (1048576 byte units)]. .TP eject stops the medium and ejects it from the device. Note that ejection (by command or button) may be prevented in which case the 'unlock' command may be useful in extreme cases. Typically only appropriate for cd/dvd drives and disk drives with removable media. Objects if sent to another peripheral device type (but objection can be overridden with '\-f' option). .TP load loads the medium and and starts it (i.e. spins it up). See 'eject' command for supported device types. .TP profile lists the various formats that a CD/DVD/HD\-DVD/BD drive supports. These are called "profiles" in the MMC standard. The profiles are listed one per line. If media is in the drive then the profile that matches the media (if any) has an "*" to the right of the line. .TP ready sends the "Test Unit Ready" SCSI command to the \fIDEVICE\fR. No error is reported if the device will respond to data requests (e.g. READ) in a reasonable timescale. For example, if a disk is stopped then it will report "not ready". All devices should respond to this command. .TP sense sends a REQUEST SENSE command. It reports a hardware threshold exceeded, warning or low power condition if flagged. If a progress indication is present (e.g. during a format) then it will be output as a percentage. Yields a process status of 0 if the command succeeds and the sense key is 0; else yields 1. The \fI\-\-quiet\fR option can be used to lessen output, and \fI\-\-hex\fR to output sense data in hex. .TP speed=SPEED permits the speed of a CD, DVD, HD_DVD or BD disc in a drive to be set (or at least influenced). It has this format: \fI\-\-command=speed=SPEED\fR where SPEED is in kilobytes per second. In this case a kilobyte is 1000 bytes. The "times one" speed for a CD is 176.4 kB/s, for a DVD is 1350 kB/s and for both HD\-DVD and BD it is 4500 kB/s. If SPEED is zero then the drive is set to the speed that it considers gives optimal performance. This command sends a SET STREAMING multi\-media command (MMC) to the drive. The EXACT bit is clear so the drive will round the given SPEED as necessary. The command is designed to control read speed; setting write speed should be left to "burning" programs. .TP start starts the medium (i.e. spins it up). Harmless if medium has already been started. See 'eject' command for supported device types. If the \fIDEVICE\fR is an ATA disk in Linux the '\-\-readonly' option may be required. .TP stop stops the medium (i.e. spins it down). Harmless if medium has already been stopped. See 'eject' command for supported device types. If the \fIDEVICE\fR is an ATA disk in Linux the '\-\-readonly' option may be required. See the NOTES section above. .TP sync sends a SYNCHRONIZE CACHE command. The device should flush any data held in its (volatile) buffers to the media. .TP unlock tells a device to allow medium removal. It uses the SCSI "prevent allow medium removal" command. This is desperation stuff, possibly overriding a prevention applied by the OS on a mounted file system. The "eject" utility (from the "eject" package) is more graceful and should be tried first. This command is only appropriate for devices with removable media. .PP For loading and ejecting tapes the mt utility should be used (i.e. not these commands). The 'ready' command is valid for tape devices. .SH EXAMPLES To list the common (generic) mode parameters of a disk: .PP sdparm /dev/sda .PP To list the designators within the device identification VPD page of a disk: .PP sdparm \-\-inquiry /dev/sda .PP To see all parameters for the caching mode page: .PP sdparm \-\-page=ca /dev/sda .PP To see all parameters for the caching mode page with parameter descriptions to the right: .PP sdparm \-\-page=ca \-\-long /dev/sda .PP To get the WCE values (current changeable default and saved) in hex: .PP sdparm \-g WCE \-H /dev/sda .br 0x01 0x00 0x01 0x01 .PP To get the WCE current value in hex: .PP sdparm \-g WCE=1 \-H /dev/sda .br 0x01 .PP To set the "Writeback Cache Enable" bit in the current values page: .PP sdparm \-\-set=WCE /dev/sda .PP To set the "Writeback Cache Enable" bit in the current and saved values page: .PP sdparm \-\-set=WCE \-\-save /dev/sda .PP To set the "Writeback Cache Enable" and clear "Read Cache Disable": .PP sdparm \-\-set=WCE \-\-clear=RCD \-\-save /dev/sda .PP The previous example can also by written as: .PP sdparm \-s WCE=1,RCD=0 \-S /dev/sda .PP To re\-establish the manufacturer's defaults in the current and saved values of the caching mode page: .PP sdparm \-\-page=ca \-\-defaults \-\-save /dev/sda .PP If an ATAPI cd/dvd drive is at /dev/hdc then its common (mode) parameters could be listed in the lk 2.6 series with: .PP sdparm /dev/hdc .PP If there is a DVD in the drive at /dev/hdc then it could be ejected in the lk 2.6 series with: .PP sdparm \-\-command=eject /dev/hdc .PP If the ejection is being prevented by software then that can be overridden with: .PP sdparm \-\-command=unlock /dev/hdc .PP One disk vendor has a "Performance Mode" bit (PM) in the vendor specific unit attention mode page [0x0,0x0]. PM=0 is server mode (the default) while PM=1 is desktop mode. Desktop mode can be set (both current and saved values) with: .PP sdparm \-\-page=0 \-\-set=2:7:1=1 \-\-save /dev/sda .PP The resultant change can be viewed in hex with the \fI\-\-hex\fR option as there are no acronyms for vendor extensions yet. The PM bit is now covered by vendor specific mode pages and the above can also be accomplished with: .PP sdparm \-\-vendor=sea \-\-set=PM \-\-save /dev/sda .PP What follows are some examples from Windows using the '\-\-wscan' option. The idea is to list the storage device names on the system that might be invoked by other uses of sdparm. .PP # sdparm \-\-wscan .br PD0 [C] FUJITSU MHY2160BH 0000 .br PD1 [DF] WD 2500BEV External 1.05 WD\-WXE90 .br CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03 .PP So 'sdparm \-a CDROM0' and 'sdparm \-a E' will show all the (known) mode page fields for the Matshita DVD/CD drive. By using the '\-\-wsacan' option twice, the bus type (as seen by the OS) is added to the output: .PP # sdparm \-ww .br PD0 [C] FUJITSU MHY2160BH 0000 .br PD1 [DF] WD 2500BEV External 1.05 WD\-WXE90 .br CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03 .PP And the pattern continues to add a SCSI adapter scan. This may be useful if there are specialized storage related devices (e.g. a SES device in an enclosure) but does add much extra information in this case. .PP # sdparm \-www .br PD0 [C] FUJITSU MHY2160BH 0000 .br PD1 [DF] WD 2500BEV External 1.05 WD\-WXE90 .br CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03 .br .br SCSI0:0,0,0 claimed=1 pdt=0h FUJITSU MHY2160BH 0000 .br SCSI1:0,0,0 claimed=1 pdt=5h MATSHITA DVD/CDRW UJDA775 CB03 .PP .SH EXIT STATUS To aid scripts that call sdparm, the exit status is set to indicate success (0) or failure (1 or more). Note that some of the lower values correspond to the SCSI sense key values. The exit status values are: .TP .B 0 success .TP .B 1 syntax error. Either illegal command line options, options with bad arguments or a combination of options that is not permitted. .TP .B 2 the \fIDEVICE\fR reports that it is not ready for the operation requested. The device may be in the process of becoming ready (e.g. spinning up but not at speed) so the utility may work after a wait. .TP .B 3 the \fIDEVICE\fR reports a medium or hardware error (or a blank check). For example an attempt to read a corrupted block on a disk will yield this value. .TP .B 5 the \fIDEVICE\fR reports an "illegal request" with an additional sense code other than "invalid operation code". This is often a supported command with a field set requesting an unsupported capability. For commands that require a "service action" field this value can indicate that the command is not supported. .TP .B 6 the \fIDEVICE\fR reports a "unit attention" condition. This usually indicates that something unrelated to the requested command has occurred (e.g. a device reset) potentially before the current SCSI command was sent. The requested command has not been executed by the device. Note that unit attention conditions are usually only reported once by a device. .TP .B 9 the \fIDEVICE\fR reports an illegal request with an additional sense code of "invalid operation code" which means that it doesn't support the requested command. .TP .B 11 the \fIDEVICE\fR reports an aborted command. In some cases aborted commands can be retried immediately (e.g. if the transport aborted the command due to congestion). .TP .B 15 the utility is unable to open, close or use the given \fIDEVICE\fR. The given file name could be incorrect or there may be permission problems. Adding the \fI\-v\fR option may give more information. .TP .B 20 the \fIDEVICE\fR reports it has a check condition but "no sense". Some polling commands (e.g. REQUEST SENSE) can react this way. It is unlikely that this value will occur as an exit status. .TP .B 21 the \fIDEVICE\fR reports a "recovered error". The requested command was successful. Most likely a utility will report a recovered error to stderr and continue, probably leaving the utility with an exit status of 0 . .TP .B 33 the command sent to \fIDEVICE\fR has timed out. This occurs in Linux only; in other ports a command timeout will appear as a transport (or OS) error. .TP .B 97 the response to a SCSI command failed sanity checks. .TP .B 98 the \fIDEVICE\fR reports it has a check condition but the error doesn't fit into any of the above categories. .TP .B 99 any errors that can't be categorized into values 1 to 98 may yield this value. This includes transport and operating system errors after the command has been sent to the device. .PP Most of the error conditions reported above will be repeatable (an example of one that is not is "unit attention") so the utility can be run again with the \fI\-v\fR option (or several) to obtain more information. .SH AUTHORS Written by Douglas Gilbert. .SH "REPORTING BUGS" Report bugs to . .SH COPYRIGHT Copyright \(co 2005\-2013 Douglas Gilbert .br This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH WEB SITE There is a web page discussing this package at http://sg.danny.cz/sg/sdparm.html . .SH "SEE ALSO" .B hdparm(hdparm), .B sg_modes, sg_wr_mode, sginfo, sg_inq, sg_vpd(all in sg3_utils), .B smartmontools(smartmontools.sourceforge.net), mt, eject(eject), sdparm-1.08/doc/Makefile.am0000664000175000017500000000057112145473377014547 0ustar douggdougg if OS_LINUX man_MANS = sdparm.8 sas_disk_blink.8 scsi_ch_swp.8 endif if OS_WIN32_MINGW man_MANS = sdparm.8 sas_disk_blink.8 endif if OS_WIN32_CYGWIN man_MANS = sdparm.8 sas_disk_blink.8 endif if OS_FREEBSD man_MANS = sdparm.8 sas_disk_blink.8 endif if OS_SOLARIS man_MANS = sdparm.8 sas_disk_blink.8 endif if OS_OSF man_MANS = sdparm.8 sas_disk_blink.8 endif sdparm-1.08/doc/sas_disk_blink.80000664000175000017500000000307412144501012015535 0ustar douggdougg.TH SAS_DISK_BLINK "8" "May 2013" "sdparm\-1.08" SDPARM .SH NAME sas_disk_blink \- blink the LED on a SAS disk .SH SYNOPSIS .B sas_disk_blink [\fI\-\-help\fR] [\fI\-\-set NUM\fR] [\fI\-\-verbose\fR] \fIDEVICE\fR .SH DESCRIPTION .\" Add any additional description here .PP This bash shell script attempts to blink the LED on the SAS disk referred to by \fIDEVICE\fR. By default the LED will blink for 30 seconds. This is meant to help identify which disk corresponds to a given \fIDEVICE\fR. .PP The script use the sdparm utility and manipulates the "Ready LED Meaning" (RLM) field in the Protocol specific port mode page in order to blink the LED. .SH OPTIONS Arguments to long options are mandatory for short options as well. .TP \fB\-h\fR, \fB\-\-help\fR print out the usage message then exit. .TP \fB\-s\fR, \fB\-\-set\fR \fINUM\fR when \fINUM\fR is 0 then the RLM field is cleared. When \fINUM\fR is 1 then the RLM field is set. When \fINUM\fR > 1 then the SAS disk LED is made to blink for \fINUM\fR seconds. If this option is not given then the SAS disk LED is made to blink for 30 seconds. .TP \fB\-v\fR, \fB\-\-verbose\fR increase level or verbosity. .SH EXIT STATUS The exit status of this script is 0 when it is successful. Otherwise the exit status is that of the last sdparm utility called. See the sdparm(8) man page. .SH AUTHORS Written by D. Gilbert .SH COPYRIGHT Copyright \(co 2013 Douglas Gilbert .br This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH "SEE ALSO" .B sdparm (sdparm) sdparm-1.08/README0000664000175000017500000003054712154112737012622 0ustar douggdouggIntroduction ------------ sdparm is a utility for listing and potentially changing SCSI disk parameters. More generally it can be used on any device that uses a SCSI command set. Apart form SCSI disks, examples of devices that use SCSI command sets are ATAPI CD/DVD drives, SCSI and ATAPI tape drives and SCSI enclosures. This utility was originally written for Linux. It has been ported to FreeBSD, Solaris, Tru64, and Windows. Relationship to sg3_utils ------------------------- This package shares code with sg3_utils (version 1.33). With the subversion revision control system this is done by having sdparm's "include/" and "lib/" subdirectories pointing to the correspondingly named directories in the sg3_utils package using the "svn:externals" property. These two "external" directories include more files than sdparm uses. The excess files include "lib/Makefile.am" and "lib/Makefile.in". The "Makefile.am" in sdparm's "src/" directory does the main part of the build. When the tarball is generated for this utility, various files are "exported" out of the subversion repository and "svn:externals" redirection is no longer visible (but the unused files are visible). The sdparm executable may or may not be built depending on the libsgutils (shared) library. Currently the ./configure rules are looking for a library called libsgutils2.a or libsgutils2.so . In Debian those libraries are found only in the libsgutils2-dev package, not the libsgutils2 package. If one of those libraries is detected then sdparm will be built depending on libsgutils (check 'ldd sdparm'). If neither of those libraries is detected at build time, then the sdparm executable built will compile and link the relevant code from its "include/" and "lib/" subdirectories. Documentation ------------- The utility outputs a usage message when the "--help" (or '-h' or '-?') option is given. Many syntax errors also result in the usage message being printed. There is also a man page which is in section 8 (administration and privileged commands). It can be accessed with "man sdparm" once this package is installed. Prior to installation the man page can be viewed from this package's main directory with "man doc/sdparm.8". There is a web page about this utility at http://sg.danny.cz/sg/sdparm.html . Build infrastructure -------------------- This packages uses the automake and autoconf tools. The generating files (scripts) are configure.ac, Makefile.am, src/Makefile.am and autogen.sh . The autogen.sh script only needs to be executed if one of the other generating files in the above list is changed. There is a rpm "spec" file in the main directory: sdparm.spec . There are Debian build files in the "debian" directory and a script called build_debian.sh in the main directory. If build_debian.sh fails due to compatibility level. Amongst other things debian builds are sensitive to the value in the debian/compat file. If it contains "7" then it works on lenny and gives warning on squeeze (but fails on the earlier etch). The ./configure script contains two extra options: '--disable-linuxbsg' and '--disable-scsistrings'. The former drops Linux bsg driver support which should no longer be necessary. The latter option drops asc/ascq and command name strings (defined by SCSI) in an attempt to reduce the size of the executable. License ------- This utility is covered by a FreeBSD license. The intention of the author is that both open source and commercial entities can re-use this code. Naturally credit and improvement/bug feedback are encouraged. The part of this code that others may be able to re-use is the information in the tables in sdparm_data.c , sg_lib.c and sg_lib_data.c . This is information garnered from SCSI drafts and standards at http://www.t10.org (plus some information from the ATA drafts and standards at http://www.t13.org ). Vendor specific mode page information is found in the sdparm_data_vendor.c file and is derived from vendor product manuals. Notes ----- Generic information about building this package (i.e. './configure ; make; make install') can be found in the INSTALL file. The contents of the COPYING file is a FreeBSD license (rather than the GPL v2 found in the usual template). Linux port ---------- The utility can be used on any device that supports the SG_IO ioctl. In the Linux 2.4 series that is only the scsi generic (i.e. /dev/sg* ) device nodes. In the Linux 2.6 series the supported device nodes has expanded to all other SCSI device nodes (e.g. /dev/sd* and /dev/sr*) plus block devices such as /dev/hdc when the associated device is a DVD drive. The man page and sg.danny.cz/sg/sdparm.html web page examples use Linux device node names. FreeBSD port ------------ Virtually all of sdparm's features work with FreeBSD. SCSI commands are routed through the CAM pass through interface. The author tested sdparm with FreeBSD version 5.3 and found SCSI disks worked with the "da" device (e.g. 'sdparm /dev/da0'). SCSI tape drives can be accessed via the "sa" device via /dev nodes starting with "esa", "nsa" and "sa". To access cd/dvd drives, the kernel needs to be build with the "atapicam" device after which access is via the "cd" device. Other SCSI devices are "ses" (for enclosure services), "ch" (media changer (for tapes)), and "pr" for processor device type (e.g. SAF-TE devices). All these device may also be accessed via the "pass" device. To see the mapping between the "pass" device name and the corresponding higher level device node try "camcontrol devlist". The traditional './configure ; make ; make install' sequence from the top level of the unpacked tarball will work on FreeBSD. But the man pages will be placed under the /usr/local/share/man directory which unfortunately is not on the standard manpath. One solution is to add this path by creating a file with a name like local_share.conf in the /usr/local/etc/man.d/ directory and placing this line in it: MANPATH /usr/local/share/man FreeBSD 9.0 has a "ports" entry for sdparm under the /usr/ports/sysutils directory. It points to version 1.06 of sdparm. It could be used as a template to point to more recent versions. sdparm can be built into a Debian package for kFreeBSD using the ./build_debian.sh script in the top level directory. This has been tested with Debian 6.0 release. Solaris port ------------ The uscsi pass-through mechanism is used and is only available on SCSI devices. There seems to be no corresponding ATA pass through and recent SATA disks do not seem to have a SAT layer in front of them (within Solaris). If SAT is present (perhaps externally or within a HBA) then that would allow SATA disks to accept SCSI commands including the SCSI ATA PASS THROUGH commands. SCSI device names below the '/dev' directory have a form like: c5t4d3s2 where the number following "c" is the controller (HBA) number, the number following "t" is the target number (from the SCSI parallel interface days) and the number following "d" is the LUN. Following the "s" is the slice number which is related to a partition and by convention "s2" is the whole disk. OpenSolaris also has a c5t4d3p2 form where the number following the "p" is the partition number apart from "p0" which is the whole disk. So a whole disk may be referred to as either: - c5t4d3 - c5t4d3s2 - c5t4d3p0 And these device names are duplicated in the /dev/dsk and /dev/rdsk directories. The former is the block device name and the latter is for "raw" (or char device) access which is what sdparm needs. So in openSolaris something of the form: sdparm /dev/rdsk/c5t4d3p0 should work. If it doesn't add a '-vvv' option. If that is attempted on the /dev/dsk/c5t4d3p0 variant an inappropriate ioctl for device error will result. The device names within the /dev directory are typically symbolic links to much longer topological names in the /device directory. In Solaris cd/dvd/bd players seem to be treated as disks and so are found in the /dev/rdsk directory. Tape drives appear in the /dev/rmt directory. There is also a sgen (SCSI generic) driver which by default does not attach to any device. See the /kernel/drv/sgen.conf file to control what is attached. Any attached device will have a device name of the form /dev/scsi/c5t4d3 . Listing available SCSI devices in Solaris seems to be a challenge. "Use the 'format' command" advice works but seems a very dangerous way to list devices. [It does prompt again before doing any damage.] 'devfsadm -Cv' cleans out the clutter in the /dev/rdsk directory, only leaving what is "live". The "cfgadm -v" command looks promising. Tru64 (osf) port ---------------- Any feedback on this platform welcome. Win32 port ---------- This port supports Windows NT, 2000, 2003++, XP, Vista and Windows 7 (i.e. not 95, 98, ME or earlier). It uses the Microsoft SCSI Pass Through "Direct" (SPTD) rather than ASPI32 which requires a dll from Adaptec. The source can be built in a cygwin environment and can run in a cygwin bash shell. It can also run in a DOS shell if the cygwin1.dll is put in an appropriate place. Alternatively the source can be built with the MinGW compiler using its MSYS shell. This removes the dependence on the cygwin1.dll file. The device naming schemes attempt to follow what DOS does, with a few short cuts. If volume "D:" is an ATAPI DVD drive then the actual file opened is "\\.\D:". All device nodes of interest to sdparm have a leading "\\.\" so if the user doesn't supply it, sdparm will. Thus 'sdparm d:' should work. Note that volume names map to Windows partitions so there can be multiple volume names per disk. SCSI devices (or those that use a SCSI command set) can also be accessed via their "class" driver. These have names like "PhysicalDrive", "CDROM" and "TAPE" where is a number starting at 0. Since "PhysicalDrive" is tedious to type, a shortened form "PD" is accepted. So if "PD3" is a SCSI disk (or a SATA disk behind a SAT layer) then 'sdparm pd3' should work. Finally there is a lower level "SCSI:" interface that addresses a SCSI adapter. The device needs further sub-addressing in the form of a bus number (also called a PathId), a target identifier and a lun (logical unit number). sdparm uses this notation: "SCSI:,,". The trailing "," may be omitted in which case a lun of 0 is assumed. Once a device has been "claimed" by an upper level "class" driver the OS will not allow it to be accessed via the "SCSI:" interface. Hence this is only needed for special devices (e.g. with processor or SES peripheral device type) that are not claimed by the class drivers. The '--wscan' (or '-w') option has been added to show the mapping between a class driver device name and its associated volume name(s). Here are some examples: $ sdparm -w PD0 [C] FUJITSU MHY2160BH 0000 PD1 [DF] WD 2500BEV External 1.05 WD-WXE90 CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03 Now request bus types as well. $ sdparm -ww PD0 [C] FUJITSU MHY2160BH 0000 PD1 [DF] WD 2500BEV External 1.05 WD-WXE90 CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03 Now request a SCSI adapter scan as well. $ sdparm -www PD0 [C] FUJITSU MHY2160BH 0000 PD1 [DF] WD 2500BEV External 1.05 WD-WXE90 CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03 SCSI0:0,0,0 claimed=1 pdt=0h FUJITSU MHY2160BH 0000 SCSI1:0,0,0 claimed=1 pdt=5h MATSHITA DVD/CDRW UJDA775 CB03 And finally here is a more interesting example showing disks with no Windows (2000) volumes, a tape drive and a wierd unclaimed SCSI pseudo device with BCC (Bridge Controller Commands) peripheral device type. $ sdparm -www PD0 [C] ST380011A 8.01 PD1 SEAGATE ST373455SS 2189 PD2 ATA ST3160812AS D PD3 SEAGATE ST336754SS 0003 CDROM0 [F] HL-DT-ST DVDRAM GSA-4163B A103 TAPE0 SONY SDT-7000 0192 SCSI0:0,0,0 claimed=1 pdt=0h dubious ST380011 A 8.01 SCSI1:0,0,0 claimed=1 pdt=5h HL-DT-ST DVDRAM GSA-4163B A103 SCSI2:0,6,0 claimed=1 pdt=1h SONY SDT-7000 0192 SCSI5:0,17,0 claimed=1 pdt=0h SEAGATE ST373455SS 2189 SCSI5:0,19,0 claimed=1 pdt=0h ATA ST3160812AS D SCSI5:0,21,0 claimed=1 pdt=0h SEAGATE ST336754SS 0003 SCSI5:0,112,0 claimed=0 pdt=10h LSI PSEUDO DEVICE 2.34 Douglas Gilbert 6th June 2013 sdparm-1.08/AUTHORS0000664000175000017500000000005710640274765013013 0ustar douggdouggDouglas Gilbert sdparm-1.08/config.guess0000775000175000017500000012743212025134440014252 0ustar douggdougg#! /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, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-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 # the Free Software Foundation; either version 2 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. # # 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. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a 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 me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." 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, 2011, 2012 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." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # 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 armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-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 arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # 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 Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; 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 ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} 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}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. 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" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") 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'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 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 ;; 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 echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 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 ;; 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 ;; 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" # 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 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) 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 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) 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 # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # 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 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) 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); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # 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 ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) 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 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi 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 #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF 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 ;; *: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 IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 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 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); } EOF (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" ] then 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" else HP_ARCH="hppa64" fi fi 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 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) 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 ;; 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 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) 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 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`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 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-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 ;; arm*:Linux:*:*) 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-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-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 ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 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; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu 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 PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu 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 ;; 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, # I just have to hope. -- rms. # 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 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) 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 ;; i*86:*:4.*:* | i*86:SYSTEM_V: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} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi 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 ;; 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 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi 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 i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 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 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) 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; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { 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; } ;; 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 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) 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 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi 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 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 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 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) 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 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *: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} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) 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 UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) 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 ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix 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 ;; 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 #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 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); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # 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 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: sdparm-1.08/config.h.in0000664000175000017500000000301511731071714013752 0ustar douggdougg/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `getopt_long' function. */ #undef HAVE_GETOPT_LONG /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_BSG_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_KDEV_T_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_TYPES_H /* ignore linux bsg */ #undef IGNORE_LINUX_BSG /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* sdparm Build Host */ #undef SG_LIB_BUILD_HOST /* sdparm on FreeBSD */ #undef SG_LIB_FREEBSD /* assume sdparm on linux */ #undef SG_LIB_LINUX /* also MinGW environment */ #undef SG_LIB_MINGW /* sdparm on Tru64 UNIX */ #undef SG_LIB_OSF1 /* sdparm on Solaris */ #undef SG_LIB_SOLARIS /* sdparm on Win32 */ #undef SG_LIB_WIN32 /* full SCSI sense strings */ #undef SG_SCSI_STRINGS /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION /* allow large buffers, aligned? */ #undef WIN32_SPT_DIRECT sdparm-1.08/install-sh0000775000175000017500000003325612025134440013736 0ustar douggdougg#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # 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 # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # 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} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --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 CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done 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. # This can happen when creating conditional directories. exit 0 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 problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src 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 '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi 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: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false 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. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/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-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # 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 eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob 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 fi fi if test -n "$dir_arg"; then { 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 # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # 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 $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` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob 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 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-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: sdparm-1.08/INSTALL0000664000175000017500000002245011115062773012765 0ustar douggdouggInstallation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 6. Often, you can also type `make uninstall' to remove the installed files again. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. sdparm-1.08/src/0000755000175000017500000000000012155115504012512 5ustar douggdouggsdparm-1.08/src/Makefile.in0000664000175000017500000011251512153451342014567 0ustar douggdougg# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = sdparm$(EXEEXT) @OS_WIN32_MINGW_TRUE@am__append_1 = sdparm_wscan.c @OS_WIN32_CYGWIN_TRUE@am__append_2 = sdparm_wscan.c @HAVE_SGUTILS_FALSE@am__append_3 = $(sglib_SOURCES) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__sdparm_SOURCES_DIST = sdparm.c sdparm.h sdparm_data.c \ sdparm_data_vendor.c sdparm_access.c sdparm_vpd.c sdparm_cmd.c \ sdparm_wscan.c ../lib/sg_lib.c ../include/sg_lib.h \ ../lib/sg_lib_data.c ../include/sg_lib_data.h \ ../lib/sg_cmds_basic.c ../lib/sg_cmds_basic2.c \ ../include/sg_cmds_basic.h ../lib/sg_cmds_mmc.c \ ../include/sg_cmds_mmc.h ../include/sg_pt.h \ ../lib/sg_pt_common.c @OS_WIN32_MINGW_TRUE@am__objects_1 = sdparm_wscan.$(OBJEXT) @OS_WIN32_CYGWIN_TRUE@am__objects_2 = sdparm_wscan.$(OBJEXT) am__objects_3 = sg_lib.$(OBJEXT) sg_lib_data.$(OBJEXT) \ sg_cmds_basic.$(OBJEXT) sg_cmds_basic2.$(OBJEXT) \ sg_cmds_mmc.$(OBJEXT) sg_pt_common.$(OBJEXT) @HAVE_SGUTILS_FALSE@am__objects_4 = $(am__objects_3) am_sdparm_OBJECTS = sdparm.$(OBJEXT) sdparm_data.$(OBJEXT) \ sdparm_data_vendor.$(OBJEXT) sdparm_access.$(OBJEXT) \ sdparm_vpd.$(OBJEXT) sdparm_cmd.$(OBJEXT) $(am__objects_1) \ $(am__objects_2) $(am__objects_4) sdparm_OBJECTS = $(am_sdparm_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(sdparm_SOURCES) $(EXTRA_sdparm_SOURCES) DIST_SOURCES = $(am__sdparm_SOURCES_DIST) $(EXTRA_sdparm_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETOPT_O_FILES = @GETOPT_O_FILES@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SGUTILS_LIBS = @SGUTILS_LIBS@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ os_deps = @os_deps@ os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # for C++/clang testing # -std= can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) AM_CFLAGS = -I$(top_srcdir)/include -Wall -W # AM_CFLAGS = -I$(top_srcdir)/include -Wall -W -pedantic -std=c11 sdparm_SOURCES = sdparm.c sdparm.h sdparm_data.c sdparm_data_vendor.c \ sdparm_access.c sdparm_vpd.c sdparm_cmd.c $(am__append_1) \ $(am__append_2) $(am__append_3) sglib_SOURCES = ../lib/sg_lib.c \ ../include/sg_lib.h \ ../lib/sg_lib_data.c \ ../include/sg_lib_data.h \ ../lib/sg_cmds_basic.c \ ../lib/sg_cmds_basic2.c \ ../include/sg_cmds_basic.h \ ../lib/sg_cmds_mmc.c \ ../include/sg_cmds_mmc.h \ ../include/sg_pt.h \ ../lib/sg_pt_common.c @HAVE_SGUTILS_FALSE@INCLUDES = -I$(top_srcdir)/include @HAVE_SGUTILS_TRUE@INCLUDES = -I/usr/include/scsi @HAVE_SGUTILS_FALSE@sdparm_LDADD = @os_deps@ @GETOPT_O_FILES@ @os_libs@ @SGUTILS_LIBS@ @HAVE_SGUTILS_TRUE@sdparm_LDADD = @GETOPT_O_FILES@ @os_libs@ @SGUTILS_LIBS@ @HAVE_SGUTILS_FALSE@sdparm_DEPENDENCIES = @os_deps@ @GETOPT_O_FILES@ @HAVE_SGUTILS_TRUE@sdparm_DEPENDENCIES = @GETOPT_O_FILES@ EXTRA_sdparm_SOURCES = ../lib/sg_pt_linux.c \ ../include/sg_linux_inc.h \ ../lib/sg_pt_freebsd.c \ ../lib/sg_pt_osf1.c \ ../lib/sg_pt_solaris.c \ ../lib/sg_pt_win32.c \ ../include/sg_pt_win32.h \ getopt_long.c \ port_getopt.h all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) sdparm$(EXEEXT): $(sdparm_OBJECTS) $(sdparm_DEPENDENCIES) $(EXTRA_sdparm_DEPENDENCIES) @rm -f sdparm$(EXEEXT) $(LINK) $(sdparm_OBJECTS) $(sdparm_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt_long.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm_access.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm_cmd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm_data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm_data_vendor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm_vpd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdparm_wscan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_basic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_basic2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_cmds_mmc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_lib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_lib_data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_freebsd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_linux.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_osf1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_solaris.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_pt_win32.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` sg_lib.o: ../lib/sg_lib.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_lib.o -MD -MP -MF $(DEPDIR)/sg_lib.Tpo -c -o sg_lib.o `test -f '../lib/sg_lib.c' || echo '$(srcdir)/'`../lib/sg_lib.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_lib.Tpo $(DEPDIR)/sg_lib.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_lib.c' object='sg_lib.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_lib.o `test -f '../lib/sg_lib.c' || echo '$(srcdir)/'`../lib/sg_lib.c sg_lib.obj: ../lib/sg_lib.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_lib.obj -MD -MP -MF $(DEPDIR)/sg_lib.Tpo -c -o sg_lib.obj `if test -f '../lib/sg_lib.c'; then $(CYGPATH_W) '../lib/sg_lib.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_lib.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_lib.Tpo $(DEPDIR)/sg_lib.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_lib.c' object='sg_lib.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_lib.obj `if test -f '../lib/sg_lib.c'; then $(CYGPATH_W) '../lib/sg_lib.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_lib.c'; fi` sg_lib_data.o: ../lib/sg_lib_data.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_lib_data.o -MD -MP -MF $(DEPDIR)/sg_lib_data.Tpo -c -o sg_lib_data.o `test -f '../lib/sg_lib_data.c' || echo '$(srcdir)/'`../lib/sg_lib_data.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_lib_data.Tpo $(DEPDIR)/sg_lib_data.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_lib_data.c' object='sg_lib_data.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_lib_data.o `test -f '../lib/sg_lib_data.c' || echo '$(srcdir)/'`../lib/sg_lib_data.c sg_lib_data.obj: ../lib/sg_lib_data.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_lib_data.obj -MD -MP -MF $(DEPDIR)/sg_lib_data.Tpo -c -o sg_lib_data.obj `if test -f '../lib/sg_lib_data.c'; then $(CYGPATH_W) '../lib/sg_lib_data.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_lib_data.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_lib_data.Tpo $(DEPDIR)/sg_lib_data.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_lib_data.c' object='sg_lib_data.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_lib_data.obj `if test -f '../lib/sg_lib_data.c'; then $(CYGPATH_W) '../lib/sg_lib_data.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_lib_data.c'; fi` sg_cmds_basic.o: ../lib/sg_cmds_basic.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_cmds_basic.o -MD -MP -MF $(DEPDIR)/sg_cmds_basic.Tpo -c -o sg_cmds_basic.o `test -f '../lib/sg_cmds_basic.c' || echo '$(srcdir)/'`../lib/sg_cmds_basic.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_cmds_basic.Tpo $(DEPDIR)/sg_cmds_basic.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_cmds_basic.c' object='sg_cmds_basic.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_cmds_basic.o `test -f '../lib/sg_cmds_basic.c' || echo '$(srcdir)/'`../lib/sg_cmds_basic.c sg_cmds_basic.obj: ../lib/sg_cmds_basic.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_cmds_basic.obj -MD -MP -MF $(DEPDIR)/sg_cmds_basic.Tpo -c -o sg_cmds_basic.obj `if test -f '../lib/sg_cmds_basic.c'; then $(CYGPATH_W) '../lib/sg_cmds_basic.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_cmds_basic.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_cmds_basic.Tpo $(DEPDIR)/sg_cmds_basic.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_cmds_basic.c' object='sg_cmds_basic.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_cmds_basic.obj `if test -f '../lib/sg_cmds_basic.c'; then $(CYGPATH_W) '../lib/sg_cmds_basic.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_cmds_basic.c'; fi` sg_cmds_basic2.o: ../lib/sg_cmds_basic2.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_cmds_basic2.o -MD -MP -MF $(DEPDIR)/sg_cmds_basic2.Tpo -c -o sg_cmds_basic2.o `test -f '../lib/sg_cmds_basic2.c' || echo '$(srcdir)/'`../lib/sg_cmds_basic2.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_cmds_basic2.Tpo $(DEPDIR)/sg_cmds_basic2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_cmds_basic2.c' object='sg_cmds_basic2.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_cmds_basic2.o `test -f '../lib/sg_cmds_basic2.c' || echo '$(srcdir)/'`../lib/sg_cmds_basic2.c sg_cmds_basic2.obj: ../lib/sg_cmds_basic2.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_cmds_basic2.obj -MD -MP -MF $(DEPDIR)/sg_cmds_basic2.Tpo -c -o sg_cmds_basic2.obj `if test -f '../lib/sg_cmds_basic2.c'; then $(CYGPATH_W) '../lib/sg_cmds_basic2.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_cmds_basic2.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_cmds_basic2.Tpo $(DEPDIR)/sg_cmds_basic2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_cmds_basic2.c' object='sg_cmds_basic2.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_cmds_basic2.obj `if test -f '../lib/sg_cmds_basic2.c'; then $(CYGPATH_W) '../lib/sg_cmds_basic2.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_cmds_basic2.c'; fi` sg_cmds_mmc.o: ../lib/sg_cmds_mmc.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_cmds_mmc.o -MD -MP -MF $(DEPDIR)/sg_cmds_mmc.Tpo -c -o sg_cmds_mmc.o `test -f '../lib/sg_cmds_mmc.c' || echo '$(srcdir)/'`../lib/sg_cmds_mmc.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_cmds_mmc.Tpo $(DEPDIR)/sg_cmds_mmc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_cmds_mmc.c' object='sg_cmds_mmc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_cmds_mmc.o `test -f '../lib/sg_cmds_mmc.c' || echo '$(srcdir)/'`../lib/sg_cmds_mmc.c sg_cmds_mmc.obj: ../lib/sg_cmds_mmc.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_cmds_mmc.obj -MD -MP -MF $(DEPDIR)/sg_cmds_mmc.Tpo -c -o sg_cmds_mmc.obj `if test -f '../lib/sg_cmds_mmc.c'; then $(CYGPATH_W) '../lib/sg_cmds_mmc.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_cmds_mmc.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_cmds_mmc.Tpo $(DEPDIR)/sg_cmds_mmc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_cmds_mmc.c' object='sg_cmds_mmc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_cmds_mmc.obj `if test -f '../lib/sg_cmds_mmc.c'; then $(CYGPATH_W) '../lib/sg_cmds_mmc.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_cmds_mmc.c'; fi` sg_pt_common.o: ../lib/sg_pt_common.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_common.o -MD -MP -MF $(DEPDIR)/sg_pt_common.Tpo -c -o sg_pt_common.o `test -f '../lib/sg_pt_common.c' || echo '$(srcdir)/'`../lib/sg_pt_common.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_common.Tpo $(DEPDIR)/sg_pt_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_common.c' object='sg_pt_common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_common.o `test -f '../lib/sg_pt_common.c' || echo '$(srcdir)/'`../lib/sg_pt_common.c sg_pt_common.obj: ../lib/sg_pt_common.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_common.obj -MD -MP -MF $(DEPDIR)/sg_pt_common.Tpo -c -o sg_pt_common.obj `if test -f '../lib/sg_pt_common.c'; then $(CYGPATH_W) '../lib/sg_pt_common.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_common.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_common.Tpo $(DEPDIR)/sg_pt_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_common.c' object='sg_pt_common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_common.obj `if test -f '../lib/sg_pt_common.c'; then $(CYGPATH_W) '../lib/sg_pt_common.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_common.c'; fi` sg_pt_linux.o: ../lib/sg_pt_linux.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_linux.o -MD -MP -MF $(DEPDIR)/sg_pt_linux.Tpo -c -o sg_pt_linux.o `test -f '../lib/sg_pt_linux.c' || echo '$(srcdir)/'`../lib/sg_pt_linux.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_linux.Tpo $(DEPDIR)/sg_pt_linux.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_linux.c' object='sg_pt_linux.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_linux.o `test -f '../lib/sg_pt_linux.c' || echo '$(srcdir)/'`../lib/sg_pt_linux.c sg_pt_linux.obj: ../lib/sg_pt_linux.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_linux.obj -MD -MP -MF $(DEPDIR)/sg_pt_linux.Tpo -c -o sg_pt_linux.obj `if test -f '../lib/sg_pt_linux.c'; then $(CYGPATH_W) '../lib/sg_pt_linux.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_linux.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_linux.Tpo $(DEPDIR)/sg_pt_linux.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_linux.c' object='sg_pt_linux.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_linux.obj `if test -f '../lib/sg_pt_linux.c'; then $(CYGPATH_W) '../lib/sg_pt_linux.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_linux.c'; fi` sg_pt_freebsd.o: ../lib/sg_pt_freebsd.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_freebsd.o -MD -MP -MF $(DEPDIR)/sg_pt_freebsd.Tpo -c -o sg_pt_freebsd.o `test -f '../lib/sg_pt_freebsd.c' || echo '$(srcdir)/'`../lib/sg_pt_freebsd.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_freebsd.Tpo $(DEPDIR)/sg_pt_freebsd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_freebsd.c' object='sg_pt_freebsd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_freebsd.o `test -f '../lib/sg_pt_freebsd.c' || echo '$(srcdir)/'`../lib/sg_pt_freebsd.c sg_pt_freebsd.obj: ../lib/sg_pt_freebsd.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_freebsd.obj -MD -MP -MF $(DEPDIR)/sg_pt_freebsd.Tpo -c -o sg_pt_freebsd.obj `if test -f '../lib/sg_pt_freebsd.c'; then $(CYGPATH_W) '../lib/sg_pt_freebsd.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_freebsd.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_freebsd.Tpo $(DEPDIR)/sg_pt_freebsd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_freebsd.c' object='sg_pt_freebsd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_freebsd.obj `if test -f '../lib/sg_pt_freebsd.c'; then $(CYGPATH_W) '../lib/sg_pt_freebsd.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_freebsd.c'; fi` sg_pt_osf1.o: ../lib/sg_pt_osf1.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_osf1.o -MD -MP -MF $(DEPDIR)/sg_pt_osf1.Tpo -c -o sg_pt_osf1.o `test -f '../lib/sg_pt_osf1.c' || echo '$(srcdir)/'`../lib/sg_pt_osf1.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_osf1.Tpo $(DEPDIR)/sg_pt_osf1.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_osf1.c' object='sg_pt_osf1.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_osf1.o `test -f '../lib/sg_pt_osf1.c' || echo '$(srcdir)/'`../lib/sg_pt_osf1.c sg_pt_osf1.obj: ../lib/sg_pt_osf1.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_osf1.obj -MD -MP -MF $(DEPDIR)/sg_pt_osf1.Tpo -c -o sg_pt_osf1.obj `if test -f '../lib/sg_pt_osf1.c'; then $(CYGPATH_W) '../lib/sg_pt_osf1.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_osf1.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_osf1.Tpo $(DEPDIR)/sg_pt_osf1.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_osf1.c' object='sg_pt_osf1.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_osf1.obj `if test -f '../lib/sg_pt_osf1.c'; then $(CYGPATH_W) '../lib/sg_pt_osf1.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_osf1.c'; fi` sg_pt_solaris.o: ../lib/sg_pt_solaris.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_solaris.o -MD -MP -MF $(DEPDIR)/sg_pt_solaris.Tpo -c -o sg_pt_solaris.o `test -f '../lib/sg_pt_solaris.c' || echo '$(srcdir)/'`../lib/sg_pt_solaris.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_solaris.Tpo $(DEPDIR)/sg_pt_solaris.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_solaris.c' object='sg_pt_solaris.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_solaris.o `test -f '../lib/sg_pt_solaris.c' || echo '$(srcdir)/'`../lib/sg_pt_solaris.c sg_pt_solaris.obj: ../lib/sg_pt_solaris.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_solaris.obj -MD -MP -MF $(DEPDIR)/sg_pt_solaris.Tpo -c -o sg_pt_solaris.obj `if test -f '../lib/sg_pt_solaris.c'; then $(CYGPATH_W) '../lib/sg_pt_solaris.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_solaris.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_solaris.Tpo $(DEPDIR)/sg_pt_solaris.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_solaris.c' object='sg_pt_solaris.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_solaris.obj `if test -f '../lib/sg_pt_solaris.c'; then $(CYGPATH_W) '../lib/sg_pt_solaris.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_solaris.c'; fi` sg_pt_win32.o: ../lib/sg_pt_win32.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_win32.o -MD -MP -MF $(DEPDIR)/sg_pt_win32.Tpo -c -o sg_pt_win32.o `test -f '../lib/sg_pt_win32.c' || echo '$(srcdir)/'`../lib/sg_pt_win32.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_win32.Tpo $(DEPDIR)/sg_pt_win32.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_win32.c' object='sg_pt_win32.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_win32.o `test -f '../lib/sg_pt_win32.c' || echo '$(srcdir)/'`../lib/sg_pt_win32.c sg_pt_win32.obj: ../lib/sg_pt_win32.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_pt_win32.obj -MD -MP -MF $(DEPDIR)/sg_pt_win32.Tpo -c -o sg_pt_win32.obj `if test -f '../lib/sg_pt_win32.c'; then $(CYGPATH_W) '../lib/sg_pt_win32.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_win32.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sg_pt_win32.Tpo $(DEPDIR)/sg_pt_win32.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../lib/sg_pt_win32.c' object='sg_pt_win32.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sg_pt_win32.obj `if test -f '../lib/sg_pt_win32.c'; then $(CYGPATH_W) '../lib/sg_pt_win32.c'; else $(CYGPATH_W) '$(srcdir)/../lib/sg_pt_win32.c'; fi` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # 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. .NOEXPORT: sdparm-1.08/src/port_getopt.h0000664000175000017500000000575311021564275015251 0ustar douggdougg/* $NetBSD: getopt.h,v 1.7 2005/02/03 04:39:32 perry Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dieter Baron and Thomas Klausner. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * modified May 12, 2005 by Jim Basney * * removed #include of non-POSIX and * removed references to _NETBSD_SOURCE and HAVE_NBTOOL_CONFIG_H * added #if !HAVE_GETOPT_LONG * removed __BEGIN_DECLS and __END_DECLS */ #ifndef _MYPROXY_GETOPT_H_ #define _MYPROXY_GETOPT_H_ #if !HAVE_GETOPT_LONG #include /* * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 struct option { /* name of long option */ const char *name; /* * one of no_argument, required_argument, and optional_argument: * whether option takes an argument */ int has_arg; /* if not NULL, set *flag to val when option found */ int *flag; /* if flag not NULL, value to set *flag to; else return value */ int val; }; int getopt_long(int, char * const *, const char *, const struct option *, int *); #endif /* !HAVE_GETOPT_LONG */ #endif /* !_MYPROXY_GETOPT_H_ */ sdparm-1.08/src/Makefile.chk_sdparm_data0000664000175000017500000000245310704223637017270 0ustar douggdouggSHELL = /bin/sh PREFIX=/usr/local INSTDIR=$(DESTDIR)/$(PREFIX)/bin MANDIR=$(DESTDIR)/$(PREFIX)/share/man CC = gcc LD = gcc EXECS = chk_sdparm_data MAN_PGS = MAN_PREF = man8 OS_FLAGS = LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 S_CFLAGS = $(OS_FLAGS) $(LARGE_FILE_FLAGS) # CFLAGS = -I../include -O2 -Wall -W CFLAGS = -I../include -g -O2 -Wall -W # CFLAGS = -I../include -g -O2 -Wall -W -pedantic -std=c99 LDFLAGS = # LDFLAGS = -v -lm all: $(EXECS) depend dep: for i in *.c; do $(CC) $(INCLUDES) $(CFLAGS) $(S_CFLAGS) -M $$i; \ done > .depend clean: /bin/rm -f *.o $(EXECS) core* .depend *.a *.la *.lo .c.o: $(CC) $(INCLUDES) $(CFLAGS) $(S_CFLAGS) -c -o $@ $< chk_sdparm_data: chk_sdparm_data.o sdparm_data.o sdparm_data_vendor.o $(LD) -o $@ $(LDFLAGS) $^ install: $(EXECS) install -d $(INSTDIR) for name in $^; \ do install -s -o root -g root -m 755 $$name $(INSTDIR); \ done install -d $(MANDIR)/$(MAN_PREF) for mp in $(MAN_PGS); \ do install -o root -g root -m 644 $$mp $(MANDIR)/$(MAN_PREF); \ gzip -9f $(MANDIR)/$(MAN_PREF)/$$mp; \ done uninstall: dists="$(EXECS)"; \ for name in $$dists; do \ rm -f $(INSTDIR)/$$name; \ done for mp in $(MAN_PGS); do \ rm -f $(MANDIR)/$(MAN_PREF)/$$mp.gz; \ done ifeq (.depend,$(wildcard .depend)) include .depend endif sdparm-1.08/src/sdparm_cmd.c0000664000175000017500000004131612153177432015004 0ustar douggdougg/* * Copyright (c) 2005-2013 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #define __STDC_FORMAT_MACROS 1 #include #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sg_cmds_mmc.h" #include "sdparm.h" /* sdparm_cmd.c : contains code to implement commands * (i.e "--command=") in sdparm. */ #define RCAP_REPLY_LEN 8 #define RCAP16_REPLY_LEN 32 static int do_cmd_read_capacity(int sg_fd, int verbose) { int res, k, do16; unsigned int last_blk_addr, block_size; unsigned char resp_buff[RCAP16_REPLY_LEN]; uint64_t llast_blk_addr; double sz_mib; do16 = 0; res = sg_ll_readcap_10(sg_fd, 0 /* pmi */, 0 /* lba */, resp_buff, RCAP_REPLY_LEN, 1, verbose); if (0 == res) { last_blk_addr = (((unsigned int)resp_buff[0] << 24) | (resp_buff[1] << 16) | (resp_buff[2] << 8) | resp_buff[3]); if (0xffffffff != last_blk_addr) { block_size = (((unsigned int)resp_buff[4] << 24) | (resp_buff[5] << 16) | (resp_buff[6] << 8) | resp_buff[7]); printf("blocks: %u\n", last_blk_addr + 1); printf("block_length: %u\n", block_size); sz_mib = ((double)(last_blk_addr + 1) * block_size) / (double)(1048576); #ifdef SG3_UTILS_MINGW printf("capacity_mib: %g\n", sz_mib); #else printf("capacity_mib: %.1f\n", sz_mib); #endif } else do16 = 1; } else return res; if (do16) { /* within SERVICE ACTION IN. May need RW or root permissions. */ res = sg_ll_readcap_16(sg_fd, 0 /* pmi */, 0 /* llba */, resp_buff, RCAP16_REPLY_LEN, 1, verbose); if (0 == res) { for (k = 0, llast_blk_addr = 0; k < 8; ++k) { llast_blk_addr <<= 8; llast_blk_addr |= resp_buff[k]; } block_size = (((unsigned int)resp_buff[8] << 24) | (resp_buff[9] << 16) | (resp_buff[10] << 8) | resp_buff[11]); printf("blocks: %" PRIu64 "\n", llast_blk_addr + 1); printf("block_length: %u\n", block_size); sz_mib = ((double)(llast_blk_addr + 1) * block_size) / (double)(1048576); #ifdef SG3_UTILS_MINGW printf("capacity_mib: %g\n", sz_mib); #else printf("capacity_mib: %.1f\n", sz_mib); #endif } else return res; } return 0; } static int do_cmd_sense(int sg_fd, int hex, int quiet, int verbose) { int res, resp_len, sk, asc, ascq, progress, pr, rem, something; unsigned char buff[32]; char b[128]; memset(buff, 0, sizeof(buff)); res = sg_ll_request_sense(sg_fd, 0 /* fixed format */, buff, sizeof(buff), 1, verbose); if (0 == res) { resp_len = buff[7] + 8; if (resp_len > (int)sizeof(buff)) resp_len = sizeof(buff); sk = (0xf & buff[2]); if (hex) { dStrHex((const char *)buff, resp_len, 1); return 0; } something = 0; if (verbose) { fprintf(stderr, "Decode response as sense data:\n"); sg_print_sense(NULL, buff, resp_len, 0); if (verbose > 1) { fprintf(stderr, "\nOutput response in hex\n"); dStrHex((const char *)buff, resp_len, 1); } something = 1; } asc = (resp_len > 12) ? buff[12] : 0; ascq = (resp_len > 13) ? buff[13] : 0; if (sg_get_sense_progress_fld(buff, resp_len, &progress)) { pr = (progress * 100) / 65536; rem = ((progress * 100) % 65536) / 656; printf("Operation in progress: %d.%d%% done\n", pr, rem); something = 1; } if (0 == sk) { /* NO SENSE */ /* check for hardware threshold exceeded or warning */ if ((0xb == asc) || (0x5d == asc)) printf("%s\n", sg_get_asc_ascq_str(asc, ascq, (int)sizeof(b), b)); /* check for low power conditions */ if (0x5e == asc) printf("%s\n", sg_get_asc_ascq_str(asc, ascq, (int)sizeof(b), b)); return 0; } else { if (! (something || verbose || quiet)) { fprintf(stderr, "Decode response as sense data:\n"); sg_print_sense(NULL, buff, resp_len, 0); } return 0; } } else if (SG_LIB_CAT_INVALID_OP == res) fprintf(stderr, "Request Sense command not supported\n"); else if (SG_LIB_CAT_ILLEGAL_REQ == res) fprintf(stderr, "bad field in Request Sense cdb\n"); else if (SG_LIB_CAT_NOT_READY == res) fprintf(stderr, "Request Sense failed, device not ready\n"); else if (SG_LIB_CAT_ABORTED_COMMAND == res) fprintf(stderr, "Request Sense failed, aborted command\n"); else { fprintf(stderr, "Request Sense command failed\n"); if (0 == verbose) fprintf(stderr, " try the '-v' option for " "more information\n"); } return res; } /* cmd_arg is kBytes/sec if given (i.e. 1000 bytes per second */ static int do_cmd_speed(int sg_fd, int cmd_arg, const struct sdparm_opt_coll * opts) { int res; unsigned int u; unsigned int last_lba = 0xfffffffe; unsigned int rw_time = 1000; if (cmd_arg >= 0) { unsigned char perf_desc[28]; #if 0 int kbps; if (0 == cmd_arg) kbps = 0xffff; else kbps = cmd_arg; res = sg_ll_set_cd_speed(sg_fd, 0 /* rot_control */, kbps, 0 /* drv_write_speed */, 1, opts->verbose); #else memset(perf_desc, 0, sizeof(perf_desc)); if (0 == cmd_arg) perf_desc[0] |= 0x4; /* set RDD bit: restore drive defaults */ else { perf_desc[8] = (last_lba >> 24) & 0xff; perf_desc[9] = (last_lba >> 16) & 0xff; perf_desc[10] = (last_lba >> 8) & 0xff; perf_desc[11] = last_lba & 0xff; perf_desc[12] = (cmd_arg >> 24) & 0xff; perf_desc[13] = (cmd_arg >> 16) & 0xff; perf_desc[14] = (cmd_arg >> 8) & 0xff; perf_desc[15] = cmd_arg & 0xff; perf_desc[16] = (rw_time >> 24) & 0xff; perf_desc[17] = (rw_time >> 16) & 0xff; perf_desc[18] = (rw_time >> 8) & 0xff; perf_desc[19] = rw_time & 0xff; perf_desc[20] = (cmd_arg >> 24) & 0xff; perf_desc[21] = (cmd_arg >> 16) & 0xff; perf_desc[22] = (cmd_arg >> 8) & 0xff; perf_desc[23] = cmd_arg & 0xff; perf_desc[24] = (rw_time >> 24) & 0xff; perf_desc[25] = (rw_time >> 16) & 0xff; perf_desc[26] = (rw_time >> 8) & 0xff; perf_desc[27] = rw_time & 0xff; } /* performance (type=0), tolerance 10% nominal, read speed */ res = sg_ll_set_streaming(sg_fd, 0x0 /* type */, perf_desc, sizeof(perf_desc), 1, opts->verbose); if (res) { if (SG_LIB_CAT_NOT_READY == res) fprintf(stderr, "Set Streaming failed, device not ready\n"); else fprintf(stderr, "Set Streaming failed, add '-v' for more " "information\n"); } } else { const int max_num_desc = 16; unsigned char buff[8 + (16 * 16)]; unsigned int lba; /* performance (type=0), tolerance 10% nominal, read speed */ res = sg_ll_get_performance(sg_fd, 0x10 /* data_type */, 0 /* starting_lba */, max_num_desc, 0 /* type */, buff, sizeof(buff), 1, opts->verbose); if (0 == res) { if (opts->verbose) { lba = (((unsigned int)buff[8] << 24) + (buff[9] << 16) + (buff[10] << 8) + buff[11]); printf("starting LBA: %u\n", lba); } u = (((unsigned int)buff[12] << 24) + (buff[13] << 16) + (buff[14] << 8) + buff[15]); if (opts->quiet) printf("%u\n", u); else printf("Nominal speed at starting LBA: %u kiloBytes/sec\n", u); if (opts->verbose) { lba = (((unsigned int)buff[16] << 24) + (buff[17] << 16) + (buff[18] << 8) + buff[19]); printf("ending LBA: %u\n", lba); } u = (((unsigned int)buff[20] << 24) + (buff[21] << 16) + (buff[22] << 8) + buff[23]); if (1 == opts->quiet) printf("%u\n", u); else if (0 == opts->quiet) printf("Nominal speed at ending LBA: %u kiloBytes/sec\n", u); } } return res; #endif } static const char * get_profile_str(int profile_num, char * buff) { const struct sdparm_val_desc_t * pdp; for (pdp = sdparm_profile_arr; pdp->desc; ++pdp) { if (pdp->val == profile_num) { strcpy(buff, pdp->desc); return buff; } } snprintf(buff, 64, "0x%x", profile_num); return buff; } static void decode_get_config_feature(int feature, unsigned char * ucp, int len) { int k, profile; char buff[128]; switch (feature) { case 0: /* Profile list */ printf("Available profiles, profile of current media marked " "with * \n"); for (k = 4; k < len; k += 4) { profile = (ucp[k] << 8) + ucp[k + 1]; printf(" %s %s\n", get_profile_str(profile, buff), ((ucp[k + 2] & 1) ? "*" : "")); } break; default: /* ignore other features */ break; } } static void decode_get_config(unsigned char * resp, int max_resp_len, int len) { int k, extra, feature; unsigned char * ucp; if (max_resp_len < len) { printf("get_config: response to long for buffer, resp_len=%d>>>\n", len); len = max_resp_len; } if (len < 8) { printf("get_config: response length too short: %d\n", len); return; } ucp = resp + 8; len -= 8; for (k = 0; k < len; k += extra, ucp += extra) { extra = 4 + ucp[3]; feature = (ucp[0] << 8) + ucp[1]; if (0 != (extra % 4)) printf(" get_config: additional length [%d] not a multiple " "of 4, ignore\n", extra - 4); else decode_get_config_feature(feature, ucp, extra); } } #define MAX_CONFIG_RESPLEN 2048 static int do_cmd_profile(int sg_fd, const struct sdparm_opt_coll * opts) { int res, len; unsigned char resp[MAX_CONFIG_RESPLEN]; /* performance (type=0), tolerance 10% nominal, read speed */ res = sg_ll_get_config(sg_fd, 0x0 /* rt */, 0 /* starting_lba */, resp, sizeof(resp), 1, opts->verbose); if (0 == res) { len = ((unsigned int)resp[0] << 24) + (resp[1] << 16) + (resp[2] << 8) + resp[3] + 4; decode_get_config(resp, sizeof(resp), len); } return res; } const struct sdparm_command_t * sdp_build_cmd(const char * cmd_str, int * rwp, int * argp) { const struct sdparm_command_t * scmdp; const char * eq_cp; const char * cp; char buff[16]; int len; int arg = -1; eq_cp = strchr(cmd_str, '='); if (eq_cp) { len = eq_cp - cmd_str; if (len >= (int)sizeof(buff)) return NULL; strncpy(buff, cmd_str, len); buff[len] = '\0'; if (1 != sscanf(eq_cp + 1, "%d", &arg)) return NULL; cp = buff; } else cp = cmd_str; if (argp) *argp = arg; for (scmdp = sdparm_command_arr; scmdp->name; ++scmdp) { if (sdp_strcase_eq(scmdp->name, cp)) break; } if ((NULL == scmdp->name) && (strlen(cp) >= 2)) { for (scmdp = sdparm_command_arr; scmdp->name; ++scmdp) { len = strlen(scmdp->min_abbrev); if (0 == memcmp(scmdp->min_abbrev, cp, 2)) break; } } if (scmdp->name) { if (rwp) { if ((CMD_READY == scmdp->cmd_num) || (CMD_SENSE == scmdp->cmd_num) || (CMD_CAPACITY == scmdp->cmd_num)) *rwp = 0; else *rwp = 1; } return scmdp; } else return NULL; } void sdp_enumerate_commands() { const struct sdparm_command_t * scmdp; for (scmdp = sdparm_command_arr; scmdp->name; ++scmdp) { if (scmdp->extra_arg) printf(" %s[=%s]\n", scmdp->name, scmdp->extra_arg); else printf(" %s\n", scmdp->name); } } /* Returns 0 if successful */ int sdp_process_cmd(int sg_fd, const struct sdparm_command_t * scmdp, int cmd_arg, int pdt, const struct sdparm_opt_coll * opts) { int res, progress; if (! (opts->flexible || (CMD_READY == scmdp->cmd_num) || (CMD_SENSE == scmdp->cmd_num) || (0 == pdt) || (5 == pdt)) ) { fprintf(stderr, "this command only valid on a disk or cd/dvd; " "use '--flexible' to override\n"); return SG_LIB_SYNTAX_ERROR; } switch (scmdp->cmd_num) { case CMD_CAPACITY: res = do_cmd_read_capacity(sg_fd, opts->verbose); break; case CMD_EJECT: res = sg_ll_start_stop_unit(sg_fd, 0 /* immed */, 0 /* fl_num */, 0 /* power cond. */, 0 /* fl */, 1 /*loej */, 0 /* start */, 1 /* noisy */, opts->verbose); break; case CMD_LOAD: res = sg_ll_start_stop_unit(sg_fd, 0, 0, 0, 0, 1, 1, 1, opts->verbose); break; case CMD_PROFILE: res = do_cmd_profile(sg_fd, opts); break; case CMD_READY: progress = -1; res = sg_ll_test_unit_ready_progress(sg_fd, 0, &progress, 0, opts->verbose); if (0 == res) printf("Ready\n"); else { if (progress >= 0) printf("Not ready, progress indication: %d%% done\n", (progress * 100) / 65536); else printf("Not ready\n"); } break; case CMD_SENSE: res = do_cmd_sense(sg_fd, opts->hex, opts->quiet, opts->verbose); break; case CMD_SPEED: res = do_cmd_speed(sg_fd, cmd_arg, opts); break; case CMD_START: res = sg_ll_start_stop_unit(sg_fd, 0, 0, 0, 0, 0, 1, 1, opts->verbose); break; case CMD_STOP: res = sg_ll_start_stop_unit(sg_fd, 0, 0, 0, 0, 0, 0, 1, opts->verbose); break; case CMD_SYNC: res = sg_ll_sync_cache_10(sg_fd, 0, 0, 0, 0, 0, 1, opts->verbose); break; case CMD_UNLOCK: res = sg_ll_prevent_allow(sg_fd, 0, 1, opts->verbose); break; default: fprintf(stderr, "unknown cmd number [%d]\n", scmdp->cmd_num); return SG_LIB_SYNTAX_ERROR; } return res; } sdparm-1.08/src/sdparm_data.c0000664000175000017500000024420112144176773015157 0ustar douggdougg/* * Copyright (c) 2005-2013 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include "sg_lib.h" #include "sdparm.h" #define PROTO_IDENT_STR "0: fcp; 1: spi; 4: srp; 5: iscsi; 6: sas/spl; " \ "7: adt;\t8: ata/acs; 9: uas; 10: sop" /* * sdparm is a utility program to access and change SCSI device * (logical unit) mode page fields and do some other housekeeping. * * This file contains data tables that may be useful for other * programs. The data in these tables is derived from various (draft) * documents found at http://www.t10.org */ /* SSC's medium partition mode page has a variable number of partition size fields which are treated as descriptors here */ static struct sdparm_mode_descriptor_t ssc_mpa_desc = { 3, 1, 1, 8, 2, -1, -1, "SSC medium partition" }; /* SMC's transport geometry parameters mode page doesn't give the number of following descriptors but rather parameter length (in bytes). This is flagged by -1 in num_descs_inc (third) field */ static struct sdparm_mode_descriptor_t smc_tg_desc = { 1, 1, -1, 2, 2, -1, -1, "SMC transport geometry" }; /* SBC's logical block provisioning mode page doesn't give the number of following descriptors but rather parameter length (in bytes). This is flagged by -1 in num_descs_inc (third) field */ static struct sdparm_mode_descriptor_t sbc_lbp_desc = { 2, 2, -1, 16, 8, -1, -1, "SBC logical block provisioning" }; /* SBC's application tag mode page doesn't give the number of following descriptors but rather parameter length (in bytes). This is flagged by -1 in num_descs_inc (third) field */ static struct sdparm_mode_descriptor_t sbc_atag_desc = { 2, 2, -1, 16, 24, -1, -1, "SBC application tag" }; /* Mode pages that aren't specific to any transport protocol or vendor. Note that all standard periperal device types are include. The pages are listed in acronym alphabetical order. */ struct sdparm_mode_page_t sdparm_gen_mode_pg[] = { {ADC_MP, MSP_ADC_DT_DPP, PDT_ADC, 0, "addp", "DT device primary port (ADC)", NULL}, {ADC_MP, MSP_ADC_LU, PDT_ADC, 0, "adlu", "logical unit (ADC)", NULL}, {ADC_MP, MSP_ADC_TGT_DEV, PDT_ADC, 0, "adtd", "Targer device (ADC)", NULL}, {ADC_MP, MSP_ADC_TD_SN, PDT_ADC, 0, "adts", "Targer device serial number (ADC)", NULL}, {POWER_MP, MSP_SAT_POWER, -1, 0, "apo", "SAT ATA Power condition", NULL}, {CONTROL_MP, MSP_SBC_APP_TAG, PDT_DISK, 0, "atag", "Application tag " "(SBC)", &sbc_atag_desc}, {IEC_MP, MSP_BACK_CTL, PDT_DISK, 0, "bc", "Background control (SBC)", NULL}, {CACHING_MP, 0, PDT_DISK, 0, "ca", "Caching (SBC)", NULL}, {MMCMS_MP, 0, PDT_MMC, 1, "cms", "CD/DVD (MM) capabilities and " "mechanical status (MMC)", NULL}, /* read only */ {CONTROL_MP, 0, -1, 0, "co", "Control", NULL}, {CONTROL_MP, MSP_SPC_CE, -1, 0, "coe", "Control extension", NULL}, {CONTROL_MP, MSP_SSC_CDP, -1, 0, "cdp", "Control data protection (SSC)", NULL}, {DATA_COMPR_MP, 0, PDT_TAPE, 0, "dac", "Data compression (SSC)", NULL}, {DEV_CONF_MP, 0, PDT_TAPE, 0, "dc", "Device configuration (SSC)", NULL}, {DEV_CAP_MP, 0, PDT_MCHANGER, 0, "dca", "Device capabilities (SMC)", NULL}, {DEV_CONF_MP, MSP_DEV_CONF_EXT, PDT_TAPE, 0, "dce", "Device configuration extension (SSC)", NULL}, {DISCONNECT_MP, 0, -1, 0, "dr", "Disconnect-reconnect (SPC + transports)", NULL}, {ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 0, "eaa", "Element address assignment (SMC)", NULL}, {DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 0, "edc", "Extended device capabilities (SMC)", NULL}, {ES_MAN_MP, 0, PDT_SES, 0, "esm", "Enclosure services management (SES)", NULL}, {FORMAT_MP, 0, PDT_DISK, 0, "fo", "Format (SBC)", NULL}, {IEC_MP, 0, -1, 0, "ie", "Informational exceptions control", NULL}, {IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 0, "lbp", "Logical block " "provisioning (SBC)", &sbc_lbp_desc}, {MED_CONF_MP, 0, PDT_TAPE, 0, "mco", "Medium configuration (SSC)", NULL}, {MED_PART_MP, 0, PDT_TAPE, 0, "mpa", "Medium partition (SSC)", &ssc_mpa_desc}, {MRW_MP, 0, PDT_MMC, 0, "mrw", "Mount rainier reWritable (MMC)", NULL}, {CONTROL_MP, MSP_SAT_PATA, -1, 0, "pat", "SAT pATA control", NULL}, {PROT_SPEC_LU_MP, 0, -1, 0, "pl", "Protocol specific logical unit", NULL}, {POWER_MP, 0, -1, 0, "po", "Power condition", NULL}, {POWER_MP, MSP_SPC_PS, -1, 0, "ps", "Power consumption", NULL}, {POWER_OLD_MP, 0, PDT_DISK, 0, "poo", "Power condition - old version", NULL}, /* POWER_OLD_MP for disks as it clashes with old MMC specs */ {PROT_SPEC_PORT_MP, 0, -1, 0, "pp", "Protocol specific port", NULL}, {RBC_DEV_PARAM_MP, 0, PDT_RBC, 0, "rbc", "RBC device parameters (RBC)", NULL}, {RIGID_DISK_MP, 0, PDT_DISK, 0, "rd", "Rigid disk (SBC)", NULL}, {RW_ERR_RECOVERY_MP, 0, -1, 0, "rw", "Read write error recovery", NULL}, /* since in SBC, SSC and MMC treat RW_ERR_RECOVERY_MP as if in SPC */ {TRANS_GEO_PAR_MP, 0, PDT_MCHANGER, 0, "tgp", "Transport geometry " "parameters (SMC)", &smc_tg_desc}, {TIMEOUT_PROT_MP, 0, PDT_MMC, 0, "tp", "Timeout and protect (MMC)", NULL}, {V_ERR_RECOVERY_MP, 0, PDT_DISK, 0, "ve", "Verify error recovery (SBC)", NULL}, {WRITE_PARAM_MP, 0, PDT_MMC, 0, "wp", "Write parameters (MMC)", NULL}, {XOR_MP, 0, PDT_DISK, 0, "xo", "XOR control (SBC)", NULL}, /* XOR control mode page made obsolete in sbc3r32 */ {0, 0, 0, 0, NULL, NULL, NULL}, }; /* Array for transport id, acronym and name association. */ /* Those transports commented with "none" don't have transport specific */ /* mode pages. */ struct sdparm_transport_id_t sdparm_transport_id[] = { {TPROTO_FCP, "fcp", "Fibre channel (FCP)"}, {TPROTO_SPI, "spi", "SCSI parallel interface (SPI)"}, {TPROTO_SSA, "ssa", "Serial storage architecture (SSA)"}, {TPROTO_1394, "sbp", "Serial bus (SBP)"}, /* none */ {TPROTO_SRP, "srp", "SCSI remote DMA (SRP)"}, {TPROTO_ISCSI, "iscsi", "Internet SCSI (iSCSI)"}, /* none */ {TPROTO_SAS, "sas", "Serial attached SCSI (SAS, SPL) "}, {TPROTO_ADT, "adt", "Automation/Drive interface (ADT)"}, {TPROTO_ATA, "ata", "AT attachment interface (ATA, ACS)"}, /* none */ {TPROTO_UAS, "uas", "USB attached SCSI (UAS)"}, /* none */ {TPROTO_SOP, "sop", "SCSI over PCIe (SOP)"}, /* none */ {0x9, "u0xb", NULL}, /* leading "u" so not number */ {0xc, "u0xc", NULL}, {0xd, "u0xd", NULL}, {0xe, "u0xe", NULL}, {TPROTO_NONE, "none", "No specific"}, {0, NULL, NULL}, }; static struct sdparm_mode_page_t sdparm_fcp_mode_pg[] = { /* FCP-3 */ {DISCONNECT_MP, 0, -1, 0, "dr", "Disconnect-reconnect (FCP)", NULL}, {PROT_SPEC_LU_MP, 0, -1, 0, "luc", "lu: control (FCP)", NULL}, {PROT_SPEC_PORT_MP, 0, -1, 0, "pc", "port: control (FCP)", NULL}, {PROT_SPEC_LU_MP, 0, -1, 0, "pl", "lu: control (generic name)", NULL}, {PROT_SPEC_PORT_MP, 0, -1, 0, "pp", "port: control (generic name)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_page_t sdparm_spi_mode_pg[] = { /* SPI-4 */ {DISCONNECT_MP, 0, -1, 0, "dr", "Disconnect-reconnect (SPI)", NULL}, {PROT_SPEC_LU_MP, 0, -1, 0, "luc", "lu: control (SPI)", NULL}, {PROT_SPEC_PORT_MP, MSP_SPI_MC, -1, 0, "mc", "port: margin control (SPI)", NULL}, {PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 0, "ns", "port: negotiated settings (SPI)", NULL}, {PROT_SPEC_PORT_MP, 0, -1, 0, "psf", "port: short format (SPI)", NULL}, {PROT_SPEC_PORT_MP, MSP_SPI_RTC, -1, 1, "rtc", "port: report transfer capabilities (SPI)", NULL}, {PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 0, "stc", "port: saved training config value (SPI)", NULL}, /* second preference name so put out of alphabetical order */ {PROT_SPEC_LU_MP, 0, -1, 0, "pl", "lu: control (generic name)", NULL}, {PROT_SPEC_PORT_MP, 0, -1, 0, "pp", "port: short format (generic name)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_page_t sdparm_srp_mode_pg[] = { /* SRP */ {DISCONNECT_MP, 0, -1, 0, "dr", "Disconnect-reconnect (SRP)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_descriptor_t sas_pcd_desc = { /* desc SAS/SPL */ 7, 1, 0, 8, 48, -1, -1, "SAS phy" }; static struct sdparm_mode_descriptor_t sas_e_phy_desc = { /* desc SAS/SPL */ 7, 1, 0, 8, -1, 2, 2, "Enhanced phy" }; /* N.B. In SAS 2.1 the spec was split with the upper levels going into the * SAS Protocol Layer (SPL) document. So now the SPL drafts are the * relevant SAS references. */ static struct sdparm_mode_page_t sdparm_sas_mode_pg[] = { /* SAS/SPL */ {DISCONNECT_MP, 0, -1, 0, "dr", "Disconnect-reconnect (SAS)", NULL}, {PROT_SPEC_LU_MP, 0, -1, 0, "pl", "Protocol specific logical unit (SAS)", NULL}, {PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 0, "pcd", "Phy control and discover (SAS)", &sas_pcd_desc}, {PROT_SPEC_PORT_MP, 0, -1, 0, "pp", "Protocol specific port (SAS)", NULL}, {PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 0, "sep", "Enhanced phy control (SAS)", &sas_e_phy_desc}, {PROT_SPEC_PORT_MP, MSP_SAS_SPC, -1, 0, "spc", "Shared port control (SAS)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; /* These VPD pages are listed in alphabetical order based on their * 'acron' field. The standard inquiry response is added to this list. */ struct sdparm_vpd_page_t sdparm_vpd_pg[] = { {VPD_ATA_INFO, 0, -1, "ai", "ATA information (SAT)"}, {VPD_ASCII_OP_DEF, 0, -1, "aod", "ASCII implemented operating definition (obs)"}, {VPD_AUTOMATION_DEV_SN, 0, PDT_TAPE, "adsn", "Automation device serial " "number (SSC)"}, {VPD_BLOCK_LIMITS, 0, PDT_DISK, "bl", "Block limits (SBC)"}, {VPD_BLOCK_DEV_CHARS, 0, PDT_DISK, "bdc", "Block device characteristics " "(SBC)"}, {VPD_CFA_PROFILE_INFO, 0, -1, "cfa", "CFA profile information"}, {VPD_DEVICE_CONSTITUENTS, 0, -1, "dc", "Device constituents"}, {VPD_DEVICE_ID, 0, -1, "di", "Device identification"}, {VPD_DEVICE_ID, VPD_DI_SEL_AS_IS, -1, "di_asis", "Like 'di' " "but designators ordered as found"}, {VPD_DEVICE_ID, VPD_DI_SEL_LU, -1, "di_lu", "Device identification, " "lu only"}, {VPD_DEVICE_ID, VPD_DI_SEL_TPORT, -1, "di_port", "Device " "identification, target port only"}, {VPD_DEVICE_ID, VPD_DI_SEL_TARGET, -1, "di_target", "Device " "identification, target device only"}, {VPD_EXT_INQ, 0, -1, "ei", "Extended inquiry data"}, {VPD_DTDE_ADDRESS, 0, 1, "dtde", "Data transfer device element address (SSC)"}, {VPD_IMP_OP_DEF, 0, -1, "iod", "Implemented operating definition (obs)"}, {VPD_LB_PROVISIONING, 0, PDT_DISK, "lbpv", "Logical block provisioning " "(SBC)"}, {VPD_MAN_ASS_SN, 0, PDT_TAPE, "mas", "Manufacturer assigned serial number (SSC)"}, {VPD_MAN_ASS_SN, 0, PDT_ADC, "masa", "Manufacturer assigned serial number (ADC)"}, {VPD_MAN_NET_ADDR, 0, -1, "mna", "Management network addresses"}, {VPD_MODE_PG_POLICY, 0, -1, "mpp", "Mode page policy"}, {VPD_OSD_INFO, 0, PDT_OSD, "oi", "OSD information"}, {VPD_POWER_CONDITION, 0, -1, "pc", "Power condition"}, {VPD_POWER_CONSUMPTION, 0, -1, "psm", "Power consumption"}, {VPD_PROTO_LU, 0, -1, "pslu", "Protocol-specific logical unit " "information"}, {VPD_PROTO_PORT, 0, -1, "pspo", "Protocol-specific port information"}, {VPD_REFERRALS, 0, PDT_DISK, "ref", "Referrals (SBC)"}, {VPD_SA_DEV_CAP, 0, PDT_TAPE, "sad", "Sequential access device capabilities (SSC)"}, {VPD_SOFTW_INF_ID, 0, -1, "sii", "Software interface identification"}, {VPD_NOT_STD_INQ, 0, -1, "sinq", "Standard inquiry response"}, {VPD_UNIT_SERIAL_NUM, 0, -1, "sn", "Unit serial number"}, {VPD_SCSI_PORTS, 0, -1, "sp", "SCSI ports"}, {VPD_SUPPORTED_VPDS, 0, -1, "sv", "Supported VPD pages"}, {VPD_TA_SUPPORTED, 0, PDT_TAPE, "tas", "TapeAlert supported flags (SSC)"}, {VPD_3PARTY_COPY, 0, -1, "tpc", "Third party copy"}, {0, 0, 0, NULL, NULL}, }; /* Generic (i.e. non-transport specific) mode page items follow, */ /* sorted by mode page (then subpage) number in ascending order */ struct sdparm_mode_page_item sdparm_mitem_arr[] = { /* Read write error recovery mode page [0x1] sbc2, mmc5, ssc3 */ /* treat as spc since various command sets implement variants */ {"AWRE", RW_ERR_RECOVERY_MP, 0, -1, 2, 7, 1, MF_COMMON, "Automatic write reallocation enabled", NULL}, {"ARRE", RW_ERR_RECOVERY_MP, 0, -1, 2, 6, 1, MF_COMMON, "Automatic read reallocation enabled", NULL}, {"TB", RW_ERR_RECOVERY_MP, 0, -1, 2, 5, 1, 0, "Transfer block", NULL}, {"RC", RW_ERR_RECOVERY_MP, 0, -1, 2, 4, 1, 0, "Read continuous", "0: error recovery may cause delays\t" "1: transfer data without waiting for error recovery"}, {"EER", RW_ERR_RECOVERY_MP, 0, -1, 2, 3, 1, 0, "Enable early recovery", "1: increase chance of mis-detection or mis-correction of error"}, {"PER", RW_ERR_RECOVERY_MP, 0, -1, 2, 2, 1, MF_COMMON, "Post error", "0: do not post recovered errors\t" "1: report recovered errors (via sense key: recovered error)"}, {"DTE", RW_ERR_RECOVERY_MP, 0, -1, 2, 1, 1, 0, "Data terminate on error", "1: terminate data transfer when recovered error detected"}, {"DCR", RW_ERR_RECOVERY_MP, 0, -1, 2, 0, 1, 0, "Disable correction", NULL}, {"RRC", RW_ERR_RECOVERY_MP, 0, -1, 3, 7, 8, 0, "Read retry count", NULL}, {"COR_S", RW_ERR_RECOVERY_MP, 0, -1, 4, 7, 8, 0, "Correction span (obsolete)", NULL}, {"HOC", RW_ERR_RECOVERY_MP, 0, -1, 5, 7, 8, 0, "Head offset count (obsolete)", NULL}, {"DSOC", RW_ERR_RECOVERY_MP, 0, -1, 6, 7, 8, 0, "Data strobe offset count (obsolete)", NULL}, {"LBPERE", RW_ERR_RECOVERY_MP, 0, 0, 7, 7, 1, 0, /* SBC */ "Logical block provisioning error reporting enabled", NULL}, {"EMCDR", RW_ERR_RECOVERY_MP, 0, 5, 7, 1, 2, 0, /* MMC */ "Enhanced media certification and defect reporting", NULL}, {"WRC", RW_ERR_RECOVERY_MP, 0, -1, 8, 7, 8, 0, "Write retry count", NULL}, {"ERWS", RW_ERR_RECOVERY_MP, 0, 5, 9, 7, 24, 0, /* MMC, was ERTL */ "Error reporting window size (blocks)", NULL}, {"RTL", RW_ERR_RECOVERY_MP, 0, 0, 10, 7, 16, 0, /* SBC */ "Recovery time limit (ms)", "0: default, -1: 65.5 seconds"}, /* Disconnect-reconnect mode page [0x2]: spc-4 + */ /* See transport sections for more detailed information */ {"BFR", DISCONNECT_MP, 0, -1, 2, 7, 8, 0, "Buffer full ratio", "fraction where this value is numerator, 256 is denominator"}, {"BER", DISCONNECT_MP, 0, -1, 3, 7, 8, 0, "Buffer empty ratio", "fraction where this value is numerator, 256 is denominator"}, {"BIL", DISCONNECT_MP, 0, -1, 4, 7, 16, 0, "Bus inactivity limit", "for unit see specific transport"}, {"DTL", DISCONNECT_MP, 0, -1, 6, 7, 16, 0, "Disconnect time limit", "for unit see specific transport"}, {"CTL", DISCONNECT_MP, 0, -1, 8, 7, 16, 0, "Connect time limit", "for unit see specific transport"}, {"MBS", DISCONNECT_MP, 0, -1, 10, 7, 16, 0, "Maximum burst size (512 bytes)", NULL}, {"EMDP", DISCONNECT_MP, 0, -1, 12, 7, 1, 0, "Enable modify data pointers", "1: target may send data out of order"}, {"FA", DISCONNECT_MP, 0, -1, 12, 6, 3, 0, "Fair arbitration", NULL}, {"DIMM", DISCONNECT_MP, 0, -1, 12, 3, 1, 0, "Disconnect immediate", NULL}, {"DTDC", DISCONNECT_MP, 0, -1, 12, 2, 3, 0, "Data transfer disconnect control", NULL}, {"FBS", DISCONNECT_MP, 0, -1, 14, 7, 16, 0, "First burst size (512 bytes)", NULL}, /* Format mode page [0x3] sbc2 (obsolete) */ {"TPZ", FORMAT_MP, 0, PDT_DISK, 2, 7, 16, 0, "Tracks per zone", NULL}, {"ASPZ", FORMAT_MP, 0, PDT_DISK, 4, 7, 16, 0, "Alternate sectors per zone", NULL}, {"ATPZ", FORMAT_MP, 0, PDT_DISK, 6, 7, 16, 0, "Alternate tracks per zone", NULL}, {"ATPLU", FORMAT_MP, 0, PDT_DISK, 8, 7, 16, 0, "Alternate tracks per logical unit", NULL}, {"SPT", FORMAT_MP, 0, PDT_DISK, 10, 7, 16, 0, "Sectors per track", NULL}, {"DBPPS", FORMAT_MP, 0, PDT_DISK, 12, 7, 16, 0, "Data bytes per physical sector", NULL}, {"INTLV", FORMAT_MP, 0, PDT_DISK, 14, 7, 16, 0, "Interleave", NULL}, {"TSF", FORMAT_MP, 0, PDT_DISK, 16, 7, 16, 0, "Track skew factor", NULL}, {"CSF", FORMAT_MP, 0, PDT_DISK, 18, 7, 16, 0, "Cylinder skew factor", NULL}, {"SSEC", FORMAT_MP, 0, PDT_DISK, 20, 7, 1, 0, "Soft sector", NULL}, {"HSEC", FORMAT_MP, 0, PDT_DISK, 20, 6, 1, 0, "Hard sector", NULL}, {"RMB", FORMAT_MP, 0, PDT_DISK, 20, 5, 1, 0, "Removable", NULL}, {"SURF", FORMAT_MP, 0, PDT_DISK, 20, 4, 1, 0, "Surface", NULL}, /* Mount Rainier reWitable mode page [0x3] mmc4 */ {"LBAS", MRW_MP, 0, PDT_MMC, 3, 0, 1, 0, "LBA space", NULL}, /* Rigid disk mode page [0x4] sbc2 (obsolete) */ {"NOC", RIGID_DISK_MP, 0, PDT_DISK, 2, 7, 24, 0, "Number of cylinders", NULL}, {"NOH", RIGID_DISK_MP, 0, PDT_DISK, 5, 7, 8, 0, "Number of heads", NULL}, {"SCWP", RIGID_DISK_MP, 0, PDT_DISK, 6, 7, 24, 0, "Starting cylinder for write precompensation", NULL}, {"SCRWC", RIGID_DISK_MP, 0, PDT_DISK, 9, 7, 24, 0, "Starting cylinder for reduced write current", NULL}, {"DSR", RIGID_DISK_MP, 0, PDT_DISK, 12, 7, 16, 0, "Device step rate", NULL}, {"LZC", RIGID_DISK_MP, 0, PDT_DISK, 14, 7, 24, 0, "Landing zone cylinder", NULL}, {"RPL", RIGID_DISK_MP, 0, PDT_DISK, 17, 1, 2, 0, "Rotational position locking", NULL}, {"ROTO", RIGID_DISK_MP, 0, PDT_DISK, 18, 7, 8, 0, "Rotational offset", NULL}, {"MRR", RIGID_DISK_MP, 0, PDT_DISK, 20, 7, 16, 0, "Medium rotation rate (rpm)", NULL}, /* Write parameters mode page [0x5] mmc5 */ {"BUFE", WRITE_PARAM_MP, 0, PDT_MMC, 2, 6, 1, MF_COMMON, "Buffer underrun free recording enable", NULL}, {"LS_V", WRITE_PARAM_MP, 0, PDT_MMC, 2, 5, 1, 0, "Link size valid", NULL}, {"TST_W", WRITE_PARAM_MP, 0, PDT_MMC, 2, 4, 1, 0, "Test write", NULL}, {"WR_T", WRITE_PARAM_MP, 0, PDT_MMC, 2, 3, 4, MF_COMMON, "Write type", "0: packet/incremental; 1: track-at-once\t" "2: session-at-once; 3: raw; 4: layer jump recording"}, {"MULTI_S", WRITE_PARAM_MP, 0, PDT_MMC, 3, 7, 2, MF_COMMON, "Multi session", "0: next session not allowed (no BO pointer)\t" "1: next session not allowed\t" "3: next seesion allowed (indicated by BO pointer)"}, {"FP", WRITE_PARAM_MP, 0, PDT_MMC, 3, 5, 1, 0, "Fixed packet type", NULL}, {"COPY", WRITE_PARAM_MP, 0, PDT_MMC, 3, 4, 1, 0, "Serial copy management system (SCMS) enable", NULL}, {"TRACK_M", WRITE_PARAM_MP, 0, PDT_MMC, 3, 3, 4, 0, "Track mode", NULL}, {"DBT", WRITE_PARAM_MP, 0, PDT_MMC, 4, 3, 4, 0, "Data block type", NULL}, {"LINK_S", WRITE_PARAM_MP, 0, PDT_MMC, 5, 7, 8, 0, "Link size", NULL}, {"IAC", WRITE_PARAM_MP, 0, PDT_MMC, 7, 5, 6, 0, "Initiator application code", NULL}, {"SESS_F", WRITE_PARAM_MP, 0, PDT_MMC, 8, 7, 8, 0, "Session format", NULL}, {"PACK_S", WRITE_PARAM_MP, 0, PDT_MMC, 10, 7, 32, 0, "Packet size", NULL}, {"APL", WRITE_PARAM_MP, 0, PDT_MMC, 14, 7, 16, 0, "Audio pause length (blocks)", NULL}, /* Device parameters mode page [0x6] rbc */ {"WCD", RBC_DEV_PARAM_MP, 0, PDT_RBC, 2, 0, 1, MF_COMMON, "Write cache disable", NULL}, {"LBS", RBC_DEV_PARAM_MP, 0, PDT_RBC, 3, 7, 16, MF_COMMON, "Logical block size", NULL}, {"NLBS", RBC_DEV_PARAM_MP, 0, PDT_RBC, 5, 7, 40, (MF_COMMON | MF_HEX), "Number of logical blocks", NULL}, {"P_P", RBC_DEV_PARAM_MP, 0, PDT_RBC, 10, 7, 8, 0, "Power/performance", NULL}, {"READD", RBC_DEV_PARAM_MP, 0, PDT_RBC, 11, 3, 1, 0, "Read disable", NULL}, {"WRITED", RBC_DEV_PARAM_MP, 0, PDT_RBC, 11, 2, 1, 0, "Write disable", NULL}, {"FORMATD", RBC_DEV_PARAM_MP, 0, PDT_RBC, 11, 1, 1, 0, "Format disable", NULL}, {"LOCKD", RBC_DEV_PARAM_MP, 0, PDT_RBC, 11, 0, 1, 0, "Lock disable", NULL}, /* Verify error recovery mode page [0x7] sbc2 */ {"V_EER", V_ERR_RECOVERY_MP, 0, PDT_DISK, 2, 3, 1, 0, "Enable early recovery", NULL}, {"V_PER", V_ERR_RECOVERY_MP, 0, PDT_DISK, 2, 2, 1, 0, "Post error", NULL}, {"V_DTE", V_ERR_RECOVERY_MP, 0, PDT_DISK, 2, 1, 1, 0, "Data terminate on error", NULL}, {"V_DCR", V_ERR_RECOVERY_MP, 0, PDT_DISK, 2, 0, 1, 0, "Disable correction", NULL}, {"V_RC", V_ERR_RECOVERY_MP, 0, PDT_DISK, 3, 7, 8, 0, "Verify retry count", NULL}, {"V_COR_S", V_ERR_RECOVERY_MP, 0, PDT_DISK, 4, 7, 8, 0, "Verify correction span (obsolete)", NULL}, {"V_RTL", V_ERR_RECOVERY_MP, 0, PDT_DISK, 10, 7, 16, 0, "Verify recovery time limit (ms)", NULL}, /* Caching mode page [0x8] sbc2 */ {"IC", CACHING_MP, 0, PDT_DISK, 2, 7, 1, 0, "Initiator control", "0: disk uses own adaptive caching algorithm\t" "1: disk caching algorithm controlled by NCS or CCS"}, {"ABPF", CACHING_MP, 0, PDT_DISK, 2, 6, 1, 0, "Abort pre-fetch", NULL}, {"CAP", CACHING_MP, 0, PDT_DISK, 2, 5, 1, 0, "Caching analysis permitted", NULL}, {"DISC", CACHING_MP, 0, PDT_DISK, 2, 4, 1, 0, "Discontinuity", "0: pre-fetch truncated or wrapped at time discontinuity\t" "1: pre-fetch continues across time discontinuity"}, {"SIZE", CACHING_MP, 0, PDT_DISK, 2, 3, 1, 0, "Size enable", "0: number of cache segments (NCS) controls cache segmentation\t" "1: the cache segment size (CCS) controls cache segmentation"}, {"WCE", CACHING_MP, 0, PDT_DISK, 2, 2, 1, MF_COMMON, "Write cache enable", NULL}, {"MF", CACHING_MP, 0, PDT_DISK, 2, 1, 1, 0, "Multiplication factor", "0: MIPF and MAPF specify blocks\t" "1: multiply MIPF and MAPF by blocks in read command"}, {"RCD", CACHING_MP, 0, PDT_DISK, 2, 0, 1, MF_COMMON, "Read cache disable", NULL}, {"DRRP", CACHING_MP, 0, PDT_DISK, 3, 7, 4, 0, "Demand read retention priority", "0: treat requested and other data equally\t" "1: replace requested data before other data\t" "15: replace other data before requested data"}, {"WRP", CACHING_MP, 0, PDT_DISK, 3, 3, 4, 0, "Write retention priority", "0: treat requested and other data equally\t" "1: replace requested data before other data\t" "15: replace other data before requested data"}, {"DPTL", CACHING_MP, 0, PDT_DISK, 4, 7, 16, 0, "Disable pre-fetch transfer length", NULL}, {"MIPF", CACHING_MP, 0, PDT_DISK, 6, 7, 16, 0, "Minimum pre-fetch", NULL}, {"MAPF", CACHING_MP, 0, PDT_DISK, 8, 7, 16, 0, "Maximum pre-fetch", NULL}, {"MAPFC", CACHING_MP, 0, PDT_DISK, 10, 7, 16, 0, "Maximum pre-fetch ceiling", NULL}, {"FSW", CACHING_MP, 0, PDT_DISK, 12, 7, 1, 0, "Force sequential write", NULL}, {"LBCSS", CACHING_MP, 0, PDT_DISK, 12, 6, 1, 0, "Logical block cache segment size", "0: CSS unit is bytes; 1: CSS unit is blocks"}, {"DRA", CACHING_MP, 0, PDT_DISK, 12, 5, 1, 0, "Disable read ahead", NULL}, {"SYNC_PROG", CACHING_MP, 0, PDT_DISK, 12, 2, 2, 0, /* sbc3r33 */ "Synchronous cache progress indication", "0: no pollable sense data during sync\t" "1: allow pollable sense data, allow all commands during sync\t" "2: allow pollable sense data, allow some commands during sync"}, {"NV_DIS", CACHING_MP, 0, PDT_DISK, 12, 0, 1, 0, "Non-volatile cache disable", NULL}, {"NCS", CACHING_MP, 0, PDT_DISK, 13, 7, 8, 0, "Number of cache segments", NULL}, {"CSS", CACHING_MP, 0, PDT_DISK, 14, 7, 16, 0, "Cache segment size", NULL}, /* Control mode page [0xa] spc3 */ {"TST", CONTROL_MP, 0, -1, 2, 7, 3, 0, "Task set type", "0: lu maintains one task set for all I_T nexuses\t" "1: lu maintains separate task sets for each I_T nexus"}, {"TMF_ONLY", CONTROL_MP, 0, -1, 2, 4, 1, 0, "Task management functions only", NULL}, {"DPICZ", CONTROL_MP, 0, -1, 2, 3, 1, 0, "Disable protection information check if protect field zero", NULL}, {"D_SENSE", CONTROL_MP, 0, -1, 2, 2, 1, 0, "Descriptor format sense data", NULL}, {"GLTSD", CONTROL_MP, 0, -1, 2, 1, 1, 0, "Global logging target save disable", NULL}, {"RLEC", CONTROL_MP, 0, -1, 2, 0, 1, 0, "Report log exception condition", NULL}, {"QAM", CONTROL_MP, 0, -1, 3, 7, 4, 0, "Queue algorithm modifier", "0: restricted re-ordering; 1: unrestricted"}, {"NUAR", CONTROL_MP, 0, -1, 3, 3, 1, 0, "No unit attention on release", NULL}, {"QERR", CONTROL_MP, 0, -1, 3, 2, 2, 0, "Queue error management", "0: only affected task gets CC; 1: affected tasks aborted\t" "3: affected tasks aborted on same I_T nexus"}, {"RAC", CONTROL_MP, 0, -1, 4, 6, 1, 0, "Report a check", NULL}, {"UA_INTLCK", CONTROL_MP, 0, -1, 4, 5, 2, 0, "Unit attention interlocks control", "0: unit attention cleared with check condition status\t" "2: unit attention not cleared with check condition status\t" "3: as 2 plus ua on busy, task set full or reservation conflict"}, {"SWP", CONTROL_MP, 0, -1, 4, 3, 1, MF_COMMON, "Software write protect", NULL}, {"ATO", CONTROL_MP, 0, -1, 5, 7, 1, 0, "Application tag owner", NULL}, {"TAS", CONTROL_MP, 0, -1, 5, 6, 1, 0, "Task aborted status", "0: tasks aborted without response to app client\t" "1: any other I_T nexuses receive task aborted"}, {"ATMPE", CONTROL_MP, 0, -1, 5, 5, 1, 0, /* spc4r27 */ "Application tag mode page enabled", NULL}, {"RWWP", CONTROL_MP, 0, -1, 5, 4, 1, 0, /* spc4r27 */ "Reject write without protection", NULL}, {"AUTOLOAD", CONTROL_MP, 0, -1, 5, 2, 3, 0, "Autoload mode", "0: medium loaded for full access\t" "1: loaded for medium auxiliary access only\t" "2: medium shall not be loaded"}, {"BTP", CONTROL_MP, 0, -1, 8, 7, 16, 0, "Busy timeout period (100us)", "0: undefined\t" "0ffffh (-1): unlimited"}, {"ESTCT", CONTROL_MP, 0, -1, 10, 7, 16, 0, "Extended self test completion time (sec)", "0ffffh (-1) takes 65535 seconds or longer"}, /* Control extension mode subpage [0xa,0x1] spc3 */ {"TCMOS", CONTROL_MP, MSP_SPC_CE, -1, 4, 2, 1, 0, "Timestamp changeable by methods outside standard", NULL}, {"SCSIP", CONTROL_MP, MSP_SPC_CE, -1, 4, 1, 1, 0, "SCSI timestamp commands take precedence over other methods", NULL}, {"IALUAE", CONTROL_MP, MSP_SPC_CE, -1, 4, 0, 1, 0, "Implicit asymmetric logical unit access enabled", NULL}, {"INIT_PR", CONTROL_MP, MSP_SPC_CE, -1, 5, 3, 4, 0, "Initial command priority", "0: none or vendor\t" "1: highest\t15: lowest"}, {"MSDL", CONTROL_MP, MSP_SPC_CE, -1, 6, 7, 8, 0, /* spc4r34 */ "Maximum sense data length", "0: unlimited"}, /* Application tag mode subpage [0xa,0xf0] sbc3 */ /* descriptor starts here, is relative to start of mode * page (i.e. 16 more than shown in descriptor format table) */ {"AT_LAST", CONTROL_MP, MSP_SBC_APP_TAG, PDT_DISK, 16, 7, 1, 0, "Last", NULL}, {"AT_LBAT", CONTROL_MP, MSP_SBC_APP_TAG, PDT_DISK, 22, 7, 16, 0, "Logical block application tag", NULL}, {"AT_LBA", CONTROL_MP, MSP_SBC_APP_TAG, PDT_DISK, 24, 7, 64, MF_HEX, "Logical block address", NULL}, {"AT_COUNT", CONTROL_MP, MSP_SBC_APP_TAG, PDT_DISK, 32, 7, 64, MF_HEX, "Logical block count", NULL}, /* Control data protection mode subpage [0xa,0xf0] ssc4 */ {"LBPM", CONTROL_MP, MSP_SSC_CDP, PDT_TAPE, 4, 7, 8, 0, "Logical block protection method", "0: none\t" "1: Reed-Solomon CRC"}, {"LBPIL", CONTROL_MP, MSP_SSC_CDP, PDT_TAPE, 5, 5, 6, 0, "Logical block protection information length", NULL}, {"LBP_W", CONTROL_MP, MSP_SSC_CDP, PDT_TAPE, 6, 7, 1, 0, "Logical block protection during write", NULL}, {"LBP_R", CONTROL_MP, MSP_SSC_CDP, PDT_TAPE, 6, 6, 1, 0, "Logical block protection during read", NULL}, {"RBDP", CONTROL_MP, MSP_SSC_CDP, PDT_TAPE, 6, 5, 1, 0, "Recover buffered data protected", NULL}, /* SAT: pATA control mode subpage [0xa,0xf1] sat-r09 */ /* treat as spc since could be disk or ATAPI */ {"MWD2", CONTROL_MP, MSP_SAT_PATA, -1, 4, 6, 1, 0, "Multi word DMA bit 2", NULL}, {"MWD1", CONTROL_MP, MSP_SAT_PATA, -1, 4, 5, 1, 0, "Multi word DMA bit 1", NULL}, {"MWD0", CONTROL_MP, MSP_SAT_PATA, -1, 4, 4, 1, 0, "Multi word DMA bit 0", NULL}, {"PIO4", CONTROL_MP, MSP_SAT_PATA, -1, 4, 1, 1, 0, "Parallel IO bit 4", NULL}, {"PIO3", CONTROL_MP, MSP_SAT_PATA, -1, 4, 0, 1, 0, "Parallel IO bit 3", NULL}, {"UDMA6", CONTROL_MP, MSP_SAT_PATA, -1, 5, 6, 1, 0, "Ultra DMA bit 6", NULL}, {"UDMA5", CONTROL_MP, MSP_SAT_PATA, -1, 5, 5, 1, 0, "Ultra DMA bit 5", NULL}, {"UDMA4", CONTROL_MP, MSP_SAT_PATA, -1, 5, 4, 1, 0, "Ultra DMA bit 4", NULL}, {"UDMA3", CONTROL_MP, MSP_SAT_PATA, -1, 5, 3, 1, 0, "Ultra DMA bit 3", NULL}, {"UDMA2", CONTROL_MP, MSP_SAT_PATA, -1, 5, 2, 1, 0, "Ultra DMA bit 2", NULL}, {"UDMA1", CONTROL_MP, MSP_SAT_PATA, -1, 5, 1, 1, 0, "Ultra DMA bit 1", NULL}, {"UDMA0", CONTROL_MP, MSP_SAT_PATA, -1, 5, 0, 1, 0, "Ultra DMA bit 0", NULL}, /* Power condition mode page - obsolete block-device-only version */ /* [0xd] sbc (replacement page now at 0x1a) */ {"IDLE-OLD", POWER_OLD_MP, 0, PDT_DISK, 3, 1, 1, 0, "Idle timer active", NULL}, {"STBY-OLD", POWER_OLD_MP, 0, PDT_DISK, 3, 0, 1, 0, "Standby timer active", NULL}, {"ICT-OLD", POWER_OLD_MP, 0, PDT_DISK, 4, 7, 32, 0, "Idle condition timer (100 ms)", NULL}, {"SCT-OLD", POWER_OLD_MP, 0, PDT_DISK, 8, 7, 32, 0, "Standby condition timer (100 ms)", NULL}, /* Data compression mode page [0xf] ssc3 */ {"DCE", DATA_COMPR_MP, 0, PDT_TAPE, 2, 7, 1, MF_COMMON, "Data compression enable", NULL}, {"DCC", DATA_COMPR_MP, 0, PDT_TAPE, 2, 6, 1, MF_COMMON, "Data compression capable", NULL}, {"DDE", DATA_COMPR_MP, 0, PDT_TAPE, 3, 7, 1, MF_COMMON, "Data decompression enable", NULL}, {"RED", DATA_COMPR_MP, 0, PDT_TAPE, 3, 6, 2, 0, "Report exception on decompression", NULL}, {"COMPR_A", DATA_COMPR_MP, 0, PDT_TAPE, 4, 7, 32, 0, "Compression algorithm", "0: none; 5: ALDC (2048 byte): 16: IDRC; 32: DCLZ"}, {"DCOMPR_A", DATA_COMPR_MP, 0, PDT_TAPE, 8, 7, 32, 0, "Decompression algorithm", "0: none; 5: ALDC (2048 byte): 16: IDRC; 32: DCLZ"}, /* XOR control mode page [0x10] sbc2 << obsolete in sbc3r32>> */ {"XORDIS", XOR_MP, 0, PDT_DISK, 2, 1, 1, 0, "XOR disable", NULL}, {"MXWS", XOR_MP, 0, PDT_DISK, 4, 7, 32, 0, "Maximum XOR write size (blocks)", NULL}, /* Device configuration mode page [0x10] ssc3 */ {"CAF", DEV_CONF_MP, 0, PDT_TAPE, 2, 5, 1, 0, "Change active format", NULL}, {"ACT_F", DEV_CONF_MP, 0, PDT_TAPE, 2, 4, 5, 0, "Active format", NULL}, {"ACT_P", DEV_CONF_MP, 0, PDT_TAPE, 3, 7, 8, 0, "Active partition", NULL}, {"WOBFR", DEV_CONF_MP, 0, PDT_TAPE, 4, 7, 8, 0, "Write object buffer full ratio", NULL}, {"ROBER", DEV_CONF_MP, 0, PDT_TAPE, 5, 7, 8, 0, "Read object buffer empty ratio", NULL}, {"WDT", DEV_CONF_MP, 0, PDT_TAPE, 6, 7, 16, 0, "Write delay time (100 ms)", NULL}, {"OBR", DEV_CONF_MP, 0, PDT_TAPE, 8, 7, 1, 0, "Object buffer recovery", NULL}, {"LOIS", DEV_CONF_MP, 0, PDT_TAPE, 8, 6, 1, 0, "Logical object identifiers supported", NULL}, {"RSMK", DEV_CONF_MP, 0, PDT_TAPE, 8, 5, 1, MF_COMMON, "Report setmarks (obsolete)", NULL}, {"AVC", DEV_CONF_MP, 0, PDT_TAPE, 8, 4, 1, 0, "Automatic velocity control", NULL}, {"SOCF", DEV_CONF_MP, 0, PDT_TAPE, 8, 3, 2, 0, "Stop on consecutive filemarks", NULL}, {"ROBO", DEV_CONF_MP, 0, PDT_TAPE, 8, 1, 1, 0, "Recover object buffer order", NULL}, {"REW", DEV_CONF_MP, 0, PDT_TAPE, 8, 0, 1, 0, "Report early warning", NULL}, {"GAP_S", DEV_CONF_MP, 0, PDT_TAPE, 9, 7, 8, 0, "Gap size (obsolete)", NULL}, {"EOD_D", DEV_CONF_MP, 0, PDT_TAPE, 10, 7, 3, 0, "EOD (end-of-data) defined", "0: default; 1: format defined; 2: SOCF; 3: not supported"}, {"EEG", DEV_CONF_MP, 0, PDT_TAPE, 10, 4, 1, 0, "Enable EOD generation", NULL}, {"SEW", DEV_CONF_MP, 0, PDT_TAPE, 10, 3, 1, MF_COMMON, "Synchronize early warning", NULL}, {"SWP_T", DEV_CONF_MP, 0, PDT_TAPE, 10, 2, 1, 0, "Software write protect (tape)", NULL}, {"BAML", DEV_CONF_MP, 0, PDT_TAPE, 10, 1, 1, 0, "Block address mode lock", NULL}, {"BAM", DEV_CONF_MP, 0, PDT_TAPE, 10, 0, 1, 0, "Block address mode", NULL}, {"OBSAEW", DEV_CONF_MP, 0, PDT_TAPE, 11, 7, 24, 0, "Object buffer size at early warning", NULL}, {"SDCA", DEV_CONF_MP, 0, PDT_TAPE, 14, 7, 8, MF_COMMON, "Select data compression algorithm", NULL}, {"WTRE", DEV_CONF_MP, 0, PDT_TAPE, 15, 7, 2, 0, "WORM tamper read enable", NULL}, {"OIR", DEV_CONF_MP, 0, PDT_TAPE, 15, 5, 1, 0, "Only if reserved", NULL}, {"ROR", DEV_CONF_MP, 0, PDT_TAPE, 15, 4, 2, 0, "Rewind on reset", "0: vendor specific; 1: to BOP 0 on lu reset\t" "2: hold position on lu reset"}, {"ASOCWP", DEV_CONF_MP, 0, PDT_TAPE, 15, 2, 1, 0, "Associated write protection", NULL}, {"PERSWP", DEV_CONF_MP, 0, PDT_TAPE, 15, 1, 1, 0, "Persistent write protection", NULL}, {"PRMWP", DEV_CONF_MP, 0, PDT_TAPE, 15, 0, 1, 0, "Permanent write protection", NULL}, /* Device configuration extension mode subpage [0x10,1 ] ssc3 */ {"TARPF", DEV_CONF_MP, MSP_DEV_CONF_EXT, PDT_TAPE, 4, 3, 1, 0, "TapeAlert respect parameter fields", NULL}, {"TASER", DEV_CONF_MP, MSP_DEV_CONF_EXT, PDT_TAPE, 4, 2, 1, 0, "TapeAlert select except reporting", NULL}, {"TARPC", DEV_CONF_MP, MSP_DEV_CONF_EXT, PDT_TAPE, 4, 1, 1, 0, "TapeAlert respect page control", NULL}, {"TAPLSD", DEV_CONF_MP, MSP_DEV_CONF_EXT, PDT_TAPE, 4, 0, 1, 0, "TapeAlert prevent log sense deactivation", NULL}, {"SEM", DEV_CONF_MP, MSP_DEV_CONF_EXT, PDT_TAPE, 5, 3, 4, 0, "Short erase mode", "0: as per SSC-2; 1: erase has no effect; 2: record EOD indication"}, /* Medium partition mode page [0x11] ssc3 */ {"MAX_AP", MED_PART_MP, 0, PDT_TAPE, 2, 7, 8, 0, "Maximum additional partitions", NULL}, {"APD", MED_PART_MP, 0, PDT_TAPE, 3, 7, 8, 0, "Additional partitions defined", NULL}, {"FDP", MED_PART_MP, 0, PDT_TAPE, 4, 7, 1, 0, "Fixed data partitions", NULL}, {"SDP", MED_PART_MP, 0, PDT_TAPE, 4, 6, 1, 0, "Select data partitions", NULL}, {"IDP", MED_PART_MP, 0, PDT_TAPE, 4, 5, 1, 0, "Initiator defined partitions", NULL}, {"PSUM", MED_PART_MP, 0, PDT_TAPE, 4, 4, 2, 0, "Partition size unit of measure", "0: bytes; 1: kilobytes; 2: megabytes; 3: 10**(partition_units)"}, {"POFM", MED_PART_MP, 0, PDT_TAPE, 4, 2, 1, 0, "Partition on format", NULL}, {"CLEAR", MED_PART_MP, 0, PDT_TAPE, 4, 1, 1, 0, "Erase partition(s) (in concert with ADDP)", NULL}, {"ADDP", MED_PART_MP, 0, PDT_TAPE, 4, 0, 1, 0, "Additional partition bit (in concert with CLEAR)", NULL}, {"MFR", MED_PART_MP, 0, PDT_TAPE, 5, 7, 8, 0, "Medium format recognition", "0: incapable; 1: format recognition; 2: partition recognition\t" "3: format and partition recognition"}, {"PART_U", MED_PART_MP, 0, PDT_TAPE, 6, 3, 4, 0, "Partition units (exponent of 10, bytes)", NULL}, /* "descriptor" starts here */ {"P_SZ", MED_PART_MP, 0, PDT_TAPE, 8, 7, 16, 0, "Partition size", NULL}, /* Enclosure services management mode page [0x14] ses2 */ {"ENBLTC", ES_MAN_MP, 0, PDT_SES, 5, 0, 1, MF_COMMON, "Enable timed completion", NULL}, {"MTCT", ES_MAN_MP, 0, PDT_SES, 6, 7, 16, MF_COMMON, "Maximum task completion time (100ms)", NULL}, /* Protocol specific logical unit control mode page [0x18] spc3 */ {"LUPID", PROT_SPEC_LU_MP, 0, -1, 2, 3, 4, 0, "Logical unit's (transport) protocol identifier", PROTO_IDENT_STR "\t" "[try adding '-t ' to get more fields]"}, /* Protocol specific port control mode page [0x19] spc3 */ {"PPID", PROT_SPEC_PORT_MP, 0, -1, 2, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR "\t" "[try adding '-t ' to get more fields]"}, /* Power condition mode page [0x1a] spc3 (expanded in spc4r18) */ {"PM_BG", POWER_MP, 0, -1, 2, 7, 2, 0, /* added spc4r24 */ "Power management, background functions, precedence", "0: vendor specific; 1: background function higher\t" "2: power management higher"}, {"STANDBY_Y", POWER_MP, 0, -1, 2, 0, 1, 0, "Standby_y timer enable", NULL}, {"IDLE_C", POWER_MP, 0, -1, 3, 3, 1, 0, "Idle_c timer enable", NULL}, {"IDLE_B", POWER_MP, 0, -1, 3, 2, 1, 0, "Idle_b timer enable", NULL}, {"IDLE", POWER_MP, 0, -1, 3, 1, 1, 0, /* IDLE_A in future ? */ "Idle_a timer enable", "named IDLE prior to spc4r18, thence IDLE_A"}, {"STANDBY", POWER_MP, 0, -1, 3, 0, 1, 0, /* STANDBY_Z in future ? */ "Standby_z timer enable", "named STANDBY prior to spc4r18, thence STANDBY_Z"}, {"ICT", POWER_MP, 0, -1, 4, 7, 32, 0, /* IACT in future ? */ "Idle_a condition timer (100 ms)", "named IDLE prior to spc4r18, thence IDLE_A"}, {"SCT", POWER_MP, 0, -1, 8, 7, 32, 0, /* SZCT in future ? */ "Standby_z condition timer (100 ms)", "named STANDBY prior to spc4r18, thence STANDBY_Z"}, {"IBCT", POWER_MP, 0, -1, 12, 7, 32, 0, "Idle_b condition timer (100 ms)", NULL}, {"ICCT", POWER_MP, 0, -1, 16, 7, 32, 0, "Idle_c condition timer (100 ms)", NULL}, {"SYCT", POWER_MP, 0, -1, 20, 7, 32, 0, "Standby_y condition timer (100 ms)", NULL}, {"CCF_IDLE", POWER_MP, 0, -1, 39, 7, 2, 0, /* changed spc4r35 */ "check condition on transition from idle", /* was FIDCPC (spc4r25) */ "0: restricted (SAS-2); 1: disabled; 2: enabled\n"}, {"CCF_STAND", POWER_MP, 0, -1, 39, 5, 2, 0, /* changed spc4r35 */ "check condition on transition from standby", /* was FSBCPC */ "0: restricted (SAS-2); 1: disabled; 2: enabled\n"}, {"CCF_STOPP", POWER_MP, 0, -1, 39, 3, 2, 0, /* changed spc4r35 */ "check condition on transition from stopped", /* was FSTCPC */ "0: restricted (SAS-2); 1: disabled; 2: enabled\n"}, /* Power consumption mode page [0x1a,1] added spc4r33 */ {"ps_id", POWER_MP, MSP_SPC_PS, -1, 7, 7, 8, 0, /* added spc4r24 */ "Power consumption identifier", "references Power consumption VPD page"}, /* SAT ATA Power condition mode page [0x1a,0xf1] sat2 */ {"APMP", POWER_MP, MSP_SAT_POWER, -1, 5, 0, 1, 0, "Advanced Power Management (APM) enabled/change", NULL}, {"APM", POWER_MP, MSP_SAT_POWER, -1, 6, 7, 8, 0, "Advanced Power Management (APM) value", NULL}, /* Informational exception control mode page [0x1c] spc3 */ {"PERF", IEC_MP, 0, -1, 2, 7, 1, 0, "Performance (impact of ie operations)", "0: normal (some delays); 1: abridge ie operations"}, {"EBF", IEC_MP, 0, -1, 2, 5, 1, 0, "Enable background function", NULL}, {"EWASC", IEC_MP, 0, -1, 2, 4, 1, MF_COMMON, "Enable warning", NULL}, {"DEXCPT", IEC_MP, 0, -1, 2, 3, 1, MF_COMMON, "Disable exceptions", NULL}, {"TEST", IEC_MP, 0, -1, 2, 2, 1, 0, "Test (simulate device failure)", NULL}, {"EBACKERR", IEC_MP, 0, -1, 2, 1, 1, 0, "Enable background (scan + self test) error reporting", NULL}, {"LOGERR", IEC_MP, 0, -1, 2, 0, 1, 0, "Log informational exception errors", NULL}, {"MRIE", IEC_MP, 0, -1, 3, 3, 4, MF_COMMON, "Method of reporting informational exceptions", "0: no reporting; 1: async reporting (obs); 2: unit attention\t" "3: conditional recovered error; 4: recovered error\t" "5: check condition with no sense; 6: request sense only"}, {"INTT", IEC_MP, 0, -1, 4, 7, 32, 0, "Interval timer (100 ms)", NULL}, {"REPC", IEC_MP, 0, -1, 8, 7, 32, 0, "Report count (or Test flag number [SSC-3])", NULL}, /* Background control mode subpage [0x1c,0x1] sbc3 */ {"S_L_FULL", IEC_MP, MSP_BACK_CTL, PDT_DISK, 4, 2, 1, 0, "Suspend on log full", NULL}, {"LOWIR", IEC_MP, MSP_BACK_CTL, PDT_DISK, 4, 1, 1, 0, "Log only when intervention required", NULL}, {"EN_BMS", IEC_MP, MSP_BACK_CTL, PDT_DISK, 4, 0, 1, 0, "Enable background medium scan", NULL}, {"EN_PS", IEC_MP, MSP_BACK_CTL, PDT_DISK, 5, 0, 1, 0, "Enable pre-scan", NULL}, {"BMS_I", IEC_MP, MSP_BACK_CTL, PDT_DISK, 6, 7, 16, 0, "Background medium scan interval time (hour)", NULL}, {"BPS_TL", IEC_MP, MSP_BACK_CTL, PDT_DISK, 8, 7, 16, 0, "Background pre-scan time limit (hour)", NULL}, {"MIN_IDLE", IEC_MP, MSP_BACK_CTL, PDT_DISK, 10, 7, 16, 0, "Minumum idle time before background scan (ms)", NULL}, {"MAX_SUSP", IEC_MP, MSP_BACK_CTL, PDT_DISK, 12, 7, 16, 0, "Maximum time to suspend background scan (ms)", NULL}, /* Logical block provisioning mode subpage [0x1c,0x2] sbc3 */ {"SITUA", IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 4, 0, 1, 0, "Single initiator threshold unit attention", NULL}, /* descriptor starts here, the is relative to the start * of the mode page (i.e. 16 more than descriptor format table) */ {"LBP_EN", IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 16, 7, 1, 0, "Threshold enabled", NULL}, {"LBP_TYPE", IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 16, 5, 3, 0, "Threshold type", NULL}, {"LBP_ARM", IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 16, 2, 3, 0, "Threshold arming", NULL}, {"LBP_RES", IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 17, 7, 8, 0, "Threshold resource", NULL}, {"LBP_COUNT", IEC_MP, MSP_SBC_LB_PROV, PDT_DISK, 20, 7, 32, 0, "Threshold count", NULL}, /* Medium configuration mode page [0x1d] ssc3 */ {"WORMM", MED_CONF_MP, 0, PDT_TAPE, 2, 0, 1, 0, "Worm mode", NULL}, {"WMLR", MED_CONF_MP, 0, PDT_TAPE, 4, 7, 8, 0, "Worm mode label restrictions", "0: disallow overwrite; 1: disallow some format labels overwrite\t" "2: allow all format labels to be overwritten"}, {"WMFR", MED_CONF_MP, 0, PDT_TAPE, 5, 7, 8, 0, "Worm mode filemark restrictions", "2: allow filemarks before EOD except closest to BOP\t" "3: allow any number of filemarks before EOD"}, /* Timeout and protect mode page [0x1d] mmc5 */ {"G3E", TIMEOUT_PROT_MP, 0, PDT_MMC, 4, 3, 1, 0, "Group 3 timeout capability enable", NULL}, {"TMOE", TIMEOUT_PROT_MP, 0, PDT_MMC, 4, 2, 1, 0, "Timeout enable", NULL}, {"DISP", TIMEOUT_PROT_MP, 0, PDT_MMC, 4, 1, 1, 0, "Disable (unavailable) until power cycle", NULL}, {"SWPP", TIMEOUT_PROT_MP, 0, PDT_MMC, 4, 0, 1, 0, "Software write protect until power cycle", NULL}, {"G1MT", TIMEOUT_PROT_MP, 0, PDT_MMC, 6, 7, 16, 0, "Group 1 minimum timeout (sec)", NULL}, {"G2MT", TIMEOUT_PROT_MP, 0, PDT_MMC, 8, 7, 16, 0, "Group 2 minimum timeout (sec)", NULL}, /* Element address assignment mode page [0x1d] smc2 */ {"FMTEA", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 2, 7, 16, 0, "First medium transport element address", NULL}, {"NMTE", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 4, 7, 16, 0, "Number of medium transport elements", NULL}, {"FSEA", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 6, 7, 16, 0, "First storage element address", NULL}, {"NSE", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 8, 7, 16, 0, "Number of storage elements", NULL}, {"FIEEA", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 10, 7, 16, 0, "First import/export element address", NULL}, {"NIEE", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 12, 7, 16, 0, "Number of import/export elements", NULL}, {"FDTEA", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 14, 7, 16, 0, "First data transfer element address", NULL}, {"NDTE", ELE_ADDR_ASS_MP, 0, PDT_MCHANGER, 16, 7, 16, 0, "Number of data transfer elements", NULL}, /* Transport geometry parameters mode page [0x1e] smc2 */ /* transport geometry descriptor starts here, is relative * to start of mode page (i.e. 2 more than shown in descriptor table */ {"ROTAT", TRANS_GEO_PAR_MP, 0, PDT_MCHANGER, 2, 0, 1, 0, "Rotation for double sided media handling", NULL}, {"MNTES", TRANS_GEO_PAR_MP, 0, PDT_MCHANGER, 3, 7, 8, 0, "Member number in transport element set", NULL}, /* Device capabilities mode page [0x1f] smc3 */ {"STORDT", DEV_CAP_MP, 0, PDT_MCHANGER, 2, 3, 1, 0, "Storage for data transfer element", NULL}, {"STORIE", DEV_CAP_MP, 0, PDT_MCHANGER, 2, 2, 1, 0, "Storage for import/export element", NULL}, {"STORST", DEV_CAP_MP, 0, PDT_MCHANGER, 2, 1, 1, 0, "Storage for storage element", NULL}, {"STORMT", DEV_CAP_MP, 0, PDT_MCHANGER, 2, 0, 1, 0, "Storage for medium transport element", NULL}, {"ACE", DEV_CAP_MP, 0, PDT_MCHANGER, 3, 2, 1, 0, "Auto clean enabled", NULL}, {"VTRP", DEV_CAP_MP, 0, PDT_MCHANGER, 3, 1, 1, 0, "Volume tag reader present", NULL}, {"S2C", DEV_CAP_MP, 0, PDT_MCHANGER, 3, 0, 1, 0, "SMC-2 capabilities supported", NULL}, {"MT_RA", DEV_CAP_MP, 0, PDT_MCHANGER, 4, 7, 2, 0, "Medium transport elements support Read Attribute", NULL}, {"MT2DT", DEV_CAP_MP, 0, PDT_MCHANGER, 4, 3, 1, 0, "Medium transport -> data transfer; Move Medium", NULL}, {"MT2IE", DEV_CAP_MP, 0, PDT_MCHANGER, 4, 2, 1, 0, "Medium transport -> import/export; Move Medium", NULL}, {"MT2ST", DEV_CAP_MP, 0, PDT_MCHANGER, 4, 1, 1, 0, "Medium transport -> storage; Move Medium", NULL}, {"MT2MT", DEV_CAP_MP, 0, PDT_MCHANGER, 4, 0, 1, 0, "Medium transport -> medium transport; Move Medium", NULL}, {"ST_RA", DEV_CAP_MP, 0, PDT_MCHANGER, 5, 7, 2, 0, "Storage elements support Read Attribute", NULL}, {"ST2DT", DEV_CAP_MP, 0, PDT_MCHANGER, 5, 3, 1, 0, "Storage -> data transfer; Move Medium", NULL}, {"ST2IE", DEV_CAP_MP, 0, PDT_MCHANGER, 5, 2, 1, 0, "Storage -> import/export; Move Medium", NULL}, {"ST2ST", DEV_CAP_MP, 0, PDT_MCHANGER, 5, 1, 1, 0, "Storage -> storage; Move Medium", NULL}, {"ST2MT", DEV_CAP_MP, 0, PDT_MCHANGER, 5, 0, 1, 0, "Storage -> medium transport; Move Medium", NULL}, {"IE_RA", DEV_CAP_MP, 0, PDT_MCHANGER, 6, 7, 2, 0, "Import/export elements support Read Attribute", NULL}, {"IE2DT", DEV_CAP_MP, 0, PDT_MCHANGER, 6, 3, 1, 0, "Import/export -> data transfer; Move Medium", NULL}, {"IE2IE", DEV_CAP_MP, 0, PDT_MCHANGER, 6, 2, 1, 0, "Import/export -> import/export; Move Medium", NULL}, {"IE2ST", DEV_CAP_MP, 0, PDT_MCHANGER, 6, 1, 1, 0, "Import/export -> storage; Move Medium", NULL}, {"IE2MT", DEV_CAP_MP, 0, PDT_MCHANGER, 6, 0, 1, 0, "Import/export -> medium transport; Move Medium", NULL}, {"DT_RA", DEV_CAP_MP, 0, PDT_MCHANGER, 7, 7, 2, 0, "Data transfer elements support Read Attribute", NULL}, {"DT2DT", DEV_CAP_MP, 0, PDT_MCHANGER, 7, 3, 1, 0, "Data transfer -> data transfer; Move Medium", NULL}, {"DT2IE", DEV_CAP_MP, 0, PDT_MCHANGER, 7, 2, 1, 0, "Data transfer -> import/export; Move Medium", NULL}, {"DT2ST", DEV_CAP_MP, 0, PDT_MCHANGER, 7, 1, 1, 0, "Data transfer -> storage; Move Medium", NULL}, {"DT2MT", DEV_CAP_MP, 0, PDT_MCHANGER, 7, 0, 1, 0, "Data transfer -> medium transport; Move Medium", NULL}, {"MT_WA", DEV_CAP_MP, 0, PDT_MCHANGER, 12, 7, 2, 0, "Medium transport elements support Write Attribute", NULL}, {"MTEDT", DEV_CAP_MP, 0, PDT_MCHANGER, 12, 3, 1, 0, "Medium transport -> data transfer; Exchange Medium", NULL}, {"MTEIE", DEV_CAP_MP, 0, PDT_MCHANGER, 12, 2, 1, 0, "Medium transport -> import/export; Exchange Medium", NULL}, {"MTEST", DEV_CAP_MP, 0, PDT_MCHANGER, 12, 1, 1, 0, "Medium transport -> storage; Exchange Medium", NULL}, {"MTEMT", DEV_CAP_MP, 0, PDT_MCHANGER, 12, 0, 1, 0, "Medium transport -> medium transport; Exchange Medium", NULL}, {"ST_WA", DEV_CAP_MP, 0, PDT_MCHANGER, 13, 7, 2, 0, "Storage elements support Write Attribute", NULL}, {"STEDT", DEV_CAP_MP, 0, PDT_MCHANGER, 13, 3, 1, 0, "Storage -> data transfer; Exchange Medium", NULL}, {"STEIE", DEV_CAP_MP, 0, PDT_MCHANGER, 13, 2, 1, 0, "Storage -> import/export; Exchange Medium", NULL}, {"STEST", DEV_CAP_MP, 0, PDT_MCHANGER, 13, 1, 1, 0, "Storage -> storage; Exchange Medium", NULL}, {"STEMT", DEV_CAP_MP, 0, PDT_MCHANGER, 13, 0, 1, 0, "Storage -> medium transport; Exchange Medium", NULL}, {"IE_WA", DEV_CAP_MP, 0, PDT_MCHANGER, 14, 7, 2, 0, "Import/export elements support Write Attribute", NULL}, {"IEEDT", DEV_CAP_MP, 0, PDT_MCHANGER, 14, 3, 1, 0, "Import/export -> data transfer; Exchange Medium", NULL}, {"IEEIE", DEV_CAP_MP, 0, PDT_MCHANGER, 14, 2, 1, 0, "Import/export -> import/export; Exchange Medium", NULL}, {"IEEST", DEV_CAP_MP, 0, PDT_MCHANGER, 14, 1, 1, 0, "Import/export -> storage; Exchange Medium", NULL}, {"IEEMT", DEV_CAP_MP, 0, PDT_MCHANGER, 14, 0, 1, 0, "Import/export -> medium transport; Exchange Medium", NULL}, {"DT_WA", DEV_CAP_MP, 0, PDT_MCHANGER, 15, 7, 2, 0, "Data transfer elements support Write Attribute", NULL}, {"DTEDT", DEV_CAP_MP, 0, PDT_MCHANGER, 15, 3, 1, 0, "Data transfer -> data transfer; Exchange Medium", NULL}, {"DTEIE", DEV_CAP_MP, 0, PDT_MCHANGER, 15, 2, 1, 0, "Data transfer -> import/export; Exchange Medium", NULL}, {"DTEST", DEV_CAP_MP, 0, PDT_MCHANGER, 15, 1, 1, 0, "Data transfer -> storage; Exchange Medium", NULL}, {"DTEMT", DEV_CAP_MP, 0, PDT_MCHANGER, 15, 0, 1, 0, "Data transfer -> medium transport; Exchange Medium", NULL}, /* Extended device capabilities mode page [0x1f,0x41] smc3 */ {"MVPRV", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 4, 5, 1, 0, "Move prevented to import/export element", NULL}, {"MVCL", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 4, 4, 1, 0, "Move closes import/export element", NULL}, {"MVOP", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 4, 3, 1, 0, "Move opens import/export element", NULL}, {"USRCL", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 4, 2, 1, 0, "User control import/export element close", NULL}, {"USROP", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 4, 1, 1, 0, "User control import/export element open", NULL}, {"IEST", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 4, 0, 1, 0, "Import/export element state", NULL}, {"DTETA", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 5, 4, 1, 0, "Data transfer element empty on door access", NULL}, {"RSSEA", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 5, 3, 1, 0, "Return to source storage element address", NULL}, {"MVTRY", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 5, 2, 1, 0, "Move tray", NULL}, {"IEMGZ", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 5, 1, 1, 0, "Import/export magazine", NULL}, {"SMGZ", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 5, 0, 1, 0, "Storage magazine", NULL}, {"TREXC", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 6, 2, 1, 0, "True exchange capable", NULL}, {"LCKIE", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 6, 1, 1, 0, "Lock import/export element", NULL}, {"LCKD", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 6, 0, 1, 0, "Lock door", NULL}, {"SPMER", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 7, 2, 1, 0, "Source pre-move eject required", NULL}, {"DPMER", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 7, 1, 1, 0, "Destination pre-move eject required", NULL}, {"PEPOS", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 7, 0, 1, 0, "Pre-eject position", NULL}, {"UCST", DEV_CAP_MP, MSP_EXT_DEV_CAP, PDT_MCHANGER, 8, 0, 1, 0, "Unassigned cleaning storage", NULL}, /* CD/DVD (MM) capabilities and mechanical status mode page */ /* [0x2a] obsolete in mmc4 and mmc5, last valid in mmc3 */ /* MRSS field was already obsolete in mmc3 */ {"D_RAM_R", MMCMS_MP, 0, PDT_MMC, 2, 5, 1, 0, "DVD-RAM read", NULL}, {"D_R_R", MMCMS_MP, 0, PDT_MMC, 2, 4, 1, 0, "DVD-R read", NULL}, {"D_ROM_R", MMCMS_MP, 0, PDT_MMC, 2, 3, 1, 0, "DVD-ROM read", NULL}, {"METH2", MMCMS_MP, 0, PDT_MMC, 2, 2, 1, 0, "Method 2", NULL}, {"CD_RW_R", MMCMS_MP, 0, PDT_MMC, 2, 1, 1, 0, "CD-RW read", NULL}, {"CD_R_R", MMCMS_MP, 0, PDT_MMC, 2, 0, 1, 0, "CD-R read", NULL}, {"D_RAM_W", MMCMS_MP, 0, PDT_MMC, 3, 5, 1, 0, "DVD-RAM write", NULL}, {"D_R_W", MMCMS_MP, 0, PDT_MMC, 3, 4, 1, 0, "DVD-R write", NULL}, /* was D_R_R, wrong, clashed with above */ {"TST_WR", MMCMS_MP, 0, PDT_MMC, 3, 2, 1, 0, "Test write", NULL}, /* was TST_W but clashed with page 0x5 */ {"CD_RW_W", MMCMS_MP, 0, PDT_MMC, 3, 1, 1, 0, "CD-RW write", NULL}, {"CD_R_W", MMCMS_MP, 0, PDT_MMC, 3, 0, 1, 0, "CD-R write", NULL}, {"BUF", MMCMS_MP, 0, PDT_MMC, 4, 7, 1, 0, "Buffer underrun free recording", NULL}, {"MULT_S", MMCMS_MP, 0, PDT_MMC, 4, 6, 1, 0, "Multi session", NULL}, /* was MULTI_S but clashed with page 0x5 */ {"M2F2", MMCMS_MP, 0, PDT_MMC, 4, 5, 1, 0, "Mode 2 form 2", NULL}, {"M2F1", MMCMS_MP, 0, PDT_MMC, 4, 4, 1, 0, "Mode 2 form 1", NULL}, {"DP_2", MMCMS_MP, 0, PDT_MMC, 4, 3, 1, 0, "Digital port 2", NULL}, {"DP_1", MMCMS_MP, 0, PDT_MMC, 4, 2, 1, 0, "Digital port 1", NULL}, {"COMP", MMCMS_MP, 0, PDT_MMC, 4, 1, 1, 0, "Composite", NULL}, {"AUDIO_P", MMCMS_MP, 0, PDT_MMC, 4, 0, 1, 0, "Audio play", NULL}, {"RBC", MMCMS_MP, 0, PDT_MMC, 5, 7, 1, 0, "Read bar code", NULL}, {"UPC", MMCMS_MP, 0, PDT_MMC, 5, 6, 1, 0, "Uniform product code", NULL}, {"ISRC", MMCMS_MP, 0, PDT_MMC, 5, 5, 1, 0, "International standard recording code", NULL}, {"C2PS", MMCMS_MP, 0, PDT_MMC, 5, 4, 1, 0, "C 2 pointers supported", NULL}, {"RW_DC", MMCMS_MP, 0, PDT_MMC, 5, 3, 1, 0, "R-W de-interleaved and corrected", NULL}, {"RW_S", MMCMS_MP, 0, PDT_MMC, 5, 2, 1, 0, "R-W supported", NULL}, {"CDDA_SA", MMCMS_MP, 0, PDT_MMC, 5, 1, 1, 0, "CD-DA stream accurate", NULL}, {"CDDA_CS", MMCMS_MP, 0, PDT_MMC, 5, 0, 1, 0, "CD-DA commands supported", NULL}, {"LMT", MMCMS_MP, 0, PDT_MMC, 6, 7, 3, 0, "Loading mechanism type", NULL}, {"EJECT", MMCMS_MP, 0, PDT_MMC, 6, 3, 1, 0, "Eject (individual or magazine)", NULL}, {"PJ", MMCMS_MP, 0, PDT_MMC, 6, 2, 1, 0, "Prevent jumper", NULL}, {"LS", MMCMS_MP, 0, PDT_MMC, 6, 1, 1, 0, "Lock state", NULL}, {"LOCK", MMCMS_MP, 0, PDT_MMC, 6, 0, 1, 0, "Lock (supported)", NULL}, {"RWILI", MMCMS_MP, 0, PDT_MMC, 7, 5, 1, 0, "R-W in lead in", NULL}, {"SCC", MMCMS_MP, 0, PDT_MMC, 7, 4, 1, 0, "Side change capable", NULL}, {"SSS", MMCMS_MP, 0, PDT_MMC, 7, 3, 1, 0, "Software slot selection", NULL}, {"CSDP", MMCMS_MP, 0, PDT_MMC, 7, 2, 1, 0, "Changer supports disc present", NULL}, {"SCM", MMCMS_MP, 0, PDT_MMC, 7, 1, 1, 0, "Separate channel mute", NULL}, {"SVL", MMCMS_MP, 0, PDT_MMC, 7, 0, 1, 0, "Separate volume levels", NULL}, {"MRSS", MMCMS_MP, 0, PDT_MMC, 8, 7, 16, 0, "Maximum read speed supported (kBps) (obs)", NULL}, {"NVLS", MMCMS_MP, 0, PDT_MMC, 10, 7, 16, 0, "Number of volume levels supported", NULL}, {"BSS", MMCMS_MP, 0, PDT_MMC, 12, 7, 16, 0, "Buffer size supported (1024 bytes)", NULL}, {"LENGTH", MMCMS_MP, 0, PDT_MMC, 17, 5, 2, 0, "Length (bit length of IEC958 words)", NULL}, {"LSBF", MMCMS_MP, 0, PDT_MMC, 17, 3, 1, 0, "LSB (least significant bit) first", NULL}, {"RCK", MMCMS_MP, 0, PDT_MMC, 17, 2, 1, 0, "High on LRCK indicates left channel", NULL}, {"BCKF", MMCMS_MP, 0, PDT_MMC, 17, 1, 1, 0, "BCK signal falling edge", NULL}, {"CMRS", MMCMS_MP, 0, PDT_MMC, 22, 7, 16, 0, "Copy management revision supported", NULL}, {"RCS", MMCMS_MP, 0, PDT_MMC, 27, 1, 2, 0, "Rotation control selected", NULL}, {"CWSS", MMCMS_MP, 0, PDT_MMC, 28, 7, 16, 0, "Current write speed selected", NULL}, {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; /* << Transport protocol specific mode page items follow >> */ static struct sdparm_mode_page_item sdparm_mitem_fcp_arr[] = { /* disconnect-reconnect mode page [0x2] fcp3 */ {"BFR", DISCONNECT_MP, 0, -1, 2, 7, 8, 0, "Buffer full ratio", NULL}, {"BER", DISCONNECT_MP, 0, -1, 3, 7, 8, 0, "Buffer empty ratio", NULL}, {"BIL", DISCONNECT_MP, 0, -1, 4, 7, 16, MF_COMMON, "Bus inactivity limit (transmission words)", NULL}, {"DTL", DISCONNECT_MP, 0, -1, 6, 7, 16, MF_COMMON, "Disconnect time limit (128 transmission words)", NULL}, {"CTL", DISCONNECT_MP, 0, -1, 8, 7, 16, MF_COMMON, "Connect time limit (128 transmission words)", NULL}, {"MBS", DISCONNECT_MP, 0, -1, 10, 7, 16, MF_COMMON | MF_CLASH_OK, "Maximum burst size (512 bytes)", NULL}, {"EMDP", DISCONNECT_MP, 0, -1, 12, 7, 1, MF_CLASH_OK, "Enable modify data pointers", NULL}, {"FAA", DISCONNECT_MP, 0, -1, 12, 6, 1, 0, "Fairness access A [FCP_DATA]", NULL}, {"FAB", DISCONNECT_MP, 0, -1, 12, 5, 1, 0, "Fairness access B [FCP_XFER]", NULL}, {"FAC", DISCONNECT_MP, 0, -1, 12, 4, 1, 0, "Fairness access C [FCP_RSP]", NULL}, {"FBS", DISCONNECT_MP, 0, -1, 14, 7, 16, MF_CLASH_OK, "First burst size (512 bytes)", NULL}, /* protocol specific logical unit mode page [0x18] fcp3 */ {"LUPID", PROT_SPEC_LU_MP, 0, -1, 2, 3, 4, MF_COMMON | MF_CLASH_OK, "Logical unit's (transport) protocol identifier", PROTO_IDENT_STR }, {"EPDC", PROT_SPEC_LU_MP, 0, -1, 3, 0, 1, MF_COMMON, "Enable precise delivery checking", NULL}, /* protocol specific port control page [0x19] fcp3 */ {"PPID", PROT_SPEC_PORT_MP, 0, -1, 2, 3, 4, MF_COMMON | MF_CLASH_OK, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"DTFD", PROT_SPEC_PORT_MP, 0, -1, 3, 7, 1, MF_COMMON, "Disable target fabric discovery", NULL}, {"PLPB", PROT_SPEC_PORT_MP, 0, -1, 3, 6, 1, MF_COMMON, "Prevent loop port bypass", NULL}, {"DDIS", PROT_SPEC_PORT_MP, 0, -1, 3, 5, 1, 0, "Disable discovery", NULL}, {"DLM", PROT_SPEC_PORT_MP, 0, -1, 3, 4, 1, 0, "Disable loop master", NULL}, {"RHA", PROT_SPEC_PORT_MP, 0, -1, 3, 3, 1, 0, "Require hard address", NULL}, {"ALWI", PROT_SPEC_PORT_MP, 0, -1, 3, 2, 1, 0, "Allow login without loop initialization", NULL}, {"DTIPE", PROT_SPEC_PORT_MP, 0, -1, 3, 1, 1, 0, "Disable target initialized port enable", NULL}, {"DTOLI", PROT_SPEC_PORT_MP, 0, -1, 3, 0, 1, 0, "Disable target originated loop initialization", NULL}, {"RRTVU", PROT_SPEC_PORT_MP, 0, -1, 6, 2, 3, 0, "Resource recovery timeout value unit", NULL}, {"SIRRTV", PROT_SPEC_PORT_MP, 0, -1, 7, 7, 8, 0, "Sequence initiative resource recovery timeout value", NULL}, {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_spi_arr[] = { /* disconnect-reconnect mode page [0x2] spi4 */ {"BFR", DISCONNECT_MP, 0, -1, 2, 7, 8, 0, "Buffer full ratio", NULL}, {"BER", DISCONNECT_MP, 0, -1, 3, 7, 8, 0, "Buffer empty ratio", NULL}, {"BIL", DISCONNECT_MP, 0, -1, 4, 7, 16, MF_COMMON, "Bus inactivity limit (100 us)", NULL}, {"PDTL", DISCONNECT_MP, 0, -1, 6, 7, 16, MF_COMMON, "Physical disconnect time limit (100 us)", NULL}, {"CTL", DISCONNECT_MP, 0, -1, 8, 7, 16, MF_COMMON, "Connect time limit (100 us)", NULL}, {"MBS", DISCONNECT_MP, 0, -1, 10, 7, 16, MF_COMMON | MF_CLASH_OK, "Maximum burst size (512 bytes)", NULL}, {"EMDP", DISCONNECT_MP, 0, -1, 12, 7, 1, MF_CLASH_OK, "Enable modify data pointers", NULL}, {"FA", DISCONNECT_MP, 0, -1, 12, 6, 3, 0, "Fair arbitration", NULL}, {"DIMM", DISCONNECT_MP, 0, -1, 12, 3, 1, 0, "Disconnect immediate", NULL}, {"DTDC", DISCONNECT_MP, 0, -1, 12, 2, 3, 0, "Data transfer disconnect control", NULL}, /* protocol specific logical unit control mode page [0x18] spi4 */ {"LUPID", PROT_SPEC_LU_MP, 0, -1, 2, 3, 4, MF_COMMON | MF_CLASH_OK, "Logical unit's (transport) protocol identifier", PROTO_IDENT_STR }, /* protocol specific port control page [0x19] spi4 */ {"PPID", PROT_SPEC_PORT_MP, 0, -1, 2, 3, 4, MF_COMMON | MF_CLASH_OK, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"STT", PROT_SPEC_PORT_MP, 0, -1, 4, 7, 16, MF_COMMON, "Synchronous transfer timeout (ms)", NULL}, /* margin control subpage [0x19,0x1] spi4 */ {"PPID_1", PROT_SPEC_PORT_MP, MSP_SPI_MC, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"DS", PROT_SPEC_PORT_MP, MSP_SPI_MC, -1, 7, 7, 4, 0, "Driver strength", NULL}, {"DA", PROT_SPEC_PORT_MP, MSP_SPI_MC, -1, 8, 7, 4, 0, "Driver asymmetry", NULL}, {"DP", PROT_SPEC_PORT_MP, MSP_SPI_MC, -1, 8, 3, 4, 0, "Driver precompensation", NULL}, {"DSR", PROT_SPEC_PORT_MP, MSP_SPI_MC, -1, 9, 7, 4, 0, "Driver slew rate", NULL}, /* saved training configuration subpage [0x19,0x2] spi4 */ {"PPID_2", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"DB0", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 10, 7, 32, MF_HEX, "DB(0) value", NULL}, {"DB1", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 14, 7, 32, MF_HEX, "DB(1) value", NULL}, {"DB2", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 18, 7, 32, MF_HEX, "DB(2) value", NULL}, {"DB3", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 22, 7, 32, MF_HEX, "DB(3) value", NULL}, {"DB4", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 26, 7, 32, MF_HEX, "DB(4) value", NULL}, {"DB5", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 30, 7, 32, MF_HEX, "DB(5) value", NULL}, {"DB6", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 34, 7, 32, MF_HEX, "DB(6) value", NULL}, {"DB7", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 38, 7, 32, MF_HEX, "DB(7) value", NULL}, {"DB8", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 42, 7, 32, MF_HEX, "DB(8) value", NULL}, {"DB9", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 46, 7, 32, MF_HEX, "DB(9) value", NULL}, {"DB10", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 50, 7, 32, MF_HEX, "DB(10) value", NULL}, {"DB11", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 54, 7, 32, MF_HEX, "DB(11) value", NULL}, {"DB12", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 58, 7, 32, MF_HEX, "DB(12) value", NULL}, {"DB13", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 62, 7, 32, MF_HEX, "DB(13) value", NULL}, {"DB14", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 66, 7, 32, MF_HEX, "DB(14) value", NULL}, {"DB15", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 70, 7, 32, MF_HEX, "DB(15) value", NULL}, {"P_CRCA", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 74, 7, 32, MF_HEX, "P_CRCA value", NULL}, {"P1", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 78, 7, 32, MF_HEX, "P1 value", NULL}, {"BSY", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 82, 7, 32, MF_HEX, "BSY value", NULL}, {"SEL", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 86, 7, 32, MF_HEX, "SEL value", NULL}, {"RST", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 90, 7, 32, MF_HEX, "RST value", NULL}, {"REQ", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 94, 7, 32, MF_HEX, "REQ value", NULL}, {"ACK", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 98, 7, 32, MF_HEX, "ACK value", NULL}, {"ATN", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 102, 7, 32, MF_HEX, "ATN value", NULL}, {"C_D", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 106, 7, 32, MF_HEX, "C/D value", NULL}, {"I_O", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 110, 7, 32, MF_HEX, "I/O value", NULL}, {"MSG", PROT_SPEC_PORT_MP, MSP_SPI_STC, -1, 114, 7, 32, MF_HEX, "MSG value", NULL}, /* negotiated settings subpage [0x19,0x3] spi4 */ {"PPID_3", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"TPF", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 6, 7, 8, 0, "Transfer period factor", NULL}, {"RAO", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 8, 7, 8, 0, "REQ/ACK offset", NULL}, {"TWE", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 9, 7, 8, 0, "Transfer width exponent", NULL}, {"POB", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 10, 6, 7, 0, "Protocol option bits", NULL}, {"TM", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 11, 3, 2, 0, "Transceiver mode", NULL}, {"SPE", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 11, 1, 1, 0, "Sent PCOMP_EN bit (for current I_T nexus)", NULL}, {"RPE", PROT_SPEC_PORT_MP, MSP_SPI_NS, -1, 11, 0, 1, 0, "Received PCOMP_EN bit (for current I_T nexus)", NULL}, /* report transfer capabilities subpage [0x19,0x4] spi4 */ {"PPID_4", PROT_SPEC_PORT_MP, MSP_SPI_RTC, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"MTPF", PROT_SPEC_PORT_MP, MSP_SPI_RTC, -1, 6, 7, 8, 0, "Minimum transfer period factor", NULL}, {"MRAO", PROT_SPEC_PORT_MP, MSP_SPI_RTC, -1, 8, 7, 8, 0, "Maximum REQ/ACK offset", NULL}, {"MTWE", PROT_SPEC_PORT_MP, MSP_SPI_RTC, -1, 9, 7, 8, 0, "Maximum transfer width exponent", NULL}, {"POBS", PROT_SPEC_PORT_MP, MSP_SPI_RTC, -1, 10, 7, 8, 0, "Protocol option bits supported", NULL}, {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_srp_arr[] = { /* disconnect-reconnect mode page [0x2] srp */ {"MBS", DISCONNECT_MP, 0, -1, 10, 7, 16, MF_COMMON | MF_CLASH_OK, "Maximum burst size (512 bytes)", NULL}, {"EMDP", DISCONNECT_MP, 0, -1, 12, 7, 1, MF_CLASH_OK, "Enable modify data pointers", NULL}, {"FBS", DISCONNECT_MP, 0, -1, 14, 7, 16, MF_CLASH_OK, "First burst size (512 bytes)", NULL}, /* srp2r00 */ {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_sas_arr[] = { /* disconnect-reconnect mode page [0x2] sas/spl */ {"BITL", DISCONNECT_MP, 0, -1, 4, 7, 16, MF_COMMON, "Bus inactivity time limit (100us)", NULL}, {"MCTL", DISCONNECT_MP, 0, -1, 8, 7, 16, MF_COMMON, "Maximum connect time limit (100us)", NULL}, {"MBS", DISCONNECT_MP, 0, -1, 10, 7, 16, MF_COMMON | MF_CLASH_OK, "Maximum burst size (512 bytes)", NULL}, /* obsoleted spl3r2, re-instated spl3r3 */ {"FBS", DISCONNECT_MP, 0, -1, 14, 7, 16, MF_CLASH_OK, "First burst size (512 bytes)", NULL}, /* protocol specific logical unit mode page [0x18] sas/spl */ {"LUPID", PROT_SPEC_LU_MP, 0, -1, 2, 3, 4, MF_COMMON | MF_CLASH_OK, "Logical unit's (transport) protocol identifier", PROTO_IDENT_STR }, {"TLR", PROT_SPEC_LU_MP, 0, -1, 2, 4, 1, 0, "Transport layer retries (supported)", NULL}, /* protocol specific port mode page [0x19] sas/spl */ {"PPID", PROT_SPEC_PORT_MP, 0, -1, 2, 3, 4, MF_COMMON | MF_CLASH_OK, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"CAWT", PROT_SPEC_PORT_MP, 0, -1, 2, 6, 1, 0, "Continue AWT (arbitration wait time (timer))", NULL}, {"BAE", PROT_SPEC_PORT_MP, 0, -1, 2, 5, 1, 0, "Broadcast asynchronous event", NULL}, {"RLM", PROT_SPEC_PORT_MP, 0, -1, 2, 4, 1, MF_COMMON, "Ready LED meaning", "0: usually on, flash when command processing; off when stopped\t" "1: usually off, flash when command processing"}, {"ITNLT", PROT_SPEC_PORT_MP, 0, -1, 4, 7, 16, MF_COMMON, "I_T nexus loss time (ms)", "0: vendor specific\t" "0ffffh (-1): never recognize IT nexus loss"}, {"IRT", PROT_SPEC_PORT_MP, 0, -1, 6, 7, 16, MF_COMMON, "Initiator response timeout (ms)", "0: disable initiator response timeout timer"}, {"RTOL", PROT_SPEC_PORT_MP, 0, -1, 8, 7, 16, MF_COMMON, "Reject to open limit (10 us)", /* added in sas2r14 */ "0: vendor specific"}, /* phy control and discover mode page [0x19,0x1] sas/spl */ {"PPID_1", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"GENC", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 6, 7, 8, 0, "Generation code", "0: unknown, 1..255: valid"}, {"NOP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 7, 7, 8, MF_COMMON, "Number of phys", "one descriptor per phy"}, /* Phy mode descriptor starts here, relative to start of * mode page (i.e. 8 more than phy mode descriptor table) */ {"PHID", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 9, 7, 8, 0, "Phy identifier", NULL}, {"ADT", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 12, 6, 3, 0, "Attached device type", "0: no device attached; 1: end device\t" "2: expander device; " /* in SAS-1.1 this was a "edge expander" */ "3: expander device (fanout, SAS-1.1)"}, /* obsolete in SAS-2 */ {"AREAS", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 12, 3, 4, 0, "Attached reason (other end did link reset)", "0: unknown; 1: power on; 2: hard reset; 3: SMP phy control\t" "4: loss of dword sync; 5: mux problem; ..."}, {"REAS", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 13, 7, 4, 0, "Reason (for starting link reset)", "0: unknown; 1: power on; 2: hard reset; 3: SMP phy control\t" "4: loss of dword sync; 5: mux problem; ..."}, {"NLLR", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 13, 3, 4, 0, "Negotiated logical link rate", /* sas2r07 */ "0: unknown; 1: disabled; 2: phy reset problem; 3: spinup hold\t" "4: port selector; 5: resetting; 6: attached unsupported\t" "8: 1.5 Gbps; 9: 3 Gbps; 10: 6 Gbps; 11: 12 Gbps"}, {"ASIP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 14, 3, 1, 0, "Attached SSP initiator port", NULL}, {"ATIP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 14, 2, 1, 0, "Attached STP initiator port", NULL}, {"AMIP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 14, 1, 1, 0, "Attached SMP initiator port", NULL}, {"ASTP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 15, 3, 1, 0, "Attached SSP target port", NULL}, {"ATTP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 15, 2, 1, 0, "Attached STP target port", NULL}, {"AMTP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 15, 1, 1, 0, "Attached SMP target port", NULL}, {"SASA", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 16, 7, 64, MF_HEX | MF_COMMON, "SAS address", NULL}, {"ASASA", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 24, 7, 64, MF_HEX | MF_COMMON, "Attached SAS address", NULL}, {"APHID", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 32, 7, 8, 0, "Attached phy identifier", NULL}, {"APOWCAP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 33, 6, 2, 0, "Attached power capable", "0: not; 1: can consume; 2: can source"}, {"ASLCAP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 33, 4, 1, 0, "Attached slumber capable", NULL}, {"APACAP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 33, 3, 1, 0, "Attached partial capable", NULL}, {"AIZPER", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 33, 2, 1, 0, "Attached inside ZPSDS persistent", NULL}, {"AREQIZ", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 33, 1, 1, 0, "Attached request inside ZPSDS", NULL}, {"ABRCAP", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 33, 0, 1, 0, "Attached break reply capable", NULL}, {"PMILR", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 40, 7, 4, 0, "Programmed minimum link rate", "0: not programmed; 8: 1.5 Gbps; 9: 3 Gbps; 10: 6 Gbps; 11: 12 Gbps"}, {"HMILR", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 40, 3, 4, 0, "Hardware minimum link rate", "8: 1.5 Gbps; 9: 3 Gbps; 10: 6 Gbps; 11: 12 Gbps"}, {"PMALR", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 41, 7, 4, 0, "Programmed maximum link rate", "0: not programmed; 8: 1.5 Gbps; 9: 3 Gbps; 10: 6 Gbps; 11: 12 Gbps"}, {"HMALR", PROT_SPEC_PORT_MP, MSP_SAS_PCD, -1, 41, 3, 4, 0, "Hardware maximum link rate", "8: 1.5 Gbps; 9: 3 Gbps; 10: 6 Gbps; 11: 12 Gbps"}, /* shared port control mode page [0x19,0x2] sas/spl */ {"PPID_2", PROT_SPEC_PORT_MP, MSP_SAS_SPC, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"PLT", PROT_SPEC_PORT_MP, MSP_SAS_SPC, -1, 6, 7, 16, 0, "Power loss timeout(ms)", NULL}, {"PGRATO", PROT_SPEC_PORT_MP, MSP_SAS_SPC, -1, 9, 7, 8, 0, "Power grant timeout(sec)", NULL}, /* SAS-2 Enhanced phy mode page [0x19,0x3] sas/spl */ {"PPID_3", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 5, 3, 4, 0, "Port's (transport) protocol identifier", PROTO_IDENT_STR }, {"GENC_1", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 6, 7, 8, 0, "Generation code", "0: unknown, 1..255: valid"}, {"NOP_1", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 7, 7, 8, 0, "Number of phys", "one descriptor per phy"}, /* Phy mode descriptor starts here, relative to start of * mode page (i.e. 8 more than phy mode descriptor table) */ {"PHID_1", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 9, 7, 8, 0, "Phy identifier", NULL}, {"PPCAP", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 12, 7, 32, MF_HEX, "Programmed phy capabilities", NULL}, {"CPCAP", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 16, 7, 32, MF_HEX, "Current phy capabilities", NULL}, {"APCAP", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 20, 7, 32, MF_HEX, "Attached phy capabilities", NULL}, {"OPT_M_EN", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 26, 5, 1, 0, "Optical mode enabled", NULL}, {"N_SSC", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 26, 4, 1, 0, "Negotiated spread spectrum clocking", NULL}, {"NPLR", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 26, 3, 4, 0, "Negotiated physical link rate", "0: unknown; 1: disabled; 2: phy reset problem; 3: spinup hold\t" "4: port selector; 5: resetting; 6: attached unsupported\t" "8: 1.5 Gbps; 9: 3 Gbps; 10: 6 Gbps; 11: 12 Gbps"}, {"EN_SL", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 27, 2, 1, 0, "Enable slumber phy power condition", NULL}, {"EN_PA", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 27, 1, 1, 0, "Enable partial phy power condition", NULL}, {"HMS", PROT_SPEC_PORT_MP, MSP_SAS_E_PHY, -1, 27, 0, 1, 0, "Hardware muxing supported", NULL}, {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; /* fixed length, indexed by transport protocol number */ struct sdparm_transport_pair sdparm_transport_mp[] = { {sdparm_fcp_mode_pg, sdparm_mitem_fcp_arr}, /* 0 */ {sdparm_spi_mode_pg, sdparm_mitem_spi_arr}, {NULL, NULL}, {NULL, NULL}, {sdparm_srp_mode_pg, sdparm_mitem_srp_arr}, {NULL, NULL}, {sdparm_sas_mode_pg, sdparm_mitem_sas_arr}, {NULL, NULL}, {NULL, NULL}, /* 8 */ {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, /* 15 */ }; const char * sdparm_pdt_doc_strs[] = { /* 0 */ "SBC-3", /* disk */ "SSC-3", /* tape */ "SSC", /* printer */ "SPC-2", /* processor */ "SBC", /* write once optical disk */ /* 5 */ "MMC-5", /* cd/dvd */ "SCSI-2", /* scanner */ "SBC-2", /* optical memory device */ "SMC-2", /* medium changer */ "SCSI-2", /* communications */ /* 0xa */ "SCSI-2", /* graphics [0xa] */ "SCSI-2", /* graphics [0xb] */ "SCC-2", /* storage array controller */ "SES-2", /* enclosure services device */ "RBC", /* simplified direct access device */ "OCRW", /* optical card reader/writer device */ /* 0x10 */ "BCC", /* bridge controller commands */ "OSD-2", /* object based storage */ "ADC", /* automation/driver interface */ "SPC-4", /* security manager device */ "unknown", /* 0x14 */ "unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "unknown", /* 0x1d */ "SPC-4", /* well known logical unit */ "SPC-4", /* no physical device on this lu */ }; const char * sdparm_code_set_arr[] = { "Reserved [0x0]", "Binary", "ASCII", "UTF-8", "Reserved [0x4]", "Reserved [0x5]", "Reserved [0x6]", "Reserved [0x7]", "Reserved [0x8]", "Reserved [0x9]", "Reserved [0xa]", "Reserved [0xb]", "Reserved [0xc]", "Reserved [0xd]", "Reserved [0xe]", "Reserved [0xf]", }; const char * sdparm_assoc_arr[] = { "Addressed logical unit", "Target port", /* that received request; unless SCSI ports VPD */ "Target device that contains addressed lu", "Reserved [0x3]", }; const char * sdparm_desig_type_arr[] = { "vendor specific [0x0]", "T10 vendor identification", "EUI-64 based", "NAA", "Relative target port", "Target port group", /* spc4r09: _primary_ target port group */ "Logical unit group", "MD5 logical unit identifier", "SCSI name string", "Protocol specific port identifier", /* spc4r36 */ "Reserved [0xa]", "Reserved [0xb]", "Reserved [0xc]", "Reserved [0xd]", "Reserved [0xe]", "Reserved [0xf]", }; const char * sdparm_ansi_version_arr[] = { "no conformance claimed", "SCSI-1", "SCSI-2", "SPC", "SPC-2", "SPC-3", "SPC-4", "ANSI version: 7", }; const char * sdparm_network_service_type_arr[] = { "unspecified", "storage configuration service", "diagnostics", "status", "logging", "code download", "administrative configuration service", "reserved[0x7]", "reserved[0x8]", "reserved[0x9]", "reserved[0xa]", "reserved[0xb]", "reserved[0xc]", "reserved[0xd]", "reserved[0xe]", "reserved[0xf]", "reserved[0x10]", "reserved[0x11]", "reserved[0x12]", "reserved[0x13]", "reserved[0x14]", "reserved[0x15]", "reserved[0x16]", "reserved[0x17]", "reserved[0x18]", "reserved[0x19]", "reserved[0x1a]", "reserved[0x1b]", "reserved[0x1c]", "reserved[0x1d]", "reserved[0x1e]", "reserved[0x1f]", }; const char * sdparm_mode_page_policy_arr[] = { "shared", "per target port", "per initiator port (obsolete)", /* made obsolete in SPC-4 */ "per I_T nexus", }; struct sdparm_command_t sdparm_command_arr[] = { {CMD_CAPACITY, "capacity", "ca", NULL}, {CMD_EJECT, "eject", "ej", NULL}, {CMD_LOAD, "load", "lo", NULL}, {CMD_PROFILE, "profile", "pr", NULL}, {CMD_READY, "ready", "re", NULL}, {CMD_SENSE, "sense", "se", NULL}, {CMD_SPEED, "speed", "sp", "new_speed_kbps"}, {CMD_START, "start", "sta", NULL}, {CMD_STOP, "stop", "sto", NULL}, {CMD_SYNC, "sync", "sy", NULL}, {CMD_UNLOCK, "unlock", "un", NULL}, {-1, NULL, NULL, NULL}, }; struct sdparm_val_desc_t sdparm_profile_arr[] = { {0x0, "No current profile"}, {0x1, "Non-removable disk (obs)"}, {0x2, "Removable disk"}, {0x3, "Magneto optical erasable"}, {0x4, "Optical write once"}, {0x5, "AS-MO"}, {0x8, "CD-ROM"}, {0x9, "CD-R"}, {0xa, "CD-RW"}, {0x10, "DVD-ROM"}, {0x11, "DVD-R sequential recording"}, {0x12, "DVD-RAM"}, {0x13, "DVD-RW restricted overwrite"}, {0x14, "DVD-RW sequential recording"}, {0x15, "DVD-R dual layer sequental recording"}, {0x16, "DVD-R dual layer jump recording"}, {0x17, "DVD-RW dual layer"}, {0x18, "DVD-Download disc recording"}, {0x1a, "DVD+RW"}, {0x1b, "DVD+R"}, {0x20, "DDCD-ROM"}, {0x21, "DDCD-R"}, {0x22, "DDCD-RW"}, {0x2a, "DVD+RW dual layer"}, {0x2b, "DVD+R dual layer"}, {0x40, "BD-ROM"}, {0x41, "BD-R SRM"}, {0x42, "BD-R RRM"}, {0x43, "BD-RE"}, {0x50, "HD DVD-ROM"}, {0x51, "HD DVD-R"}, {0x52, "HD DVD-RAM"}, {0x53, "HD DVD-RW"}, {0x58, "HD DVD-R dual layer"}, {0x5a, "HD DVD-RW dual layer"}, {0xffff, "Non-conforming profile"}, {-1, NULL}, }; sdparm-1.08/src/getopt_long.c0000664000175000017500000002747112062455663015226 0ustar douggdougg/* $NetBSD: getopt_long.c,v 1.17 2004/06/20 22:20:15 jmc Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dieter Baron and Thomas Klausner. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * modified May 12, 2005 by Jim Basney * * removed #include of non-POSIX * removed #include of "namespace.h" * use local "port_getopt.h" instead of * removed REPLACE_GETOPT and HAVE_NBTOOL_CONFIG_H sections * removed __P() from function declarations * use ANSI C function parameter lists * removed optreset support * replace _DIAGASSERT() with assert() * replace non-POSIX warnx(...) with fprintf(stderr, ...) * added extern declarations for optarg, optind, opterr, and optopt */ #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: getopt_long.c,v 1.17 2004/06/20 22:20:15 jmc Exp $"); #endif /* LIBC_SCCS and not lint */ #include #include #include "port_getopt.h" #include #include #include #ifdef __weak_alias __weak_alias(getopt_long,_getopt_long) #endif #if !HAVE_GETOPT_LONG #define IGNORE_FIRST (*options == '-' || *options == '+') #define PRINT_ERROR ((opterr) && ((*options != ':') \ || (IGNORE_FIRST && options[1] != ':'))) #define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL) #define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST) /* XXX: GNU ignores PC if *options == '-' */ #define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-') /* return values */ #define BADCH (int)'?' #define BADARG ((IGNORE_FIRST && options[1] == ':') \ || (*options == ':') ? (int)':' : (int)'?') #define INORDER (int)1 #define EMSG "" extern char *optarg; extern int optind, opterr, optopt; static int getopt_internal (int, char * const *, const char *); static int gcd (int, int); static void permute_args (int, int, int, char * const *); static char *place = EMSG; /* option letter processing */ static int nonopt_start = -1; /* first non option argument (for permute) */ static int nonopt_end = -1; /* first option after non options (for permute) */ /* Error messages */ static const char recargchar[] = "option requires an argument -- %c"; static const char recargstring[] = "option requires an argument -- %s"; static const char ambig[] = "ambiguous option -- %.*s"; static const char noarg[] = "option doesn't take an argument -- %.*s"; static const char illoptchar[] = "unknown option -- %c"; static const char illoptstring[] = "unknown option -- %s"; /* * Compute the greatest common divisor of a and b. */ static int gcd(int a, int b) { int c; c = a % b; while (c != 0) { a = b; b = c; c = a % b; } return b; } /* * Exchange the block from nonopt_start to nonopt_end with the block * from nonopt_end to opt_end (keeping the same order of arguments * in each block). */ static void permute_args(int panonopt_start, int panonopt_end, int opt_end, char * const *nargv) { int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; char *swap; assert(nargv != NULL); /* * compute lengths of blocks and number and size of cycles */ nnonopts = panonopt_end - panonopt_start; nopts = opt_end - panonopt_end; ncycle = gcd(nnonopts, nopts); cyclelen = (opt_end - panonopt_start) / ncycle; for (i = 0; i < ncycle; i++) { cstart = panonopt_end+i; pos = cstart; for (j = 0; j < cyclelen; j++) { if (pos >= panonopt_end) pos -= nnonopts; else pos += nopts; swap = nargv[pos]; /* LINTED const cast */ ((char **) nargv)[pos] = nargv[cstart]; /* LINTED const cast */ ((char **)nargv)[cstart] = swap; } } } /* * getopt_internal -- * Parse argc/argv argument vector. Called by user level routines. * Returns -2 if -- is found (can be long option or end of options marker). */ static int getopt_internal(int nargc, char * const *nargv, const char *options) { char *oli; /* option letter list index */ int optchar; assert(nargv != NULL); assert(options != NULL); optarg = NULL; /* * XXX Some programs (like rsyncd) expect to be able to * XXX re-initialize optind to 0 and have getopt_long(3) * XXX properly function again. Work around this braindamage. */ if (optind == 0) optind = 1; start: if (!*place) { /* update scanning pointer */ if (optind >= nargc) { /* end of argument vector */ place = EMSG; if (nonopt_end != -1) { /* do permutation, if we have to */ permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; } else if (nonopt_start != -1) { /* * If we skipped non-options, set optind * to the first of them. */ optind = nonopt_start; } nonopt_start = nonopt_end = -1; return -1; } if ((*(place = nargv[optind]) != '-') || (place[1] == '\0')) { /* found non-option */ place = EMSG; if (IN_ORDER) { /* * GNU extension: * return non-option as argument to option 1 */ optarg = nargv[optind++]; return INORDER; } if (!PERMUTE) { /* * if no permutation wanted, stop parsing * at first non-option */ return -1; } /* do permutation */ if (nonopt_start == -1) nonopt_start = optind; else if (nonopt_end != -1) { permute_args(nonopt_start, nonopt_end, optind, nargv); nonopt_start = optind - (nonopt_end - nonopt_start); nonopt_end = -1; } optind++; /* process next argument */ goto start; } if (nonopt_start != -1 && nonopt_end == -1) nonopt_end = optind; if (place[1] && *++place == '-') { /* found "--" */ place++; return -2; } } if ((optchar = (int)*place++) == (int)':' || (oli = strchr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) { /* option letter unknown or ':' */ if (!*place) ++optind; if (PRINT_ERROR) fprintf(stderr, illoptchar, optchar); optopt = optchar; return BADCH; } if (optchar == 'W' && oli[1] == ';') { /* -W long-option */ /* XXX: what if no long options provided (called by getopt)? */ if (*place) return -2; if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) fprintf(stderr, recargchar, optchar); optopt = optchar; return BADARG; } else /* white space */ place = nargv[optind]; /* * Handle -W arg the same as --arg (which causes getopt to * stop parsing). */ return -2; } if (*++oli != ':') { /* doesn't take argument */ if (!*place) ++optind; } else { /* takes (optional) argument */ optarg = NULL; if (*place) /* no white space */ optarg = place; /* XXX: disable test for :: if PC? (GNU doesn't) */ else if (oli[1] != ':') { /* arg not optional */ if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) fprintf(stderr, recargchar, optchar); optopt = optchar; return BADARG; } else optarg = nargv[optind]; } place = EMSG; ++optind; } /* dump back option letter */ return optchar; } /* * getopt_long -- * Parse argc/argv argument vector. */ int getopt_long(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx) { int retval; assert(nargv != NULL); assert(options != NULL); assert(long_options != NULL); /* idx may be NULL */ if ((retval = getopt_internal(nargc, nargv, options)) == -2) { char *current_argv, *has_equal; size_t current_argv_len; int i, match; current_argv = place; match = -1; optind++; place = EMSG; if (*current_argv == '\0') { /* found "--" */ /* * We found an option (--), so if we skipped * non-options, we have to permute. */ if (nonopt_end != -1) { permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; } nonopt_start = nonopt_end = -1; return -1; } if ((has_equal = strchr(current_argv, '=')) != NULL) { /* argument found (--option=arg) */ current_argv_len = has_equal - current_argv; has_equal++; } else current_argv_len = strlen(current_argv); for (i = 0; long_options[i].name; i++) { /* find matching long option */ if (strncmp(current_argv, long_options[i].name, current_argv_len)) continue; if (strlen(long_options[i].name) == (unsigned)current_argv_len) { /* exact match */ match = i; break; } if (match == -1) /* partial match */ match = i; else { /* ambiguous abbreviation */ if (PRINT_ERROR) fprintf(stderr, ambig, (int)current_argv_len, current_argv); optopt = 0; return BADCH; } } if (match != -1) { /* option found */ if (long_options[match].has_arg == no_argument && has_equal) { if (PRINT_ERROR) fprintf(stderr, noarg, (int)current_argv_len, current_argv); /* * XXX: GNU sets optopt to val regardless of * flag */ if (long_options[match].flag == NULL) optopt = long_options[match].val; else optopt = 0; return BADARG; } if (long_options[match].has_arg == required_argument || long_options[match].has_arg == optional_argument) { if (has_equal) optarg = has_equal; else if (long_options[match].has_arg == required_argument) { /* * optional argument doesn't use * next nargv */ optarg = nargv[optind++]; } } if ((long_options[match].has_arg == required_argument) && (optarg == NULL)) { /* * Missing argument; leading ':' * indicates no error should be generated */ if (PRINT_ERROR) fprintf(stderr, recargstring, current_argv); /* * XXX: GNU sets optopt to val regardless * of flag */ if (long_options[match].flag == NULL) optopt = long_options[match].val; else optopt = 0; --optind; return BADARG; } } else { /* unknown option */ if (PRINT_ERROR) fprintf(stderr, illoptstring, current_argv); optopt = 0; return BADCH; } if (long_options[match].flag) { *long_options[match].flag = long_options[match].val; retval = 0; } else retval = long_options[match].val; if (idx) *idx = match; } return retval; } #endif /* !GETOPT_LONG */ sdparm-1.08/src/sdparm_data_vendor.c0000664000175000017500000002070712062455663016534 0ustar douggdougg/* * Copyright (c) 2007-2012 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include "sdparm.h" /* * sdparm is a utility program to access and change SCSI device * (logical unit) mode page fields and do some other housekeeping. * * This file contains vendor data tables that may be useful for other * programs. */ /* Vendor specific mode pages */ struct sdparm_vendor_name_t sdparm_vendor_id[] = { {VENDOR_SEAGATE, "sea", "Seagate disk"}, {VENDOR_HITACHI, "hit", "Hitachi disk"}, {VENDOR_MAXTOR, "max", "Maxtor disk"}, {VENDOR_FUJITSU, "fuj", "Fujitsu disk"}, {0, NULL, NULL}, }; static struct sdparm_mode_page_t sdparm_v_seagate_mode_pg[] = { {UNIT_ATTENTION_MP, 0, 0, 0, "ua", "Unit attention (seagate)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_v_seagate_arr[] = { /* Unit attention page [0x0] Seagate */ {"PM", UNIT_ATTENTION_MP, 0, 0, 2, 7, 1, MF_COMMON, "Performance Mode", "0: adaptive cache ('server mode')\t" "1: number of cache segments as per caching page ('desktop mode')"}, {"SSM", UNIT_ATTENTION_MP, 0, 0, 2, 6, 1, 0, "Synchronous select mode (SPI)", "0: drive will not initiate WDTR or SDTR\t" "1: drive may initiate WDTR or SDTR"}, {"IL", UNIT_ATTENTION_MP, 0, 0, 2, 5, 1, MF_COMMON, "Inquiry length", "0: more than 36 bytes in response\t" "1: 36 byte response as per SCSI-2"}, {"UA", UNIT_ATTENTION_MP, 0, 0, 2, 4, 1, MF_COMMON, "Unit attention", "0: unit attention condition for all initiators after reset\t" "1: no check condition with unit attention after reset"}, {"DFUA", UNIT_ATTENTION_MP, 0, 0, 2, 3, 1, 0, "Disable force unit access (FUA)", "0: honour FUA bit setting on READ and WRITE commands\t" "1: ignore FUA bit setting"}, {"ROUND", UNIT_ATTENTION_MP, 0, 0, 2, 2, 1, 0, "Reporting of log parameter rounding (wrap around)", "0: do not report (silently round)\t" "1: report rounding (as per SPC-4)"}, {"STRICT", UNIT_ATTENTION_MP, 0, 0, 2, 1, 1, MF_COMMON, "Strict when trying to alter unchangeable mode page fields", "0: silently ignore\t" "1: report as error"}, {"SCSI2", UNIT_ATTENTION_MP, 0, 0, 2, 0, 1, MF_COMMON, "SCSI-2 lengths for control and caching mode pages", "0: as per recent standards\t" "1: SCSI-2 lengths: control, 6; caching, 10"}, {"SSEEK", UNIT_ATTENTION_MP, 0, 0, 3, 6, 1, 0, "Self seek", "0: off (normal operating mode)\t" "1: enter self seek mode (test power dissipation, acoustics, etc)"}, {"JIT3", UNIT_ATTENTION_MP, 0, 0, 4, 3, 1, 0, "Just in time 3, slowest seek type", "0: can not use this seek type in seek speed algorithm\t" "1: can use this seek type in seek speed algorithm"}, {"JIT2", UNIT_ATTENTION_MP, 0, 0, 4, 2, 1, 0, "Just in time 2, second slowest seek type", "0: can not use this seek type in seek speed algorithm\t" "1: can use this seek type in seek speed algorithm"}, {"JIT1", UNIT_ATTENTION_MP, 0, 0, 4, 1, 1, 0, "Just in time 1, second fastest seek type", "0: can not use this seek type in seek speed algorithm\t" "1: can use this seek type in seek speed algorithm"}, {"JIT0", UNIT_ATTENTION_MP, 0, 0, 4, 0, 1, 0, "Just in time 0, fastest seek type", "0: can not use this seek type in seek speed algorithm\t" "1: can use this seek type in seek speed algorithm"}, {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; static struct sdparm_mode_page_t sdparm_v_hitachi_mode_pg[] = { {UNIT_ATTENTION_MP, 0, 0, 0, "vup", "Vendor unique parameters (hitachi)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_v_hitachi_arr[] = { /* Vendor unique parameters page [0x0] Hitachi */ {"MRG", UNIT_ATTENTION_MP, 0, 0, 2, 3, 1, 0, "Merge Glist into Plist (during format)", NULL}, {"VGMDE", UNIT_ATTENTION_MP, 0, 0, 3, 6, 1, MF_COMMON, "Veggie mode (do random seeks when idle)", NULL}, {"RRNDE", UNIT_ATTENTION_MP, 0, 0, 3, 1, 1, 0, "Report recovered non data errors (when PER set)", NULL}, {"FDD", UNIT_ATTENTION_MP, 0, 0, 5, 4, 1, 0, "Format degraded disable (reporting for Test Unit Ready)", NULL}, {"CAEN", UNIT_ATTENTION_MP, 0, 0, 5, 1, 1, MF_COMMON, "Command aging enable", NULL}, {"IGRA", UNIT_ATTENTION_MP, 0, 0, 6, 7, 1, MF_COMMON, "Ignore reassigned LBA (when RC also set)", NULL}, {"AVERP", UNIT_ATTENTION_MP, 0, 0, 6, 6, 1, MF_COMMON, "AV ERP mode (maximum retry count for read errors)", "0: use default (ignore RRC)\t" "1: use RRC field"}, {"OCT", UNIT_ATTENTION_MP, 0, 0, 6, 3, 12, 0, "Overall command timer, 0 -> disabled (50 ms)", NULL}, {"TT", UNIT_ATTENTION_MP, 0, 0, 9, 7, 8, 0, "Temperature threshold (celsius), 0 -> 85C", NULL}, {"CAL", UNIT_ATTENTION_MP, 0, 0, 10, 7, 16, 0, "Command aging limit (50 ms), 0 -> 85C", NULL}, {"RRT", UNIT_ATTENTION_MP, 0, 0, 12, 7, 8, 0, "Read reporting threshold for read recovered errors when PER set", NULL}, {"WRT", UNIT_ATTENTION_MP, 0, 0, 13, 7, 8, 0, "Write reporting threshold for write recovered errors when PER set", NULL}, {"DRRT", UNIT_ATTENTION_MP, 0, 0, 14, 7, 1, 0, "Disable restore reassign target", "0: REASSIGN attempts to recovery old data\t" "1: REASSIGN ignores old data"}, {"FFMT", UNIT_ATTENTION_MP, 0, 0, 14, 3, 1, 0, "Fast format enable, format without writes to customer media", NULL}, {"FCERT", UNIT_ATTENTION_MP, 0, 0, 15, 5, 1, 0, "Format certification (enable)", NULL}, {NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, }; static struct sdparm_mode_page_t sdparm_v_maxtor_mode_pg[] = { {UNIT_ATTENTION_MP, 0, 0, 0, "uac", "Unit attention condition (maxtor)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_v_maxtor_arr[] = { /* Unit attention page [0x0] Seagate */ {"DUA", UNIT_ATTENTION_MP, 0, 0, 2, 4, 1, MF_COMMON, "Disable unit attention", NULL}, }; static struct sdparm_mode_page_t sdparm_v_fujitsu_mode_pg[] = { {0x21, 0, 0, 0, "aerp", "Additional error recovery parameters (fujitsu)", NULL}, {0, 0, 0, 0, NULL, NULL, NULL}, }; static struct sdparm_mode_page_item sdparm_mitem_v_fujitsu_arr[] = { /* Additional error recovery parameters page [0x21] Fujitsu */ {"RDSE", 0x21, 0, 0, 2, 3, 4, MF_COMMON, "Retries during a seek error", "0: no repositioning retries"}, }; /* Indexed by VENDOR_* define */ struct sdparm_vendor_pair sdparm_vendor_mp[] = { {sdparm_v_seagate_mode_pg, sdparm_mitem_v_seagate_arr}, {sdparm_v_hitachi_mode_pg, sdparm_mitem_v_hitachi_arr}, {sdparm_v_maxtor_mode_pg, sdparm_mitem_v_maxtor_arr}, {sdparm_v_fujitsu_mode_pg, sdparm_mitem_v_fujitsu_arr}, }; int sdparm_vendor_mp_len = sizeof(sdparm_vendor_mp) / sizeof(sdparm_vendor_mp[0]); sdparm-1.08/src/sdparm_wscan.c0000664000175000017500000005267412062455663015371 0ustar douggdougg/* * Copyright (c) 2006-2012 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "sg_lib.h" #define _WIN32_WINNT 0x0602 #include "sg_pt_win32.h" /* * This is called when the '--wscan' option is given to sdparm. It is * Win32 only code and shows the relationship between various device names * and volumes in Windows OSes (Windows 2000, 2003, XP and Vista). There is * an optional scsi adapter scan. */ #define MAX_SCSI_ELEMS 1024 #define MAX_ADAPTER_NUM 64 #define MAX_PHYSICALDRIVE_NUM 512 #define MAX_CDROM_NUM 512 #define MAX_TAPE_NUM 512 #define MAX_HOLE_COUNT 8 // IOCTL_STORAGE_QUERY_PROPERTY #define FILE_DEVICE_MASS_STORAGE 0x0000002d #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE #define FILE_ANY_ACCESS 0 // #define METHOD_BUFFERED 0 #define IOCTL_STORAGE_QUERY_PROPERTY \ CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS) #ifndef _DEVIOCTL_ typedef enum _STORAGE_BUS_TYPE { BusTypeUnknown = 0x00, BusTypeScsi = 0x01, BusTypeAtapi = 0x02, BusTypeAta = 0x03, BusType1394 = 0x04, BusTypeSsa = 0x05, BusTypeFibre = 0x06, BusTypeUsb = 0x07, BusTypeRAID = 0x08, BusTypeiScsi = 0x09, BusTypeSas = 0x0A, BusTypeSata = 0x0B, BusTypeSd = 0x0C, BusTypeMmc = 0x0D, BusTypeVirtual = 0xE, BusTypeFileBackedVirtual = 0xF, BusTypeMax, BusTypeMaxReserved = 0x7F } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE; typedef struct _STORAGE_DEVICE_DESCRIPTOR { ULONG Version; ULONG Size; UCHAR DeviceType; UCHAR DeviceTypeModifier; BOOLEAN RemovableMedia; BOOLEAN CommandQueueing; ULONG VendorIdOffset; /* 0 if not available */ ULONG ProductIdOffset; /* 0 if not available */ ULONG ProductRevisionOffset;/* 0 if not available */ ULONG SerialNumberOffset; /* -1 if not available ?? */ STORAGE_BUS_TYPE BusType; ULONG RawPropertiesLength; UCHAR RawDeviceProperties[1]; } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR; #endif typedef struct _STORAGE_DEVICE_UNIQUE_IDENTIFIER { ULONG Version; ULONG Size; ULONG StorageDeviceIdOffset; ULONG StorageDeviceOffset; ULONG DriveLayoutSignatureOffset; } STORAGE_DEVICE_UNIQUE_IDENTIFIER, *PSTORAGE_DEVICE_UNIQUE_IDENTIFIER; // Use CompareStorageDuids(PSTORAGE_DEVICE_UNIQUE_IDENTIFIER duid1, duid2) // to test for equality #ifndef _DEVIOCTL_ typedef enum _STORAGE_QUERY_TYPE { PropertyStandardQuery = 0, PropertyExistsQuery, PropertyMaskQuery, PropertyQueryMaxDefined } STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE; typedef enum _STORAGE_PROPERTY_ID { StorageDeviceProperty = 0, StorageAdapterProperty, StorageDeviceIdProperty, StorageDeviceUniqueIdProperty, StorageDeviceWriteCacheProperty, StorageMiniportProperty, StorageAccessAlignmentProperty } STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID; typedef struct _STORAGE_PROPERTY_QUERY { STORAGE_PROPERTY_ID PropertyId; STORAGE_QUERY_TYPE QueryType; UCHAR AdditionalParameters[1]; } STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY; #endif ///////////////////////////////////////////////////////////////////////////// union STORAGE_DEVICE_DESCRIPTOR_DATA { STORAGE_DEVICE_DESCRIPTOR desc; char raw[256]; }; union STORAGE_DEVICE_UID_DATA { STORAGE_DEVICE_UNIQUE_IDENTIFIER desc; char raw[512]; }; struct storage_elem { char name[32]; char volume_letters[32]; int qp_descriptor_valid; int qp_uid_valid; union STORAGE_DEVICE_DESCRIPTOR_DATA qp_descriptor; union STORAGE_DEVICE_UID_DATA qp_uid; }; static struct storage_elem * storage_arr; static int next_unused_elem = 0; static int verbose = 0; static char * get_err_str(DWORD err, int max_b_len, char * b) { LPVOID lpMsgBuf; int k, num, ch; if (max_b_len < 2) { if (1 == max_b_len) b[0] = '\0'; return b; } memset(b, 0, max_b_len); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); num = lstrlen((LPCTSTR)lpMsgBuf); if (num < 1) return b; num = (num < max_b_len) ? num : (max_b_len - 1); for (k = 0; k < num; ++k) { ch = *((LPCTSTR)lpMsgBuf + k); if ((ch >= 0x0) && (ch < 0x7f)) b[k] = ch & 0x7f; else b[k] = '?'; } return b; } static const char * get_bus_type(int bt) { switch (bt) { case BusTypeUnknown: return "Unkno"; case BusTypeScsi: return "Scsi "; case BusTypeAtapi: return "Atapi"; case BusTypeAta: return "Ata "; case BusType1394: return "1394 "; case BusTypeSsa: return "Ssa "; case BusTypeFibre: return "Fibre"; case BusTypeUsb: return "Usb "; case BusTypeRAID: return "RAID "; case BusTypeiScsi: return "iScsi"; case BusTypeSas: return "Sas "; case BusTypeSata: return "Sata "; case BusTypeSd: return "Sd "; case BusTypeMmc: return "Mmc "; case BusTypeVirtual: return "Virt "; case BusTypeFileBackedVirtual: return "FBVir"; case BusTypeMax: return "Max "; default: return "_unkn"; } } static int query_dev_property(HANDLE hdevice, union STORAGE_DEVICE_DESCRIPTOR_DATA * data) { DWORD num_out, err; char b[256]; STORAGE_PROPERTY_QUERY query = {StorageDeviceProperty, PropertyStandardQuery, {0} }; memset(data, 0, sizeof(*data)); if (! DeviceIoControl(hdevice, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), data, sizeof(*data), &num_out, NULL)) { if (verbose > 2) { err = GetLastError(); fprintf(stderr, " IOCTL_STORAGE_QUERY_PROPERTY(Devprop) failed, " "Error=%ld %s\n", err, get_err_str(err, sizeof(b), b)); } return -ENOSYS; } if (verbose > 3) fprintf(stderr, " IOCTL_STORAGE_QUERY_PROPERTY(DevProp) " "num_out=%ld\n", num_out); return 0; } static int query_dev_uid(HANDLE hdevice, union STORAGE_DEVICE_UID_DATA * data) { DWORD num_out, err; char b[256]; STORAGE_PROPERTY_QUERY query = {StorageDeviceUniqueIdProperty, PropertyStandardQuery, {0} }; memset(data, 0, sizeof(*data)); if (! DeviceIoControl(hdevice, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), data, sizeof(*data), &num_out, NULL)) { if (verbose > 2) { err = GetLastError(); fprintf(stderr, " IOCTL_STORAGE_QUERY_PROPERTY(DevUid) failed, " "Error=%ld %s\n", err, get_err_str(err, sizeof(b), b)); } return -ENOSYS; } if (verbose > 3) fprintf(stderr, " IOCTL_STORAGE_QUERY_PROPERTY(DevUid) num_out=%ld\n", num_out); return 0; } static int check_devices(const struct storage_elem * sep) { int k, j; struct storage_elem * sarr = storage_arr; for (k = 0; k < next_unused_elem; ++k, ++sarr) { if ('\0' == sarr->name[0]) continue; if (sep->qp_descriptor_valid && sarr->qp_descriptor_valid) { if (0 == memcmp(&sep->qp_descriptor, &sarr->qp_descriptor, sizeof(sep->qp_descriptor))) { for (j = 0; j < (int)sizeof(sep->volume_letters); ++j) { if ('\0' == sarr->volume_letters[j]) { sarr->volume_letters[j] = sep->name[0]; break; } } return 1; } } // should do uid check here (probably before descriptor compare) } return 0; } static int enum_scsi_adapters(void) { int k, j; int hole_count = 0; HANDLE fh; ULONG dummy; DWORD err; BYTE bus; BOOL success; char adapter_name[64]; char inqDataBuff[2048]; PSCSI_ADAPTER_BUS_INFO ai; char b[256]; for (k = 0; k < MAX_ADAPTER_NUM; ++k) { snprintf(adapter_name, sizeof (adapter_name), "\\\\.\\SCSI%d:", k); fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fh != INVALID_HANDLE_VALUE) { hole_count = 0; success = DeviceIoControl(fh, IOCTL_SCSI_GET_INQUIRY_DATA, NULL, 0, inqDataBuff, sizeof(inqDataBuff), &dummy, FALSE); if (success) { PSCSI_BUS_DATA pbd; PSCSI_INQUIRY_DATA pid; int num_lus, off; ai = (PSCSI_ADAPTER_BUS_INFO)inqDataBuff; for (bus = 0; bus < ai->NumberOfBusses; bus++) { pbd = ai->BusData + bus; num_lus = pbd->NumberOfLogicalUnits; off = pbd->InquiryDataOffset; for (j = 0; j < num_lus; ++j) { if ((off < (int)sizeof(SCSI_ADAPTER_BUS_INFO)) || (off > ((int)sizeof(inqDataBuff) - (int)sizeof(SCSI_INQUIRY_DATA)))) break; pid = (PSCSI_INQUIRY_DATA)(inqDataBuff + off); snprintf(b, sizeof(b) - 1, "SCSI%d:%d,%d,%d ", k, pid->PathId, pid->TargetId, pid->Lun); printf("%-15s", b); snprintf(b, sizeof(b) - 1, "claimed=%d pdt=%xh %s ", pid->DeviceClaimed, pid->InquiryData[0] % 0x3f, ((0 == pid->InquiryData[4]) ? "dubious" : "")); printf("%-26s", b); printf("%.8s %.16s %.4s\n", pid->InquiryData + 8, pid->InquiryData + 16, pid->InquiryData + 32); off = pid->NextInquiryDataOffset; } } } else { err = GetLastError(); fprintf(stderr, "%s: IOCTL_SCSI_GET_INQUIRY_DATA failed " "err=%lu\n\t%s", adapter_name, err, get_err_str(err, sizeof(b), b)); } CloseHandle(fh); } else { if (verbose > 3) { err = GetLastError(); fprintf(stderr, "%s: CreateFile failed err=%lu\n\t%s", adapter_name, err, get_err_str(err, sizeof(b), b)); } if (++hole_count >= MAX_HOLE_COUNT) break; } } return 0; } static int enum_volumes(char letter) { int k; HANDLE fh; char adapter_name[64]; struct storage_elem tmp_se; if (verbose > 2) fprintf(stderr, "%s: enter\n", __FUNCTION__ ); for (k = 0; k < 24; ++k) { memset(&tmp_se, 0, sizeof(tmp_se)); snprintf(adapter_name, sizeof (adapter_name), "\\\\.\\%c:", 'C' + k); tmp_se.name[0] = 'C' + k; fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fh != INVALID_HANDLE_VALUE) { if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0) fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ ); else tmp_se.qp_descriptor_valid = 1; if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) { if (verbose > 2) fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ ); } else tmp_se.qp_uid_valid = 1; if (('\0' == letter) || (letter == tmp_se.name[0])) check_devices(&tmp_se); CloseHandle(fh); } } return 0; } static int enum_pds(void) { int k; int hole_count = 0; HANDLE fh; DWORD err; char adapter_name[64]; char b[256]; struct storage_elem tmp_se; if (verbose > 2) fprintf(stderr, "%s: enter\n", __FUNCTION__ ); for (k = 0; k < MAX_PHYSICALDRIVE_NUM; ++k) { memset(&tmp_se, 0, sizeof(tmp_se)); snprintf(adapter_name, sizeof (adapter_name), "\\\\.\\PhysicalDrive%d", k); snprintf(tmp_se.name, sizeof(tmp_se.name), "PD%d", k); fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fh != INVALID_HANDLE_VALUE) { if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0) fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ ); else tmp_se.qp_descriptor_valid = 1; if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) { if (verbose > 2) fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ ); } else tmp_se.qp_uid_valid = 1; hole_count = 0; memcpy(&storage_arr[next_unused_elem++], &tmp_se, sizeof(tmp_se)); CloseHandle(fh); } else { if (verbose > 3) { err = GetLastError(); fprintf(stderr, "%s: CreateFile failed err=%lu\n\t%s", adapter_name, err, get_err_str(err, sizeof(b), b)); } if (++hole_count >= MAX_HOLE_COUNT) break; } } return 0; } static int enum_cdroms(void) { int k; int hole_count = 0; HANDLE fh; DWORD err; char adapter_name[64]; char b[256]; struct storage_elem tmp_se; if (verbose > 2) fprintf(stderr, "%s: enter\n", __FUNCTION__ ); for (k = 0; k < MAX_CDROM_NUM; ++k) { memset(&tmp_se, 0, sizeof(tmp_se)); snprintf(adapter_name, sizeof (adapter_name), "\\\\.\\CDROM%d", k); snprintf(tmp_se.name, sizeof(tmp_se.name), "CDROM%d", k); fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fh != INVALID_HANDLE_VALUE) { if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0) fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ ); else tmp_se.qp_descriptor_valid = 1; if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) { if (verbose > 2) fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ ); } else tmp_se.qp_uid_valid = 1; hole_count = 0; memcpy(&storage_arr[next_unused_elem++], &tmp_se, sizeof(tmp_se)); CloseHandle(fh); } else { if (verbose > 3) { err = GetLastError(); fprintf(stderr, "%s: CreateFile failed err=%lu\n\t%s", adapter_name, err, get_err_str(err, sizeof(b), b)); } if (++hole_count >= MAX_HOLE_COUNT) break; } } return 0; } static int enum_tapes(void) { int k; int hole_count = 0; HANDLE fh; DWORD err; char adapter_name[64]; char b[256]; struct storage_elem tmp_se; if (verbose > 2) fprintf(stderr, "%s: enter\n", __FUNCTION__ ); for (k = 0; k < MAX_TAPE_NUM; ++k) { memset(&tmp_se, 0, sizeof(tmp_se)); snprintf(adapter_name, sizeof (adapter_name), "\\\\.\\TAPE%d", k); snprintf(tmp_se.name, sizeof(tmp_se.name), "TAPE%d", k); fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fh != INVALID_HANDLE_VALUE) { if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0) fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ ); else tmp_se.qp_descriptor_valid = 1; if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) { if (verbose > 2) fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ ); } else tmp_se.qp_uid_valid = 1; hole_count = 0; memcpy(&storage_arr[next_unused_elem++], &tmp_se, sizeof(tmp_se)); CloseHandle(fh); } else { if (verbose > 3) { err = GetLastError(); fprintf(stderr, "%s: CreateFile failed err=%lu\n\t%s", adapter_name, err, get_err_str(err, sizeof(b), b)); } if (++hole_count >= MAX_HOLE_COUNT) break; } } return 0; } static int do_wscan(char letter, int show_bt, int scsi_scan) { int k, j, n; struct storage_elem * sp; if (scsi_scan < 2) { k = enum_pds(); if (k) return k; k = enum_cdroms(); if (k) return k; k = enum_tapes(); if (k) return k; k = enum_volumes(letter); if (k) return k; for (k = 0; k < next_unused_elem; ++k) { sp = storage_arr + k; if ('\0' == sp->name[0]) continue; printf("%-7s ", sp->name); n = strlen(sp->volume_letters); if (0 == n) printf(" "); else if (1 == n) printf("[%s] ", sp->volume_letters); else if (2 == n) printf("[%s] ", sp->volume_letters); else if (3 == n) printf("[%s] ", sp->volume_letters); else if (4 == n) printf("[%s] ", sp->volume_letters); else printf("[%4s+] ", sp->volume_letters); if (sp->qp_descriptor_valid) { if (show_bt) printf("<%s> ", get_bus_type(sp->qp_descriptor.desc.BusType)); j = sp->qp_descriptor.desc.VendorIdOffset; if (j > 0) printf("%s ", sp->qp_descriptor.raw + j); j = sp->qp_descriptor.desc.ProductIdOffset; if (j > 0) printf("%s ", sp->qp_descriptor.raw + j); j = sp->qp_descriptor.desc.ProductRevisionOffset; if (j > 0) printf("%s ", sp->qp_descriptor.raw + j); j = sp->qp_descriptor.desc.SerialNumberOffset; if (j > 0) printf("%s", sp->qp_descriptor.raw + j); printf("\n"); if (verbose > 2) dStrHex(sp->qp_descriptor.raw, 144, 0); } else printf("\n"); } } if (scsi_scan) { if (scsi_scan < 2) printf("\n"); enum_scsi_adapters(); } return 0; } int sg_do_wscan(char letter, int do_scan, int verb) { int ret, show_bt, scsi_scan; verbose = verb; show_bt = (do_scan > 1); scsi_scan = (do_scan > 2) ? (do_scan - 2) : 0; storage_arr = calloc(sizeof(struct storage_elem) * MAX_SCSI_ELEMS, 1); if (storage_arr) { ret = do_wscan(letter, show_bt, scsi_scan); free(storage_arr); } else { fprintf(stderr, "Failed to allocate storage_arr on heap\n"); ret = SG_LIB_SYNTAX_ERROR; } return ret; } sdparm-1.08/src/sdparm.h0000664000175000017500000002621411722232420014154 0ustar douggdougg#ifndef SDPARM_H #define SDPARM_H /* * sdparm is a utility program for getting and setting parameters on devices * that use one of the SCSI command sets. In some cases commands can be sent * to the device (e.g. eject removable media). */ #include #define DEF_MODE_RESP_LEN 252 #define DEF_INQ_RESP_LEN 252 #define VPD_ATA_INFO_RESP_LEN 572 /* Mode page numbers */ #define UNIT_ATTENTION_MP 0 #define RW_ERR_RECOVERY_MP 1 #define DISCONNECT_MP 2 #define FORMAT_MP 3 #define MRW_MP 3 #define RIGID_DISK_MP 4 #define WRITE_PARAM_MP 5 #define RBC_DEV_PARAM_MP 6 #define V_ERR_RECOVERY_MP 7 #define CACHING_MP 8 #define CONTROL_MP 0xa #define POWER_OLD_MP 0xd /* #define CD_DEV_PARAMS 0xd */ #define ADC_MP 0xe #define DATA_COMPR_MP 0xf #define DEV_CONF_MP 0x10 #define XOR_MP 0x10 #define MED_PART_MP 0x11 #define ES_MAN_MP 0x14 #define PROT_SPEC_LU_MP 0x18 #define PROT_SPEC_PORT_MP 0x19 #define POWER_MP 0x1a #define IEC_MP 0x1c #define MED_CONF_MP 0x1d #define TIMEOUT_PROT_MP 0x1d #define ELE_ADDR_ASS_MP 0x1d #define TRANS_GEO_PAR_MP 0x1e #define DEV_CAP_MP 0x1f #define MMCMS_MP 0x2a #define ALL_MPAGES 0x3f /* Mode subpage numbers */ #define MSP_SPC_CE 1 /* control extension */ #define MSP_SPI_MC 1 #define MSP_SPI_STC 2 #define MSP_SPI_NS 3 #define MSP_SPI_RTC 4 #define MSP_SAS_PCD 1 #define MSP_SAS_SPC 2 #define MSP_SAS_E_PHY 3 #define MSP_BACK_CTL 1 #define MSP_SAT_PATA 0xf1 /* SAT PATA Control */ #define MSP_SAT_POWER 0xf1 /* SAT ATA Power condition */ #define MSP_DEV_CONF_EXT 1 /* device conf extension (ssc) */ #define MSP_EXT_DEV_CAP 0x41 /* extended device capabilities (smc) */ #define MSP_ADC_TGT_DEV 0x1 #define MSP_ADC_DT_DPP 0x2 #define MSP_ADC_LU 0x3 #define MSP_ADC_TD_SN 0x4 #define MSP_SBC_LB_PROV 0x2 #define MSP_SSC_CDP 0xf0 #define MSP_SBC_APP_TAG 0x2 /* changed from 0xf0 to 0x2 sbc3r28 */ #define MSP_SPC_PS 0x1 /* power consumption */ #define MODE_DATA_OVERHEAD 128 #define EBUFF_SZ 256 #define MAX_MP_IT_VAL 128 /* maximum number of items that can be */ /* changed in one invocation */ #define MAX_MODE_DATA_LEN 2048 /* VPD pages (fetched by INQUIRY command) */ #define VPD_SUPPORTED_VPDS 0x0 #define VPD_UNIT_SERIAL_NUM 0x80 #define VPD_IMP_OP_DEF 0x81 /* obsolete in SPC-2 */ #define VPD_ASCII_OP_DEF 0x82 /* obsolete in SPC-2 */ #define VPD_DEVICE_ID 0x83 #define VPD_SOFTW_INF_ID 0x84 #define VPD_MAN_NET_ADDR 0x85 #define VPD_EXT_INQ 0x86 #define VPD_MODE_PG_POLICY 0x87 #define VPD_SCSI_PORTS 0x88 #define VPD_ATA_INFO 0x89 #define VPD_POWER_CONDITION 0x8a #define VPD_DEVICE_CONSTITUENTS 0x8b #define VPD_CFA_PROFILE_INFO 0x8c #define VPD_POWER_CONSUMPTION 0x8d #define VPD_3PARTY_COPY 0x8f #define VPD_PROTO_LU 0x90 #define VPD_PROTO_PORT 0x91 #define VPD_BLOCK_LIMITS 0xb0 /* SBC-3 */ #define VPD_SA_DEV_CAP 0xb0 /* SSC-3 */ #define VPD_OSD_INFO 0xb0 /* OSD */ #define VPD_BLOCK_DEV_CHARS 0xb1 /* SBC-3 */ #define VPD_MAN_ASS_SN 0xb1 /* SSC-3, ADC-2 */ #define VPD_SECURITY_TOKEN 0xb1 /* OSD */ #define VPD_TA_SUPPORTED 0xb2 /* SSC-3 */ #define VPD_LB_PROVISIONING 0xb2 /* SBC-3 */ #define VPD_REFERRALS 0xb3 #define VPD_AUTOMATION_DEV_SN 0xb3 /* SSC-3 */ #define VPD_DTDE_ADDRESS 0xb4 /* SSC-4 */ #define VPD_NOT_STD_INQ -2 /* request for standard inquiry */ #define VPD_ASSOC_LU 0 #define VPD_ASSOC_TPORT 1 #define VPD_ASSOC_TDEVICE 2 /* values are 2**vpd_assoc */ #define VPD_DI_SEL_LU 1 #define VPD_DI_SEL_TPORT 2 #define VPD_DI_SEL_TARGET 4 #define VPD_DI_SEL_AS_IS 32 #define DEF_TRANSPORT_PROTOCOL TPROTO_SAS /* Vendor identifiers */ #define VENDOR_SEAGATE 0x0 #define VENDOR_HITACHI 0x1 #define VENDOR_MAXTOR 0x2 #define VENDOR_FUJITSU 0x3 /* bit flag settings for sdparm_mode_page_item::flags */ #define MF_COMMON 0x1 /* output in summary mode */ #define MF_HEX 0x2 #define MF_CLASH_OK 0x4 /* know this overlaps safely with generic */ /* enumerations for commands */ #define CMD_READY 1 #define CMD_START 2 #define CMD_STOP 3 #define CMD_LOAD 4 #define CMD_EJECT 5 #define CMD_UNLOCK 6 #define CMD_SENSE 7 #define CMD_SYNC 8 #define CMD_CAPACITY 9 #define CMD_SPEED 10 #define CMD_PROFILE 11 #ifndef TPROTO_UAS #define TPROTO_UAS 0x9 #endif #ifndef TPROTO_SOP #define TPROTO_SOP 0xa #endif struct sdparm_opt_coll { int all; int dbd; int defaults; int dummy; int enumerate; int flexible; int hex; int inquiry; int long_out; int mode_6; int num_desc; int quiet; int read_only; int save; int transport; /* -1 means not transport specific (def) */ int vendor; /* -1 means not vendor specific (def) */ int verbose; }; struct sdparm_mode_descriptor_t { int num_descs_off; /* byte offset of start of num_descriptors */ int num_descs_bytes; /* number of bytes in num_descriptors field */ int num_descs_inc; /* number to add to num_descriptors */ /* if negative then value in num_descriptors */ /* is byte count, so divide by desc_len */ int first_desc_off; int desc_len; /* -1 for unknown otherwise fixed per desc */ int desc_len_off; /* if (-1 == desc_len) then this is offset */ int desc_len_bytes; /* ... after start of descriptor */ /* Hence: = deref(base + d_len_off, d_len_bytes) + */ /* d_len_off + d_len_bytes */ const char * name; }; struct sdparm_mode_page_t { int page; int subpage; int pdt; /* peripheral device type id, -1 is the default */ /* (not applicable) value */ int ro; /* read-only */ const char * acron; const char * name; const struct sdparm_mode_descriptor_t * mp_desc; /* non-NULL when mpage has descriptor format */ }; struct sdparm_transport_id_t { int proto_num; const char * acron; const char * name; }; struct sdparm_vpd_page_t { int vpd_num; int subvalue; int pdt; /* peripheral device type id, -1 is the default */ /* (not applicable) value */ const char * acron; const char * name; }; struct sdparm_vendor_name_t { int vendor_num; const char * acron; const char * name; }; struct sdparm_mode_page_item { const char * acron; int page_num; int subpage_num; int pdt; /* peripheral device type or -1 (default) if not */ /* applicable */ int start_byte; int start_bit; int num_bits; int flags; /* bit settings or-ed, see MF_* */ const char * description; const char * extra; }; struct sdparm_mode_page_it_val { struct sdparm_mode_page_item mpi; int64_t val; int64_t orig_val; int descriptor_num; }; struct sdparm_mode_page_settings { int page_num; int subpage_num; struct sdparm_mode_page_it_val it_vals[MAX_MP_IT_VAL]; int num_it_vals; }; struct sdparm_transport_pair { struct sdparm_mode_page_t * mpage; struct sdparm_mode_page_item * mitem; }; struct sdparm_vendor_pair { struct sdparm_mode_page_t * mpage; struct sdparm_mode_page_item * mitem; }; struct sdparm_command_t { int cmd_num; const char * name; const char * min_abbrev; const char * extra_arg; }; struct sdparm_val_desc_t { int val; const char * desc; }; extern struct sdparm_mode_page_t sdparm_gen_mode_pg[]; extern struct sdparm_vpd_page_t sdparm_vpd_pg[]; extern struct sdparm_transport_id_t sdparm_transport_id[]; extern struct sdparm_transport_pair sdparm_transport_mp[]; extern struct sdparm_vendor_name_t sdparm_vendor_id[]; extern struct sdparm_vendor_pair sdparm_vendor_mp[]; extern int sdparm_vendor_mp_len; extern struct sdparm_mode_page_item sdparm_mitem_arr[]; extern struct sdparm_command_t sdparm_command_arr[]; extern struct sdparm_val_desc_t sdparm_profile_arr[]; extern const char * sdparm_pdt_doc_strs[]; extern const char * sdparm_transport_proto_arr[]; extern const char * sdparm_code_set_arr[]; extern const char * sdparm_assoc_arr[]; extern const char * sdparm_desig_type_arr[]; extern const char * sdparm_ansi_version_arr[]; extern const char * sdparm_network_service_type_arr[]; extern const char * sdparm_mode_page_policy_arr[]; /* * Declarations for access functions found in sdparm_access.c */ extern int sdp_get_mp_len(unsigned char * mp); extern const struct sdparm_mode_page_t * sdp_get_mode_detail( int page_num, int subpage_num, int pdt, int transp_proto, int vendor_num); extern const struct sdparm_mode_page_t * sdp_get_mpage_name( int page_num, int subpage_num, int pdt, int transp_proto, int vendor_num, int plus_acron, int hex, char * bp, int max_b_len); extern const struct sdparm_mode_page_t * sdp_find_mp_by_acron( const char * ap, int transp_proto, int vendor_num); const struct sdparm_vpd_page_t * sdp_get_vpd_detail(int page_num, int subvalue, int pdt); extern const struct sdparm_vpd_page_t * sdp_find_vpd_by_acron( const char * ap); extern const char * sdp_get_transport_name(int proto_num); extern const struct sdparm_transport_id_t * sdp_find_transport_by_acron( const char * ap); extern const char * sdp_get_vendor_name(int vendor_num); extern const struct sdparm_vendor_name_t * sdp_find_vendor_by_acron( const char * ap); extern const struct sdparm_vendor_pair * sdp_get_vendor_pair(int vendor_num); extern const struct sdparm_mode_page_item * sdp_find_mitem_by_acron( const char * ap, int * from, int transp_proto, int vendor_num); extern uint64_t sdp_get_big_endian(const unsigned char * from, int start_bit, int num_bits); extern void sdp_set_big_endian(uint64_t val, unsigned char * to, int start_bit, int num_bits); extern uint64_t sdp_mp_get_value(const struct sdparm_mode_page_item *mpi, const unsigned char * mp); extern uint64_t sdp_mp_get_value_check( const struct sdparm_mode_page_item *mpi, const unsigned char * mp, int * all_set); extern void sdp_mp_set_value(uint64_t val, const struct sdparm_mode_page_item *mpi, unsigned char * mp); extern char * sdp_get_ansi_version_str(int version, int buff_len, char * buff); extern char * sdp_get_pdt_doc_str(int version, int buff_len, char * buff); extern int sdp_strcase_eq(const char * s1p, const char * s2p); /* * Declarations for functions found in sdparm_vpd.c */ extern int sdp_process_vpd_page(int sg_fd, int pn, int spn, const struct sdparm_opt_coll * opts, int req_pdt, int protect); /* * Declarations for functions found in sdparm_cmd.c */ extern const struct sdparm_command_t * sdp_build_cmd(const char * cmd_str, int * rwp, int * argp); extern void sdp_enumerate_commands(); extern int sdp_process_cmd(int sg_fd, const struct sdparm_command_t * scmdp, int cmd_arg, int pdt, const struct sdparm_opt_coll * opts); /* * Declarations for functions that are port dependant */ #ifdef SG_LIB_WIN32 extern int sg_do_wscan(char letter, int do_scan, int verbose); #endif #endif sdparm-1.08/src/sdparm_vpd.c0000664000175000017500000020151212145473377015036 0ustar douggdougg/* * Copyright (c) 2005-2013 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #define __STDC_FORMAT_MACROS 1 #include #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sdparm.h" /* sdparm_vpd.c : does mainly VPD page processing associated with the * INQUIRY SCSI command. */ /* Prints outs an abridged set of device identification designators selected by association, designator type and/or code set. */ static int decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc, int m_desig_type, int m_code_set) { int m, p_id, c_set, piv, assoc, desig_type, i_len, is_sas; int naa, off, u, rtp; const unsigned char * ucp; const unsigned char * ip; unsigned char sas_tport_addr[8]; rtp = 0; memset(sas_tport_addr, 0, sizeof(sas_tport_addr)); off = -1; while ((u = sg_vpd_dev_id_iter(buff, len, &off, m_assoc, m_desig_type, m_code_set)) == 0) { ucp = buff + off; i_len = ucp[3]; if ((off + i_len + 4) > len) { fprintf(stderr, " VPD page error: designator length longer " "than\n remaining response length=%d\n", (len - off)); return SG_LIB_CAT_MALFORMED; } ip = ucp + 4; p_id = ((ucp[0] >> 4) & 0xf); c_set = (ucp[0] & 0xf); piv = ((ucp[1] & 0x80) ? 1 : 0); is_sas = (piv && (6 == p_id)) ? 1 : 0; assoc = ((ucp[1] >> 4) & 0x3); desig_type = (ucp[1] & 0xf); switch (desig_type) { case 0: /* vendor specific */ break; case 1: /* T10 vendor identification */ break; case 2: /* EUI-64 based */ if ((8 != i_len) && (12 != i_len) && (16 != i_len)) fprintf(stderr, " << expect 8, 12 and 16 byte " "EUI, got %d>>\n", i_len); printf("0x"); for (m = 0; m < i_len; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); break; case 3: /* NAA */ if (1 != c_set) { fprintf(stderr, " << unexpected code set %d for " "NAA>>\n", c_set); dStrHex((const char *)ip, i_len, 0); break; } naa = (ip[0] >> 4) & 0xff; if ((naa < 2) || (naa > 6) || (4 == naa)) { fprintf(stderr, " << unexpected NAA [0x%x]>>\n", naa); dStrHex((const char *)ip, i_len, 0); break; } if (2 == naa) { /* NAA IEEE Extended */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 2 identifier " "length: 0x%x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); } else if ((3 == naa ) || (5 == naa)) { /* NAA=3 Locally assigned; NAA=5 IEEE Registered */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 3 or 5 " "identifier length: 0x%x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } if ((0 == is_sas) || (1 != assoc)) { printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); } else if (rtp) { printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf(",0x%x\n", rtp); rtp = 0; } else { if (sas_tport_addr[0]) { printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)sas_tport_addr[m]); printf("\n"); } memcpy(sas_tport_addr, ip, sizeof(sas_tport_addr)); } } else if (6 == naa) { /* NAA IEEE Registered extended */ if (16 != i_len) { fprintf(stderr, " << unexpected NAA 6 identifier " "length: 0x%x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } printf("0x"); for (m = 0; m < 16; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); } break; case 4: /* Relative target port */ if ((0 == is_sas) || (1 != c_set) || (1 != assoc) || (4 != i_len)) break; rtp = ((ip[2] << 8) | ip[3]); if (sas_tport_addr[0]) { printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)sas_tport_addr[m]); printf(",0x%x\n", rtp); memset(sas_tport_addr, 0, sizeof(sas_tport_addr)); rtp = 0; } break; case 5: /* (primary) Target port group */ break; case 6: /* Logical unit group */ break; case 7: /* MD5 logical unit identifier */ break; case 8: /* SCSI name string */ if (3 != c_set) { fprintf(stderr, " << expected UTF-8 code_set>>\n"); dStrHex((const char *)ip, i_len, 0); break; } /* does %s print out UTF-8 ok?? * Seems to depend on the locale. Looks ok here with my * locale setting: en_AU.UTF-8 */ printf("%s\n", (const char *)ip); break; case 9: /* PCIe routing ID */ break; default: /* reserved */ break; } } if (sas_tport_addr[0]) { printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)sas_tport_addr[m]); printf("\n"); } if (-2 == u) { fprintf(stderr, "VPD page error: short designator near " "offset %d\n", off); return SG_LIB_CAT_MALFORMED; } return 0; } static void decode_designation_descriptor(const unsigned char * ucp, int i_len, int long_out, int print_assoc) { int m, p_id, piv, c_set, assoc, desig_type, ci_off, c_id, d_id, naa; int vsi, k; const unsigned char * ip; uint64_t vsei; uint64_t id_ext; char b[64]; ip = ucp + 4; p_id = ((ucp[0] >> 4) & 0xf); c_set = (ucp[0] & 0xf); piv = ((ucp[1] & 0x80) ? 1 : 0); assoc = ((ucp[1] >> 4) & 0x3); desig_type = (ucp[1] & 0xf); if (print_assoc) printf(" %s:\n", sdparm_assoc_arr[assoc]); printf(" designator type: %s, code set: %s\n", sdparm_desig_type_arr[desig_type], sdparm_code_set_arr[c_set]); if (piv && ((1 == assoc) || (2 == assoc))) printf(" transport: %s\n", sg_get_trans_proto_str(p_id, sizeof(b), b)); /* printf(" associated with the %s\n", sdparm_assoc_arr[assoc]); */ switch (desig_type) { case 0: /* vendor specific */ k = 0; if ((1 == c_set) || (2 == c_set)) { /* ASCII or UTF-8 */ for (k = 0; (k < i_len) && isprint(ip[k]); ++k) ; if (k >= i_len) k = 1; } if (k) printf(" vendor specific: %.*s\n", i_len, ip); else dStrHex((const char *)ip, i_len, 0); break; case 1: /* T10 vendor identification */ printf(" vendor id: %.8s\n", ip); if (i_len > 8) printf(" vendor specific: %.*s\n", i_len - 8, ip + 8); break; case 2: /* EUI-64 based */ if (! long_out) { if ((8 != i_len) && (12 != i_len) && (16 != i_len)) { fprintf(stderr, " << expect 8, 12 and 16 byte " "EUI, got %d>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } printf(" 0x"); for (m = 0; m < i_len; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); break; } printf(" EUI-64 based %d byte identifier\n", i_len); if (1 != c_set) { fprintf(stderr, " << expected binary code_set (1)>>\n"); dStrHex((const char *)ip, i_len, 0); break; } ci_off = 0; if (16 == i_len) { ci_off = 8; id_ext = 0; for (m = 0; m < 8; ++m) { if (m > 0) id_ext <<= 8; id_ext |= ip[m]; } printf(" Identifier extension: 0x%" PRIx64 "\n", id_ext); } else if ((8 != i_len) && (12 != i_len)) { fprintf(stderr, " << can only decode 8, 12 and 16 " "byte ids>>\n"); dStrHex((const char *)ip, i_len, 0); break; } c_id = ((ip[ci_off] << 16) | (ip[ci_off + 1] << 8) | ip[ci_off + 2]); printf(" IEEE Company_id: 0x%x\n", c_id); vsei = 0; for (m = 0; m < 5; ++m) { if (m > 0) vsei <<= 8; vsei |= ip[ci_off + 3 + m]; } printf(" Vendor Specific Extension Identifier: 0x%" PRIx64 "\n", vsei); if (12 == i_len) { d_id = (((unsigned int)ip[8] << 24) | (ip[9] << 16) | (ip[10] << 8) | ip[11]); printf(" Directory ID: 0x%x\n", d_id); } break; case 3: /* NAA */ if (1 != c_set) { fprintf(stderr, " << unexpected code set %d for " "NAA>>\n", c_set); dStrHex((const char *)ip, i_len, 0); break; } naa = (ip[0] >> 4) & 0xff; if (! ((2 == naa) || (5 == naa) || (6 == naa))) { fprintf(stderr, " << unexpected NAA [0x%x]>>\n", naa); dStrHex((const char *)ip, i_len, 0); break; } if (2 == naa) { if (8 != i_len) { fprintf(stderr, " << unexpected NAA 2 identifier " "length: 0x%x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } d_id = (((ip[0] & 0xf) << 8) | ip[1]); c_id = ((ip[2] << 16) | (ip[3] << 8) | ip[4]); vsi = ((ip[5] << 16) | (ip[6] << 8) | ip[7]); if (long_out) { printf(" NAA 2, vendor specific identifier A: " "0x%x\n", d_id); printf(" IEEE Company_id: 0x%x\n", c_id); printf(" vendor specific identifier B: 0x%x\n", vsi); printf(" [0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf("]\n"); } printf(" 0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); } else if (5 == naa) { if (8 != i_len) { fprintf(stderr, " << unexpected NAA 5 identifier " "length: 0x%x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } c_id = (((ip[0] & 0xf) << 20) | (ip[1] << 12) | (ip[2] << 4) | ((ip[3] & 0xf0) >> 4)); vsei = ip[3] & 0xf; for (m = 1; m < 5; ++m) { vsei <<= 8; vsei |= ip[3 + m]; } if (long_out) { printf(" NAA 5, IEEE Company_id: 0x%x\n", c_id); printf(" Vendor Specific Identifier: 0x%" PRIx64 "\n", vsei); printf(" [0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf("]\n"); } else { printf(" 0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); } } else if (6 == naa) { if (16 != i_len) { fprintf(stderr, " << unexpected NAA 6 identifier " "length: 0x%x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } c_id = (((ip[0] & 0xf) << 20) | (ip[1] << 12) | (ip[2] << 4) | ((ip[3] & 0xf0) >> 4)); vsei = ip[3] & 0xf; for (m = 1; m < 5; ++m) { vsei <<= 8; vsei |= ip[3 + m]; } if (long_out) { printf(" NAA 6, IEEE Company_id: 0x%x\n", c_id); printf(" Vendor Specific Identifier: 0x%" PRIx64 "\n", vsei); vsei = 0; for (m = 0; m < 8; ++m) { if (m > 0) vsei <<= 8; vsei |= ip[8 + m]; } printf(" Vendor Specific Identifier Extension: " "0x%" PRIx64 "\n", vsei); printf(" [0x"); for (m = 0; m < 16; ++m) printf("%02x", (unsigned int)ip[m]); printf("]\n"); } else { printf(" 0x"); for (m = 0; m < 16; ++m) printf("%02x", (unsigned int)ip[m]); printf("\n"); } } break; case 4: /* Relative target port */ if ((1 != c_set) || (1 != assoc) || (4 != i_len)) { fprintf(stderr, " << expected binary code_set, target " "port association, length 4>>\n"); dStrHex((const char *)ip, i_len, 0); break; } d_id = ((ip[2] << 8) | ip[3]); printf(" Relative target port: 0x%x\n", d_id); break; case 5: /* (primary) Target port group */ if ((1 != c_set) || (1 != assoc) || (4 != i_len)) { fprintf(stderr, " << expected binary code_set, target " "port association, length 4>>\n"); dStrHex((const char *)ip, i_len, 0); break; } d_id = ((ip[2] << 8) | ip[3]); printf(" Target port group: 0x%x\n", d_id); break; case 6: /* Logical unit group */ if ((1 != c_set) || (0 != assoc) || (4 != i_len)) { fprintf(stderr, " << expected binary code_set, logical " "unit association, length 4>>\n"); dStrHex((const char *)ip, i_len, 0); break; } d_id = ((ip[2] << 8) | ip[3]); printf(" Logical unit group: 0x%x\n", d_id); break; case 7: /* MD5 logical unit identifier */ if ((1 != c_set) || (0 != assoc)) { printf(" << expected binary code_set, logical " "unit association>>\n"); dStrHex((const char *)ip, i_len, 0); break; } printf(" MD5 logical unit identifier:\n"); dStrHex((const char *)ip, i_len, 0); break; case 8: /* SCSI name string */ if (3 != c_set) { fprintf(stderr, " << expected UTF-8 code_set>>\n"); dStrHex((const char *)ip, i_len, 0); break; } printf(" SCSI name string:\n"); /* does %s print out UTF-8 ok?? * Seems to depend on the locale. Looks ok here with my * locale setting: en_AU.UTF-8 */ printf(" %s\n", (const char *)ip); break; case 9: /* Protocol specific port identifier */ /* added in spc4r36, PIV must be set, proto_id indicates */ /* whether UAS (USB) or SOP (PCIe) or ... */ if (! piv) printf(" >>>> Protocol specific port identifier " "expects protocol\n" " identifier to be valid and it is not\n"); if (TPROTO_UAS == p_id) { printf(" USB device address: 0x%x\n", 0x7f & ip[0]); printf(" USB interface number: 0x%x\n", ip[2]); } else if (TPROTO_SOP == p_id) { printf(" PCIe routing ID, bus number: 0x%x\n", ip[0]); printf(" function number: 0x%x\n", ip[1]); printf(" [or device number: 0x%x, function number: " "0x%x]\n", (0x1f & (ip[1] >> 3)), 0x7 & ip[1]); } else printf(" >>>> unexpected protocol indentifier: %s\n" " with Protocol specific port " "identifier\n", sg_get_trans_proto_str(p_id, sizeof(b), b)); break; default: /* reserved */ dStrHex((const char *)ip, i_len, 0); break; } } /* Prints outs device identification designators selected by association, designator type and/or code set. */ static int decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, int m_assoc, int m_desig_type, int m_code_set, int long_out, int quiet) { int i_len, assoc, printed, off, u; const unsigned char * ucp; if (quiet) return decode_dev_ids_quiet(buff, len, m_assoc, m_desig_type, m_code_set); off = -1; printed = 0; while ((u = sg_vpd_dev_id_iter(buff, len, &off, m_assoc, m_desig_type, m_code_set)) == 0) { ucp = buff + off; i_len = ucp[3]; if ((off + i_len + 4) > len) { fprintf(stderr, " VPD page error: designator length longer " "than\n remaining response length=%d\n", (len - off)); return SG_LIB_CAT_MALFORMED; } assoc = ((ucp[1] >> 4) & 0x3); if (print_if_found && (0 == printed)) { printed = 1; printf(" %s:\n", print_if_found); } if (NULL == print_if_found) printf(" %s:\n", sdparm_assoc_arr[assoc]); decode_designation_descriptor(ucp, i_len, long_out, 0); } if (-2 == u) { fprintf(stderr, "VPD page error: short designator around " "offset %d\n", off); return SG_LIB_CAT_MALFORMED; } return 0; } /* VPD_MODE_PG_POLICY */ static int decode_mode_policy_vpd(unsigned char * buff, int len) { int k, bump; unsigned char * ucp; if (len < 4) { fprintf(stderr, "Mode page policy VPD page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } len -= 4; ucp = buff + 4; for (k = 0; k < len; k += bump, ucp += bump) { bump = 4; if ((k + bump) > len) { fprintf(stderr, "Mode page policy VPD page, short " "descriptor length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } printf(" Policy page code: 0x%x", (ucp[0] & 0x3f)); if (ucp[1]) printf(", subpage code: 0x%x\n", ucp[1]); else printf("\n"); printf(" MLUS=%d, Policy: %s\n", !!(ucp[2] & 0x80), sdparm_mode_page_policy_arr[ucp[2] & 0x3]); } return 0; } /* VPD_MAN_NET_ADDR */ static int decode_man_net_vpd(unsigned char * buff, int len) { int k, bump, na_len; unsigned char * ucp; if (len < 4) { fprintf(stderr, "Management network addresses VPD page length too " "short=%d\n", len); return SG_LIB_CAT_MALFORMED; } len -= 4; ucp = buff + 4; for (k = 0; k < len; k += bump, ucp += bump) { printf(" %s, Service type: %s\n", sdparm_assoc_arr[(ucp[0] >> 5) & 0x3], sdparm_network_service_type_arr[ucp[0] & 0x1f]); na_len = (ucp[2] << 8) + ucp[3]; bump = 4 + na_len; if ((k + bump) > len) { fprintf(stderr, "Management network addresses VPD page, short " "descriptor length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } if (na_len > 0) { printf(" %s\n", ucp + 4); } } return 0; } /* VPD_PROTO_LU */ static int decode_proto_lu_vpd(unsigned char * buff, int len) { int k, bump, rel_port, desc_len, proto; unsigned char * ucp; if (len < 4) { fprintf(stderr, "Protocol-specific logical unit information VPD " "page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } len -= 4; ucp = buff + 4; for (k = 0; k < len; k += bump, ucp += bump) { rel_port = (ucp[0] << 8) + ucp[1]; printf("Relative port=%d\n", rel_port); proto = ucp[2] & 0xf; desc_len = (ucp[6] << 8) + ucp[7]; bump = 8 + desc_len; if ((k + bump) > len) { fprintf(stderr, "Protocol-specific logical unit information VPD " "page, short descriptor length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } if (desc_len > 0) { switch (proto) { case TPROTO_SAS: printf(" Protocol identifier: SAS\n"); printf(" TLR control supported: %d\n", !!(ucp[8] & 0x1)); break; default: fprintf(stderr, "Unexpected proto=%d\n", proto); dStrHex((const char *)ucp, bump, 1); break; } } } return 0; } /* VPD_PROTO_PORT */ static int decode_proto_port_vpd(unsigned char * buff, int len) { int k, j, bump, rel_port, desc_len, proto; unsigned char * ucp; unsigned char * pidp; if (len < 4) { fprintf(stderr, "Protocol-specific port information VPD " "page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } len -= 4; ucp = buff + 4; for (k = 0; k < len; k += bump, ucp += bump) { rel_port = (ucp[0] << 8) + ucp[1]; printf("Relative port=%d\n", rel_port); proto = ucp[2] & 0xf; desc_len = (ucp[6] << 8) + ucp[7]; bump = 8 + desc_len; if ((k + bump) > len) { fprintf(stderr, "Protocol-specific port information VPD " "page, short descriptor length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } if (desc_len > 0) { switch (proto) { case TPROTO_SAS: /* for SSP, added spl3r2 */ printf(" pwr_d_s=%d\n", !!(ucp[3] & 0x1)); pidp = ucp + 8; for (j = 0; j < desc_len; j += 4, pidp += 4) printf(" phy id=%d, ssp persistent capable=%d\n", pidp[1], (0x1 & pidp[2])); break; default: fprintf(stderr, "Unexpected proto=%d\n", proto); dStrHex((const char *)ucp, bump, 1); break; } } } return 0; } /* VPD_SCSI_PORTS */ static int decode_scsi_ports_vpd(unsigned char * buff, int len, int long_out, int quiet) { int k, bump, rel_port, ip_tid_len, tpd_len, res; unsigned char * ucp; if (len < 4) { fprintf(stderr, "SCSI Ports VPD page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } len -= 4; ucp = buff + 4; for (k = 0; k < len; k += bump, ucp += bump) { rel_port = (ucp[2] << 8) + ucp[3]; printf("Relative port=%d\n", rel_port); ip_tid_len = (ucp[6] << 8) + ucp[7]; bump = 8 + ip_tid_len; if ((k + bump) > len) { fprintf(stderr, "SCSI Ports VPD page, short descriptor " "length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } if (ip_tid_len > 0) { /* * SCSI devices that are both target and initiator are rare. * Only target devices can receive this command, so if they * are also initiators then print out the "Initiator port * transport id" in hex. sg_inq in sg3_utils decodes it. */ printf(" Initiator port transport id:\n"); dStrHex((const char *)(ucp + 8), ip_tid_len, 1); } tpd_len = (ucp[bump + 2] << 8) + ucp[bump + 3]; if ((k + bump + tpd_len + 4) > len) { fprintf(stderr, "SCSI Ports VPD page, short descriptor(tgt) " "length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } if (tpd_len > 0) { res = decode_dev_ids(" Target port descriptor(s)", ucp + bump + 4, tpd_len, VPD_ASSOC_TPORT, -1, -1, long_out, quiet); if (res) return res; } bump += tpd_len + 4; } return 0; } /* VPD_EXT_INQ Extended Inquiry page */ static int decode_ext_inq_vpd(unsigned char * b, int len, int long_out, int protect) { int n; if (len < 7) { fprintf(stderr, "Extended INQUIRY data VPD page length too " "short=%d\n", len); return SG_LIB_CAT_MALFORMED; } if (long_out) { n = (b[4] >> 6) & 0x3; printf(" ACTIVATE_MICROCODE=%d", n); if (1 == n) printf(" [before final WRITE BUFFER]\n"); else if (2 == n) printf(" [after power on or hard reset]\n"); else printf("\n"); n = (b[4] >> 3) & 0x7; printf(" SPT=%d", n); if (protect) { switch (n) { case 0: printf(" [protection type 1 supported]\n"); break; case 1: printf(" [protection types 1 and 2 supported]\n"); break; case 2: printf(" [protection type 2 supported]\n"); break; case 3: printf(" [protection types 1 and 3 supported]\n"); break; case 4: printf(" [protection type 3 supported]\n"); break; case 5: printf(" [protection types 2 and 3 supported]\n"); break; case 7: printf(" [protection types 1, 2 and 3 supported]\n"); break; default: printf("\n"); break; } } else printf("\n"); printf(" GRD_CHK=%d\n", !!(b[4] & 0x4)); printf(" APP_CHK=%d\n", !!(b[4] & 0x2)); printf(" REF_CHK=%d\n", !!(b[4] & 0x1)); printf(" UASK_SUP=%d\n", !!(b[5] & 0x20)); printf(" GROUP_SUP=%d\n", !!(b[5] & 0x10)); printf(" PRIOR_SUP=%d\n", !!(b[5] & 0x8)); printf(" HEADSUP=%d\n", !!(b[5] & 0x4)); printf(" ORDSUP=%d\n", !!(b[5] & 0x2)); printf(" SIMPSUP=%d\n", !!(b[5] & 0x1)); printf(" WU_SUP=%d\n", !!(b[6] & 0x8)); printf(" CRD_SUP=%d\n", !!(b[6] & 0x4)); printf(" NV_SUP=%d\n", !!(b[6] & 0x2)); printf(" V_SUP=%d\n", !!(b[6] & 0x1)); printf(" P_I_I_SUP=%d\n", !!(b[7] & 0x10)); printf(" LUICLR=%d\n", !!(b[7] & 0x1)); printf(" R_SUP=%d\n", !!(b[8] & 0x10)); printf(" CBCS=%d\n", !!(b[8] & 0x1)); printf(" Multi I_T nexus microcode download=%d\n", b[9] & 0xf); printf(" Extended self-test completion minutes=%d\n", (b[10] << 8) + b[11]); printf(" POA_SUP=%d\n", !!(b[12] & 0x80)); /* spc4r32 */ printf(" HRA_SUP=%d\n", !!(b[12] & 0x40)); /* spc4r32 */ printf(" VSA_SUP=%d\n", !!(b[12] & 0x20)); /* spc4r32 */ printf(" Maximum supported sense data length=%d\n", b[13]); /* spc4r34 */ } else { printf(" ACTIVATE_MICROCODE=%d SPT=%d GRD_CHK=%d APP_CHK=%d " "REF_CHK=%d\n", ((b[4] >> 6) & 0x3), ((b[4] >> 3) & 0x7), !!(b[4] & 0x4), !!(b[4] & 0x2), !!(b[4] & 0x1)); printf(" UASK_SUP=%d GROUP_SUP=%d PRIOR_SUP=%d HEADSUP=%d ORDSUP=%d " "SIMPSUP=%d\n", !!(b[5] & 0x20), !!(b[5] & 0x10), !!(b[5] & 0x8), !!(b[5] & 0x4), !!(b[5] & 0x2), !!(b[5] & 0x1)); printf(" WU_SUP=%d CRD_SUP=%d NV_SUP=%d V_SUP=%d\n", !!(b[6] & 0x8), !!(b[6] & 0x4), !!(b[6] & 0x2), !!(b[6] & 0x1)); printf(" P_I_I_SUP=%d LUICLR=%d R_SUP=%d CBCS=%d\n", !!(b[7] & 0x10), !!(b[7] & 0x1), !!(b[8] & 0x10), !!(b[8] & 0x1)); printf(" Multi I_T nexus microcode download=%d\n", b[9] & 0xf); printf(" Extended self-test completion minutes=%d\n", (b[10] << 8) + b[11]); printf(" POA_SUP=%d HRA_SUP=%d VSA_SUP=%d\n", /* spc4r32 */ !!(b[12] & 0x80), !!(b[12] & 0x40), !!(b[12] & 0x20)); printf(" Maximum supported sense data length=%d\n", b[13]); /* spc4r34 */ } return 0; } /* VPD_ATA_INFO */ static int decode_ata_info_vpd(unsigned char * buff, int len, int long_out, int do_hex) { char b[80]; int num, is_be; const char * cp; if (len < 36) { fprintf(stderr, "ATA information VPD page length too " "short=%d\n", len); return SG_LIB_CAT_MALFORMED; } memcpy(b, buff + 8, 8); b[8] = '\0'; printf(" SAT Vendor identification: %s\n", b); memcpy(b, buff + 16, 16); b[16] = '\0'; printf(" SAT Product identification: %s\n", b); memcpy(b, buff + 32, 4); b[4] = '\0'; printf(" SAT Product revision level: %s\n", b); if (len < 56) return SG_LIB_CAT_MALFORMED; if (long_out) { printf(" Signature (Device to host FIS):\n"); dStrHex((const char *)buff + 36, 20, 1); } if (len < 60) return SG_LIB_CAT_MALFORMED; is_be = sg_is_big_endian(); if ((0xec == buff[56]) || (0xa1 == buff[56])) { cp = (0xa1 == buff[56]) ? "PACKET " : ""; printf(" ATA command IDENTIFY %sDEVICE response summary:\n", cp); num = sg_ata_get_chars((const unsigned short *)(buff + 60), 27, 20, is_be, b); b[num] = '\0'; printf(" model: %s\n", b); num = sg_ata_get_chars((const unsigned short *)(buff + 60), 10, 10, is_be, b); b[num] = '\0'; printf(" serial number: %s\n", b); num = sg_ata_get_chars((const unsigned short *)(buff + 60), 23, 4, is_be, b); b[num] = '\0'; printf(" firmware revision: %s\n", b); if (long_out) printf(" ATA command IDENTIFY %sDEVICE response in hex:\n", cp); } else if (long_out) printf(" ATA command 0x%x got following response:\n", (unsigned int)buff[56]); if (len < 572) return SG_LIB_CAT_MALFORMED; if (do_hex) dStrHex((const char *)(buff + 60), 512, 0); else if (long_out) dWordHex((const unsigned short *)(buff + 60), 256, 0, is_be); return 0; } /* VPD_POWER_CONDITION */ static int decode_power_condition(unsigned char * buff, int len) { if (len < 18) { fprintf(stderr, "Power condition VPD page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } printf(" Standby_y=%d Standby_z=%d Idle_c=%d Idle_b=%d Idle_a=%d\n", !!(buff[4] & 0x2), !!(buff[4] & 0x1), !!(buff[5] & 0x4), !!(buff[5] & 0x2), !!(buff[5] & 0x1)); printf(" Stopped condition recovery time (ms) %d\n", (buff[6] << 8) + buff[7]); printf(" Standby_z condition recovery time (ms) %d\n", (buff[8] << 8) + buff[9]); printf(" Standby_y condition recovery time (ms) %d\n", (buff[10] << 8) + buff[11]); printf(" Idle_a condition recovery time (ms) %d\n", (buff[12] << 8) + buff[13]); printf(" Idle_b condition recovery time (ms) %d\n", (buff[14] << 8) + buff[15]); printf(" Idle_c condition recovery time (ms) %d\n", (buff[16] << 8) + buff[17]); return 0; } static const char * power_unit_arr[] = { "Gigawatts", "Megawatts", "Kilowatts", "Watts", "Milliwatts", "Microwatts", "Unit reserved", "Unit reserved", }; /* VPD_POWER_CONSUMPTION */ static int decode_power_consumption_vpd(unsigned char * buff, int len) { int k, bump; unsigned char * ucp; unsigned int value; if (len < 4) { fprintf(stderr, "Power consumption VPD page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } len -= 4; ucp = buff + 4; for (k = 0; k < len; k += bump, ucp += bump) { bump = 4; if ((k + bump) > len) { fprintf(stderr, "Power consumption VPD page, short " "descriptor length=%d, left=%d\n", bump, (len - k)); return SG_LIB_CAT_MALFORMED; } value = (ucp[2] << 8) + ucp[3]; printf(" Power consumption identifier: 0x%x", ucp[0]); if (value >= 1000 && (ucp[1] & 0x7) > 0) printf(" Maximum power consumption: %d.%03d %s\n", value / 1000, value % 1000, power_unit_arr[(ucp[1] & 0x7) - 1]); else printf(" Maximum power consumption: %d %s\n", value, power_unit_arr[ucp[1] & 0x7]); } return 0; } /* VPD_BLOCK_LIMITS */ static int decode_block_limits_vpd(unsigned char * buff, int len) { unsigned int u; int m; uint64_t mwsl; if (len < 16) { fprintf(stderr, "Block limits VPD page length too " "short=%d\n", len); return SG_LIB_CAT_MALFORMED; } printf(" Write same no zero (WSNZ): %d\n", !!(buff[4] & 0x1)); printf(" Maximum compare and write length: %u blocks\n", buff[5]); u = (buff[6] << 8) | buff[7]; printf(" Optimal transfer length granularity: %u blocks\n", u); u = ((unsigned int)buff[8] << 24) | (buff[9] << 16) | (buff[10] << 8) | buff[11]; printf(" Maximum transfer length: %u blocks\n", u); u = ((unsigned int)buff[12] << 24) | (buff[13] << 16) | (buff[14] << 8) | buff[15]; printf(" Optimal transfer length: %u blocks\n", u); if (len > 19) { /* added in sbc3r09 */ u = ((unsigned int)buff[16] << 24) | (buff[17] << 16) | (buff[18] << 8) | buff[19]; printf(" Maximum prefetch length: %u blocks\n", u); /* was 'Maximum prefetch transfer length' prior to sbc3r33 */ } if (len > 27) { /* added in sbc3r18 */ u = ((unsigned int)buff[20] << 24) | (buff[21] << 16) | (buff[22] << 8) | buff[23]; printf(" Maximum unmap LBA count: %u\n", u); u = ((unsigned int)buff[24] << 24) | (buff[25] << 16) | (buff[26] << 8) | buff[27]; printf(" Maximum unmap block descriptor count: %u\n", u); } if (len > 35) { /* added in sbc3r19 */ u = ((unsigned int)buff[28] << 24) | (buff[29] << 16) | (buff[30] << 8) | buff[31]; printf(" Optimal unmap granularity: %u\n", u); printf(" Unmap granularity alignment valid: %u\n", !!(buff[32] & 0x80)); u = ((unsigned int)(buff[32] & 0x7f) << 24) | (buff[33] << 16) | (buff[34] << 8) | buff[35]; printf(" Unmap granularity alignment: %u\n", u); } if (len > 43) { /* added in sbc3r26 */ mwsl = 0; for (m = 0; m < 8; ++m) { if (m > 0) mwsl <<= 8; mwsl |= buff[36 + m]; } printf(" Maximum write same length: 0x%" PRIx64 " blocks\n", mwsl); } return 0; } /* VPD_BLOCK_DEV_CHARS */ static int decode_block_dev_chars_vpd(unsigned char * buff, int len) { unsigned int u; if (len < 64) { fprintf(stderr, "Block device capabilities VPD page length too " "short=%d\n", len); return SG_LIB_CAT_MALFORMED; } u = (buff[4] << 8) | buff[5]; if (0 == u) printf(" Medium rotation rate is not reported\n"); else if (1 == u) printf(" Non-rotating medium (e.g. solid state)\n"); else if ((u < 0x401) || (0xffff == u)) printf(" Reserved [0x%x]\n", u); else printf(" Nominal rotation rate: %d rpm\n", u); u = buff[7] & 0xf; printf(" Product type=%d\n", buff[6]); printf(" WABEREQ=%d\n", (buff[7] >> 6) & 0x3); printf(" WACEREQ=%d\n", (buff[7] >> 4) & 0x3); printf(" Nominal form factor"); switch (u) { case 0: printf(" not reported\n"); break; case 1: printf(": 5.25 inch\n"); break; case 2: printf(": 3.5 inch\n"); break; case 3: printf(": 2.5 inch\n"); break; case 4: printf(": 1.8 inch\n"); break; case 5: printf(": less then 1.8 inch\n"); break; default: printf(": reserved\n"); break; } printf(" FUAB=%d\n", buff[8] & 0x2); printf(" VBULS=%d\n", buff[8] & 0x1); return 0; } /* VPD_SA_DEV_CAP */ static int decode_tape_dev_caps_vpd(unsigned char * buff, int len) { if (len < 6) { fprintf(stderr, "Sequential access device capabilities VPD page " "length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } printf(" Worm: %d\n", !!(buff[4] & 0x1)); return 0; } /* VPD_MAN_ASS_SN */ static int decode_tape_man_ass_sn_vpd(unsigned char * buff, int len) { if (len < 64) { fprintf(stderr, "Manufacturer-assigned serial number VPD page " "length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } printf(" Manufacturer-assigned serial number: %.*s\n", len - 4, buff + 4); return 0; } /* VPD_LB_PROVISIONING [0xb2] */ static int decode_block_lb_prov_vpd(unsigned char * b, int len) { int dp; if (len < 4) { fprintf(stderr, "Logical block provisioning page too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } printf(" Unmap command supported (LBPU): %d\n", !!(0x80 & b[5])); printf(" Write same (16) with unmap bit supported (LBWS): %d\n", !!(0x40 & b[5])); printf(" Write same (10) with unmap bit supported (LBWS10): %d\n", !!(0x20 & b[5])); printf(" Logical block provisioning read zeros (LBPRZ): %d\n", !!(0x4 & b[5])); printf(" Anchored LBAs supported (ANC_SUP): %d\n", !!(0x2 & b[5])); printf(" Threshold exponent: %d\n", b[4]); dp = !!(b[5] & 0x1); printf(" Descriptor present: %d\n", dp); printf(" Provisioning type: %d\n", b[6] & 0x7); if (dp) { const unsigned char * ucp; int i_len; ucp = b + 8; i_len = ucp[3]; if (0 == i_len) { fprintf(stderr, "Logical block provisioning page provisioning " "group descriptor too short=%d\n", i_len); return 0; } printf(" Provisioning group descriptor\n"); decode_designation_descriptor(ucp, i_len, 0, 1); } return 0; } /* VPD_TA_SUPPORTED */ static int decode_tapealert_supported_vpd(unsigned char * b, int len) { if (len < 12) { fprintf(stderr, "TapeAlert supported flags length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } printf(" Flag01h: %d 02h: %d 03h: %d 04h: %d 05h: %d 06h: %d " "07h: %d 08h: %d\n", !!(b[4] & 0x80), !!(b[4] & 0x40), !!(b[4] & 0x20), !!(b[4] & 0x10), !!(b[4] & 0x8), !!(b[4] & 0x4), !!(b[4] & 0x2), !!(b[4] & 0x1)); printf(" Flag09h: %d 0ah: %d 0bh: %d 0ch: %d 0dh: %d 0eh: %d " "0fh: %d 10h: %d\n", !!(b[5] & 0x80), !!(b[5] & 0x40), !!(b[5] & 0x20), !!(b[5] & 0x10), !!(b[5] & 0x8), !!(b[5] & 0x4), !!(b[5] & 0x2), !!(b[5] & 0x1)); printf(" Flag11h: %d 12h: %d 13h: %d 14h: %d 15h: %d 16h: %d " "17h: %d 18h: %d\n", !!(b[6] & 0x80), !!(b[6] & 0x40), !!(b[6] & 0x20), !!(b[6] & 0x10), !!(b[6] & 0x8), !!(b[6] & 0x4), !!(b[6] & 0x2), !!(b[6] & 0x1)); printf(" Flag19h: %d 1ah: %d 1bh: %d 1ch: %d 1dh: %d 1eh: %d " "1fh: %d 20h: %d\n", !!(b[7] & 0x80), !!(b[7] & 0x40), !!(b[7] & 0x20), !!(b[7] & 0x10), !!(b[7] & 0x8), !!(b[7] & 0x4), !!(b[7] & 0x2), !!(b[7] & 0x1)); printf(" Flag21h: %d 22h: %d 23h: %d 24h: %d 25h: %d 26h: %d " "27h: %d 28h: %d\n", !!(b[8] & 0x80), !!(b[8] & 0x40), !!(b[8] & 0x20), !!(b[8] & 0x10), !!(b[8] & 0x8), !!(b[8] & 0x4), !!(b[8] & 0x2), !!(b[8] & 0x1)); printf(" Flag29h: %d 2ah: %d 2bh: %d 2ch: %d 2dh: %d 2eh: %d " "2fh: %d 30h: %d\n", !!(b[9] & 0x80), !!(b[9] & 0x40), !!(b[9] & 0x20), !!(b[9] & 0x10), !!(b[9] & 0x8), !!(b[9] & 0x4), !!(b[9] & 0x2), !!(b[9] & 0x1)); printf(" Flag31h: %d 32h: %d 33h: %d 34h: %d 35h: %d 36h: %d " "37h: %d 38h: %d\n", !!(b[10] & 0x80), !!(b[10] & 0x40), !!(b[10] & 0x20), !!(b[10] & 0x10), !!(b[10] & 0x8), !!(b[10] & 0x4), !!(b[10] & 0x2), !!(b[10] & 0x1)); printf(" Flag39h: %d 3ah: %d 3bh: %d 3ch: %d 3dh: %d 3eh: %d " "3fh: %d 40h: %d\n", !!(b[11] & 0x80), !!(b[11] & 0x40), !!(b[11] & 0x20), !!(b[11] & 0x10), !!(b[11] & 0x8), !!(b[11] & 0x4), !!(b[11] & 0x2), !!(b[11] & 0x1)); return 0; } /* VPD_REFERRALS */ static int decode_referrals_vpd(unsigned char * b, int len) { unsigned int u; if (len < 16) { fprintf(stderr, "Referrals VPD page length too short=%d\n", len); return SG_LIB_CAT_MALFORMED; } u = ((unsigned int)b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11]; printf(" User data segment size: %u\n", u); u = ((unsigned int)b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15]; printf(" User data segment multiplier: %u\n", u); return 0; } /* Assume index is less than 16 */ const char * sg_ansi_version_arr[] = { "no conformance claimed", "SCSI-1", /* obsolete, ANSI X3.131-1986 */ "SCSI-2", /* obsolete, ANSI X3.131-1994 */ "SPC", /* withdrawn */ "SPC-2", "SPC-3", "SPC-4", "reserved [7h]", "ecma=1, [8h]", "ecma=1, [9h]", "ecma=1, [Ah]", "ecma=1, [Bh]", "reserved [Ch]", "reserved [Dh]", "reserved [Eh]", "reserved [Fh]", }; static int decode_std_inq(int sg_fd, const struct sdparm_opt_coll * opts) { int res, verb, sz, len, pqual; unsigned char b[DEF_INQ_RESP_LEN]; verb = (opts->verbose > 0) ? opts->verbose - 1 : 0; sz = sizeof(b); memset(b, 0, sizeof(b)); sz = opts->long_out ? sizeof(b) : 36; res = sg_ll_inquiry(sg_fd, 0, 0, 0, b, sz, 0, verb); if (res) { fprintf(stderr, "INQUIRY fetching standar response failed\n"); return res; } pqual = (b[0] & 0xe0) >> 5; if (0 == pqual) printf("standard INQUIRY:\n"); else if (1 == pqual) printf("standard INQUIRY: [qualifier indicates no connected " "LU]\n"); else if (3 == pqual) printf("standard INQUIRY: [qualifier indicates not capable " "of supporting LU]\n"); else printf("standard INQUIRY: [reserved or vendor specific " "qualifier [%d]]\n", pqual); len = b[4] + 5; len = (len <= sz) ? len : sz; if (opts->hex) { dStrHex((const char *)b, len, 0); return 0; } printf(" PQual=%d Device_type=%d RMB=%d version=0x%02x ", pqual, b[0] & 0x1f, !!(b[1] & 0x80), (unsigned int)b[2]); printf(" [%s]\n", sg_ansi_version_arr[b[2] & 0xf]); printf(" [AERC=%d] [TrmTsk=%d] NormACA=%d HiSUP=%d " " Resp_data_format=%d\n SCCS=%d ", !!(b[3] & 0x80), !!(b[3] & 0x40), !!(b[3] & 0x20), !!(b[3] & 0x10), b[3] & 0x0f, !!(b[5] & 0x80)); printf("ACC=%d TPGS=%d 3PC=%d Protect=%d ", !!(b[5] & 0x40), ((b[5] & 0x30) >> 4), !!(b[5] & 0x08), !!(b[5] & 0x01)); printf(" [BQue=%d]\n EncServ=%d ", !!(b[6] & 0x80), !!(b[6] & 0x40)); if (b[6] & 0x10) printf("MultiP=1 (VS=%d) ", !!(b[6] & 0x20)); else printf("MultiP=0 "); printf("[MChngr=%d] [ACKREQQ=%d] Addr16=%d\n [RelAdr=%d] ", !!(b[6] & 0x08), !!(b[6] & 0x04), !!(b[6] & 0x01), !!(b[7] & 0x80)); printf("WBus16=%d Sync=%d Linked=%d [TranDis=%d] ", !!(b[7] & 0x20), !!(b[7] & 0x10), !!(b[7] & 0x08), !!(b[7] & 0x04)); printf("CmdQue=%d\n", !!(b[7] & 0x02)); printf(" Vendor_identification: %.8s\n", b + 8); printf(" Product_identification: %.16s\n", b + 16); printf(" Product_revision_level: %.4s\n", b + 32); return 0; } /* Returns 0 if successful, else error */ int sdp_process_vpd_page(int sg_fd, int pn, int spn, const struct sdparm_opt_coll * opts, int req_pdt, int protect) { int res, len, k, verb, dev_pdt, pdt; unsigned char b[VPD_ATA_INFO_RESP_LEN]; int sz; unsigned char * up; const struct sdparm_vpd_page_t * vpp; const char * vpd_name; int adc = 0; int sbc = 0; int ssc = 0; verb = (opts->verbose > 0) ? opts->verbose - 1 : 0; sz = sizeof(b); memset(b, 0, sz); if (pn < 0) { if (VPD_NOT_STD_INQ == pn) return decode_std_inq(sg_fd, opts); else if (opts->all) pn = VPD_SUPPORTED_VPDS; /* if '--all' list supported vpds */ else pn = VPD_DEVICE_ID; /* default to device identification page */ } sz = (VPD_ATA_INFO == pn) ? VPD_ATA_INFO_RESP_LEN : DEF_INQ_RESP_LEN; res = sg_ll_inquiry(sg_fd, 0, 1, pn, b, sz, 0, verb); if (res) { fprintf(stderr, "INQUIRY fetching VPD page=0x%x failed\n", pn); return res; } dev_pdt = b[0] & 0x1f; if ((req_pdt >= 0) && (req_pdt != (dev_pdt))) { fprintf(stderr, "given peripheral device type [%d] differs " "from reported [%d]\n", req_pdt, dev_pdt); fprintf(stderr, " start with given pdt\n"); pdt = req_pdt; } else pdt = dev_pdt; switch (pn) { case VPD_SUPPORTED_VPDS: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; /* spc4r25 */ printf("Supported VPD pages VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } if (len > 0) { for (k = 0; k < len; ++k) { vpp = sdp_get_vpd_detail(b[4 + k], -1, pdt); if (vpp) { if (opts->long_out) printf(" [0x%02x] %s [%s]\n", b[4 + k], vpp->name, vpp->acron); else printf(" %s [%s]\n", vpp->name, vpp->acron); } else printf(" 0x%x\n", b[4 + k]); } } else printf(" \n"); break; case VPD_ATA_INFO: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to ATA information VPD page " "truncated\n"); len = sz; } if (3 == opts->hex) { /* output suitable for "hdparm --Istdin" */ dWordHex((const unsigned short *)(b + 60), 256, -2, sg_is_big_endian()); return 0; } if (opts->long_out) printf("ATA information [0x89] VPD page:\n"); else printf("ATA information VPD page:\n"); if (opts->hex && (2 != opts->hex)) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_ata_info_vpd(b, len + 4, opts->long_out, opts->hex); if (res) return res; break; case VPD_DEVICE_ID: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to device identification VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("Device identification [0x83] VPD page:\n"); else if (! opts->quiet) printf("Device identification VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = 0; if ((0 == spn) || (VPD_DI_SEL_LU & spn)) res = decode_dev_ids(sdparm_assoc_arr[VPD_ASSOC_LU], b + 4, len, VPD_ASSOC_LU, -1, -1, opts->long_out, opts->quiet); if ((0 == spn) || (VPD_DI_SEL_TPORT & spn)) res = decode_dev_ids(sdparm_assoc_arr[VPD_ASSOC_TPORT], b + 4, len, VPD_ASSOC_TPORT, -1, -1, opts->long_out, opts->quiet); if ((0 == spn) || (VPD_DI_SEL_TARGET & spn)) res = decode_dev_ids(sdparm_assoc_arr[VPD_ASSOC_TDEVICE], b + 4, len, VPD_ASSOC_TDEVICE, -1, -1, opts->long_out, opts->quiet); if (VPD_DI_SEL_AS_IS & spn) res = decode_dev_ids(NULL, b + 4, len, -1, -1, -1, opts->long_out, opts->quiet); if (res) return res; break; case VPD_EXT_INQ: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; /* spc4r25 */ if (len > sz) { fprintf(stderr, "Response to Extended inquiry data VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("Extended inquiry data [0x86] VPD page:\n"); else if (! opts->quiet) printf("Extended inquiry data VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_ext_inq_vpd(b, len + 4, opts->long_out, protect); if (res) return res; break; case VPD_MAN_NET_ADDR: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Management network addresses VPD " "page truncated\n"); len = sz; } if (opts->long_out) printf("Management network addresses [0x85] VPD page:\n"); else printf("Management network addresses VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_man_net_vpd(b, len + 4); if (res) return res; break; case VPD_MODE_PG_POLICY: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Mode page policy VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("Mode page policy [0x87] VPD page:\n"); else printf("mode page policy VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_mode_policy_vpd(b, len + 4); if (res) return res; break; case VPD_POWER_CONDITION: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Power condition VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("Power condition [0x8a] VPD page:\n"); else if (! opts->quiet) printf("Power condition VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_power_condition(b, len + 4); if (res) return res; break; case VPD_POWER_CONSUMPTION: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Power consumption VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("Power consumption [0x8d] VPD page:\n"); else printf("Power consumption VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_power_consumption_vpd(b, len + 4); if (res) return res; break; case VPD_PROTO_LU: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Protocol-specific logical unit " "information VPD page truncated\n"); len = sz; } if (opts->long_out) printf("Protocol-specific logical unit information [0x90] VPD " "page:\n"); else printf("Protocol-specific logical unit information VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_proto_lu_vpd(b, len + 4); if (res) return res; break; case VPD_PROTO_PORT: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Protocol-specific port " "information VPD page truncated\n"); len = sz; } if (opts->long_out) printf("Protocol-specific port information [0x91] VPD " "page:\n"); else printf("Protocol-specific port information VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_proto_port_vpd(b, len + 4); if (res) return res; break; case VPD_SCSI_PORTS: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to SCSI Ports VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("SCSI Ports [0x88] VPD page:\n"); else printf("SCSI Ports VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = decode_scsi_ports_vpd(b, len + 4, opts->long_out, opts->quiet); if (res) return res; break; case VPD_SOFTW_INF_ID: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; /* spc4r25 */ if (len > sz) { fprintf(stderr, "Response to Software interface identification " "VPD page truncated\n"); len = sz; } if (opts->long_out) printf("Software interface identification [0x84] VPD page:\n"); else printf("Software interface identification VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } up = b + 4; for ( ; len > 5; len -= 6, up += 6) printf(" IEEE Company_id: 0x%06x, vendor specific extension " "id: 0x%06x\n", (up[0] << 16) | (up[1] << 8) | up[2], (up[3] << 16) | (up[4] << 8) | up[5]); break; case VPD_UNIT_SERIAL_NUM: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; /* spc4r25 */ if (opts->long_out) printf("Unit serial number [0x80] VPD page:\n"); else printf("Unit serial number VPD page:\n"); if (opts->hex) dStrHex((const char *)b, len + 4, 0); else if (len > 0) { if (len + 4 < (int)sizeof(b)) b[len + 4] = '\0'; else b[sizeof(b) - 1] = '\0'; printf(" %s\n", b + 4); } else printf(" \n"); break; case VPD_3PARTY_COPY: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; /* spc4r25 */ if (len > sz) { fprintf(stderr, "Response to Third party copy VPD page " "truncated\n"); len = sz; } if (opts->long_out) printf("Third party copy [0x8f] VPD page:\n"); else printf("Third party copy VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } printf(" Leave decoding until needed, in hex:\n"); dStrHex((const char *)b, len + 4, 0); break; case 0xb0: /* VPD page depends on pdt */ if (b[1] != pn) goto dumb_inq; switch (pdt) { case PDT_DISK: case PDT_WO: case PDT_OPTICAL: vpd_name = "Block limits"; sbc = 1; break; case PDT_TAPE: case PDT_MCHANGER: vpd_name = "Sequential access device capabilities"; ssc = 1; break; case PDT_OSD: vpd_name = "OSD information"; /* osd = 1; */ break; default: vpd_name = "unexpected pdt for B0h"; break; } len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to %s VPD page truncated\n", vpd_name); len = sz; } if (opts->long_out) printf("%s [0xb0] VPD page:\n", vpd_name); else printf("%s VPD page:\n", vpd_name); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = 0; if (ssc) res = decode_tape_dev_caps_vpd(b, len + 4); else if (sbc) res = decode_block_limits_vpd(b, len + 4); else dStrHex((const char *)b, len + 4, 0); if (res) return res; break; case 0xb1: /* VPD page depends on pdt */ if (b[1] != pn) goto dumb_inq; switch (pdt) { case PDT_DISK: case PDT_WO: case PDT_OPTICAL: vpd_name = "Block device characteristics"; sbc = 1; break; case PDT_TAPE: case PDT_MCHANGER: vpd_name = "Manufactured assigned serial number"; ssc = 1; break; case PDT_OSD: vpd_name = "Security token"; /* osd = 1; */ break; case PDT_ADC: vpd_name = "Manufactured assigned serial number"; adc = 1; break; default: vpd_name = "unexpected pdt for B1h"; break; } len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to %s VPD page truncated\n", vpd_name); len = sz; } if (opts->long_out) printf("%s [0xb1] VPD page:\n", vpd_name); else printf("%s VPD page:\n", vpd_name); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = 0; if (ssc || adc) res = decode_tape_man_ass_sn_vpd(b, len + 4); else if (sbc) res = decode_block_dev_chars_vpd(b, len + 4); else dStrHex((const char *)b, len + 4, 0); if (res) return res; break; case 0xb2: /* VPD page depends on pdt */ if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; switch (pdt) { case PDT_DISK: case PDT_WO: case PDT_OPTICAL: vpd_name = "Logical block provisioning"; sbc = 1; break; case PDT_TAPE: case PDT_MCHANGER: vpd_name = "TapeAlert supported flags"; ssc = 1; break; default: vpd_name = "unexpected pdt for B2h"; break; } if (opts->long_out) printf("%s [0xb2] VPD page:\n", vpd_name); else printf("%s VPD page:\n", vpd_name); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = 0; if (ssc) res = decode_tapealert_supported_vpd(b, len + 4); else if (sbc) /* added in sbc3r20 */ res = decode_block_lb_prov_vpd(b, len + 4); else dStrHex((const char *)b, len + 4, 0); if (res) return res; break; case 0xb3: /* VPD page depends on pdt */ if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; switch (pdt) { case PDT_DISK: case PDT_WO: case PDT_OPTICAL: vpd_name = "Referrals"; sbc = 1; break; case PDT_TAPE: case PDT_MCHANGER: vpd_name = "Automation device serial number"; ssc = 1; break; default: vpd_name = "unexpected pdt for B3h"; break; } if (opts->long_out) printf("%s [0xb3] VPD page:\n", vpd_name); else printf("%s VPD page:\n", vpd_name); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } res = 0; if (ssc) { /* VPD_AUTOMATION_DEV_SN ssc */ if (len > 0) { if (len + 4 < (int)sizeof(b)) b[len + 4] = '\0'; else b[sizeof(b) - 1] = '\0'; printf(" serial number: %s\n", b + 4); } else printf(" serial number: \n"); } else if (sbc) /* added in sbc3r22 */ res = decode_referrals_vpd(b, len + 4); else dStrHex((const char *)b, len + 4, 0); if (res) return res; break; case VPD_DTDE_ADDRESS: /* 0xb4 */ if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3]; if (len > sz) { fprintf(stderr, "Response to Data transfer device element " "address VPD page truncated\n"); len = sz; } if (opts->long_out) printf("Data transfer device element address [0xB4] VPD page:\n"); else printf("Data transfer device element address VPD page:\n"); if (opts->hex) { dStrHex((const char *)b, len + 4, 0); return 0; } else if (len > 0) { printf(" 0x"); for (k = 0; k < len; ++k) printf("%02x", (unsigned int)b[4 + k]); printf("\n"); } else printf(" \n"); break; default: if (b[1] != pn) goto dumb_inq; len = (b[2] << 8) + b[3] + 4; vpp = sdp_get_vpd_detail(pn, -1, pdt); if (vpp) fprintf(stderr, "%s VPD page in hex:\n", vpp->name); else fprintf(stderr, "VPD page 0x%x in hex:\n", pn); if (len > (int)sizeof(b)) { if (opts->verbose) fprintf(stderr, "page length=%d too long, trim\n", len); len = sizeof(b); } dStrHex((const char *)b, len, 0); break; } return 0; dumb_inq: fprintf(stderr, "malformed VPD response, VPD pages probably not " "supported\n"); return SG_LIB_CAT_MALFORMED; } sdparm-1.08/src/Makefile.am0000664000175000017500000000265112153451342014555 0ustar douggdouggbin_PROGRAMS = sdparm # for C++/clang testing ## CC = g++ -std=c++11 ## CC = g++ ## CC = clang # -std= can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) AM_CFLAGS = -I$(top_srcdir)/include -Wall -W # AM_CFLAGS = -I$(top_srcdir)/include -Wall -W -pedantic -std=c11 sdparm_SOURCES = sdparm.c \ sdparm.h \ sdparm_data.c \ sdparm_data_vendor.c \ sdparm_access.c \ sdparm_vpd.c \ sdparm_cmd.c if OS_WIN32_MINGW sdparm_SOURCES += sdparm_wscan.c endif if OS_WIN32_CYGWIN sdparm_SOURCES += sdparm_wscan.c endif sglib_SOURCES = ../lib/sg_lib.c \ ../include/sg_lib.h \ ../lib/sg_lib_data.c \ ../include/sg_lib_data.h \ ../lib/sg_cmds_basic.c \ ../lib/sg_cmds_basic2.c \ ../include/sg_cmds_basic.h \ ../lib/sg_cmds_mmc.c \ ../include/sg_cmds_mmc.h \ ../include/sg_pt.h \ ../lib/sg_pt_common.c if HAVE_SGUTILS INCLUDES = -I/usr/include/scsi sdparm_LDADD = @GETOPT_O_FILES@ @os_libs@ @SGUTILS_LIBS@ sdparm_DEPENDENCIES = @GETOPT_O_FILES@ else INCLUDES = -I$(top_srcdir)/include sdparm_SOURCES += $(sglib_SOURCES) sdparm_LDADD = @os_deps@ @GETOPT_O_FILES@ @os_libs@ @SGUTILS_LIBS@ sdparm_DEPENDENCIES = @os_deps@ @GETOPT_O_FILES@ endif EXTRA_sdparm_SOURCES = ../lib/sg_pt_linux.c \ ../include/sg_linux_inc.h \ ../lib/sg_pt_freebsd.c \ ../lib/sg_pt_osf1.c \ ../lib/sg_pt_solaris.c \ ../lib/sg_pt_win32.c \ ../include/sg_pt_win32.h \ getopt_long.c \ port_getopt.h sdparm-1.08/src/sdparm_access.c0000664000175000017500000002601011722232420015462 0ustar douggdougg/* * Copyright (c) 2005-2012 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include "sdparm.h" /* sdparm_access.c : helpers for sdparm to access tables in * sdparm_data.c */ /* Returns 1 if strings equal (same length, characters same or only differ * by case), else returns 0. Assumes 7 bit ASCII (English alphabet). */ int sdp_strcase_eq(const char * s1p, const char * s2p) { int c1, c2; do { c1 = *s1p++; c2 = *s2p++; if (c1 != c2) { if (c2 >= 'a') c2 = toupper(c2); else if (c1 >= 'a') c1 = toupper(c1); else return 0; if (c1 != c2) return 0; } } while (c1); return 1; } int sdp_get_mp_len(unsigned char * mp) { return (mp[0] & 0x40) ? ((mp[2] << 8) + mp[3] + 4) : (mp[1] + 2); } const struct sdparm_mode_page_t * sdp_get_mode_detail(int page_num, int subpage_num, int pdt, int transp_proto, int vendor_num) { const struct sdparm_mode_page_t * mpp; if (vendor_num >= 0) { const struct sdparm_vendor_pair * vpp; vpp = sdp_get_vendor_pair(vendor_num); mpp = (vpp ? vpp->mpage : NULL); } else if ((transp_proto >= 0) && (transp_proto < 16)) mpp = sdparm_transport_mp[transp_proto].mpage; else mpp = sdparm_gen_mode_pg; if (NULL == mpp) return NULL; for ( ; mpp->acron; ++mpp) { if ((page_num == mpp->page) && (subpage_num == mpp->subpage)) { if ((pdt < 0) || (mpp->pdt < 0) || (mpp->pdt == pdt)) return mpp; } } return NULL; } const struct sdparm_mode_page_t * sdp_get_mpage_name(int page_num, int subpage_num, int pdt, int transp_proto, int vendor_num, int plus_acron, int hex, char * bp, int max_b_len) { int len = max_b_len - 1; const struct sdparm_mode_page_t * mpp = NULL; const char * cp; if (len < 0) return mpp; bp[len] = '\0'; mpp = sdp_get_mode_detail(page_num, subpage_num, pdt, transp_proto, vendor_num); if (NULL == mpp) mpp = sdp_get_mode_detail(page_num, subpage_num, -1, transp_proto, vendor_num); if (mpp && mpp->name) { cp = mpp->acron; if (NULL == cp) cp = ""; if (hex) { if (0 == subpage_num) { if (plus_acron) snprintf(bp, len, "%s [%s: 0x%x]", mpp->name, cp, page_num); else snprintf(bp, len, "%s [0x%x]", mpp->name, page_num); } else { if (plus_acron) snprintf(bp, len, "%s [%s: 0x%x,0x%x]", mpp->name, cp, page_num, subpage_num); else snprintf(bp, len, "%s [0x%x,0x%x]", mpp->name, page_num, subpage_num); } } else { if (plus_acron) snprintf(bp, len, "%s [%s]", mpp->name, cp); else snprintf(bp, len, "%s", mpp->name); } } else { if (0 == subpage_num) snprintf(bp, len, "[0x%x]", page_num); else snprintf(bp, len, "[0x%x,0x%x]", page_num, subpage_num); } return mpp; } const struct sdparm_mode_page_t * sdp_find_mp_by_acron(const char * ap, int transp_proto, int vendor_num) { const struct sdparm_mode_page_t * mpp; if (vendor_num >= 0) { const struct sdparm_vendor_pair * vpp; vpp = sdp_get_vendor_pair(vendor_num); mpp = (vpp ? vpp->mpage : NULL); } else if ((transp_proto >= 0) && (transp_proto < 16)) mpp = sdparm_transport_mp[transp_proto].mpage; else mpp = sdparm_gen_mode_pg; if (NULL == mpp) return NULL; for ( ; mpp->acron; ++mpp) { if (sdp_strcase_eq(mpp->acron, ap)) return mpp; } return NULL; } const struct sdparm_vpd_page_t * sdp_get_vpd_detail(int page_num, int subvalue, int pdt) { const struct sdparm_vpd_page_t * vpp; int sv, ty; sv = (subvalue < 0) ? 1 : 0; ty = (pdt < 0) ? 1 : 0; for (vpp = sdparm_vpd_pg; vpp->acron; ++vpp) { if ((page_num == vpp->vpd_num) && (sv || (subvalue == vpp->subvalue)) && (ty || (pdt == vpp->pdt))) return vpp; } if (! ty) return sdp_get_vpd_detail(page_num, subvalue, -1); if (! sv) return sdp_get_vpd_detail(page_num, -1, -1); return NULL; } const struct sdparm_vpd_page_t * sdp_find_vpd_by_acron(const char * ap) { const struct sdparm_vpd_page_t * vpp; for (vpp = sdparm_vpd_pg; vpp->acron; ++vpp) { if (sdp_strcase_eq(vpp->acron, ap)) return vpp; } return NULL; } const char * sdp_get_transport_name(int proto_num) { const struct sdparm_transport_id_t * tip; for (tip = sdparm_transport_id; tip->acron; ++tip) { if (proto_num == tip->proto_num) return tip->name; } return NULL; } const struct sdparm_transport_id_t * sdp_find_transport_by_acron(const char * ap) { const struct sdparm_transport_id_t * tip; for (tip = sdparm_transport_id; tip->acron; ++tip) { if (sdp_strcase_eq(tip->acron, ap)) return tip; } return NULL; } const char * sdp_get_vendor_name(int vendor_num) { const struct sdparm_vendor_name_t * vnp; for (vnp = sdparm_vendor_id; vnp->acron; ++vnp) { if (vendor_num == vnp->vendor_num) return vnp->name; } return NULL; } const struct sdparm_vendor_name_t * sdp_find_vendor_by_acron(const char * ap) { const struct sdparm_vendor_name_t * vnp; for (vnp = sdparm_vendor_id; vnp->acron; ++vnp) { if (sdp_strcase_eq(vnp->acron, ap)) return vnp; } return NULL; } const struct sdparm_vendor_pair * sdp_get_vendor_pair(int vendor_num) { return ((vendor_num >= 0) && (vendor_num < sdparm_vendor_mp_len)) ? (sdparm_vendor_mp + vendor_num) : NULL; } const struct sdparm_mode_page_item * sdp_find_mitem_by_acron(const char * ap, int * from, int transp_proto, int vendor_num) { int k = 0; const struct sdparm_mode_page_item * mpi; if (from) { k = *from; if (k < 0) k = 0; } if (vendor_num >= 0) { const struct sdparm_vendor_pair * vpp; vpp = sdp_get_vendor_pair(vendor_num); mpi = (vpp ? vpp->mitem : NULL); } else if ((transp_proto >= 0) && (transp_proto < 16)) mpi = sdparm_transport_mp[transp_proto].mitem; else mpi = sdparm_mitem_arr; if (NULL == mpi) return NULL; for (mpi += k; mpi->acron; ++k, ++mpi) { if (sdp_strcase_eq(mpi->acron, ap)) break; } if (NULL == mpi->acron) mpi = NULL; if (from) *from = (mpi ? (k + 1) : k); return mpi; } uint64_t sdp_get_big_endian(const unsigned char * from, int start_bit, int num_bits) { uint64_t res; int sbit_o1 = start_bit + 1; res = (*from++ & ((1 << sbit_o1) - 1)); num_bits -= sbit_o1; while (num_bits > 0) { res <<= 8; res |= *from++; num_bits -= 8; } if (num_bits < 0) res >>= (-num_bits); return res; } void sdp_set_big_endian(uint64_t val, unsigned char * to, int start_bit, int num_bits) { int sbit_o1 = start_bit + 1; int mask, num, k, x; mask = (8 != sbit_o1) ? ((1 << sbit_o1) - 1) : 0xff; k = start_bit - ((num_bits - 1) % 8); if (0 != k) val <<= ((k > 0) ? k : (8 + k)); num = (num_bits + 15 - sbit_o1) / 8; for (k = 0; k < num; ++k) { if ((sbit_o1 - num_bits) > 0) mask &= ~((1 << (sbit_o1 - num_bits)) - 1); if (k < (num - 1)) x = (val >> ((num - k - 1) * 8)) & 0xff; else x = val & 0xff; to[k] = (to[k] & ~mask) | (x & mask); mask = 0xff; num_bits -= sbit_o1; sbit_o1 = 8; } } uint64_t sdp_mp_get_value(const struct sdparm_mode_page_item *mpi, const unsigned char * mp) { return sdp_get_big_endian(mp + mpi->start_byte, mpi->start_bit, mpi->num_bits); } uint64_t sdp_mp_get_value_check(const struct sdparm_mode_page_item *mpi, const unsigned char * mp, int * all_set) { uint64_t res; res = sdp_get_big_endian(mp + mpi->start_byte, mpi->start_bit, mpi->num_bits); if (all_set) { if ((16 == mpi->num_bits) && (0xffff == res)) *all_set = 1; else if ((32 == mpi->num_bits) && (0xffffffff == res)) *all_set = 1; else if ((64 == mpi->num_bits) && (0xffffffffffffffffULL == res)) *all_set = 1; else *all_set = 0; } return res; } void sdp_mp_set_value(uint64_t val, const struct sdparm_mode_page_item * mpi, unsigned char * mp) { sdp_set_big_endian(val, mp + mpi->start_byte, mpi->start_bit, mpi->num_bits); } char * sdp_get_ansi_version_str(int version, int buff_len, char * buff) { version &= 0x7; buff[buff_len - 1] = '\0'; strncpy(buff, sdparm_ansi_version_arr[version], buff_len - 1); return buff; } char * sdp_get_pdt_doc_str(int pdt, int buff_len, char * buff) { if ((pdt < -1) || (pdt > 31)) snprintf(buff, buff_len, "bad pdt"); else if (-1 == pdt) snprintf(buff, buff_len, "SPC-4"); else snprintf(buff, buff_len, "%s", sdparm_pdt_doc_strs[pdt]); return buff; } sdparm-1.08/src/sdparm.c0000664000175000017500000027552112154112737014166 0ustar douggdougg/* * Copyright (c) 2005-2013 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ /* * sdparm is a utility program for getting and setting parameters on devices * that use one of the SCSI command sets. In some cases commands can be sent * to the device (e.g. eject removable media). * * Note that some devices, such as CD/DVD drives, use a SCSI command set * (i.e. MMC-4 and SPC-3) but are not normally categorized as "SCSI" since * most use the packet interface over the ATA transport (ATAPI). */ #include #include #include #include #include #include #define __STDC_FORMAT_MACROS 1 #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef HAVE_GETOPT_LONG #include #else #include "port_getopt.h" #endif #ifdef SG_LIB_LINUX #include #include #include #include #include /* Following needed for lk 2.4 series; may be dropped in future */ #include #include static int map_if_lk24(int sg_fd, const char * device_name, int rw, int verbose); #endif /* SG_LIB_LINUX */ #include "sg_lib.h" #include "sg_cmds_basic.h" #include "sdparm.h" #define MAX_DEV_NAMES 256 static const char * version_str = "1.08 20130606 [svn: r215]"; static struct option long_options[] = { {"six", no_argument, 0, '6'}, {"all", no_argument, 0, 'a'}, {"dbd", no_argument, 0, 'B'}, {"clear", required_argument, 0, 'c'}, {"command", required_argument, 0, 'C'}, {"defaults", no_argument, 0, 'D'}, {"dummy", no_argument, 0, 'd'}, {"enumerate", no_argument, 0, 'e'}, {"flexible", no_argument, 0, 'f'}, {"get", required_argument, 0, 'g'}, {"help", no_argument, 0, 'h'}, {"hex", no_argument, 0, 'H'}, {"inquiry", no_argument, 0, 'i'}, {"long", no_argument, 0, 'l'}, {"num-desc", no_argument, 0, 'n'}, {"page", required_argument, 0, 'p'}, {"quiet", no_argument, 0, 'q'}, {"readonly", no_argument, 0, 'r'}, {"set", required_argument, 0, 's'}, {"save", no_argument, 0, 'S'}, {"transport", required_argument, 0, 't'}, {"vendor", required_argument, 0, 'M'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, #ifdef SG_LIB_WIN32 {"wscan", no_argument, 0, 'w'}, #endif {0, 0, 0, 0}, }; static void usage() { fprintf(stderr, "Usage: " "sdparm [--all] [--clear=STR] [--command=CMD] [--dbd] " "[--defaults]\n" " [--dummy] [--flexible] [--get=STR] [--help] " "[--hex] [--inquiry]\n" " [--long] [--num-desc] [--page=PG[,SPG]] [--quiet] " "[--readonly]\n" " [--save] [--set=STR] [--six] [--transport=TN] " "[--vendor=VN]\n" " [--verbose] [--version] DEVICE [DEVICE...]\n\n" " sdparm --enumerate [--all] [--inquiry] [--long] " "[--page=PG[,SPG]]\n" " [--transport=TN] [--vendor=VN]\n" " where:\n" " --all | -a list all known fields for given " "device\n" " --clear=STR | -c STR clear (zero) field value(s)\n" " --command=CMD | -C CMD perform CMD (e.g. 'eject')\n" " --dbd | -B set DBD bit in mode sense cdb\n" " --defaults | -D set a mode page to its default " "values\n" " --dummy | -d don't write back modified mode page\n" " --enumerate | -e list known pages and fields " "(ignore device)\n" " --flexible | -f compensate for common errors, " "relax some checks\n" " --get=STR | -g STR get (fetch) field value(s)\n" " --help | -h print out usage message\n" " --hex | -H output in hex rather than name/value " "pairs\n" " --inquiry | -i output INQUIRY VPD page(s) (def: mode " "page(s))\n" " use --page=PG for VPD number (-1 " "for std inq)\n" " --long | -l add description to field output\n" " --num-desc | -n report number of mode page " "descriptors\n" " --page=PG[,SPG] | -p PG[,SPG] page (and optionally " "subpage) number\n" " [or abbrev] to output, change or " "enumerate\n" " --quiet | -q suppress device vendor/product/" "revision string line\n" " --readonly | -r force read-only open of DEVICE (def: " "depends\n" " on operation). Mainly for ATA disks\n" " --save | -S place mode changes in saved page as " "well\n" " --set=STR | -s STR set field value(s)\n" " --six | -6 use 6 byte SCSI mode cdbs (def: 10 " "byte)\n" " --transport=TN | -t TN transport protocol number " "[or abbrev]\n" " --vendor=VN | -M VN vendor (manufacturer) number " "[or abbrev]\n" " --verbose | -v increase verbosity\n" " --version | -V print version string and exit\n" #ifdef SG_LIB_WIN32 " --wscan | -w windows scan for device names\n" #endif "\nView or change SCSI mode page fields (e.g. of a disk or CD/DVD " "drive).\nSTR can be [=val] or ::" "[=val].\n" ); } static void enumerate_mpages(int transport, int vendor) { const struct sdparm_mode_page_t * mpp; if (vendor >= 0) { const struct sdparm_vendor_pair * vpp; vpp = sdp_get_vendor_pair(vendor); if (NULL == vpp) { fprintf(stderr, "Bad vendor number\n"); return; } mpp = vpp->mpage; } else if ((transport >= 0) && (transport < 16)) mpp = sdparm_transport_mp[transport].mpage; else mpp = sdparm_gen_mode_pg; for ( ; mpp && mpp->acron; ++mpp) { if (mpp->name) { if (mpp->subpage) printf(" %-4s 0x%02x,0x%02x %s\n", mpp->acron, mpp->page, mpp->subpage, mpp->name); else printf(" %-4s 0x%02x %s\n", mpp->acron, mpp->page, mpp->name); } } } static void enumerate_vpds() { const struct sdparm_vpd_page_t * vpp; for (vpp = sdparm_vpd_pg; vpp->acron; ++vpp) { if (vpp->name) { if (vpp->vpd_num < 0) printf(" %-10s -1 %s\n", vpp->acron, vpp->name); else printf(" %-10s 0x%02x %s\n", vpp->acron, vpp->vpd_num, vpp->name); } } } static void enumerate_transports() { const struct sdparm_transport_id_t * tip; for (tip = sdparm_transport_id; tip->acron; ++tip) { if (tip->name) printf(" %-6s 0x%02x %s\n", tip->acron, tip->proto_num, tip->name); } } static void enumerate_vendors() { const struct sdparm_vendor_name_t * vnp; for (vnp = sdparm_vendor_id; vnp->acron; ++vnp) { if (vnp->name) printf(" %-6s 0x%02x %s\n", vnp->acron, vnp->vendor_num, vnp->name); } } static void print_mp_extra(const char * extra) { int n; char b[128]; char * cp; char * p; for (p = (char *)extra; (cp = (char *)strchr(p, '\t')); p = cp + 1) { n = cp - p; if (n > (int)(sizeof(b) - 1)) n = (sizeof(b) - 1); strncpy(b, p, n); b[n] = '\0'; printf("\t%s\n", b); } printf("\t%s\n", p); } /* Enumerate mode page items. Reading from internal dataset. */ static void enumerate_mitems(int pn, int spn, int pdt, const struct sdparm_opt_coll * opts) { int t_pn, t_spn, t_pdt, vendor, transp, long_o; const struct sdparm_mode_page_t * mpp = NULL; const struct sdparm_mode_page_item * mpi; char buff[128]; char b[128]; int found = 0; t_pn = -1; t_spn = -1; t_pdt = -2; vendor = opts->vendor; transp = opts->transport; long_o = opts->long_out; if (vendor >= 0) { const struct sdparm_vendor_pair * vpp; vpp = sdp_get_vendor_pair(vendor); mpi = (vpp ? vpp->mitem : NULL); } else if ((transp >= 0) && (transp < 16)) mpi = sdparm_transport_mp[transp].mitem; else mpi = sdparm_mitem_arr; if (NULL == mpi) return; for ( ; mpi->acron; ++mpi) { if ((pdt >= 0) && (mpi->pdt >= 0) && (pdt != mpi->pdt)) continue; if ((t_pn != mpi->page_num) || (t_spn != mpi->subpage_num) || (t_pdt != mpi->pdt)) { t_pn = mpi->page_num; t_spn = mpi->subpage_num; t_pdt = mpi->pdt; if ((pn >= 0) && ((pn != t_pn) || (spn != t_spn))) continue; if ((pdt >= 0) && (pdt != t_pdt)) continue; mpp = sdp_get_mpage_name(t_pn, t_spn, t_pdt, transp, vendor, long_o, 1, buff, sizeof(buff)); if (long_o && (transp < 0) && (vendor < 0)) printf("%s [%s] mode page:\n", buff, sdp_get_pdt_doc_str(t_pdt, sizeof(b), b)); else printf("%s mode page:\n", buff); } else { if ((pn >= 0) && ((pn != t_pn) || (spn != t_spn))) continue; } printf(" %-10s [0x%02x:%d:%-2d] %s\n", mpi->acron, mpi->start_byte, mpi->start_bit, mpi->num_bits, mpi->description); if ((long_o > 1) && mpi->extra) print_mp_extra(mpi->extra); found = 1; } if ((! found) && (pn >= 0)) { sdp_get_mpage_name(pn, spn, pdt, transp, vendor, long_o, 1, buff, sizeof(buff)); fprintf(stderr, "%s mode page: no items found\n", buff); } if (found && mpp && mpp->mp_desc && long_o) { const struct sdparm_mode_descriptor_t * mdp = mpp->mp_desc; if (mdp->name) printf(" <<%s mode descriptor>>\n", mdp->name); else printf(" <>\n"); printf(" num_descs_off=%d, num_descs_bytes=%d, " "num_descs_inc=%d, first_desc_off=%d\n", mdp->num_descs_off, mdp->num_descs_bytes, mdp->num_descs_inc, mdp->first_desc_off); if (mdp->desc_len > 0) printf(" descriptor_len=%d\n", mdp->desc_len); else printf(" desc_len_off=%d, desc_len_bytes=%d\n", mdp->desc_len_off, mdp->desc_len_bytes); } } static void list_mp_settings(const struct sdparm_mode_page_settings * mps, int get) { const struct sdparm_mode_page_item * mpip; int k; printf("mp_settings: page,subpage=0x%x,0x%x num=%d\n", mps->page_num, mps->subpage_num, mps->num_it_vals); for (k = 0; k < mps->num_it_vals; ++k) { mpip = &mps->it_vals[k].mpi; if (get) printf(" [0x%x,0x%x]", mpip->page_num, mpip->subpage_num); printf(" pdt=%d start_byte=0x%x start_bit=%d num_bits=%d val=%" PRId64 "", mpip->pdt, mpip->start_byte, mpip->start_bit, mpip->num_bits, mps->it_vals[k].val); if (mpip->acron) { printf(" acronym: %s", mpip->acron); if (mps->it_vals[k].descriptor_num > 0) printf(" descriptor_num=%d\n", mps->it_vals[k].descriptor_num); else printf("\n"); } else printf("\n"); } } /* Print prefix and acronymn plus current, changeable, default and saved * values for an item */ static void print_mp_entry(const char * pre, int smask, const struct sdparm_mode_page_item *mpi, const unsigned char * cur_mp, const unsigned char * cha_mp, const unsigned char * def_mp, const unsigned char * sav_mp, int long_out, int force_decimal) { int sep = 0; int all_set; uint64_t u; const char * acron; all_set = 0; acron = (mpi->acron ? mpi->acron : ""); u = sdp_mp_get_value_check(mpi, cur_mp, &all_set); printf("%s%-10s", pre, acron); if (force_decimal) printf("%" PRId64 "", (int64_t)u); else if (mpi->flags & MF_HEX) printf("0x%" PRIx64 "", u); else if (all_set) printf(" -1"); else printf("%3" PRIu64 "", u); if (smask & 0xe) { printf(" ["); if (cha_mp && (smask & 2)) { printf("cha: %s", (sdp_mp_get_value(mpi, cha_mp) ? "y" : "n")); sep = 1; } if (def_mp && (smask & 4)) { all_set = 0; u = sdp_mp_get_value_check(mpi, def_mp, &all_set); printf("%sdef:", (sep ? ", " : " ")); if (force_decimal) printf("%" PRId64 "", (int64_t)u); else if (mpi->flags & MF_HEX) printf("0x%" PRIx64 "", u); else if (all_set) printf(" -1"); else printf("%3" PRIu64 "", u); sep = 1; } if (sav_mp && (smask & 8)) { all_set = 0; u = sdp_mp_get_value_check(mpi, sav_mp, &all_set); printf("%ssav:", (sep ? ", " : " ")); if (force_decimal) printf("%" PRId64 "", (int64_t)u); else if (mpi->flags & MF_HEX) printf("0x%" PRIx64 "", u); else if (all_set) printf(" -1"); else printf("%3" PRIu64 "", u); } printf("]"); } if (long_out && mpi->description) printf(" %s", mpi->description); printf("\n"); if ((long_out > 1) && mpi->extra) print_mp_extra(mpi->extra); } static void print_mp_arr_entry(const char * pre, int smask, const struct sdparm_mode_page_item *mpi, void ** pc_arr, int long_out, int force_decimal) { const unsigned char * cur_mp = (const unsigned char *)pc_arr[0]; const unsigned char * cha_mp = (const unsigned char *)pc_arr[1]; const unsigned char * def_mp = (const unsigned char *)pc_arr[2]; const unsigned char * sav_mp = (const unsigned char *)pc_arr[3]; print_mp_entry(pre, smask, mpi, cur_mp, cha_mp, def_mp, sav_mp, long_out, force_decimal); } static int ll_mode_sense(int fd, const struct sdparm_opt_coll * opts, int pn, int spn, unsigned char * resp, int mx_resp_len, int verb) { if (opts->mode_6) return sg_ll_mode_sense6(fd, opts->dbd, 0 /*current */, pn, spn, resp, mx_resp_len, 1 /* noisy */, verb); else return sg_ll_mode_sense10(fd, 0 /* llbaa */, opts->dbd, 0, pn, spn, resp, mx_resp_len, 1 /* noisy */, verb); } /* Make some noise if the mode page response seems badly formed */ static void check_mode_page(unsigned char * cur_mp, int pn, int rep_len, const struct sdparm_opt_coll * opts) { int const pn_in_page = cur_mp[0] & 0x3f; if (pn != pn_in_page) { if (pn == POWER_MP && pn_in_page == POWER_OLD_MP) { /* Some devices, e.g. IBM DCHS disk, ca. 1997, in violation of * SCSI, report the old block device power control page when * asked for the new generic power control page. The format * is identical except for the page number, so we can ignore * the mismatch. */ } else { fprintf(stderr, ">>> warning: mode page seems malformed\n" " The page number field should be 0x%02x, but is 0x%02x", pn, pn_in_page); if (! opts->flexible) fprintf(stderr, "; try '--flexible'"); fprintf(stderr, "\n"); } } else if (opts->verbose && (rep_len > 0xa00)) { fprintf(stderr, ">>> warning: mode page length=%d " "too long", rep_len); if (! opts->flexible) fprintf(stderr, ", perhaps try '--flexible'"); fprintf(stderr, "\n"); } } /* When mode page has descriptor, print_mode_pages() will print the first */ /* descriptor. This function is called to print subsequent descriptors */ static void print_mpage_extra_desc(void ** pc_arr, int rep_len, const struct sdparm_mode_page_t * mpp, const struct sdparm_mode_page_item * fdesc_mpi, const struct sdparm_mode_page_item * last_mpi, const struct sdparm_opt_coll * opts, int smask) { const struct sdparm_mode_descriptor_t * mdp = mpp->mp_desc; const struct sdparm_mode_page_item * mpi; const unsigned char * cur_mp = (const unsigned char *)pc_arr[0]; const unsigned char * cha_mp = (const unsigned char *)pc_arr[1]; const unsigned char * def_mp = (const unsigned char *)pc_arr[2]; const unsigned char * sav_mp = (const unsigned char *)pc_arr[3]; const unsigned char * ucp; struct sdparm_mode_page_item ampi; uint64_t u; int k, num, len, d_off, n, bad; char b[32]; if ((NULL == mdp) || (NULL == cur_mp) || (rep_len < 4) || (mdp->num_descs_off >= rep_len)) return; if ((mdp->num_descs_inc < 0) && (mdp->desc_len > 0)) u = sdp_get_big_endian(cur_mp + mdp->num_descs_off, 7, mdp->num_descs_bytes * 8) / mdp->desc_len; else u = sdp_get_big_endian(cur_mp + mdp->num_descs_off, 7, mdp->num_descs_bytes * 8) + mdp->num_descs_inc; num = (int)u; if (opts->verbose) fprintf(stderr, " >>> mode page says it has %d descriptors\n", num); if ((u < 2) || (u > 256)) return; if (mdp->desc_len <= 0) { ucp = cur_mp + mdp->first_desc_off + mdp->desc_len_off; u = sdp_get_big_endian(ucp, 7, mdp->desc_len_bytes * 8); len = mdp->desc_len_off + mdp->desc_len_bytes + u; } else len = mdp->desc_len; d_off = mdp->first_desc_off + len; for (k = 1; k < num; ++k, d_off += len) { bad = 0; for (mpi = fdesc_mpi; mpi <= last_mpi; ++mpi) { strncpy(b, mpi->acron, sizeof(b)); ampi = *mpi; b[sizeof(b) - 8] = '\0'; n = strlen(b); snprintf(b + n, sizeof(b) - n, ".%d", k); ampi.acron = b; ampi.start_byte += (d_off - mdp->first_desc_off); if (ampi.start_byte >= rep_len) { fprintf(stderr, "descriptor overflows reply len (%d) for " "%s\n", rep_len, ampi.acron); bad = 1; break; } print_mp_entry(" ", smask, &i, cur_mp, cha_mp, def_mp, sav_mp, opts->long_out, 0); } if (bad) break; if (mdp->desc_len <= 0) { ucp = cur_mp + d_off + mdp->desc_len_off; u = sdp_get_big_endian(ucp, 7, mdp->desc_len_bytes * 8); len = mdp->desc_len_off + mdp->desc_len_bytes + u; } } } /* Print WP and DPOFUA bits for direct access devices (disks). * Return 0 for success, else error value. */ static int print_direct_access_info(int sg_fd, const struct sdparm_opt_coll * opts, int verb) { int res, v; unsigned char cur_mp[DEF_MODE_RESP_LEN]; memset(cur_mp, 0, sizeof(cur_mp)); res = ll_mode_sense(sg_fd, opts, ALL_MPAGES, 0, cur_mp, 8, verb); if (0 == res) { v = cur_mp[opts->mode_6 ? 2 : 3]; printf(" Direct access device specific parameters: WP=%d " "DPOFUA=%d\n", !!(v & 0x80), !!(v & 0x10)); } else if (SG_LIB_CAT_NOT_READY == res) { fprintf(stderr, "mode sense command failed, device not ready\n"); return res; } else if (SG_LIB_CAT_INVALID_OP == res) { if (opts->mode_6) fprintf(stderr, "6 byte MODE SENSE cdb not supported, " "try again without '-6' option\n"); else fprintf(stderr, "10 byte MODE SENSE cdb not supported, " "try again with '-6' option\n"); return res; } else if (SG_LIB_CAT_UNIT_ATTENTION == res) { fprintf(stderr, "mode sense command failed, unit attention\n"); return res; } else if (SG_LIB_CAT_ABORTED_COMMAND == res) { fprintf(stderr, "mode sense command failed, aborted command\n"); return res; } return 0; } /* Print one or more mode pages. Returns 0 if ok else IO error number. */ static int print_mode_pages(int sg_fd, int pn, int spn, int pdt, const struct sdparm_opt_coll * opts) { int res, len, verb, smask, single_pg, fetch_pg, rep_len, orig_pn, warned; int first_desc_off; const struct sdparm_mode_page_item * mpi; const struct sdparm_mode_page_item * hmpi; const struct sdparm_mode_page_item * fdesc_mpi = NULL; const struct sdparm_mode_page_t * mpp = NULL; const struct sdparm_mode_descriptor_t * mdp; unsigned char cur_mp[DEF_MODE_RESP_LEN]; unsigned char cha_mp[DEF_MODE_RESP_LEN]; unsigned char def_mp[DEF_MODE_RESP_LEN]; unsigned char sav_mp[DEF_MODE_RESP_LEN]; void * pc_arr[4]; char buff[128]; buff[0] = '\0'; verb = (opts->verbose > 0) ? opts->verbose - 1 : 0; if ((0 == pdt) && (opts->long_out > 0) && (0 == opts->quiet)) { if (0 != (res = print_direct_access_info(sg_fd, opts, verb))) return res; } orig_pn = pn; /* choose a mode page item namespace (vendor, transport or generic) */ if (opts->vendor >= 0) { const struct sdparm_vendor_pair * vpp; vpp = sdp_get_vendor_pair(opts->vendor); mpi = (vpp ? vpp->mitem : NULL); } else if ((opts->transport >= 0) && (opts->transport < 16)) mpi = sdparm_transport_mp[opts->transport].mitem; else mpi = sdparm_mitem_arr; if (NULL == mpi) return SG_LIB_CAT_OTHER; hmpi = mpi; if (pn >= 0) { /* step to first item of given page */ single_pg = 1; fetch_pg = 1; for ( ; mpi->acron; ++mpi) { if ((pn == mpi->page_num) && (spn == mpi->subpage_num)) { if ((pdt < 0) || (mpi->pdt < 0) || (pdt == mpi->pdt) || opts->flexible) break; } } if (NULL == mpi->acron) { /* page has no known fields */ if (opts->hex) mpi = hmpi; /* trick to enter main loop once */ else { sdp_get_mpage_name(pn, spn, pdt, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); if ((opts->vendor < 0) && ((0 == pn) || (pn >= 0x20))) fprintf(stderr, "%s mode page seems to be vendor " "specific, try '--vendor=VN'.\nOtherwise " "add '-H' to see page in hex.\n", buff); else fprintf(stderr, "%s mode page, no fields found, " "add '-H' to see page in hex.\n", buff); } } } else { /* want all so check all items in given namespace */ single_pg = 0; fetch_pg = 0; mpi = hmpi; } mdp = NULL; /* loop over each mode page item in given namespace */ for (smask = 0, len = 0, warned = 0 ; mpi->acron; ++mpi, fetch_pg = 0) { if (0 == fetch_pg) { if ((pdt >=0) && (mpi->pdt >= 0) && (pdt != mpi->pdt) && (0 == opts->flexible)) continue; if (! (((orig_pn >= 0) ? 1 : opts->all) || (MF_COMMON & mpi->flags))) continue; if ((pn != mpi->page_num) || (spn != mpi->subpage_num)) { if (fdesc_mpi) { hmpi = mpi - 1; if ((pn == hmpi->page_num) && (spn == hmpi->subpage_num)) print_mpage_extra_desc(pc_arr, rep_len, mpp, fdesc_mpi, hmpi, opts, smask); } if (single_pg) break; fetch_pg = 1; pn = mpi->page_num; spn = mpi->subpage_num; } } if (fetch_pg) { /* Only fetch mode page when needed (e.g. item page changed) */ mpp = sdp_get_mpage_name(pn, spn, pdt, opts->transport, opts->vendor, opts->long_out, opts->hex, buff, sizeof(buff)); smask = 0; warned = 0; fdesc_mpi = NULL; pc_arr[0] = cur_mp; pc_arr[1] = cha_mp; pc_arr[2] = def_mp; pc_arr[3] = sav_mp; res = sg_get_mode_page_controls(sg_fd, opts->mode_6, pn, spn, opts->dbd, opts->flexible, DEF_MODE_RESP_LEN, &smask, pc_arr, &rep_len, verb); if (SG_LIB_CAT_INVALID_OP == res) { if (opts->mode_6) fprintf(stderr, "6 byte MODE SENSE cdb not supported, " "try again without '-6' option\n"); else fprintf(stderr, "10 byte MODE SENSE cdb not supported, " "try again with '-6' option\n"); return res; } else if (SG_LIB_CAT_NOT_READY == res) { fprintf(stderr, "MODE SENSE failed, device not ready\n"); return res; } else if (SG_LIB_CAT_UNIT_ATTENTION == res) { fprintf(stderr, "mode sense command failed, unit " "attention\n"); return res; } else if (SG_LIB_CAT_ABORTED_COMMAND == res) { fprintf(stderr, "mode sense command failed, aborted " "command\n"); return res; } /* check for mode page descriptors */ mdp = (mpp && (! opts->hex)) ? mpp->mp_desc : NULL; first_desc_off = mdp ? mdp->first_desc_off : 0; if (first_desc_off > 1) { for (res = 0, fdesc_mpi = mpi; fdesc_mpi && (pn == fdesc_mpi->page_num) && (spn == fdesc_mpi->subpage_num); ++fdesc_mpi) { if (fdesc_mpi->start_byte >= first_desc_off) { res = 1; break; } } if (0 == res) fdesc_mpi = NULL; } if (opts->num_desc) { int num = 0; uint64_t u; if (fdesc_mpi && (smask & 1)) { if ((mdp->num_descs_inc < 0) && (mdp->desc_len > 0)) u = sdp_get_big_endian(cur_mp + mdp->num_descs_off, 7, mdp->num_descs_bytes * 8) / mdp->desc_len; else u = sdp_get_big_endian(cur_mp + mdp->num_descs_off, 7, mdp->num_descs_bytes * 8) + mdp->num_descs_inc; num = (int)u; } if (opts->long_out) printf("number of descriptors=%d\n", num); else printf("%d\n", num); return 0; } if (smask & 1) { len = sdp_get_mp_len(cur_mp); printf("%s ", buff); if (opts->verbose) { if (spn) printf("[0x%x,0x%x] ", pn, spn); else printf("[0x%x] ", pn); } printf("mode page"); if ((opts->long_out > 1) || opts->verbose) printf(" [PS=%d]:\n", !!(cur_mp[0] & 0x80)); else printf(":\n"); check_mode_page(cur_mp, pn, rep_len, opts); if (opts->hex) { if (len > (int)sizeof(cur_mp)) { fprintf(stderr, ">> decoded page length too " "large=%d, trim\n", len); len = sizeof(cur_mp); } printf(" Current:\n"); dStrHex((const char *)cur_mp, len, 1); if (smask & 2) { printf(" Changeable:\n"); dStrHex((const char *)cha_mp, len, 1); } if (smask & 4) { printf(" Default:\n"); dStrHex((const char *)def_mp, len, 1); } if (smask & 8) { printf(" Saved:\n"); dStrHex((const char *)sav_mp, len, 1); } } } else { if (opts->verbose || single_pg) { fprintf(stderr, ">> %s mode %spage ", buff, (spn ? "sub" : "")); if (opts->verbose) { if (spn) fprintf(stderr, "[0x%x,0x%x] ", pn, spn); else fprintf(stderr, "[0x%x] ", pn); } if (SG_LIB_CAT_ILLEGAL_REQ == res) fprintf(stderr, "not found\n"); else if (0 == res) fprintf(stderr, "some problem\n"); else fprintf(stderr, "failed\n"); } } } /* end of fetch_pg */ if (smask && (! opts->hex)) { if (mpi->start_byte >= len) { if ((0 == opts->flexible) && (0 == opts->verbose)) continue; // step over if (0 == warned) { warned = 1; if (opts->flexible) fprintf(stderr, " >> hereafter field position " "exceeds mode page length=%d\n", len); else { fprintf(stderr, " >> skipping rest as field position " "exceeds mode page length=%d\n", len); continue; } } if (0 == opts->flexible) continue; } print_mp_arr_entry(" ", smask, mpi, pc_arr, opts->long_out, 0); } } if (mpi && (NULL == mpi->acron) && fdesc_mpi) { --mpi; if ((pn == mpi->page_num) && (spn == mpi->subpage_num)) print_mpage_extra_desc(pc_arr, rep_len, mpp, fdesc_mpi, mpi, opts, smask); } return 0; } /* returns 1 when ok, else 0 */ static int check_desc_convert_mpi(int desc_num, const struct sdparm_mode_page_t * mpp, const struct sdparm_mode_page_item * ref_mpi, struct sdparm_mode_page_item * out_mpi, char * b, int b_len) { int n; if (mpp && mpp->mp_desc && ref_mpi->acron) { *out_mpi = *ref_mpi; strncpy(b, ref_mpi->acron, b_len); b[(b_len > 10) ? (b_len - 8) : 4] = '\0'; n = strlen(b); snprintf(b + n, b_len - n, ".%d", desc_num); out_mpi->acron = b; return 1; } else return 0; } /* returns 1 when ok, else 0 */ static int desc_adjust_start_byte(int desc_num, const struct sdparm_mode_page_t * mpp, unsigned char * cur_mp, int rep_len, struct sdparm_mode_page_item * mpi, const struct sdparm_opt_coll * opts) { const struct sdparm_mode_descriptor_t * mdp; uint64_t u; const unsigned char * ucp; int d_off, sb_off, j; mdp = mpp->mp_desc; if ((mdp->num_descs_off < rep_len) && (mdp->num_descs_off < 64)) { if ((mdp->num_descs_inc < 0) && (mdp->desc_len > 0)) u = sdp_get_big_endian(cur_mp + mdp->num_descs_off, 7, mdp->num_descs_bytes * 8) / mdp->desc_len; else u = sdp_get_big_endian(cur_mp + mdp->num_descs_off, 7, mdp->num_descs_bytes * 8) + mdp->num_descs_inc; if ((uint64_t)desc_num < u) { if (mdp->desc_len > 0) { mpi->start_byte += (mdp->desc_len * desc_num); if (mpi->start_byte < rep_len) return 1; } else if (mdp->desc_len_off > 0) { /* need to walk through variable length descriptors */ sb_off = mpi->start_byte - mdp->first_desc_off; d_off = mdp->first_desc_off; for (j = 0; ; ++j) { if (j > desc_num) { fprintf(stderr, ">> descriptor number sanity ...\n"); break; /* sanity */ } if (j == desc_num) { mpi->start_byte = d_off + sb_off; if (mpi->start_byte < rep_len) return 1; else fprintf(stderr, ">> new start_byte " "exceeds current page ...\n"); break; } ucp = cur_mp + d_off + mdp->desc_len_off; u = sdp_get_big_endian(ucp, 7, mdp->desc_len_bytes * 8); d_off += mdp->desc_len_off + mdp->desc_len_bytes + u; if (d_off >= rep_len) { fprintf(stderr, ">> descriptor number too " "large for current page ...\n"); break; } } } } else if (opts->verbose) fprintf(stderr, " >> mode page says it has only %d " "descriptors\n", (int)u); } return 0; } /* Print one or more mode page items (from '--get='). Returns 0 if ok. */ static int print_mode_items(int sg_fd, const struct sdparm_mode_page_settings * mps, int pdt, const struct sdparm_opt_coll * opts) { int k, res, verb, smask, pn, spn, warned, rep_len, len, desc_num, adapt; int long_o; uint64_t u; int64_t val; const struct sdparm_mode_page_item * mpi; struct sdparm_mode_page_item ampi; const struct sdparm_mode_page_t * mpp = NULL; unsigned char cur_mp[DEF_MODE_RESP_LEN]; unsigned char cha_mp[DEF_MODE_RESP_LEN]; unsigned char def_mp[DEF_MODE_RESP_LEN]; unsigned char sav_mp[DEF_MODE_RESP_LEN]; const struct sdparm_mode_page_it_val * ivp; char buff[128]; char b_tmp[32]; void * pc_arr[4]; warned = 0; verb = (opts->verbose > 0) ? opts->verbose - 1 : 0; long_o = opts->long_out; for (k = 0, pn = 0, spn = 0; k < mps->num_it_vals; ++k) { ivp = &mps->it_vals[k]; val = ivp->val; desc_num = ivp->descriptor_num; mpi = &ivp->mpi; mpp = sdp_get_mpage_name(mpi->page_num, mpi->subpage_num, mpi->pdt, opts->transport, opts->vendor, long_o, opts->hex, buff, sizeof(buff)); if (desc_num > 0) { if (check_desc_convert_mpi(desc_num, mpp, mpi, &i, b_tmp, sizeof(b_tmp))) { adapt = 1; mpi = &i; } else { fprintf(stderr, "can't decode descriptors for %s in %s mode " "page\n", (mpi->acron ? mpi->acron : ""), buff); return SG_LIB_SYNTAX_ERROR; } } else adapt = 0; if ((0 == k) || (pn != mpi->page_num) || (spn != mpi->subpage_num)) { pn = mpi->page_num; spn = mpi->subpage_num; smask = 0; res = 0; switch (val) { case 0: pc_arr[0] = cur_mp; pc_arr[1] = cha_mp; pc_arr[2] = def_mp; pc_arr[3] = sav_mp; res = sg_get_mode_page_controls(sg_fd, opts->mode_6, pn, spn, opts->dbd, opts->flexible, DEF_MODE_RESP_LEN, &smask, pc_arr, &rep_len, verb); break; case 1: case 2: pc_arr[0] = cur_mp; pc_arr[1] = NULL; pc_arr[2] = NULL; pc_arr[3] = NULL; res = sg_get_mode_page_controls(sg_fd, opts->mode_6, pn, spn, opts->dbd, opts->flexible, DEF_MODE_RESP_LEN, &smask, pc_arr, &rep_len, verb); break; default: if (mpi->acron) fprintf(stderr, "bad value given to %s\n", mpi->acron); else fprintf(stderr, "bad value given to 0x%x:%d:%d\n", mpi->start_byte, mpi->start_bit, mpi->num_bits); return SG_LIB_SYNTAX_ERROR; } if (SG_LIB_CAT_INVALID_OP == res) { if (opts->mode_6) fprintf(stderr, "6 byte MODE SENSE cdb not supported, " "try again without '-6' option\n"); else fprintf(stderr, "10 byte MODE SENSE cdb not supported, " "try again with '-6' option\n"); return res; } else if (SG_LIB_CAT_NOT_READY == res) { fprintf(stderr, "MODE SENSE failed, device not ready\n"); return res; } else if (SG_LIB_CAT_UNIT_ATTENTION == res) { fprintf(stderr, "MODE SENSE failed, unit attention\n"); return res; } else if (SG_LIB_CAT_ABORTED_COMMAND == res) { fprintf(stderr, "MODE SENSE failed, aborted command\n"); return res; } if ((0 == smask) && res) { if (mpi->acron) fprintf(stderr, "%s ", mpi->acron); else fprintf(stderr, "0x%x:%d:%d ", mpi->start_byte, mpi->start_bit, mpi->num_bits); if (SG_LIB_CAT_ILLEGAL_REQ == res) fprintf(stderr, "not found in "); else fprintf(stderr, "error %sin ", (verb ? "" : "(try adding '-vv') ")); fprintf(stderr, "%s mode page\n", buff); return res; } if (smask & 1) check_mode_page(cur_mp, pn, rep_len, opts); } if (adapt) { if (! desc_adjust_start_byte(desc_num, mpp, cur_mp, rep_len, &i, opts)) { fprintf(stderr, ">> failed to find field acronym: %s in " "current page\n", mpi->acron); return SG_LIB_CAT_OTHER; } } if ((pdt >= 0) && (0 == warned) && mpi->acron && (mpi->pdt >= 0) && (pdt != mpi->pdt)) { warned = 1; fprintf(stderr, ">> warning: peripheral device type (pdt) is " "0x%x but acronym %s\n is associated with pdt 0x%x.\n", pdt, ivp->mpi.acron, ivp->mpi.pdt); } len = (smask & 1) ? sdp_get_mp_len(cur_mp) : 0; if (mpi->start_byte >= len) { fprintf(stderr, ">> warning: "); if (mpi->acron) fprintf(stderr, "%s ", mpi->acron); else fprintf(stderr, "0x%x:%d:%d ", mpi->start_byte, mpi->start_bit, mpi->num_bits); fprintf(stderr, "field position exceeds mode page length=%d\n", len); if (! opts->flexible) continue; } if (0 == val) { if (opts->hex) { if (smask & 1) { u = sdp_mp_get_value(mpi, cur_mp); printf("0x%02" PRIx64 " ", u); } else printf("- "); if (smask & 2) { u = sdp_mp_get_value(mpi, cha_mp); printf("0x%02" PRIx64 " ", u); } else printf("- "); if (smask & 4) { u = sdp_mp_get_value(mpi, def_mp); printf("0x%02" PRIx64 " ", u); } else printf("- "); if (smask & 8) { u = sdp_mp_get_value(mpi, sav_mp); printf("0x%02" PRIx64 " ", u); } else printf("- "); printf("\n"); } else print_mp_arr_entry("", smask, mpi, pc_arr, long_o, 0); } else if (1 == val) { if (opts->hex) { if (smask & 1) { u = sdp_mp_get_value(mpi, cur_mp); printf("0x%02" PRIx64 " ", u); } else printf("- "); printf("\n"); } else print_mp_arr_entry("", smask & 1, mpi, pc_arr, long_o, 0); } else if (2 == val) { if (opts->hex) { if (smask & 1) { u = sdp_mp_get_value(mpi, cur_mp); printf("%02" PRId64 " ", (int64_t)u); } else printf("- "); printf("\n"); } else print_mp_arr_entry("", smask & 1, mpi, pc_arr, long_o, 1); } } return 0; } /* Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, SG_LIB_CAT_NOT_READY, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */ static int change_mode_page(int sg_fd, int pdt, const struct sdparm_mode_page_settings * mps, const struct sdparm_opt_coll * opts) { int k, off, md_len, len, res, desc_num, pn, spn; char ebuff[EBUFF_SZ]; const struct sdparm_mode_page_t * mpp = NULL; unsigned char mdpg[MAX_MODE_DATA_LEN]; const struct sdparm_mode_page_it_val * ivp; const struct sdparm_mode_page_item * mpi; struct sdparm_mode_page_item ampi; char b[128]; char b_tmp[32]; if (pdt >= 0) { /* sanity check: check acronym's pdt matches device's pdt */ for (k = 0; k < mps->num_it_vals; ++k) { ivp = &mps->it_vals[k]; if (ivp->mpi.acron && (ivp->mpi.pdt >= 0) && (pdt != ivp->mpi.pdt)) { fprintf(stderr, "change_mode_page: peripheral device type " "(pdt) is 0x%x but acronym %s\n is associated with " "pdt 0x%x. To bypass use numeric addressing mode.\n", pdt, ivp->mpi.acron, ivp->mpi.pdt); return SG_LIB_SYNTAX_ERROR; } } } pn = mps->page_num; spn = mps->subpage_num; mpp = sdp_get_mpage_name(pn, spn, pdt, opts->transport, opts->vendor, 0, 0, b, sizeof(b)); memset(mdpg, 0, sizeof(mdpg)); res = ll_mode_sense(sg_fd, opts, pn, spn, mdpg, 4, opts->verbose); if (0 != res) { if (SG_LIB_CAT_NOT_READY == res) fprintf(stderr, "mode sense command failed, device not ready\n"); else if (SG_LIB_CAT_INVALID_OP == res) { if (opts->mode_6) fprintf(stderr, "6 byte MODE SENSE cdb not supported, " "try again without '-6' option\n"); else fprintf(stderr, "10 byte MODE SENSE cdb not supported, " "try again with '-6' option\n"); } else if (SG_LIB_CAT_UNIT_ATTENTION == res) fprintf(stderr, "mode sense command failed, unit attention\n"); else if (SG_LIB_CAT_ABORTED_COMMAND == res) fprintf(stderr, "mode sense command failed, aborted command\n"); fprintf(stderr, "change_mode_page: failed fetching page: %s\n", b); return res; } md_len = opts->mode_6 ? (mdpg[0] + 1) : ((mdpg[0] << 8) + mdpg[1] + 2); if (md_len > (int)sizeof(mdpg)) { fprintf(stderr, "change_mode_page: mode data length=%d exceeds " "allocation length=%d\n", md_len, (int)sizeof(mdpg)); return SG_LIB_CAT_MALFORMED; } res = ll_mode_sense(sg_fd, opts, pn, spn, mdpg, md_len, opts->verbose); if (0 != res) { fprintf(stderr, "change_mode_page: failed fetching page: %s\n", b); return res; } off = sg_mode_page_offset(mdpg, md_len, opts->mode_6, ebuff, EBUFF_SZ); if (off < 0) { fprintf(stderr, "change_mode_page: page offset failed: %s\n", ebuff); return SG_LIB_CAT_MALFORMED; } len = sdp_get_mp_len(mdpg + off); mdpg[0] = 0; /* mode data length reserved for mode select */ if (! opts->mode_6) mdpg[1] = 0; /* mode data length reserved for mode select */ if (PDT_DISK == pdt) /* entire disk specific parameters is ... */ mdpg[opts->mode_6 ? 2 : 3] = 0x00; /* reserved for mode select */ for (k = 0; k < mps->num_it_vals; ++k) { ivp = &mps->it_vals[k]; mpi = &ivp->mpi; desc_num = ivp->descriptor_num; if (desc_num > 0) { if (check_desc_convert_mpi(desc_num, mpp, mpi, &i, b_tmp, sizeof(b_tmp))) { mpi = &i; if (! desc_adjust_start_byte(desc_num, mpp, mdpg + off, len, &i, opts)) { fprintf(stderr, ">> failed to find field acronym: %s in " "current page\n", mpi->acron); return SG_LIB_CAT_OTHER; } } else { fprintf(stderr, "can't decode descriptors for %s in %s mode " "page\n", (mpi->acron ? mpi->acron : ""), b); return SG_LIB_SYNTAX_ERROR; } } if (mpi->start_byte >= len) { /* mpi->start_byte is too large for actual mpage length */ fprintf(stderr, "The start_byte of "); if (mpi->acron) fprintf(stderr, "%s ", mpi->acron); else fprintf(stderr, "0x%x:%d:%d ", mpi->start_byte, mpi->start_bit, mpi->num_bits); fprintf(stderr, "exceeds length of this mode page: %d [0x%x]\n", len, len); if (opts->flexible) fprintf(stderr, " applying anyway\n"); else { fprintf(stderr, " nothing modified, use '--flexible' to " "override\n"); return SG_LIB_CAT_MALFORMED; } } if ((ivp->val >= 0) && (ivp->orig_val > 0) && (ivp->orig_val > ivp->val) && (0 == opts->quiet)) { fprintf(stderr, "warning: given value (%" PRId64 ") truncated " "to %" PRId64 " by field size [%d bits]\n", ivp->orig_val, ivp->val, mpi->num_bits); fprintf(stderr, " applying anyway\n"); } sdp_mp_set_value(ivp->val, mpi, mdpg + off); } if ((! (mdpg[off] & 0x80)) && opts->save) { fprintf(stderr, "change_mode_page: mode page indicates it is not " "savable but\n '--save' option given (try without " "it)\n"); return SG_LIB_CAT_MALFORMED; } mdpg[off] &= 0x7f; /* mask out PS bit, reserved in mode select */ if (opts->dummy) { fprintf(stderr, "Mode data that would have been written:\n"); dStrHex((const char *)mdpg, md_len, 1); return 0; } if (opts->mode_6) res = sg_ll_mode_select6(sg_fd, 1, opts->save, mdpg, md_len, 1, opts->verbose); else res = sg_ll_mode_select10(sg_fd, 1, opts->save, mdpg, md_len, 1, opts->verbose); if (0 != res) { fprintf(stderr, "change_mode_page: failed setting page: %s\n", b); return res; } return 0; } /* Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, SG_LIB_CAT_NOT_READY, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */ static int set_def_mode_page(int sg_fd, int pn, int spn, unsigned char * mode_pg, int mode_pg_len, const struct sdparm_opt_coll * opts) { int len, off, md_len; unsigned char * mdp; char ebuff[EBUFF_SZ]; int ret = -1; char buff[128]; len = mode_pg_len + MODE_DATA_OVERHEAD; mdp = (unsigned char *)malloc(len); if (NULL ==mdp) { fprintf(stderr, "set_def_mode_page: malloc failed, out of memory\n"); return SG_LIB_FILE_ERROR; } memset(mdp, 0, len); ret = ll_mode_sense(sg_fd, opts, pn, spn, mdp, 4, opts->verbose); if (0 != ret) { sdp_get_mpage_name(pn, spn, -1, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); fprintf(stderr, "set_def_mode_page: failed fetching page: %s\n", buff); goto err_out; } md_len = opts->mode_6 ? (mdp[0] + 1) : ((mdp[0] << 8) + mdp[1] + 2); if (md_len > len) { fprintf(stderr, "set_def_mode_page: mode data length=%d exceeds " "allocation length=%d\n", md_len, len); ret = SG_LIB_CAT_MALFORMED; goto err_out; } ret = ll_mode_sense(sg_fd, opts, pn, spn, mdp, md_len, opts->verbose); if (0 != ret) { sdp_get_mpage_name(pn, spn, -1, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); fprintf(stderr, "set_def_mode_page: failed fetching page: %s\n", buff); goto err_out; } off = sg_mode_page_offset(mdp, len, opts->mode_6, ebuff, EBUFF_SZ); if (off < 0) { fprintf(stderr, "set_def_mode_page: page offset failed: %s\n", ebuff); ret = SG_LIB_CAT_MALFORMED; goto err_out; } mdp[0] = 0; /* mode data length reserved for mode select */ if (! opts->mode_6) mdp[1] = 0; /* mode data length reserved for mode select */ if ((md_len - off) > mode_pg_len) { fprintf(stderr, "set_def_mode_page: mode length length=%d exceeds " "new contents length=%d\n", md_len - off, mode_pg_len); ret = SG_LIB_CAT_MALFORMED; goto err_out; } memcpy(mdp + off, mode_pg, md_len - off); mdp[off] &= 0x7f; /* mask out PS bit, reserved in mode select */ if (opts->dummy) { fprintf(stderr, "Mode data that would have been written:\n"); dStrHex((const char *)mdp, md_len, 1); ret = 0; goto err_out; } if (opts->mode_6) ret = sg_ll_mode_select6(sg_fd, 1, opts->save, mdp, md_len, 1, opts->verbose); else ret = sg_ll_mode_select10(sg_fd, 1, opts->save, mdp, md_len, 1, opts->verbose); if (0 != ret) { sdp_get_mpage_name(pn, spn, -1, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); fprintf(stderr, "set_def_mode_page: failed setting page: %s\n", buff); goto err_out; } err_out: free(mdp); return ret; } static int set_mp_defaults(int sg_fd, int pn, int spn, int pdt, const struct sdparm_opt_coll * opts) { int smask, res, len, rep_len; unsigned char cur_mp[DEF_MODE_RESP_LEN]; unsigned char def_mp[DEF_MODE_RESP_LEN]; char buff[128]; void * pc_arr[4]; smask = 0; pc_arr[0] = cur_mp; pc_arr[1] = NULL; pc_arr[2] = def_mp; pc_arr[3] = NULL; res = sg_get_mode_page_controls(sg_fd, opts->mode_6, pn, spn, opts->dbd, opts->flexible, DEF_MODE_RESP_LEN, &smask, pc_arr, &rep_len, opts->verbose); if (SG_LIB_CAT_INVALID_OP == res) { if (opts->mode_6) fprintf(stderr, "6 byte MODE SENSE cdb not supported, " "try again without '-6' option\n"); else fprintf(stderr, "10 byte MODE SENSE cdb not supported, " "try again with '-6' option\n"); return res; } else if (SG_LIB_CAT_NOT_READY == res) { fprintf(stderr, "MODE SENSE failed, device not ready\n"); return res; } else if (SG_LIB_CAT_ABORTED_COMMAND == res) { fprintf(stderr, "MODE SENSE failed, aborted command\n"); return res; } if (opts->verbose && (0 == opts->flexible) && (rep_len > 0xa00)) { sdp_get_mpage_name(pn, spn, pdt, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); fprintf(stderr, "%s mode page length=%d too long, perhaps " "try '--flexible'\n", buff, rep_len); } if ((smask & 1)) { len = sdp_get_mp_len(cur_mp); if ((smask & 4)) { return set_def_mode_page(sg_fd, pn, spn, def_mp, len, opts); } else { sdp_get_mpage_name(pn, spn, pdt, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); fprintf(stderr, ">> %s mode page (default) not supported\n", buff); return SG_LIB_CAT_ILLEGAL_REQ; } } else { sdp_get_mpage_name(pn, spn, pdt, opts->transport, opts->vendor, 0, 0, buff, sizeof(buff)); fprintf(stderr, ">> %s mode page not supported\n", buff); return SG_LIB_CAT_ILLEGAL_REQ; } } /* Returns 64 bit signed integer given in either decimal or in hex. The * hex number is either preceded by "0x" or followed by "h". Returns -1 * on error (so check for "-1" string before using this function). */ static int64_t get_llnum(const char * buf) { int res, len; int64_t num; uint64_t unum; if ((NULL == buf) || ('\0' == buf[0])) return -1; len = strlen(buf); if (('0' == buf[0]) && (('x' == buf[1]) || ('X' == buf[1]))) { res = sscanf(buf + 2, "%" SCNx64 "", &unum); num = unum; } else if ('H' == toupper(buf[len - 1])) { res = sscanf(buf, "%" SCNx64 "", &unum); num = unum; } else res = sscanf(buf, "%" SCNd64 "", &num); return (1 == res) ? num : -1; } static int build_mp_settings(const char * arg, struct sdparm_mode_page_settings * mps, struct sdparm_opt_coll * opts, int clear, int get) { int len, b_sz, num, from, cont, colon; unsigned int u; int64_t ll; char buff[64]; char acron[64]; char vb[64]; const char * cp; const char * ncp; const char * ecp; struct sdparm_mode_page_it_val * ivp; const struct sdparm_mode_page_item * mpi; const struct sdparm_mode_page_item * prev_mpi; b_sz = sizeof(buff) - 1; cp = arg; while (mps->num_it_vals < MAX_MP_IT_VAL) { memset(buff, 0, sizeof(buff)); ivp = &mps->it_vals[mps->num_it_vals]; if ('\0' == *cp) break; ncp = strchr(cp, ','); if (ncp) { len = ncp - cp; if (len <= 0) { ++cp; continue; } strncpy(buff, cp, (len < b_sz ? len : b_sz)); } else strncpy(buff, cp, b_sz); colon = strchr(buff, ':') ? 1 : 0; if ((isalpha(buff[0]) && (! colon)) || (isdigit(buff[0]) && ('_' == buff[1]))) { /* expect acronym */ ecp = strchr(buff, '='); if (ecp) { strncpy(acron, buff, ecp - buff); acron[ecp - buff] = '\0'; strcpy(vb, ecp + 1); if (0 == strcmp("-1", vb)) ivp->val = -1; else { ivp->val = get_llnum(vb); if (-1 == ivp->val) { fprintf(stderr, "unable to decode: %s value\n", buff); fprintf(stderr, " expected: [=]\n"); return -1; } } } else { strcpy(acron, buff); ivp->val = ((clear || get) ? 0 : -1); } if ((ecp = strchr(acron, '.'))) { strcpy(vb, acron); strncpy(acron, vb, ecp - acron); acron[ecp - acron] = '\0'; strcpy(vb, ecp + 1); ivp->descriptor_num = get_llnum(vb); if (ivp->descriptor_num < 0) { fprintf(stderr, "unable to decode: %s descriptor number\n", buff); fprintf(stderr, " expected: " "[.][=]\n"); return -1; } } ivp->orig_val = ivp->val; from = 0; cont = 0; prev_mpi = NULL; if (get) { do { mpi = sdp_find_mitem_by_acron(acron, &from, opts->transport, opts->vendor); if (NULL == mpi) { if (cont) { mpi = prev_mpi; break; } if ((opts->vendor < 0) && (opts->transport < 0)) { from = 0; mpi = sdp_find_mitem_by_acron(acron, &from, DEF_TRANSPORT_PROTOCOL, -1); if (NULL == mpi) { fprintf(stderr, "couldn't find field " "acronym: %s\n", acron); fprintf(stderr, " [perhaps a '--transport=" "' or '--vendor=' option is " "needed]\n"); return -1; } else /* keep going in this case */ opts->transport = DEF_TRANSPORT_PROTOCOL; } else { fprintf(stderr, "couldn't find field acronym: " "%s\n", acron); return -1; } } if (mps->page_num < 0) { mps->page_num = mpi->page_num; mps->subpage_num = mpi->subpage_num; break; } cont = 1; prev_mpi = mpi; /* got acronym match but if not at specified pn,spn */ /* then keep searching */ } while ((mps->page_num != mpi->page_num) || (mps->subpage_num != mpi->subpage_num)); } else { /* --set or --clear */ do { mpi = sdp_find_mitem_by_acron(acron, &from, opts->transport, opts->vendor); if (NULL == mpi) { if (cont) { fprintf(stderr, "mode page of acronym: %s " "[0x%x,0x%x] doesn't match prior\n", acron, prev_mpi->page_num, prev_mpi->subpage_num); fprintf(stderr, " mode page: 0x%x,0x%x\n", mps->page_num, mps->subpage_num); fprintf(stderr, "For '--set' and '--clear' all " "fields must be in the same mode " "page\n"); return -1; } if ((opts->vendor < 0) && (opts->transport < 0)) { from = 0; mpi = sdp_find_mitem_by_acron(acron, &from, DEF_TRANSPORT_PROTOCOL, -1); if (NULL == mpi) { fprintf(stderr, "couldn't find field " "acronym: %s\n", acron); fprintf(stderr, " [perhaps a '--transport=" "' or '--vendor=' option is " "needed]\n"); return -1; } else /* keep going in this case */ opts->transport = DEF_TRANSPORT_PROTOCOL; } else { fprintf(stderr, "couldn't find field acronym: " "%s\n", acron); return -1; } } if (mps->page_num < 0) { mps->page_num = mpi->page_num; mps->subpage_num = mpi->subpage_num; break; } cont = 1; prev_mpi = mpi; /* got acronym match but if not at specified pn,spn */ /* then keep searching */ } while ((mps->page_num != mpi->page_num) || (mps->subpage_num != mpi->subpage_num)); } if (mpi->num_bits < 64) { ll = 1; ivp->val &= (ll << mpi->num_bits) - 1; } ivp->mpi = *mpi; /* struct assignment */ } else { /* expect "start_byte:start_bit:num_bits[=]" */ /* start_byte may be in hex ('0x' prefix or 'h' suffix) */ if ((0 == strncmp("0x", buff, 2)) || (0 == strncmp("0X", buff, 2))) { num = sscanf(buff + 2, "%x:%d:%d=%s", &u, &ivp->mpi.start_bit, &ivp->mpi.num_bits, vb); ivp->mpi.start_byte = u; } else { if (strstr(buff, "h:")) { num = sscanf(buff, "%xh:%d:%d=%s", &u, &ivp->mpi.start_bit, &ivp->mpi.num_bits, vb); ivp->mpi.start_byte = u; } else if (strstr(buff, "H:")) { num = sscanf(buff, "%xH:%d:%d=%s", &u, &ivp->mpi.start_bit, &ivp->mpi.num_bits, vb); ivp->mpi.start_byte = u; } else num = sscanf(buff, "%d:%d:%d=%s", &ivp->mpi.start_byte, &ivp->mpi.start_bit, &ivp->mpi.num_bits, vb); } if (num < 3) { fprintf(stderr, "unable to decode: %s\n", buff); fprintf(stderr, " expected: start_byte:start_bit:num_bits" "[=]\n"); return -1; } if (3 == num) ivp->val = ((clear || get) ? 0 : -1); else { if (0 == strcmp("-1", vb)) ivp->val = -1; else { ivp->val = get_llnum(vb); if (-1 == ivp->val) { fprintf(stderr, "unable to decode " "start_byte:start_bit:num_bits value\n"); return -1; } } } ivp->mpi.pdt = -1; /* don't known pdt now, so don't restrict */ if (ivp->mpi.start_byte < 0) { fprintf(stderr, "need positive start byte offset\n"); return -1; } if ((ivp->mpi.start_bit < 0) || (ivp->mpi.start_bit > 7)) { fprintf(stderr, "need start bit in 0..7 range " "(inclusive)\n"); return -1; } if ((ivp->mpi.num_bits < 1) || (ivp->mpi.num_bits > 64)) { fprintf(stderr, "need number of bits in 1..64 range " "(inclusive)\n"); return -1; } if (mps->page_num < 0) { fprintf(stderr, "need '--page=' option for mode page " "name or number\n"); return -1; } else if (get) { ivp->mpi.page_num = mps->page_num; ivp->mpi.subpage_num = mps->subpage_num; } ivp->orig_val = ivp->val; if (ivp->mpi.num_bits < 64) { int64_t ll = 1; ivp->val &= (ll << ivp->mpi.num_bits) - 1; } } ++mps->num_it_vals; if (ncp) cp = ncp + 1; else break; } return 0; } static int open_and_simple_inquiry(const char * device_name, int rw, int * pdt, int * protect, const struct sdparm_opt_coll * opts) { int res, verb, sg_fd, l_pdt; struct sg_simple_inquiry_resp sir; char b[32]; verb = (opts->verbose > 0) ? opts->verbose - 1 : 0; sg_fd = sg_cmds_open_device(device_name, ! rw /* read_only */ , verb); if (sg_fd < 0) { fprintf(stderr, "open error: %s [%s]: %s\n", device_name, (rw ? "read/write" : "read only"), safe_strerror(-sg_fd)); return -1; } res = sg_simple_inquiry(sg_fd, &sir, 0, verb); if (res) { #ifdef SG_LIB_LINUX if (-1 == res) { int sg_sg_fd; sg_sg_fd = map_if_lk24(sg_fd, device_name, rw, opts->verbose); if (sg_sg_fd < 0) goto err_out; sg_cmds_close_device(sg_fd); sg_fd = sg_sg_fd; res = sg_simple_inquiry(sg_fd, &sir, 0, verb); if (sg_sg_fd < 0) goto err_out; } #endif /* SG_LIB_LINUX */ if (res) { fprintf(stderr, "SCSI INQUIRY command failed on %s\n", device_name); goto err_out; } } l_pdt = sir.peripheral_type; if ((PDT_WO == l_pdt) || (PDT_OPTICAL == l_pdt)) *pdt = PDT_DISK; /* map disk-like pdt's to PDT_DOSK */ else *pdt = l_pdt; if (protect) *protect = sir.byte_5 & 0x1; /* PROTECT bit SPC-3 and later */ if ((0 == opts->hex) && (0 == opts->quiet)) { printf(" %s: %.8s %.16s %.4s", device_name, sir.vendor, sir.product, sir.revision); if (0 != l_pdt) printf(" [%s]", sg_get_pdt_str(l_pdt, sizeof(b), b)); printf("\n"); } return sg_fd; err_out: sg_cmds_close_device(sg_fd); return -1; } /* Process mode page(s) operation. Returns 0 if successful */ static int process_mode(int sg_fd, const struct sdparm_mode_page_settings * mps, int pn, int spn, int set_clear, int get, const struct sdparm_opt_coll * opts, int pdt) { int res; const struct sdparm_mode_page_t * mpp; if ((pn > 0x3e) || (spn > 0xfe)) { if ((0x3f == pn) || (0xff == spn)) fprintf(stderr, "Does not support requesting all mode pages or " "subpages this way.\n Try '--all' option.\n"); else fprintf(stderr, "Accepts mode page numbers from 0 to 62 .\n" " Accepts mode subpage numbers from 0 to 254 .\n" " For VPD pages add a '--inquiry' option.\n"); return SG_LIB_SYNTAX_ERROR; } if ((pn > 0) && (pdt >= 0)) { mpp = sdp_get_mode_detail(pn, spn, pdt, opts->transport, opts->vendor); if (NULL == mpp) mpp = sdp_get_mode_detail(pn, spn, -1, opts->transport, opts->vendor); if (mpp && mpp->name && (mpp->pdt >= 0) && (pdt != mpp->pdt)) { fprintf(stderr, ">> Warning: %s mode page associated with\n", mpp->name); fprintf(stderr, " peripheral device type 0x%x but device " "pdt is 0x%x\n", mpp->pdt, pdt); if (! opts->flexible) fprintf(stderr, " may need '--flexible' option to " "override\n"); } } if (opts->defaults) res = set_mp_defaults(sg_fd, pn, spn, pdt, opts); else if (set_clear) { if (mps->num_it_vals < 1) { fprintf(stderr, "no fields found to set or clear\n"); return SG_LIB_CAT_OTHER; } res = change_mode_page(sg_fd, pdt, mps, opts); if (res) return res; } else if (get) { if (mps->num_it_vals < 1) { fprintf(stderr, "no fields found to get\n"); return SG_LIB_CAT_OTHER; } res = print_mode_items(sg_fd, mps, pdt, opts); } else res = print_mode_pages(sg_fd, pn, spn, pdt, opts); return res; } int main(int argc, char * argv[]) { int sg_fd, res, c, pdt, req_pdt, k, orig_transport, r; struct sdparm_opt_coll opts; const char * clear_str = NULL; const char * cmd_str = NULL; const char * get_str = NULL; const char * set_str = NULL; const char * page_str = NULL; const char * device_name_arr[MAX_DEV_NAMES]; int num_devices = 0; int pn = -1; int spn = -1; int rw = 0; /* 1: requires RDWR, 0: perhaps RDONLY ok */ int set_clear = 0; int protect = 0; int cmd_arg = -1; const struct sdparm_mode_page_t * mpp = NULL; const struct sdparm_transport_id_t * tip; const struct sdparm_vpd_page_t * vpp = NULL; const struct sdparm_vendor_name_t * vnp; struct sdparm_mode_page_settings mp_settings; char * cp; const char * ccp; const struct sdparm_command_t * scmdp = NULL; int ret = 0; #ifdef SG_LIB_WIN32 int do_wscan = 0; #endif memset(&opts, 0, sizeof(opts)); opts.transport = -1; opts.vendor = -1; memset(device_name_arr, 0, sizeof(device_name_arr)); memset(&mp_settings, 0, sizeof(mp_settings)); pdt = -1; while (1) { int option_index = 0; #ifdef SG_LIB_WIN32 c = getopt_long(argc, argv, "6aBc:C:dDefg:hHilM:np:qrs:St:vVw", long_options, &option_index); #else c = getopt_long(argc, argv, "6aBc:C:dDefg:hHilM:np:qrs:St:vV", long_options, &option_index); #endif if (c == -1) break; switch (c) { case '6': ++opts.mode_6; break; case 'a': ++opts.all; break; case 'B': ++opts.dbd; break; case 'c': clear_str = optarg; set_clear = 1; rw = 1; break; case 'C': cmd_str = optarg; case 'd': ++opts.dummy; break; case 'D': ++opts.defaults; rw = 1; break; case 'e': ++opts.enumerate; break; case 'f': ++opts.flexible; break; case 'g': get_str = optarg; break; case 'h': case '?': usage(); return 0; case 'H': ++opts.hex; break; case 'i': ++opts.inquiry; break; case 'l': ++opts.long_out; break; case 'M': if (isalpha(optarg[0])) { vnp = sdp_find_vendor_by_acron(optarg); if (NULL == vnp) { fprintf(stderr, "abbreviation does not match a " "vendor\n"); printf("Available vendors:\n"); enumerate_vendors(); return SG_LIB_SYNTAX_ERROR; } else opts.vendor = vnp->vendor_num; } else { const struct sdparm_vendor_pair * vpp; res = sg_get_num_nomult(optarg); vpp = sdp_get_vendor_pair(res); if (NULL == vpp) { fprintf(stderr, "Bad vendor value after '-M' " " (or '--vendor=') option\n"); printf("Available vendors:\n"); enumerate_vendors(); return SG_LIB_SYNTAX_ERROR; } opts.vendor = res; } break; case 'n': ++opts.num_desc; break; case 'q': ++opts.quiet; break; case 'p': if (page_str) { fprintf(stderr, "only one '--page=' option permitted\n"); usage(); return SG_LIB_SYNTAX_ERROR; } else page_str = optarg; break; case 'r': ++opts.read_only; break; case 's': set_str = optarg; rw = 1; set_clear = 1; break; case 'S': ++opts.save; break; case 't': if (isalpha(optarg[0])) { tip = sdp_find_transport_by_acron(optarg); if (NULL == tip) { fprintf(stderr, "abbreviation does not match a " "transport protocol\n"); printf("Available transport protocols:\n"); enumerate_transports(); return SG_LIB_SYNTAX_ERROR; } else opts.transport = tip->proto_num; } else { res = sg_get_num_nomult(optarg); if ((res < 0) || (res > 15)) { fprintf(stderr, "Bad transport value after '-t' " "option\n"); printf("Available transport protocols:\n"); enumerate_transports(); return SG_LIB_SYNTAX_ERROR; } opts.transport = res; } break; case 'v': ++opts.verbose; break; case 'V': fprintf(stderr, "version: %s\n", version_str); return 0; #ifdef SG_LIB_WIN32 case 'w': ++do_wscan; break; #endif default: fprintf(stderr, "unrecognised option code 0x%x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } } while (optind < argc) { if (num_devices < MAX_DEV_NAMES) { device_name_arr[num_devices++] = argv[optind]; ++optind; } else { for (; optind < argc; ++optind) fprintf(stderr, "Unexpected extra argument: %s\n", argv[optind]); usage(); return SG_LIB_SYNTAX_ERROR; } } if (opts.read_only) rw = 0; // override any read-write settings if ((!!get_str + !!set_str + !!clear_str) > 1) { fprintf(stderr, "Can only give one of '--get=', '--set=' and " "'--clear='\n"); return SG_LIB_SYNTAX_ERROR; } #ifdef SG_LIB_WIN32 if (do_wscan) return sg_do_wscan('\0', do_wscan, opts.verbose); #endif if (page_str) { if ((0 == strcmp("-1", page_str)) || (0 == strcmp("-2", page_str))) { opts.inquiry = 1; pn = VPD_NOT_STD_INQ; } else if (isalpha(page_str[0])) { while ( 1 ) { /* dummy loop, just using break */ mpp = sdp_find_mp_by_acron(page_str, opts.transport, opts.vendor); if (mpp) break; vpp = sdp_find_vpd_by_acron(page_str); if (vpp) break; orig_transport = opts.transport; if ((opts.vendor < 0) && (opts.transport < 0)) { opts.transport = DEF_TRANSPORT_PROTOCOL; mpp = sdp_find_mp_by_acron(page_str, opts.transport, opts.vendor); if (mpp) break; } if ((opts.vendor < 0) && (orig_transport < 0)) fprintf(stderr, "abbreviation matches neither a " "mode page nor a VPD page\n" " [perhaps a '--transport=' or " "'--vendor=' option is needed]\n"); else fprintf(stderr, "abbreviation matches neither a mode " "page nor a VPD page\n"); if (opts.inquiry) { printf("available VPD pages:\n"); enumerate_vpds(); return SG_LIB_SYNTAX_ERROR; } else { printf("available mode pages"); if (opts.vendor >= 0) printf(" (for given vendor):\n"); else if (orig_transport >= 0) printf(" (for given transport):\n"); else printf(":\n"); enumerate_mpages(orig_transport, opts.vendor); return SG_LIB_SYNTAX_ERROR; } } if (vpp) { pn = vpp->vpd_num; spn = vpp->subvalue; opts.inquiry = 1; pdt = vpp->pdt; } else { if (opts.inquiry) { fprintf(stderr, "matched mode page acronym but given " "'-i' so expecting a VPD page\n"); return SG_LIB_SYNTAX_ERROR; } pn = mpp->page; spn = mpp->subpage; pdt = mpp->pdt; } } else { /* got page_str and first char probably numeric */ cp = (char *)strchr(page_str, ','); pn = sg_get_num_nomult(page_str); if ((pn < 0) || (pn > 255)) { fprintf(stderr, "Bad page code value after '-p' " "option\n"); if (opts.inquiry) { printf("available VPD pages:\n"); enumerate_vpds(); return SG_LIB_SYNTAX_ERROR; } else { printf("available mode pages"); if (opts.vendor >= 0) printf(" (for given vendor):\n"); else if (opts.transport >= 0) printf(" (for given transport):\n"); else printf(":\n"); enumerate_mpages(opts.transport, opts.vendor); return SG_LIB_SYNTAX_ERROR; } } if (cp) { spn = sg_get_num_nomult(cp + 1); if ((spn < 0) || (spn > 255)) { fprintf(stderr, "Bad second value after " "'-p' option\n"); return SG_LIB_SYNTAX_ERROR; } } else spn = 0; } } if (opts.inquiry) { if (set_clear || get_str || cmd_str || opts.defaults || opts.save) { fprintf(stderr, "'--inquiry' option lists VPD pages so other " "options that are\nconcerned with mode pages are " "inappropriate\n"); return SG_LIB_SYNTAX_ERROR; } if (pn > 255) { fprintf(stderr, "VPD page numbers are from 0 to 255\n"); return SG_LIB_SYNTAX_ERROR; } if (opts.enumerate) { printf("VPD pages:\n"); enumerate_vpds(); return 0; } } else if (cmd_str) { if (set_clear || get_str || opts.defaults || opts.save) { fprintf(stderr, "'--command=' option is not valid with other " "options that are\nconcerned with mode pages\n"); return SG_LIB_SYNTAX_ERROR; } if (opts.enumerate) { printf("Available commands:\n"); sdp_enumerate_commands(); return 0; } scmdp = sdp_build_cmd(cmd_str, &rw, &cmd_arg); if (NULL == scmdp) { fprintf(stderr, "'--command=%s' not found\n", cmd_str); printf("available commands\n"); sdp_enumerate_commands(); return SG_LIB_SYNTAX_ERROR; } if (opts.read_only) rw = 0; // override any read-write settings } else { /* assume mode pages */ if (pn < 0) { mp_settings.page_num = -1; mp_settings.subpage_num = -1; } else { mp_settings.page_num = pn; mp_settings.subpage_num = spn; } if (get_str) { if (set_clear) { fprintf(stderr, "'--get=' can't be used with '--set=' " "or " "'--clear='\n"); return SG_LIB_SYNTAX_ERROR; } if (build_mp_settings(get_str, &mp_settings, &opts, 0, 1)) return SG_LIB_SYNTAX_ERROR; } if (1 == opts.enumerate) { if ((num_devices > 0) || set_clear || get_str || opts.save) /* think about --get= with --enumerate */ printf(" as well as most options are ignored " "when '--enumerate' is given\n"); if (pn < 0) { if (opts.vendor >= 0) { ccp = sdp_get_vendor_name(opts.vendor); if (ccp) printf("Mode pages for %s vendor:\n", ccp); else printf("Mode pages for vendor 0x%x:\n", opts.vendor); if (opts.all) enumerate_mitems(pn, spn, pdt, &opts); else { enumerate_mpages(opts.transport, opts.vendor); } } else if (opts.transport >= 0) { ccp = sdp_get_transport_name(opts.transport); if (ccp) printf("Mode pages for %s transport protocol:\n", ccp); else printf("Mode pages for transport protocol 0x%x:\n", opts.transport); if (opts.all) enumerate_mitems(pn, spn, pdt, &opts); else { enumerate_mpages(opts.transport, opts.vendor); } } else { /* neither vendor nor transport given */ if (opts.long_out) { printf("Mode pages (not related to any transport " "protocol or vendor):\n"); enumerate_mpages(-1, -1); printf("\n"); printf("Transport protocols:\n"); enumerate_transports(); printf("\n"); printf("Vendors:\n"); enumerate_vendors(); if (opts.all) { struct sdparm_opt_coll t_opts; printf("\n"); t_opts = opts; enumerate_mitems(pn, spn, pdt, &opts); for (k = 0; k < 16; ++k) { ccp = sdp_get_transport_name(k); if (NULL == ccp) continue; printf("\n"); printf("Mode pages for %s transport " "protocol:\n", ccp); t_opts.transport = k; t_opts.vendor = -1; enumerate_mitems(pn, spn, pdt, &t_opts); } for (k = 0; k < sdparm_vendor_mp_len; ++k) { ccp = sdp_get_vendor_name(k); if (NULL == ccp) break; printf("\n"); printf("Mode pages for %s vendor:\n", ccp); t_opts.transport = -1; t_opts.vendor = k; enumerate_mitems(pn, spn, pdt, &t_opts); } } else { for (k = 0; k < 16; ++k) { ccp = sdp_get_transport_name(k); if (NULL == ccp) continue; printf("\n"); printf("Mode pages for %s transport " "protocol:\n", ccp); enumerate_mpages(k, -1); } for (k = 0; k < sdparm_vendor_mp_len; ++k) { ccp = sdp_get_vendor_name(k); if (NULL == ccp) break; printf("\n"); printf("Mode pages for %s vendor:\n", ccp); enumerate_mpages(-1, k); } } printf("\n"); printf("Commands:\n"); sdp_enumerate_commands(); } else { printf("Mode pages:\n"); enumerate_mpages(-1, -1); if (opts.all) enumerate_mitems(pn, spn, pdt, &opts); } } } else /* given mode page number */ enumerate_mitems(pn, spn, pdt, &opts); return 0; } else if (opts.enumerate) { printf("Available commands:\n"); sdp_enumerate_commands(); return 0; } if ((opts.num_desc > 0) && (pn < 0)) { fprintf(stderr, "when '--num-desc' is given an explicit mode " "page is required\n"); return SG_LIB_SYNTAX_ERROR; } if (opts.defaults && (set_clear || get_str)) { fprintf(stderr, "'--get=', '--set=' or '--clear=' " "can't be used with '--defaults'\n"); return SG_LIB_SYNTAX_ERROR; } if (set_str) { if (build_mp_settings(set_str, &mp_settings, &opts, 0, 0)) return SG_LIB_SYNTAX_ERROR; } if (clear_str) { if (build_mp_settings(clear_str, &mp_settings, &opts, 1, 0)) return SG_LIB_SYNTAX_ERROR; } if (opts.verbose && (mp_settings.num_it_vals > 0)) list_mp_settings(&mp_settings, (NULL != get_str)); if (opts.defaults && (pn < 0)) { fprintf(stderr, "to set defaults, the '--page=' option must " "be used\n"); return SG_LIB_SYNTAX_ERROR; } } if (0 == num_devices) { fprintf(stderr, "one or more device names required\n"); usage(); return SG_LIB_SYNTAX_ERROR; } req_pdt = pdt; ret = 0; for (k = 0; k < num_devices; ++k) { r = 0; pdt = -1; if (opts.verbose > 0) fprintf(stderr, ">>> about to open device name: %s\n", device_name_arr[k]); sg_fd = open_and_simple_inquiry(device_name_arr[k], rw, &pdt, &protect, &opts); if (sg_fd < 0) { r = SG_LIB_FILE_ERROR; if (0 == ret) ret = r; continue; } if (opts.inquiry) r = sdp_process_vpd_page(sg_fd, pn, ((spn < 0) ? 0: spn), &opts, req_pdt, protect); else { if (cmd_str && scmdp) /* process command */ r = sdp_process_cmd(sg_fd, scmdp, cmd_arg, pdt, &opts); else /* mode page */ r = process_mode(sg_fd, &mp_settings, pn, spn, set_clear, (NULL != get_str), &opts, pdt); } res = sg_cmds_close_device(sg_fd); if (res < 0) { fprintf(stderr, "close error: %s\n", safe_strerror(-sg_fd)); if (0 == r) r = SG_LIB_FILE_ERROR; } if (r && ((0 == ret) || (SG_LIB_FILE_ERROR == ret))) ret = r; } return (ret >= 0) ? ret : SG_LIB_CAT_OTHER; } #ifdef SG_LIB_LINUX /* Following needed for lk 2.4 series; may be dropped in future. * In the lk 2.4 series (and earlier) no pass-through was available on the * often used /dev/sd* device nodes. So the code below attempts to map a * given /dev/sd device node to the corresponding /dev/sg device * node. */ typedef struct my_scsi_idlun { int mux4; int host_unique_id; } My_scsi_idlun; #define DEVNAME_SZ 256 #define MAX_SG_DEVS 256 #define MAX_NUM_NODEVS 4 /* Given a file descriptor 'oth_fd' that refers to a linux SCSI device node * this function returns the open file descriptor of the corresponding sg * device node. Returns a value >= 0 on success, else -1 or -2. device_name * should correspond with oth_fd. If a corresponding sg device node is found * then it is opened with rw setting. The oth_fd is left as is (i.e. it is * not closed). sg device node scanning is done "O_RDONLY | O_NONBLOCK". * Assumes (and is currently only invoked for) lk 2.4. */ static int find_corresponding_sg_fd(int oth_fd, const char * device_name, int rw, int verbose) { int fd, err, bus, bbus, k, v; My_scsi_idlun m_idlun, mm_idlun; char name[DEVNAME_SZ]; int num_nodevs = 0; int num_sgdevs = 0; err = ioctl(oth_fd, SCSI_IOCTL_GET_BUS_NUMBER, &bus); if (err < 0) { fprintf(stderr, "%s does not present a standard Linux SCSI device " "interface (a\nSCSI_IOCTL_GET_BUS_NUMBER ioctl to it " "failed). Examples of typical\n", device_name); fprintf(stderr, "names of devices that do are /dev/sda, /dev/scd0, " "dev/st0, /dev/osst0,\nand /dev/sg0. An example of a " "typical non-SCSI device name is /dev/hdd.\n"); return -2; } err = ioctl(oth_fd, SCSI_IOCTL_GET_IDLUN, &m_idlun); if (err < 0) { if (verbose) fprintf(stderr, "%s does not understand SCSI commands(2)\n", device_name); return -2; } fd = -2; for (k = 0; (k < MAX_SG_DEVS) && (num_nodevs < MAX_NUM_NODEVS); k++) { snprintf(name, sizeof(name), "/dev/sg%d", k); fd = open(name, O_RDONLY | O_NONBLOCK); if (fd < 0) { if (ENODEV != errno) ++num_sgdevs; if ((ENODEV == errno) || (ENOENT == errno) || (ENXIO == errno)) { ++num_nodevs; continue; /* step over MAX_NUM_NODEVS holes */ } if (EBUSY == errno) continue; /* step over if O_EXCL already on it */ else break; } else ++num_sgdevs; err = ioctl(fd, SCSI_IOCTL_GET_BUS_NUMBER, &bbus); if (err < 0) { if (verbose) perror("SCSI_IOCTL_GET_BUS_NUMBER failed"); return -2; } err = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &mm_idlun); if (err < 0) { if (verbose) perror("SCSI_IOCTL_GET_IDLUN failed"); return -2; } if ((bus == bbus) && ((m_idlun.mux4 & 0xff) == (mm_idlun.mux4 & 0xff)) && (((m_idlun.mux4 >> 8) & 0xff) == ((mm_idlun.mux4 >> 8) & 0xff)) && (((m_idlun.mux4 >> 16) & 0xff) == ((mm_idlun.mux4 >> 16) & 0xff))) break; else { close(fd); fd = -2; } } if (0 == num_sgdevs) { fprintf(stderr, "No /dev/sg* devices found; is the sg driver " "loaded?\n"); return -2; } if (fd >= 0) { if ((ioctl(fd, SG_GET_VERSION_NUM, &v) < 0) || (v < 30000)) { fprintf(stderr, "requires lk 2.4 (sg driver) or lk 2.6\n"); close(fd); return -2; } close(fd); if (verbose) fprintf(stderr, ">> mapping %s to %s (in lk 2.4 series)\n", device_name, name); /* re-opening corresponding sg device with given rw setting */ return open(name, O_NONBLOCK | (rw ? O_RDWR : O_RDONLY)); } else return fd; } static int map_if_lk24(int sg_fd, const char * device_name, int rw, int verbose) { /* could be lk 2.4 and not using a sg device */ struct utsname a_uts; int two, four; int res; struct stat a_stat; if (stat(device_name, &a_stat) < 0) { fprintf(stderr, "unable to 'stat' %s, errno=%d\n", device_name, errno); perror("stat failed"); return -1; } if ((! S_ISBLK(a_stat.st_mode)) && (! S_ISCHR(a_stat.st_mode))) { fprintf(stderr, "expected %s to be a block or char device\n", device_name); return -1; } if (uname(&a_uts) < 0) { fprintf(stderr, "uname system call failed, couldn't send " "SG_IO ioctl to %s\n", device_name); return -1; } res = sscanf(a_uts.release, "%d.%d", &two, &four); if (2 != res) { fprintf(stderr, "unable to read uname release\n"); return -1; } if (! ((2 == two) && (4 == four))) { fprintf(stderr, "unable to access %s, ATA disk?\n", device_name); return -1; } return find_corresponding_sg_fd(sg_fd, device_name, rw, verbose); } #endif /* SG_LIB_LINUX */ sdparm-1.08/src/chk_sdparm_data.c0000664000175000017500000002313512144176773016005 0ustar douggdougg/* * Copyright (c) 2005-2012 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Version 1.6 20130513 */ #include #include #include #include "sdparm.h" /* * This is a maintenance program for checking the integrity of * data in the sdparm_data.c tables. * * Build with a line like: * gcc -Wall -o chk_sdparm_data sdparm_data.o sdparm_data_vendor.o * chk_sdparm_data.c * */ #define MAX_MP_LEN 1024 #define MAX_PDT 0x1f static unsigned char cl_pdt_arr[MAX_PDT + 1][MAX_MP_LEN]; static unsigned char cl_common_arr[MAX_MP_LEN]; static void clear_cl() { memset(cl_pdt_arr, 0, sizeof(cl_pdt_arr)); memset(cl_common_arr, 0, sizeof(cl_common_arr)); } /* result: 0 -> good, 1 -> clash at given pdt, 2 -> clash * other than given pdt, -1 -> bad input */ static int check_cl(int off, int pdt, unsigned char mask) { int k; if (off >= MAX_MP_LEN) return -1; if (pdt < 0) { if (cl_common_arr[off] & mask) return 1; for (k = 0; k <= MAX_PDT; ++k) { if (cl_pdt_arr[k][off] & mask) return 2; } return 0; } else if (pdt <= MAX_PDT) { if (cl_pdt_arr[pdt][off] & mask) return 1; if (cl_common_arr[off] & mask) return 2; return 0; } return -1; } static void set_cl(int off, int pdt, unsigned char mask) { if (off < MAX_MP_LEN) { if (pdt < 0) cl_common_arr[off] |= mask; else if (pdt <= MAX_PDT) cl_pdt_arr[pdt][off] |= mask; } } static void check(const struct sdparm_mode_page_item * mpi, const struct sdparm_mode_page_item * mpi_b) { unsigned char mask; const struct sdparm_mode_page_item * kp = mpi; const struct sdparm_mode_page_item * jp = mpi; const char * acron; int res, prev_mp, prev_msp, prev_pdt, sbyte, sbit, nbits; int second_k = 0; int second_j = 0; clear_cl(); for (prev_mp = 0, prev_msp = 0, prev_pdt = -1; ; ++kp) { if (NULL == kp->acron) { if ((NULL == mpi_b) || second_k) break; prev_mp = 0; prev_msp = 0; kp = mpi_b; second_k = 1; } acron = kp->acron ? kp->acron : "?"; if ((prev_mp != kp->page_num) || (prev_msp != kp->subpage_num)) { if (prev_mp > kp->page_num) printf(" mode page 0x%x,0x%x out of order\n", kp->page_num, kp->subpage_num); if ((prev_mp == kp->page_num) && (prev_msp > kp->subpage_num)) printf(" mode subpage 0x%x,0x%x out of order, previous msp " "was 0x%x\n", kp->page_num, kp->subpage_num, prev_msp); prev_mp = kp->page_num; prev_msp = kp->subpage_num; prev_pdt = kp->pdt; clear_cl(); } else if ((prev_pdt >= 0) && (prev_pdt != kp->pdt)) { if (prev_pdt > kp->pdt) printf(" mode page 0x%x,0x%x pdt out of order, pdt was " "%d, now %d\n", kp->page_num, kp->subpage_num, prev_pdt, kp->pdt); prev_pdt = kp->pdt; } for (jp = kp + 1, second_j = second_k; ; ++jp) { if (NULL == jp->acron) { if ((NULL == mpi_b) || second_j) break; jp = mpi_b; second_j = 1; } if ((0 == strcmp(acron, jp->acron)) && (! (jp->flags & MF_CLASH_OK))) printf(" acronym '%s' with this description: '%s'\n " "clashes with '%s'\n", acron, kp->description, jp->description); } sbyte = kp->start_byte; if ((unsigned)sbyte + 8 > MAX_MP_LEN) { printf(" acronym: %s start byte too large: %d\n", kp->acron, sbyte); continue; } sbit = kp->start_bit; if ((unsigned)sbit > 7) { printf(" acronym: %s start bit too large: %d\n", kp->acron, sbit); continue; } nbits = kp->num_bits; if (nbits > 64) { printf(" acronym: %s number of bits too large: %d\n", kp->acron, nbits); continue; } if (nbits < 1) { printf(" acronym: %s number of bits too small: %d\n", kp->acron, nbits); continue; } mask = (1 << (sbit + 1)) - 1; if ((nbits - 1) < sbit) mask &= ~((1 << (sbit + 1 - nbits)) - 1); res = check_cl(sbyte, kp->pdt, mask); if (res) { if (1 == res) printf(" 0x%x,0x%x: clash at start_byte: %d, bit: %d " "[latest acron: %s, this pdt]\n", prev_mp, prev_msp, sbyte, sbit, acron); else if (2 == res) printf(" 0x%x,0x%x: clash at start_byte: %d, bit: %d " "[latest acron: %s, another pdt]\n", prev_mp, prev_msp, sbyte, sbit, acron); else printf(" 0x%x,0x%x: clash, bad data at start_byte: %d, " "bit: %d [latest acron: %s]\n", prev_mp, prev_msp, sbyte, sbit, acron); } set_cl(sbyte, kp->pdt, mask); if ((nbits - 1) > sbit) { nbits -= (sbit + 1); if ((nbits > 7) && (0 != (nbits % 8))) printf(" 0x%x,0x%x: check nbits: %d, start_byte: %d, bit: " "%d [acron: %s]\n", prev_mp, prev_msp, kp->num_bits, sbyte, sbit, acron); do { ++sbyte; mask = 0xff; if (nbits > 7) nbits -= 8; else { mask &= ~((1 << (8 - nbits)) - 1); nbits = 0; } res = check_cl(sbyte, kp->pdt, mask); if (res) { if (1 == res) printf(" 0x%x,0x%x: clash at start_byte: %d, " "bit: %d [latest acron: %s, this pdt]\n", prev_mp, prev_msp, sbyte, sbit, acron); else if (2 == res) printf(" 0x%x,0x%x: clash at start_byte: %d, " "bit: %d [latest acron: %s, another pdt]\n", prev_mp, prev_msp, sbyte, sbit, acron); else printf(" 0x%x,0x%x: clash, bad at start_byte: " "%d, bit: %d [latest acron: %s]\n", prev_mp, prev_msp, sbyte, sbit, acron); } set_cl(sbyte, kp->pdt, mask); } while (nbits > 0); } } } static const char * get_vendor_name(int vendor_num) { const struct sdparm_vendor_name_t * vnp; for (vnp = sdparm_vendor_id; vnp->acron; ++vnp) { if (vendor_num == vnp->vendor_num) return vnp->name; } return NULL; } int main(int argc, char ** argv) { int k; const struct sdparm_transport_pair * tp; const struct sdparm_vendor_pair * vp; const char * ccp; printf(" Check integrity of mode page item tables in sdparm\n"); printf(" ==================================================\n\n"); printf("Generic (i.e. non-transport specific) mode page items:\n"); check(sdparm_mitem_arr, NULL); printf("\n"); tp = sdparm_transport_mp; for (k = 0; k < 16; ++k, ++tp) { if (tp->mitem) { printf("%s mode page items:\n", sdparm_transport_id[k].name); check(tp->mitem, NULL); printf("\n"); } } vp = sdparm_vendor_mp; for (k = 0; k < sdparm_vendor_mp_len; ++k, ++vp) { if (vp->mitem) { ccp = get_vendor_name(k); if (ccp) printf("%s mode page items:\n", ccp); else printf("0x%x mode page items:\n", k); check(vp->mitem, NULL); printf("\n"); } } printf("Cross check Generic with SAS mode page items:\n"); check(sdparm_mitem_arr, sdparm_transport_mp[6].mitem); return 0; } sdparm-1.08/scripts/0000755000175000017500000000000012155115504013412 5ustar douggdouggsdparm-1.08/scripts/Makefile.in0000664000175000017500000003122612144501012015454 0ustar douggdougg# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = scripts DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in 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) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(bindir)" SCRIPTS = $(bin_SCRIPTS) SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETOPT_O_FILES = @GETOPT_O_FILES@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SGUTILS_LIBS = @SGUTILS_LIBS@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ os_deps = @os_deps@ os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @OS_FREEBSD_TRUE@bin_SCRIPTS = sas_disk_blink @OS_LINUX_TRUE@bin_SCRIPTS = sas_disk_blink scsi_ch_swp @OS_OSF_TRUE@bin_SCRIPTS = sas_disk_blink @OS_SOLARIS_TRUE@bin_SCRIPTS = sas_disk_blink @OS_WIN32_CYGWIN_TRUE@bin_SCRIPTS = sas_disk_blink @OS_WIN32_MINGW_TRUE@bin_SCRIPTS = sas_disk_blink all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n' \ -e 'h;s|.*|.|' \ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) { files[d] = files[d] " " $$1; \ if (++n[d] == $(am__install_max)) { \ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ else { print "f", d "/" $$4, $$1 } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(SCRIPTS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binSCRIPTS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binSCRIPTS .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-binSCRIPTS install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am uninstall uninstall-am uninstall-binSCRIPTS # 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. .NOEXPORT: sdparm-1.08/scripts/README0000664000175000017500000000114411244656704014306 0ustar douggdougg README for sdparm/scripts ========================= Introduction ============ This directory contains bash shell scripts. Currently there is only one. It assumes the sdparm executable is on the PATH of the user. Details ======= Each script supplies more information, typically by supplying a '-h' or '--help' option. The script source often contains explanatory information. Following is a usage summary with a one line description: sas_disk_blink [-h] [-s ] - blink LED on using RLM (Ready LED Meaning) bit Douglas Gilbert 11th August 2009 sdparm-1.08/scripts/scsi_ch_swp0000775000175000017500000000777412154112737015671 0ustar douggdougg#!/bin/bash # scsi_ch_swp # # Script to change the Software Read Protect (SWP) state of a disk in Linux. # When '-s ' (or '--set ') is not given then read SWP state. # # Uses sdparm and blockdev utilities. # # Douglas Gilbert 20130606 rdonly="--readonly" swp="-1" verbose="" bdverbose="" usage() { echo "Usage: scsi_ch_swp [-h] [-s 0|1] [-v] [-w] " echo " where:" echo " -h, --help print usage message" echo " -s 0|1, --set 0|1 where:" echo " 0 - clear SWP and set RW mode" echo " 1 - set SWP and set RO mode" echo " (default: read SWP and get RO flag)" echo " -v, --verbose more verbose, show commands invoked" echo " -w, --wr access read-write when '-s 0'" echo " (default: access read-only in this case)" echo "" echo "Access the Software Write Protect (SWP) bit in the SCSI control" echo "mode page and if changed adjust the Linux block device (e.g." echo "/dev/sdc) settings accordingly. If supported, when the SWP bit" echo "is set (1) the device is read-only; when clear (0) the device" echo "is read-write (i.e. its contents can be read and changed)." echo "When no options given it reads SWP and gets blockdev's RO flag." } opt="$1" while test ! -z "$opt" -a -z "${opt##-*}"; do opt=${opt#-} case "$opt" in h|-help) usage ; exit 0 ;; s|-set) shift ; let swp=$1 ;; v|-verbose) verbose="-v" ;; w|-wr) rdonly="" ;; vv) verbose="-vv" ;; vvv) verbose="-vvv" ;; *) echo "Unknown option: -$opt " ; exit 1 ;; esac shift opt="$1" done if [ $# -lt 1 ] ; then echo "Need at least a argument." echo "" usage exit 1 fi if [ ${verbose} ] ; then bdverbose="-v" fi if ( which sdparm >/dev/null 2>&1 ) ; then true else echo "sdparm not found" sdparm ${rdonly} ${verbose} fi if ( which blockdev >/dev/null 2>&1 ) ; then true else echo "blockdev not found" blockdev fi if [ $swp -lt 0 ] ; then if [ ${verbose} ] ; then echo sdparm --quiet ${rdonly} ${verbose} --get=SWP=1 $1 fi sdparm --quiet ${rdonly} ${verbose} --get=SWP=1 $1 if [ ${bdverbose} ] ; then echo "blockdev --getro ${bdverbose} $1" fi echo -n "blockdev's RO flag: " blockdev --getro ${bdverbose} $1 elif [ $swp = "0" ] ; then if [ ${verbose} ] ; then echo sdparm --quiet ${rdonly} ${verbose} --clear=SWP $1 fi sdparm --quiet ${rdonly} ${verbose} --clear=SWP $1 res=$? if [ $res -ne 0 ] ; then exit $res fi if [ ${bdverbose} ] ; then echo blockdev --setrw ${bdverbose} $1 fi blockdev --setrw ${bdverbose} $1 # res=$? # if [ $res -ne 0 ] ; then # exit $res # fi ## There is still some uncertainity whether calling blockdev --rereadpt ## is needed or defeats this operation. Feedback please. # # Need to re-read partition table before --setro takes effect # if [ ${bdverbose} ] ; then # echo blockdev --rereadpt ${bdverbose} $1 # fi # blockdev --rereadpt ${bdverbose} $1 elif [ $swp = "1" ] ; then if [ ${verbose} ] ; then echo sdparm --quiet ${verbose} --set=SWP $1 fi sdparm --quiet ${verbose} --set=SWP $1 res=$? if [ $res -ne 0 ] ; then exit $res fi if [ ${bdverbose} ] ; then echo blockdev --setro ${bdverbose} $1 fi blockdev --setro ${bdverbose} $1 # res=$? # if [ $res -ne 0 ] ; then # exit $res # fi ## There is still some uncertainity whether calling blockdev --rereadpt ## is needed or defeats this operation. Feedback please. # # Need to re-read partition table before --setrw takes effect # if [ ${bdverbose} ] ; then # echo blockdev --rereadpt ${bdverbose} $1 # fi # blockdev --rereadpt ${bdverbose} $1 else echo "option --set ${swp} is invalid" exit 1 fi sdparm-1.08/scripts/Makefile.am0000664000175000017500000000050712144501012015441 0ustar douggdougg if OS_LINUX bin_SCRIPTS = sas_disk_blink scsi_ch_swp endif if OS_WIN32_MINGW bin_SCRIPTS = sas_disk_blink endif if OS_WIN32_CYGWIN bin_SCRIPTS = sas_disk_blink endif if OS_FREEBSD bin_SCRIPTS = sas_disk_blink endif if OS_SOLARIS bin_SCRIPTS = sas_disk_blink endif if OS_OSF bin_SCRIPTS = sas_disk_blink endif sdparm-1.08/scripts/sas_disk_blink0000775000175000017500000000502112144501012016306 0ustar douggdougg#!/bin/bash # sas_disk_blink # # Script to blink the LED on a SAS disk. # By default it blinks the LED for 30 seconds, thereafter leaving # the LED in the state it was prior to this command being called. # The blink is one second on, one second off, etc. # # Uses sdparm rather than sg3_utils as the former is simpler to # use for setting mode page value. # # Douglas Gilbert 20130513 seconds=30 verbose="" usage() { echo "Usage: sas_disk_blink [-h] [-s ] [-v] " echo " where:" echo " -h, --help print usage message" echo " -s , --set where is:" echo " 0 - set RLM to 0" echo " 1 - set RLM to 1" echo " >1 - blink LED for seconds" echo " (default: blink for 30 seconds)" echo " -v, --verbose more verbose output" echo "" echo "Use Ready LED Meaning (RLM) mode page field to blink SAS device LED" } opt="$1" while test ! -z "$opt" -a -z "${opt##-*}"; do opt=${opt#-} case "$opt" in h|-help) usage ; exit 0 ;; s|-set) shift ; let seconds=$1 ;; v|-verbose) verbose="-v" ;; vv) verbose="-vv" ;; vvv) verbose="-vvv" ;; *) echo "Unknown option: -$opt " ; exit 1 ;; esac shift opt="$1" done if [ $# -lt 1 ] then usage exit 1 fi if ( which sdparm >/dev/null 2>&1 ) ; then true else echo "sdparm not found" sdparm fi if [ $seconds = "0" ] then sdparm ${verbose} -t sas -c RLM $1 exit $? elif [ $seconds = "1" ] then sdparm ${verbose} -t sas -s RLM $1 exit $? elif [ $seconds -gt 1 ] then outt=$(sdparm ${verbose} -t sas -g RLM -H $1) let res=$? if [ $res -ne 0 ] then exit $res fi if [ ${outt:0:4} = "0x00" ] then let start=0 else let start=1 fi echo "start blinking for $seconds seconds" for (( times = 1; times < $seconds; times=$times+2 )); do if [ $start -eq 0 ] then sdparm ${verbose} -q -t sas -s RLM $1 let res=$? if [ $res -ne 0 ] then exit $res fi sleep 1 sdparm ${verbose} -q -t sas -c RLM $1 sleep 1 else sdparm ${verbose} -q -t sas -c RLM $1 let res=$? if [ $res -ne 0 ] then exit $res fi sleep 1 sdparm ${verbose} -q -t sas -s RLM $1 sleep 1 fi done echo "stop blinking" fi sdparm-1.08/notes.txt0000664000175000017500000000516310675764600013637 0ustar douggdouggThe sdparm utility uses the MODE SENSE SCSI command to read device parameters and the MODE SELECT SCSI command to change them. CD/DVD drives (and their media) have a large amount of information that either the user can't change or are characteristics of the media. The MMC set has a GET CONFIGURATION SCSI command to fetch information (basically capabilities) that the user is not able to change. To read this information see the sg_get_config utility in the sg3_utils package. Earlier versions of MMC put information in the "CD/DVD (MM) capabilities and mechanical status" mode page that is now found in the GET CONFIGURATION feature and profile pages. The sdparm utility shows the CD/DVD capabilities and mechanical status mode page which has information up to about "DVD-R" vintage. Thereafter, (MMC-4 and MMC-5) information about "DVD+R" and later (e.g. BD and HD-DVD) are in feature and profile pages fetched with the GET CONFIGURATION command. There is a C program called chk_sdparm_data.c in the src directory for checking the integrity of the mode items in the sdparm_data.c file. A simple example for building chk_sdparm_data is given inside the source file. The sdparm_data.c file only needs to be checked for integrity after new mode page items are added or changed. The linux hdparm utility is usually found in the /sbin and sometimes in the /usr/sbin directory. That location is not usually on the PATH of a non-root user. Since hdparm is mainly used on disks, this is an appropriate place. Currently in Linux sdparm is placed in the /usr/bin directory (by the sdparm.spec file) or /usr/local/bin (by 'make install' when not overridden by option given to "./configure"). This allows both root and non-root users to access sdparm. Permissions on SCSI disks devices should be sufficient to stop a non-root user changing parameters unless they have both read and write permissions. Non-root users should be able read SCSI disk (or other device) parameters if they have read permissions on the appropriate device. A typical SCSI disk has permissions like this: # ls -l /dev/sda brw-r----- 1 root disk 8, 0 Jul 28 2005 /dev/sda There are also CD/DVD drives to consider. Many distributions give non-root (GUI) users permissions (and indeed ownership) of these devices. This allows users to "burn" CDs and DVDs. Almost all CD/DVD drives use MMC which is a SCSI command set. Hence sdparm is appropriate to read and change parameters on CD/DVD drives. A typical (ATAPI transport) CD/DVD drive has permissions like this (where "fred" is the GUI user): # ls -l /dev/hdc brw------- 1 fred disk 22, 0 Jul 28 2005 /dev/hdc Doug Gilbert 24th September 2007 sdparm-1.08/configure.ac0000664000175000017500000000645312144501012014212 0ustar douggdouggAC_INIT(sdparm, 1.08, dgilbert@interlog.com) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h) AC_PROG_CC # AC_PROG_CXX AC_PROG_INSTALL # check for headers AC_HEADER_STDC AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [], [[#ifdef HAVE_LINUX_TYPES_H # include #endif ]]) AC_CHECK_FUNCS(getopt_long, GETOPT_O_FILES='', GETOPT_O_FILES='getopt_long.o') AC_SUBST(GETOPT_O_FILES) AC_CANONICAL_HOST AC_DEFINE_UNQUOTED(SG_LIB_BUILD_HOST, "${host}", [sdparm Build Host]) case "${host}" in *-*-linux-gnu*) AC_SUBST([os_deps], ['sg_pt_linux.o']) AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sdparm on linux]) AC_SUBST([os_libs], ['']) ;; *-*-linux*) AC_SUBST([os_deps], ['sg_pt_linux.o']) AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sdparm on linux]) AC_SUBST([os_libs], ['']) ;; *-*-freebsd*|*-*-kfreebsd*-gnu*) AC_SUBST([os_deps], ['sg_pt_freebsd.o']) AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sdparm on FreeBSD]) AC_SUBST([os_libs], ['-lcam']);; *-*-solaris*) AC_SUBST([os_deps], ['sg_pt_solaris.o']) AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sdparm on Solaris]) AC_SUBST([os_libs], ['']);; *-*-osf*) AC_SUBST([os_deps], ['sg_pt_osf1.o']) AC_DEFINE_UNQUOTED(SG_LIB_OSF1, 1, [sdparm on Tru64 UNIX]) AC_SUBST([os_libs], ['']) ;; *-*-cygwin*) AC_SUBST([os_deps], ['sg_pt_win32.o']) AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sdparm on Win32]) AC_DEFINE_UNQUOTED(WIN32_SPT_DIRECT, 1, [allow large buffers, aligned?]) AC_SUBST([os_libs], ['']) ;; *-*-mingw*) AC_SUBST([os_deps], ['sg_pt_win32.o']) AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sdparm on Win32]) AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment]) AC_DEFINE_UNQUOTED(WIN32_SPT_DIRECT, 1, [allow large buffers, aligned?]) AC_SUBST([os_libs], ['']) ;; *) AC_SUBST([os_deps], ['sg_pt_linux.o']) AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [assume sdparm on linux]) AC_SUBST([os_libs], ['']) ;; esac # Define platform-specific symbol. AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep 'freebsd' > /dev/null]) AM_CONDITIONAL(OS_LINUX, [echo $host_os | grep '^linux' > /dev/null]) AM_CONDITIONAL(OS_OSF, [echo $host_os | grep '^osf' > /dev/null]) AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null]) AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null]) AM_CONDITIONAL(OS_WIN32_CYGWIN, [echo $host_os | grep '^cygwin' > /dev/null]) AC_ARG_ENABLE([linuxbsg], AC_HELP_STRING([--disable-linuxbsg], [ignore linux bsg (sgv4) if present]), [AC_DEFINE_UNQUOTED(IGNORE_LINUX_BSG, 1, [ignore linux bsg], )], []) AC_CHECK_LIB(sgutils2, sg_ll_inquiry, [SGUTILS_LIBS="-lsgutils2"; have_sgutils=yes], have_sgutils=no) AC_SUBST(SGUTILS_LIBS) AM_CONDITIONAL(HAVE_SGUTILS, test x"$have_sgutils" = xyes) AC_ARG_ENABLE([scsistrings], [AS_HELP_STRING([--disable-scsistrings], [Disable full SCSI sense strings])], [], [AC_DEFINE_UNQUOTED(SG_SCSI_STRINGS, 1, [full SCSI sense strings], )]) # AC_PROG_LIBTOOL AC_OUTPUT(Makefile src/Makefile doc/Makefile scripts/Makefile) sdparm-1.08/configure0000775000175000017500000050674112144501012013640 0ustar douggdougg#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for sdparm 1.08. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" 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 \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: dgilbert@interlog.com about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` 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" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS 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. 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 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO 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'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" 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, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sdparm' PACKAGE_TARNAME='sdparm' PACKAGE_VERSION='1.08' PACKAGE_STRING='sdparm 1.08' PACKAGE_BUGREPORT='dgilbert@interlog.com' PACKAGE_URL='' ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS HAVE_SGUTILS_FALSE HAVE_SGUTILS_TRUE SGUTILS_LIBS OS_WIN32_CYGWIN_FALSE OS_WIN32_CYGWIN_TRUE OS_WIN32_MINGW_FALSE OS_WIN32_MINGW_TRUE OS_SOLARIS_FALSE OS_SOLARIS_TRUE OS_OSF_FALSE OS_OSF_TRUE OS_LINUX_FALSE OS_LINUX_TRUE OS_FREEBSD_FALSE OS_FREEBSD_TRUE os_libs os_deps host_os host_vendor host_cpu host build_os build_vendor build_cpu build GETOPT_O_FILES EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_maintainer_mode enable_dependency_tracking enable_linuxbsg enable_scsistrings ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) 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" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) 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" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) 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" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) 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" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --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" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # 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'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` 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" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. 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 do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac 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' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- 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" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no 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" 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" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # 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 sdparm 1.08 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --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 --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 --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --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] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/sdparm] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --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 sdparm 1.08:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-linuxbsg ignore linux bsg (sgv4) if present --disable-scsistrings Disable full SCSI sense strings Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory 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. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF sdparm configure 1.08 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" 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_compile") 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; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; 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_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_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 # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext 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>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; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. 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_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly 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 \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext 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_func 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 sdparm $as_me 1.08, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. 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 elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $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; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $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 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## 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__api_version='1.11' 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 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 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) 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;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # 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 alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else 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 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. 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` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; 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_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # 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_STRIP="${ac_tool_prefix}strip" $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 STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; 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_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_STRIP="strip" $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_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" 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 STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk 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_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # 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_AWK="$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 AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $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 \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # 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;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." 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 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='sdparm' VERSION='1.08' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. 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}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' { $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. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE ac_config_headers="$ac_config_headers config.h" 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 if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; 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_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # 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_CC="${ac_tool_prefix}gcc" $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 CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; 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_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_CC="gcc" $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_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" 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 CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; 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_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # 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_CC="${ac_tool_prefix}cc" $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 CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; 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_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no 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 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $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 if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe 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_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # 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_CC="$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 CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe 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_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_CC="$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_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" 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 CC=$ac_ct_CC fi fi 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; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" 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_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" 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_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 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; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } 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; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac 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; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { 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; } if { ac_try='./conftest$ac_cv_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 cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes 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. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" 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_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 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; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : 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 DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # AC_PROG_CXX # check for headers 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 for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H # include #endif " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getopt_long do : ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long" if test "x$ac_cv_func_getopt_long" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETOPT_LONG 1 _ACEOF GETOPT_O_FILES='' else GETOPT_O_FILES='getopt_long.o' fi done # 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 cat >>confdefs.h <<_ACEOF #define SG_LIB_BUILD_HOST "${host}" _ACEOF case "${host}" in *-*-linux-gnu*) os_deps='sg_pt_linux.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_LINUX 1 _ACEOF os_libs='' ;; *-*-linux*) os_deps='sg_pt_linux.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_LINUX 1 _ACEOF os_libs='' ;; *-*-freebsd*|*-*-kfreebsd*-gnu*) os_deps='sg_pt_freebsd.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_FREEBSD 1 _ACEOF os_libs='-lcam' ;; *-*-solaris*) os_deps='sg_pt_solaris.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_SOLARIS 1 _ACEOF os_libs='' ;; *-*-osf*) os_deps='sg_pt_osf1.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_OSF1 1 _ACEOF os_libs='' ;; *-*-cygwin*) os_deps='sg_pt_win32.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_WIN32 1 _ACEOF cat >>confdefs.h <<_ACEOF #define WIN32_SPT_DIRECT 1 _ACEOF os_libs='' ;; *-*-mingw*) os_deps='sg_pt_win32.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_WIN32 1 _ACEOF cat >>confdefs.h <<_ACEOF #define SG_LIB_MINGW 1 _ACEOF cat >>confdefs.h <<_ACEOF #define WIN32_SPT_DIRECT 1 _ACEOF os_libs='' ;; *) os_deps='sg_pt_linux.o' cat >>confdefs.h <<_ACEOF #define SG_LIB_LINUX 1 _ACEOF os_libs='' ;; esac # Define platform-specific symbol. if echo $host_os | grep 'freebsd' > /dev/null; then OS_FREEBSD_TRUE= OS_FREEBSD_FALSE='#' else OS_FREEBSD_TRUE='#' OS_FREEBSD_FALSE= fi if echo $host_os | grep '^linux' > /dev/null; then OS_LINUX_TRUE= OS_LINUX_FALSE='#' else OS_LINUX_TRUE='#' OS_LINUX_FALSE= fi if echo $host_os | grep '^osf' > /dev/null; then OS_OSF_TRUE= OS_OSF_FALSE='#' else OS_OSF_TRUE='#' OS_OSF_FALSE= fi if echo $host_os | grep '^solaris' > /dev/null; then OS_SOLARIS_TRUE= OS_SOLARIS_FALSE='#' else OS_SOLARIS_TRUE='#' OS_SOLARIS_FALSE= fi if echo $host_os | grep '^mingw' > /dev/null; then OS_WIN32_MINGW_TRUE= OS_WIN32_MINGW_FALSE='#' else OS_WIN32_MINGW_TRUE='#' OS_WIN32_MINGW_FALSE= fi if echo $host_os | grep '^cygwin' > /dev/null; then OS_WIN32_CYGWIN_TRUE= OS_WIN32_CYGWIN_FALSE='#' else OS_WIN32_CYGWIN_TRUE='#' OS_WIN32_CYGWIN_FALSE= fi # Check whether --enable-linuxbsg was given. if test "${enable_linuxbsg+set}" = set; then : enableval=$enable_linuxbsg; cat >>confdefs.h <<_ACEOF #define IGNORE_LINUX_BSG 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sg_ll_inquiry in -lsgutils2" >&5 $as_echo_n "checking for sg_ll_inquiry in -lsgutils2... " >&6; } if ${ac_cv_lib_sgutils2_sg_ll_inquiry+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsgutils2 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sg_ll_inquiry (); int main () { return sg_ll_inquiry (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_sgutils2_sg_ll_inquiry=yes else ac_cv_lib_sgutils2_sg_ll_inquiry=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sgutils2_sg_ll_inquiry" >&5 $as_echo "$ac_cv_lib_sgutils2_sg_ll_inquiry" >&6; } if test "x$ac_cv_lib_sgutils2_sg_ll_inquiry" = xyes; then : SGUTILS_LIBS="-lsgutils2"; have_sgutils=yes else have_sgutils=no fi if test x"$have_sgutils" = xyes; then HAVE_SGUTILS_TRUE= HAVE_SGUTILS_FALSE='#' else HAVE_SGUTILS_TRUE='#' HAVE_SGUTILS_FALSE= fi # Check whether --enable-scsistrings was given. if test "${enable_scsistrings+set}" = set; then : enableval=$enable_scsistrings; else cat >>confdefs.h <<_ACEOF #define SG_SCSI_STRINGS 1 _ACEOF fi # AC_PROG_LIBTOOL ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile scripts/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' 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$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then 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. 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. 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. 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. 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. 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. 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. 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. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_SGUTILS_TRUE}" && test -z "${HAVE_SGUTILS_FALSE}"; then as_fn_error $? "conditional \"HAVE_SGUTILS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS 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. 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 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` 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" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by sdparm $as_me 1.08, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ sdparm config.status 1.08 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. 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 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $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;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' 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' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_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 '^'` 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 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 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || 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 # 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/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "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'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_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 $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;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_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 "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false 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 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 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi sdparm-1.08/aclocal.m40000664000175000017500000011036412062455663013604 0ustar douggdougg# generated automatically by aclocal 1.11.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. 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'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 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. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # 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.11' 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.11.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 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. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # 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` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # 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. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 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. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # 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. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # 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. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 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. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. 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 _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) 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 dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 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. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 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. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, # 2011 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. # serial 5 # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless `enable' is passed literally. # For symmetry, `disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful (and sometimes confusing) to the casual installer], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 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. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # 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. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 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. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 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. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # 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. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # 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". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005, 2011 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. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 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. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 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. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR sdparm-1.08/missing0000775000175000017500000002415212025134440013324 0ustar douggdougg#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally 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 # 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. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # 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" 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 ;; -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. 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' autom4te touch the output file, or create a stub one 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 yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # 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). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) 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 $program 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 "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 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 test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -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 test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -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 "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? 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 "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 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 # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) 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 exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: sdparm-1.08/Makefile.am0000664000175000017500000000013312144501012013745 0ustar douggdouggSUBDIRS = src doc scripts EXTRA_DIST=autogen.sh distclean-local: rm -rf autom4te.cache sdparm-1.08/CREDITS0000664000175000017500000000124010732247151012745 0ustar douggdouggThe author of sdparm would like to thank the following people who have made contributions: Bryan Henderson < bryanh at giraffe-data dot com > add old power condition page (0xd); sg device mapping in lk 2.4 series fixes [20061113] Hayashi Naoyuki port to Tru64 [20060127] Joe Krahn help with int64_t cleanup [20071219] Kai Makisara for tape mode pages and interface usability suggestions [20050517] Luben Tuikov help with documentation and other suggestions [20061014] Doug Gilbert 19th December 2007 sdparm-1.08/NEWS0000664000175000017500000000000010640274765012426 0ustar douggdouggsdparm-1.08/depcomp0000775000175000017500000005064312062455663013324 0ustar douggdougg#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2012-03-27.16; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011, 2012 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 # 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. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. 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 outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # A tabulation character. tab=' ' # A newline character. nl=' ' 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 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # 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 # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # 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 informations. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## 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. ## 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 rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## 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). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else 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. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## 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 ' ' "$nl" < "$tmpdepfile" | ## 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. 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 "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # 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 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" 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 # dependency line. 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 ' ' "$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" 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 # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. 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 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 $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # 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,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$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 "$tmpdepfile" ;; icc) # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. # However on # $CC -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 # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\': # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... # tcc 0.9.26 (FIXME still under development at the moment of writing) # will emit a similar output, but also prepend the continuation lines # with horizontal tabulation characters. "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form 'foo.o: dependent.h', # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. # Do two passes, one to just change these to # '$object: dependent.h' and one to simply 'dependent.h:'. sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ < "$tmpdepfile" > "$depfile" sed ' s/[ '"$tab"'][ '"$tab"']*/ /g s/^ *// s/ *\\*$// s/^[^:]*: *// /^$/d /:$/d s/$/ :/ ' < "$tmpdepfile" >> "$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. 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 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 -eq 0; then : else 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,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#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 mechanism 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 $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 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" sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -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" = 0; then : else 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" 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 # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # 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. "$@" $dashmflag | sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' "$nl" < "$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" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift 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/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$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" sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ ## 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" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # 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 # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -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" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # 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 "$@" "$arg" shift shift ;; esac done "$@" -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" 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 "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: sdparm-1.08/include/0000755000175000017500000000000012155115504013346 5ustar douggdouggsdparm-1.08/include/sg_cmds_basic.h0000664000175000017500000003150112113731552016302 0ustar douggdougg#ifndef SG_CMDS_BASIC_H #define SG_CMDS_BASIC_H /* * Copyright (c) 2004-2013 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. */ /* * Error, warning and verbose output is sent to the file pointed to by * sg_warnings_strm which is declared in sg_lib.h and can be set with * the sg_set_warnings_strm() function. If not given sg_warnings_strm * defaults to stderr. * If 'noisy' and 'verbose' are both zero then following functions should * not output anything to sg_warnings_strm. If 'noisy' is non-zero and * 'verbose' is zero then Unit Attention, Recovered, Medium and Hardware * errors (sense keys) send output to sg_warnings_strm. Increasing values * of 'verbose' send increasing amounts of (debug) output to * sg_warnings_strm. */ #ifdef __cplusplus extern "C" { #endif /* Invokes a SCSI INQUIRY command and yields the response * Returns 0 when successful, SG_LIB_CAT_INVALID_OP -> not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other errors */ extern int sg_ll_inquiry(int sg_fd, int cmddt, int evpd, int pg_op, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI LOG SELECT command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Log Select not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, * -1 -> other failure */ extern int sg_ll_log_select(int sg_fd, int pcr, int sp, int pc, int pg_code, int subpg_code, unsigned char * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI LOG SENSE command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Log Sense not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_log_sense(int sg_fd, int ppc, int sp, int pc, int pg_code, int subpg_code, int paramp, unsigned char * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI MODE SELECT (6) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_mode_select6(int sg_fd, int pf, int sp, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI MODE SELECT (10) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_mode_select10(int sg_fd, int pf, int sp, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI MODE SENSE (6) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_mode_sense6(int sg_fd, int dbd, int pc, int pg_code, int sub_pg_code, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI MODE SENSE (10) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_ILLEGAL_REQ -> * bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_mode_sense10(int sg_fd, int llbaa, int dbd, int pc, int pg_code, int sub_pg_code, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI PREVENT ALLOW MEDIUM REMOVAL command (SPC-3) * prevent==0 allows removal, prevent==1 prevents removal ... * Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> command not supported * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_prevent_allow(int sg_fd, int prevent, int noisy, int verbose); /* Invokes a SCSI READ CAPACITY (10) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_UNIT_ATTENTION * -> perhaps media changed, SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_readcap_10(int sg_fd, int pmi, unsigned int lba, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI READ CAPACITY (16) command. Returns 0 -> success, * SG_LIB_CAT_UNIT_ATTENTION -> media changed??, SG_LIB_CAT_INVALID_OP * -> cdb not supported, SG_LIB_CAT_IlLEGAL_REQ -> bad field in cdb * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_readcap_16(int sg_fd, int pmi, uint64_t llba, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI REPORT LUNS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Luns not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_NOT_READY (shouldn't happen), -1 -> other failure */ extern int sg_ll_report_luns(int sg_fd, int select_report, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI REQUEST SENSE command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Request Sense not supported??, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_request_sense(int sg_fd, int desc, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI START STOP UNIT command (SBC + MMC). * Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Start stop unit not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure * SBC-3 and MMC partially overlap on the power_condition_modifier(sbc) and * format_layer_number(mmc) fields. They also overlap on the noflush(sbc) * and fl(mmc) one bit field. This is the cause of the awkardly named * pc_mod__fl_num and noflush__fl arguments to this function. */ extern int sg_ll_start_stop_unit(int sg_fd, int immed, int pc_mod__fl_num, int power_cond, int noflush__fl, int loej, int start, int noisy, int verbose); /* Invokes a SCSI SYNCHRONIZE CACHE (10) command. Return of 0 -> success, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_INVALID_OP -> cdb not supported, * SG_LIB_CAT_IlLEGAL_REQ -> bad field in cdb * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ extern int sg_ll_sync_cache_10(int sg_fd, int sync_nv, int immed, int group, unsigned int lba, unsigned int count, int noisy, int verbose); /* Invokes a SCSI TEST UNIT READY command. * 'pack_id' is just for diagnostics, safe to set to 0. * Return of 0 -> success, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */ extern int sg_ll_test_unit_ready(int sg_fd, int pack_id, int noisy, int verbose); /* Invokes a SCSI TEST UNIT READY command. * 'pack_id' is just for diagnostics, safe to set to 0. * Looks for progress indicator if 'progress' non-NULL; * if found writes value [0..65535] else write -1. * Return of 0 -> success, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_NOT_READY -> * device not ready, -1 -> other failure */ extern int sg_ll_test_unit_ready_progress(int sg_fd, int pack_id, int * progress, int noisy, int verbose); struct sg_simple_inquiry_resp { unsigned char peripheral_qualifier; unsigned char peripheral_type; unsigned char rmb; unsigned char version; /* as per recent drafts: whole of byte 2 */ unsigned char byte_3; unsigned char byte_5; unsigned char byte_6; unsigned char byte_7; char vendor[9]; char product[17]; char revision[5]; }; /* Yields most of first 36 bytes of a standard INQUIRY (evpd==0) response. * Returns 0 when successful, SG_LIB_CAT_INVALID_OP -> not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other errors */ extern int sg_simple_inquiry(int sg_fd, struct sg_simple_inquiry_resp * inq_data, int noisy, int verbose); /* MODE SENSE commands yield a response that has block descriptors followed * by mode pages. In most cases users are interested in the first mode page. * This function returns the (byte) offset of the start of the first mode * page. Set mode_sense_6 to 1 for MODE SENSE (6) and 0 for MODE SENSE (10). * Returns >= 0 is successful or -1 if failure. If there is a failure * a message is written to err_buff. */ extern int sg_mode_page_offset(const unsigned char * resp, int resp_len, int mode_sense_6, char * err_buff, int err_buff_len); /* Fetches current, changeable, default and/or saveable modes pages as * indicated by pcontrol_arr for given pg_code and sub_pg_code. If * mode6==0 then use MODE SENSE (10) else use MODE SENSE (6). If * flexible set and mode data length seems wrong then try and * fix (compensating hack for bad device or driver). pcontrol_arr * should have 4 elements for output of current, changeable, default * and saved values respectively. Each element should be NULL or * at least mx_mpage_len bytes long. * Return of 0 -> overall success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, * SG_LIB_CAT_MALFORMED -> bad response, -1 -> other failure. * If success_mask pointer is not NULL then first zeros it. Then set bits * 0, 1, 2 and/or 3 if the current, changeable, default and saved values * respectively have been fetched. If error on current page * then stops and returns that error; otherwise continues if an error is * detected but returns the first error encountered. */ extern int sg_get_mode_page_controls(int sg_fd, int mode6, int pg_code, int sub_pg_code, int dbd, int flexible, int mx_mpage_len, int * success_mask, void * pcontrol_arr[], int * reported_len, int verbose); /* Returns file descriptor >= 0 if successful. If error in Unix returns negated errno. Implementation calls scsi_pt_open_device(). */ extern int sg_cmds_open_device(const char * device_name, int read_only, int verbose); /* Returns file descriptor >= 0 if successful. If error in Unix returns negated errno. Implementation calls scsi_pt_open_flags(). */ extern int sg_cmds_open_flags(const char * device_name, int flags, int verbose); /* Returns 0 if successful. If error in Unix returns negated errno. Implementation calls scsi_pt_close_device(). */ extern int sg_cmds_close_device(int device_fd); extern const char * sg_cmds_version(); struct sg_pt_base; /* This is a helper function used by sg_cmds_* implementations after * the call to the pass-through. pt_res is returned from do_scsi_pt(). * If valid sense data is found it is decoded and output to sg_warnings_strm * (def: stderr); depending on the 'noisy' and 'verbose' settings. * Returns -2 for sense data (may not be fatal), -1 for failed or the * number of data in bytes received. For data out (to device) or no data, * set 'mx_di_len' to 0 or less. If -2 returned then sense category * output via 'o_sense_cat' pointer (if not NULL). Note that several sense * categories also have data in bytes received; -2 is still returned. */ extern int sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin, int pt_res, int mx_di_len, const unsigned char * sense_b, int noisy, int verbose, int * o_sense_cat); #ifdef __cplusplus } #endif #endif sdparm-1.08/include/Makefile.in0000664000175000017500000004145712061266052015431 0ustar douggdougg# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = include DIST_COMMON = $(am__noinst_HEADERS_DIST) \ $(am__scsiinclude_HEADERS_DIST) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in 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) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__noinst_HEADERS_DIST = sg_linux_inc.h sg_io_linux.h sg_pt_win32.h am__scsiinclude_HEADERS_DIST = sg_lib.h sg_lib_data.h sg_cmds.h \ sg_cmds_basic.h sg_cmds_extra.h sg_cmds_mmc.h sg_pt.h \ sg_linux_inc.h sg_io_linux.h sg_pt_win32.h am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(scsiincludedir)" HEADERS = $(noinst_HEADERS) $(scsiinclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GETOPT_O_FILES = @GETOPT_O_FILES@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ 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@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ scsiincludedir = $(includedir)/scsi @OS_FREEBSD_TRUE@scsiinclude_HEADERS = \ @OS_FREEBSD_TRUE@ sg_lib.h \ @OS_FREEBSD_TRUE@ sg_lib_data.h \ @OS_FREEBSD_TRUE@ sg_cmds.h \ @OS_FREEBSD_TRUE@ sg_cmds_basic.h \ @OS_FREEBSD_TRUE@ sg_cmds_extra.h \ @OS_FREEBSD_TRUE@ sg_cmds_mmc.h \ @OS_FREEBSD_TRUE@ sg_pt.h @OS_LINUX_TRUE@scsiinclude_HEADERS = \ @OS_LINUX_TRUE@ sg_lib.h \ @OS_LINUX_TRUE@ sg_lib_data.h \ @OS_LINUX_TRUE@ sg_cmds.h \ @OS_LINUX_TRUE@ sg_cmds_basic.h \ @OS_LINUX_TRUE@ sg_cmds_extra.h \ @OS_LINUX_TRUE@ sg_cmds_mmc.h \ @OS_LINUX_TRUE@ sg_pt.h \ @OS_LINUX_TRUE@ sg_linux_inc.h \ @OS_LINUX_TRUE@ sg_io_linux.h @OS_OSF_TRUE@scsiinclude_HEADERS = \ @OS_OSF_TRUE@ sg_lib.h \ @OS_OSF_TRUE@ sg_lib_data.h \ @OS_OSF_TRUE@ sg_cmds.h \ @OS_OSF_TRUE@ sg_cmds_basic.h \ @OS_OSF_TRUE@ sg_cmds_extra.h \ @OS_OSF_TRUE@ sg_cmds_mmc.h \ @OS_OSF_TRUE@ sg_pt.h @OS_SOLARIS_TRUE@scsiinclude_HEADERS = \ @OS_SOLARIS_TRUE@ sg_lib.h \ @OS_SOLARIS_TRUE@ sg_lib_data.h \ @OS_SOLARIS_TRUE@ sg_cmds.h \ @OS_SOLARIS_TRUE@ sg_cmds_basic.h \ @OS_SOLARIS_TRUE@ sg_cmds_extra.h \ @OS_SOLARIS_TRUE@ sg_cmds_mmc.h \ @OS_SOLARIS_TRUE@ sg_pt.h @OS_WIN32_CYGWIN_TRUE@scsiinclude_HEADERS = \ @OS_WIN32_CYGWIN_TRUE@ sg_lib.h \ @OS_WIN32_CYGWIN_TRUE@ sg_lib_data.h \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds.h \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_basic.h \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_extra.h \ @OS_WIN32_CYGWIN_TRUE@ sg_cmds_mmc.h \ @OS_WIN32_CYGWIN_TRUE@ sg_pt.h \ @OS_WIN32_CYGWIN_TRUE@ sg_pt_win32.h @OS_WIN32_MINGW_TRUE@scsiinclude_HEADERS = \ @OS_WIN32_MINGW_TRUE@ sg_lib.h \ @OS_WIN32_MINGW_TRUE@ sg_lib_data.h \ @OS_WIN32_MINGW_TRUE@ sg_cmds.h \ @OS_WIN32_MINGW_TRUE@ sg_cmds_basic.h \ @OS_WIN32_MINGW_TRUE@ sg_cmds_extra.h \ @OS_WIN32_MINGW_TRUE@ sg_cmds_mmc.h \ @OS_WIN32_MINGW_TRUE@ sg_pt.h \ @OS_WIN32_MINGW_TRUE@ sg_pt_win32.h @OS_FREEBSD_TRUE@noinst_HEADERS = \ @OS_FREEBSD_TRUE@ sg_linux_inc.h \ @OS_FREEBSD_TRUE@ sg_io_linux.h \ @OS_FREEBSD_TRUE@ sg_pt_win32.h @OS_LINUX_TRUE@noinst_HEADERS = \ @OS_LINUX_TRUE@ sg_pt_win32.h @OS_OSF_TRUE@noinst_HEADERS = \ @OS_OSF_TRUE@ sg_linux_inc.h \ @OS_OSF_TRUE@ sg_io_linux.h \ @OS_OSF_TRUE@ sg_pt_win32.h @OS_SOLARIS_TRUE@noinst_HEADERS = \ @OS_SOLARIS_TRUE@ sg_linux_inc.h \ @OS_SOLARIS_TRUE@ sg_io_linux.h \ @OS_SOLARIS_TRUE@ sg_pt_win32.h @OS_WIN32_CYGWIN_TRUE@noinst_HEADERS = \ @OS_WIN32_CYGWIN_TRUE@ sg_linux_inc.h \ @OS_WIN32_CYGWIN_TRUE@ sg_io_linux.h @OS_WIN32_MINGW_TRUE@noinst_HEADERS = \ @OS_WIN32_MINGW_TRUE@ sg_linux_inc.h \ @OS_WIN32_MINGW_TRUE@ sg_io_linux.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu include/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-scsiincludeHEADERS: $(scsiinclude_HEADERS) @$(NORMAL_INSTALL) @list='$(scsiinclude_HEADERS)'; test -n "$(scsiincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(scsiincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(scsiincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(scsiincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(scsiincludedir)" || exit $$?; \ done uninstall-scsiincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(scsiinclude_HEADERS)'; test -n "$(scsiincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(scsiincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(scsiincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-scsiincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-scsiincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool ctags distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-scsiincludeHEADERS \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-scsiincludeHEADERS # 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. .NOEXPORT: sdparm-1.08/include/sg_lib_data.h0000664000175000017500000000543611731071457015770 0ustar douggdougg#ifndef SG_LIB_DATA_H #define SG_LIB_DATA_H /* * Copyright (c) 2007-2012 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. */ /* * This header file contains some structure declarations and array name * declarations which are defined in the sg_lib_data.c . * Typically this header does not need to be exposed to users of the * sg_lib interface declared in sg_libs.h . */ #include #ifdef __cplusplus extern "C" { #endif /* Commands with service actions that change the command name */ #define SG_MAINTENANCE_IN 0xa3 #define SG_MAINTENANCE_OUT 0xa4 #define SG_PERSISTENT_RESERVE_IN 0x5e #define SG_PERSISTENT_RESERVE_OUT 0x5f #define SG_EXTENDED_COPY 0x83 #define SG_RECEIVE_COPY 0x84 #define SG_SERVICE_ACTION_IN_12 0xab #define SG_SERVICE_ACTION_OUT_12 0xa9 #define SG_SERVICE_ACTION_BIDI 0x9d #define SG_SERVICE_ACTION_IN_16 0x9e #define SG_SERVICE_ACTION_OUT_16 0x9f #define SG_READ_BUFFER 0x3c #define SG_WRITE_BUFFER 0x3b #define SG_VARIABLE_LENGTH_CMD 0x7f struct sg_lib_value_name_t { int value; int peri_dev_type; /* 0 -> SPC and/or PDT_DISK, >0 -> PDT */ const char * name; }; struct sg_lib_asc_ascq_t { unsigned char asc; /* additional sense code */ unsigned char ascq; /* additional sense code qualifier */ const char * text; }; struct sg_lib_asc_ascq_range_t { unsigned char asc; /* additional sense code (ASC) */ unsigned char ascq_min; /* ASCQ minimum in range */ unsigned char ascq_max; /* ASCQ maximum in range */ const char * text; }; extern const char * sg_lib_version_str; extern struct sg_lib_value_name_t sg_lib_normal_opcodes[]; extern struct sg_lib_value_name_t sg_lib_read_buff_arr[]; extern struct sg_lib_value_name_t sg_lib_write_buff_arr[]; extern struct sg_lib_value_name_t sg_lib_maint_in_arr[]; extern struct sg_lib_value_name_t sg_lib_maint_out_arr[]; extern struct sg_lib_value_name_t sg_lib_pr_in_arr[]; extern struct sg_lib_value_name_t sg_lib_pr_out_arr[]; extern struct sg_lib_value_name_t sg_lib_serv_in12_arr[]; extern struct sg_lib_value_name_t sg_lib_serv_out12_arr[]; extern struct sg_lib_value_name_t sg_lib_serv_in16_arr[]; extern struct sg_lib_value_name_t sg_lib_serv_out16_arr[]; extern struct sg_lib_value_name_t sg_lib_serv_bidi_arr[]; extern struct sg_lib_value_name_t sg_lib_xcopy_sa_arr[]; extern struct sg_lib_value_name_t sg_lib_rec_copy_sa_arr[]; extern struct sg_lib_value_name_t sg_lib_variable_length_arr[]; extern struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[]; extern struct sg_lib_asc_ascq_t sg_lib_asc_ascq[]; extern const char * sg_lib_sense_key_desc[]; extern const char * sg_lib_pdt_strs[]; extern const char * sg_lib_transport_proto_strs[]; #ifdef __cplusplus } #endif #endif sdparm-1.08/include/sg_io_linux.h0000664000175000017500000001452612024633456016056 0ustar douggdougg#ifndef SG_IO_LINUX_H #define SG_IO_LINUX_H /* * Copyright (c) 2004-2012 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. */ /* * Version 1.03 [20120914] */ /* * This header file contains linux specific information related to the SCSI * command pass through in the SCSI generic (sg) driver and the linux * block layer. */ #include "sg_lib.h" #include "sg_linux_inc.h" #ifdef __cplusplus extern "C" { #endif /* The following are 'host_status' codes */ #ifndef DID_OK #define DID_OK 0x00 #endif #ifndef DID_NO_CONNECT #define DID_NO_CONNECT 0x01 /* Unable to connect before timeout */ #define DID_BUS_BUSY 0x02 /* Bus remain busy until timeout */ #define DID_TIME_OUT 0x03 /* Timed out for some other reason */ #define DID_BAD_TARGET 0x04 /* Bad target (id?) */ #define DID_ABORT 0x05 /* Told to abort for some other reason */ #define DID_PARITY 0x06 /* Parity error (on SCSI bus) */ #define DID_ERROR 0x07 /* Internal error */ #define DID_RESET 0x08 /* Reset by somebody */ #define DID_BAD_INTR 0x09 /* Received an unexpected interrupt */ #define DID_PASSTHROUGH 0x0a /* Force command past mid-level */ #define DID_SOFT_ERROR 0x0b /* The low-level driver wants a retry */ #endif #ifndef DID_IMM_RETRY #define DID_IMM_RETRY 0x0c /* Retry without decrementing retry count */ #endif #ifndef DID_REQUEUE #define DID_REQUEUE 0x0d /* Requeue command (no immediate retry) also * without decrementing the retry count */ #endif #ifndef DID_TRANSPORT_DISRUPTED #define DID_TRANSPORT_DISRUPTED 0xe #endif #ifndef DID_TRANSPORT_FAILFAST #define DID_TRANSPORT_FAILFAST 0xf #endif #ifndef DID_TARGET_FAILURE #define DID_TARGET_FAILURE 0x10 #endif #ifndef DID_NEXUS_FAILURE #define DID_NEXUS_FAILURE 0x11 #endif /* These defines are to isolate applications from kernel define changes */ #define SG_LIB_DID_OK DID_OK #define SG_LIB_DID_NO_CONNECT DID_NO_CONNECT #define SG_LIB_DID_BUS_BUSY DID_BUS_BUSY #define SG_LIB_DID_TIME_OUT DID_TIME_OUT #define SG_LIB_DID_BAD_TARGET DID_BAD_TARGET #define SG_LIB_DID_ABORT DID_ABORT #define SG_LIB_DID_PARITY DID_PARITY #define SG_LIB_DID_ERROR DID_ERROR #define SG_LIB_DID_RESET DID_RESET #define SG_LIB_DID_BAD_INTR DID_BAD_INTR #define SG_LIB_DID_PASSTHROUGH DID_PASSTHROUGH #define SG_LIB_DID_SOFT_ERROR DID_SOFT_ERROR #define SG_LIB_DID_IMM_RETRY DID_IMM_RETRY #define SG_LIB_DID_REQUEUE DID_REQUEUE #define SG_LIB_TRANSPORT_DISRUPTED DID_TRANSPORT_DISRUPTED #define SG_LIB_DID_TRANSPORT_FAILFAST DID_TRANSPORT_FAILFAST #define SG_LIB_DID_TARGET_FAILURE DID_TARGET_FAILURE #define SG_LIB_DID_NEXUS_FAILURE DID_NEXUS_FAILURE /* The following are 'driver_status' codes */ #ifndef DRIVER_OK #define DRIVER_OK 0x00 #endif #ifndef DRIVER_BUSY #define DRIVER_BUSY 0x01 #define DRIVER_SOFT 0x02 #define DRIVER_MEDIA 0x03 #define DRIVER_ERROR 0x04 #define DRIVER_INVALID 0x05 #define DRIVER_TIMEOUT 0x06 #define DRIVER_HARD 0x07 #define DRIVER_SENSE 0x08 /* Sense_buffer has been set */ /* Following "suggests" are "or-ed" with one of previous 8 entries */ #define SUGGEST_RETRY 0x10 #define SUGGEST_ABORT 0x20 #define SUGGEST_REMAP 0x30 #define SUGGEST_DIE 0x40 #define SUGGEST_SENSE 0x80 #define SUGGEST_IS_OK 0xff #endif #ifndef DRIVER_MASK #define DRIVER_MASK 0x0f #endif #ifndef SUGGEST_MASK #define SUGGEST_MASK 0xf0 #endif /* These defines are to isolate applications from kernel define changes */ #define SG_LIB_DRIVER_OK DRIVER_OK #define SG_LIB_DRIVER_BUSY DRIVER_BUSY #define SG_LIB_DRIVER_SOFT DRIVER_SOFT #define SG_LIB_DRIVER_MEDIA DRIVER_MEDIA #define SG_LIB_DRIVER_ERROR DRIVER_ERROR #define SG_LIB_DRIVER_INVALID DRIVER_INVALID #define SG_LIB_DRIVER_TIMEOUT DRIVER_TIMEOUT #define SG_LIB_DRIVER_HARD DRIVER_HARD #define SG_LIB_DRIVER_SENSE DRIVER_SENSE #define SG_LIB_SUGGEST_RETRY SUGGEST_RETRY #define SG_LIB_SUGGEST_ABORT SUGGEST_ABORT #define SG_LIB_SUGGEST_REMAP SUGGEST_REMAP #define SG_LIB_SUGGEST_DIE SUGGEST_DIE #define SG_LIB_SUGGEST_SENSE SUGGEST_SENSE #define SG_LIB_SUGGEST_IS_OK SUGGEST_IS_OK #define SG_LIB_DRIVER_MASK DRIVER_MASK #define SG_LIB_SUGGEST_MASK SUGGEST_MASK extern void sg_print_masked_status(int masked_status); extern void sg_print_host_status(int host_status); extern void sg_print_driver_status(int driver_status); /* sg_chk_n_print() returns 1 quietly if there are no errors/warnings else it prints errors/warnings (prefixed by 'leadin') to 'sg_warnings_fd' and returns 0. raw_sinfo indicates whether the raw sense buffer (in ASCII hex) should be printed. */ extern int sg_chk_n_print(const char * leadin, int masked_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len, int raw_sinfo); /* The following function declaration is for the sg version 3 driver. */ struct sg_io_hdr; /* sg_chk_n_print3() returns 1 quietly if there are no errors/warnings; else it prints errors/warnings (prefixed by 'leadin') to 'sg_warnings_fd' and returns 0. */ extern int sg_chk_n_print3(const char * leadin, struct sg_io_hdr * hp, int raw_sinfo); /* Calls sg_scsi_normalize_sense() after obtaining the sense buffer and its length from the struct sg_io_hdr pointer. If these cannot be obtained, 0 is returned. */ extern int sg_normalize_sense(const struct sg_io_hdr * hp, struct sg_scsi_sense_hdr * sshp); extern int sg_err_category(int masked_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len); extern int sg_err_category_new(int scsi_status, int host_status, int driver_status, const unsigned char * sense_buffer, int sb_len); /* The following function declaration is for the sg version 3 driver. */ extern int sg_err_category3(struct sg_io_hdr * hp); /* Note about SCSI status codes found in older versions of Linux. Linux has traditionally used a 1 bit right shifted and masked version of SCSI standard status codes. Now CHECK_CONDITION and friends (in ) are deprecated. */ #ifdef __cplusplus } #endif #endif sdparm-1.08/include/sg_cmds.h0000664000175000017500000000151710756351213015150 0ustar douggdougg#ifndef SG_CMDS_H #define SG_CMDS_H /******************************************************************** * This header did contain wrapper declarations for many SCSI commands * up until sg3_utils version 1.22 . In that version, the command * wrappers were broken into two groups, the 'basic' ones found in the * "sg_cmds_basic.h" header and the 'extra' ones found in the * "sg_cmds_extra.h" header. This header now simply includes those two * headers. * In sg3_utils version 1.26 the sg_cmds_mmc.h header was added and * contains some MMC specific commands. * The corresponding function definitions are found in the sg_cmds_basic.c, * sg_cmds_extra.c and sg_cmds_mmc.c files. ********************************************************************/ #include "sg_cmds_basic.h" #include "sg_cmds_extra.h" #include "sg_cmds_mmc.h" #endif sdparm-1.08/include/sg_cmds_mmc.h0000664000175000017500000000412211346470114015775 0ustar douggdougg#ifndef SG_CMDS_MMC_H #define SG_CMDS_MMC_H /* * Copyright (c) 2008-2010 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. */ #ifdef __cplusplus extern "C" { #endif /* Invokes a SCSI GET CONFIGURATION command (MMC-3...6). * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ extern int sg_ll_get_config(int sg_fd, int rt, int starting, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI GET PERFORMANCE command (MMC-3...6). * Returns 0 when successful, SG_LIB_CAT_INVALID_OP if command not * supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ extern int sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba, int max_num_desc, int type, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI SET CD SPEED command (MMC). * Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> command not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed, int drv_write_speed, int noisy, int verbose); /* Invokes a SCSI SET STREAMING command (MMC). Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Set Streaming not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_NOT_READY -> device not ready, * -1 -> other failure */ extern int sg_ll_set_streaming(int sg_fd, int type, void * paramp, int param_len, int noisy, int verbose); #ifdef __cplusplus } #endif #endif sdparm-1.08/include/sg_pt.h0000664000175000017500000001453311524334352014646 0ustar douggdougg#ifndef SG_PT_H #define SG_PT_H /* * Copyright (c) 2005-2011 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 #ifdef __cplusplus extern "C" { #endif /* This declaration hides the fact that each implementation has its own * structure "derived" (using a C++ term) from this one. It compiles * because 'struct sg_pt_base' is only referenced (by pointer: 'objp') * in this interface. An instance of this structure represents the * context of one SCSI command. */ struct sg_pt_base; /* The format of the version string is like this: "2.01 20090201". * The leading digit will be incremented if this interface changes * in a way that may impact backward compatibility. */ extern const char * scsi_pt_version(); /* Returns >= 0 if successful. If error in Unix returns negated errno. */ extern int scsi_pt_open_device(const char * device_name, int read_only, int verbose); /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed * together. Returns valid file descriptor( >= 0 ) if successful, otherwise * returns -1 or a negated errno. */ extern int scsi_pt_open_flags(const char * device_name, int flags, int verbose); /* Returns 0 if successful. If error in Unix returns negated errno. */ extern int scsi_pt_close_device(int device_fd); /* Creates an object that can be used to issue one or more SCSI commands * (or task management functions). Returns NULL if problem. * Once this object has been created it should be destroyed with * destruct_scsi_pt_obj() when it is no longer needed. */ extern struct sg_pt_base * construct_scsi_pt_obj(void); /* Clear state information held in *objp . This allows this object to be * used to issue more than one SCSI command. */ extern void clear_scsi_pt_obj(struct sg_pt_base * objp); /* Set the CDB (command descriptor block) */ extern void set_scsi_pt_cdb(struct sg_pt_base * objp, const unsigned char * cdb, int cdb_len); /* Set the sense buffer and the maximum length that it can handle */ extern void set_scsi_pt_sense(struct sg_pt_base * objp, unsigned char * sense, int max_sense_len); /* Set a pointer and length to be used for data transferred from device */ extern void set_scsi_pt_data_in(struct sg_pt_base * objp, /* from device */ unsigned char * dxferp, int dxfer_len); /* Set a pointer and length to be used for data transferred to device */ extern void set_scsi_pt_data_out(struct sg_pt_base * objp, /* to device */ const unsigned char * dxferp, int dxfer_len); /* The following "set_"s implementations may be dummies */ extern void set_scsi_pt_packet_id(struct sg_pt_base * objp, int pack_id); extern void set_scsi_pt_tag(struct sg_pt_base * objp, uint64_t tag); extern void set_scsi_pt_task_management(struct sg_pt_base * objp, int tmf_code); extern void set_scsi_pt_task_attr(struct sg_pt_base * objp, int attribute, int priority); /* Following is a guard which is defined when set_scsi_pt_flags() is * present. Older versions of this library may not have this function. */ #define SCSI_PT_FLAGS_FUNCTION 1 /* If neither QUEUE_AT_HEAD nor QUEUE_AT_TAIL are given, or both * are given, use the pass-through default. */ #define SCSI_PT_FLAGS_QUEUE_AT_TAIL 0x10 #define SCSI_PT_FLAGS_QUEUE_AT_HEAD 0x20 /* Set (potentially OS dependant) flags for pass-through mechanism. * Apart from contradictions, flags can be OR-ed together. */ extern void set_scsi_pt_flags(struct sg_pt_base * objp, int flags); #define SCSI_PT_DO_START_OK 0 #define SCSI_PT_DO_BAD_PARAMS 1 #define SCSI_PT_DO_TIMEOUT 2 /* If OS error prior to or during command submission then returns negated * error value (e.g. Unix '-errno'). This includes interrupted system calls * (e.g. by a signal) in which case -EINTR would be returned. Note that * system call errors also can be fetched with get_scsi_pt_os_err(). * Return 0 if okay (i.e. at the very least: command sent). Positive * return values are errors (see SCSI_PT_DO_* defines). */ extern int do_scsi_pt(struct sg_pt_base * objp, int fd, int timeout_secs, int verbose); #define SCSI_PT_RESULT_GOOD 0 #define SCSI_PT_RESULT_STATUS 1 /* other than GOOD and CHECK CONDITION */ #define SCSI_PT_RESULT_SENSE 2 #define SCSI_PT_RESULT_TRANSPORT_ERR 3 #define SCSI_PT_RESULT_OS_ERR 4 /* highest numbered applicable category returned */ extern int get_scsi_pt_result_category(const struct sg_pt_base * objp); /* If not available return 0 */ extern int get_scsi_pt_resid(const struct sg_pt_base * objp); /* Returns SCSI status value (from device that received the command). */ extern int get_scsi_pt_status_response(const struct sg_pt_base * objp); /* Actual sense length returned. If sense data is present but actual sense length is not known, return 'max_sense_len' */ extern int get_scsi_pt_sense_len(const struct sg_pt_base * objp); /* If not available return 0 */ extern int get_scsi_pt_os_err(const struct sg_pt_base * objp); extern char * get_scsi_pt_os_err_str(const struct sg_pt_base * objp, int max_b_len, char * b); /* If not available return 0 */ extern int get_scsi_pt_transport_err(const struct sg_pt_base * objp); extern char * get_scsi_pt_transport_err_str(const struct sg_pt_base * objp, int max_b_len, char * b); /* If not available return -1 */ extern int get_scsi_pt_duration_ms(const struct sg_pt_base * objp); /* Should be invoked once per objp after other processing is complete in * order to clean up resources. For ever successful construct_scsi_pt_obj() * call there should be one destruct_scsi_pt_obj(). */ extern void destruct_scsi_pt_obj(struct sg_pt_base * objp); #ifdef SG_LIB_WIN32 #define SG_LIB_WIN32_DIRECT 1 /* Request SPT direct interface when state_direct is 1, state_direct set * to 0 for the SPT indirect interface. Default setting selected by build * (i.e. library compile time) and is usually indirect. */ extern void scsi_pt_win32_direct(int state_direct); /* Returns current SPT interface state, 1 for direct, 0 for indirect */ extern int scsi_pt_win32_spt_state(void); #endif #ifdef __cplusplus } #endif #endif sdparm-1.08/include/Makefile.am0000664000175000017500000000256411215540460015412 0ustar douggdougg scsiincludedir = $(includedir)/scsi if OS_LINUX scsiinclude_HEADERS = \ sg_lib.h \ sg_lib_data.h \ sg_cmds.h \ sg_cmds_basic.h \ sg_cmds_extra.h \ sg_cmds_mmc.h \ sg_pt.h \ sg_linux_inc.h \ sg_io_linux.h noinst_HEADERS = \ sg_pt_win32.h endif if OS_WIN32_MINGW scsiinclude_HEADERS = \ sg_lib.h \ sg_lib_data.h \ sg_cmds.h \ sg_cmds_basic.h \ sg_cmds_extra.h \ sg_cmds_mmc.h \ sg_pt.h \ sg_pt_win32.h noinst_HEADERS = \ sg_linux_inc.h \ sg_io_linux.h endif if OS_WIN32_CYGWIN scsiinclude_HEADERS = \ sg_lib.h \ sg_lib_data.h \ sg_cmds.h \ sg_cmds_basic.h \ sg_cmds_extra.h \ sg_cmds_mmc.h \ sg_pt.h \ sg_pt_win32.h noinst_HEADERS = \ sg_linux_inc.h \ sg_io_linux.h endif if OS_FREEBSD scsiinclude_HEADERS = \ sg_lib.h \ sg_lib_data.h \ sg_cmds.h \ sg_cmds_basic.h \ sg_cmds_extra.h \ sg_cmds_mmc.h \ sg_pt.h noinst_HEADERS = \ sg_linux_inc.h \ sg_io_linux.h \ sg_pt_win32.h endif if OS_SOLARIS scsiinclude_HEADERS = \ sg_lib.h \ sg_lib_data.h \ sg_cmds.h \ sg_cmds_basic.h \ sg_cmds_extra.h \ sg_cmds_mmc.h \ sg_pt.h noinst_HEADERS = \ sg_linux_inc.h \ sg_io_linux.h \ sg_pt_win32.h endif if OS_OSF scsiinclude_HEADERS = \ sg_lib.h \ sg_lib_data.h \ sg_cmds.h \ sg_cmds_basic.h \ sg_cmds_extra.h \ sg_cmds_mmc.h \ sg_pt.h noinst_HEADERS = \ sg_linux_inc.h \ sg_io_linux.h \ sg_pt_win32.h endif sdparm-1.08/include/sg_cmds_extra.h0000664000175000017500000003776111733121044016356 0ustar douggdougg#ifndef SG_CMDS_EXTRA_H #define SG_CMDS_EXTRA_H /* * Copyright (c) 2004-2012 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. */ #ifdef __cplusplus extern "C" { #endif /* Invokes a ATA PASS-THROUGH (12 or 16) SCSI command (SAT). If cdb_len * is 12 then a ATA PASS-THROUGH (12) command is called. If cdb_len is 16 * then a ATA PASS-THROUGH (16) command is called. If cdb_len is any other * value -1 is returned. After copying from cdbp to an internal buffer, * the first byte (i.e. offset 0) is set to 0xa1 if cdb_len is 12; or is * set to 0x85 if cdb_len is 16. The last byte (offset 11 or offset 15) is * set to 0x0 in the internal buffer. If timeout_secs <= 0 then the timeout * is set to 60 seconds. For data in or out transfers set dinp or doutp, * and dlen to the number of bytes to transfer. If dlen is zero then no data * transfer is assumed. If sense buffer obtained then it is written to * sensep, else sensep[0] is set to 0x0. If ATA return descriptor is obtained * then written to ata_return_dp, else ata_return_dp[0] is set to 0x0. Either * sensep or ata_return_dp (or both) may be NULL pointers. Returns SCSI * status value (>= 0) or -1 if other error. Users are expected to check the * sense buffer themselves. If available the data in resid is written to * residp. Note in SAT-2 and later, fixed format sense data may be placed in * *sensep in which case sensep[0]==0x70 . */ extern int sg_ll_ata_pt(int sg_fd, const unsigned char * cdbp, int cdb_len, int timeout_secs, void * dinp, void * doutp, int dlen, unsigned char * sensep, int max_sense_len, unsigned char * ata_return_dp, int max_ata_return_len, int * residp, int verbose); /* Invokes a FORMAT UNIT (SBC-3) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Format unit not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_format_unit(int sg_fd, int fmtpinfo, int longlist, int fmtdata, int cmplist, int dlist_format, int timeout_secs, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI GET LBA STATUS command (SBC). Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> GET LBA STATUS not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ extern int sg_ll_get_lba_status(int sg_fd, uint64_t start_llba, void * resp, int alloc_len, int noisy, int verbose); /* Invokes a SCSI PERSISTENT RESERVE IN command (SPC). Returns 0 * when successful, SG_LIB_CAT_INVALID_OP if command not supported, * SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ extern int sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI PERSISTENT RESERVE OUT command (SPC). Returns 0 * when successful, SG_LIB_CAT_INVALID_OP if command not supported, * SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported, * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */ extern int sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope, unsigned int rq_type, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI READ BLOCK LIMITS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> READ BLOCK LIMITS not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_NOT_READY (shouldn't happen), -1 -> other failure */ extern int sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI READ BUFFER command (SPC). Return of 0 -> * success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI READ DEFECT DATA (10) command (SBC). Return of 0 -> * success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_read_defect10(int sg_fd, int req_plist, int req_glist, int dl_format, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI READ LONG (10) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> READ LONG(10) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_read_long10(int sg_fd, int pblock, int correct, unsigned int lba, void * resp, int xfer_len, int * offsetp, int noisy, int verbose); /* Invokes a SCSI READ LONG (16) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> READ LONG(16) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_read_long16(int sg_fd, int pblock, int correct, uint64_t llba, void * resp, int xfer_len, int * offsetp, int noisy, int verbose); /* Invokes a SCSI READ MEDIA SERIAL NUMBER command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Read media serial number not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI REASSIGN BLOCKS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */ extern int sg_ll_reassign_blocks(int sg_fd, int longlba, int longlist, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Receive diagnostic results not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_receive_diag(int sg_fd, int pcv, int pg_code, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI REPORT IDENTIFYING INFORMATION command. This command was * called REPORT DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report identifying information not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len, int noisy, int verbose); /* Invokes a SCSI REPORT TARGET PORT GROUPS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Target Port Groups not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ extern int sg_ll_report_tgt_prt_grp(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose); extern int sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len, int extended, int noisy, int verbose); /* Invokes a SCSI SET TARGET PORT GROUPS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Target Port Groups not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ extern int sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI REPORT REFERRALS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Report Referrals not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ extern int sg_ll_report_referrals(int sg_fd, uint64_t start_llba, int one_seg, void * resp,int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI SEND DIAGNOSTIC command. Foreground, extended self tests can * take a long time, if so set long_duration flag. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Send diagnostic not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_send_diag(int sg_fd, int sf_code, int pf_bit, int sf_bit, int devofl_bit, int unitofl_bit, int long_duration, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was * called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Set identifying information not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI UNMAP (SBC-3) command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> command not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND, * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */ extern int sg_ll_unmap(int sg_fd, int group_num, int timeout_secs, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI UNMAP (SBC-3) command. Version 2 adds anchor field * (sbc3r22). Otherwise same as sg_ll_unmap() . */ extern int sg_ll_unmap_v2(int sg_fd, int anchor, int group_num, int timeout_secs, void * paramp, int param_len, int noisy, int verbose); /* Invokes a SCSI VERIFY (10) command (SBC and MMC). * Note that 'veri_len' is in blocks while 'data_out_len' is in bytes. * Returns of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Verify(10) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_MEDIUM_HARD -> medium or hardware error, no valid info, * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> as previous, with valid info, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_verify10(int sg_fd, int vrprotect, int dpo, int bytechk, unsigned int lba, int veri_len, void * data_out, int data_out_len, unsigned int * infop, int noisy, int verbose); /* Invokes a SCSI VERIFY (16) command (SBC). * Note that 'veri_len' is in blocks while 'data_out_len' is in bytes. * Returns of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Verify(16) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_MEDIUM_HARD -> medium or hardware error, no valid info, * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> as previous, with valid info, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_verify16(int sg_fd, int vrprotect, int dpo, int bytechk, uint64_t llba, int veri_len, int group_num, void * data_out, int data_out_len, uint64_t * infop, int noisy, int verbose); /* Invokes a SCSI WRITE BUFFER command (SPC). Return of 0 -> * success, SG_LIB_CAT_INVALID_OP -> invalid opcode, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset, void * paramp, int param_len, int noisy, int verbose); /* Need a sg_ll_write_buffer_v2() function because SPC-4 rev32 has added * a "mode specific" field. Wait for next rev change of this library */ /* Invokes a SCSI WRITE LONG (10) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> WRITE LONG(10) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock, unsigned int lba, void * data_out, int xfer_len, int * offsetp, int noisy, int verbose); /* Invokes a SCSI WRITE LONG (16) command (SBC). Note that 'xfer_len' * is in bytes. Returns 0 -> success, * SG_LIB_CAT_INVALID_OP -> WRITE LONG(16) not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock, uint64_t llba, void * data_out, int xfer_len, int * offsetp, int noisy, int verbose); /* Invokes a SCSI RECEIVE COPY RESULTS command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Receive copy results not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp, int mx_resp_len, int noisy, int verbose); /* Invokes a SCSI EXTENDEd COPY command. Return of 0 -> success, * SG_LIB_CAT_INVALID_OP -> Extended copy not supported, * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION, * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND, * -1 -> other failure */ extern int sg_ll_extended_copy(int sg_fd, void * resp, int mx_resp_len, int noisy, int verbose); #ifdef __cplusplus } #endif #endif sdparm-1.08/include/sg_linux_inc.h0000664000175000017500000000367010671112741016211 0ustar douggdougg#ifndef SG_LINUX_INC_H #define SG_LINUX_INC_H #ifdef SG_KERNEL_INCLUDES #define __user typedef unsigned char u8; #include "/usr/src/linux/include/scsi/sg.h" #include "/usr/src/linux/include/scsi/scsi.h" #else #ifdef SG_TRICK_GNU_INCLUDES #include #include #else #include #include #endif #endif #ifdef BLKGETSIZE64 #ifndef u64 #include /* C99 header for exact integer types */ typedef uint64_t u64; /* problems with BLKGETSIZE64 ioctl in lk 2.4 */ #endif #endif /* Getting the correct include files for the sg interface can be an ordeal. In a perfect world, one would just write: #include #include This would include the files found in the /usr/include/scsi directory. Those files are maintained with the GNU library which may or may not agree with the kernel and version of sg driver that is running. Any many cases this will not matter. However in some it might, for example glibc 2.1's include files match the sg driver found in the lk 2.2 series. Hence if glibc 2.1 is used with lk 2.4 then the additional sg v3 interface will not be visible. If this is a problem then defining SG_KERNEL_INCLUDES will access the kernel supplied header files (assuming they are in the normal place). The GNU library maintainers and various kernel people don't like this approach (but it does work). The technique selected by defining SG_TRICK_GNU_INCLUDES worked (and was used) prior to glibc 2.2 . Prior to that version /usr/include/linux was a symbolic link to /usr/src/linux/include/linux . There are other approaches if this include "mixup" causes pain. These would involve include files being copied or symbolic links being introduced. Sorry about the inconvenience. Typically neither SG_KERNEL_INCLUDES nor SG_TRICK_GNU_INCLUDES is defined. dpg 20010415, 20030522 */ #endif sdparm-1.08/include/sg_lib.h0000664000175000017500000004224512117736101014767 0ustar douggdougg#ifndef SG_LIB_H #define SG_LIB_H /* * Copyright (c) 2004-2013 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. */ /* * * On 5th October 2004 a FreeBSD license was added to this file. * The intention is to keep this file and the related sg_lib.c file * as open source and encourage their unencumbered use. * * Current version number is in the sg_lib.c file and can be accessed * with the sg_lib_version() function. */ /* * This header file contains defines and function declarations that may * be useful to applications that communicate with devices that use a * SCSI command set. These command sets have names like SPC-4, SBC-3, * SSC-3, SES-2 and draft standards defining them can be found at * http://www.t10.org . Virtually all devices in the Linux SCSI subsystem * utilize SCSI command sets. Many devices in other Linux device subsystems * utilize SCSI command sets either natively or via emulation (e.g. a * parallel ATA disk in a USB enclosure). */ #include #include #ifdef __cplusplus extern "C" { #endif /* SCSI Peripheral Device Types (PDT) [5 bit field] */ #define PDT_DISK 0x0 /* direct access block device (disk) */ #define PDT_TAPE 0x1 /* sequential access device (magnetic tape) */ #define PDT_PRINTER 0x2 /* printer device (see SSC-1) */ #define PDT_PROCESSOR 0x3 /* processor device (e.g. SAFTE device) */ #define PDT_WO 0x4 /* write once device (some optical disks) */ #define PDT_MMC 0x5 /* CD/DVD/BD (multi-media) */ #define PDT_SCANNER 0x6 /* obsolete */ #define PDT_OPTICAL 0x7 /* optical memory device (some optical disks) */ #define PDT_MCHANGER 0x8 /* media changer device (e.g. tape robot) */ #define PDT_COMMS 0x9 /* communications device (obsolete) */ #define PDT_SAC 0xc /* storage array controller device */ #define PDT_SES 0xd /* SCSI Enclosure Services (SES) device */ #define PDT_RBC 0xe /* Reduced Block Commands (simplified PDT_DISK) */ #define PDT_OCRW 0xf /* optical card read/write device */ #define PDT_BCC 0x10 /* bridge controller commands */ #define PDT_OSD 0x11 /* Object Storage Device (OSD) */ #define PDT_ADC 0x12 /* Automation/drive commands (ADC) */ #define PDT_SMD 0x13 /* Security Manager Device (SMD) */ #define PDT_WLUN 0x1e /* Well known logical unit (WLUN) */ #define PDT_UNKNOWN 0x1f /* Unknown or no device type */ #ifndef SAM_STAT_GOOD /* The SCSI status codes as found in SAM-4 at www.t10.org */ #define SAM_STAT_GOOD 0x0 #define SAM_STAT_CHECK_CONDITION 0x2 #define SAM_STAT_CONDITION_MET 0x4 #define SAM_STAT_BUSY 0x8 #define SAM_STAT_INTERMEDIATE 0x10 /* obsolete in SAM-4 */ #define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14 /* obsolete in SAM-4 */ #define SAM_STAT_RESERVATION_CONFLICT 0x18 #define SAM_STAT_COMMAND_TERMINATED 0x22 /* obsolete in SAM-3 */ #define SAM_STAT_TASK_SET_FULL 0x28 #define SAM_STAT_ACA_ACTIVE 0x30 #define SAM_STAT_TASK_ABORTED 0x40 #endif /* The SCSI sense key codes as found in SPC-4 at www.t10.org */ #define SPC_SK_NO_SENSE 0x0 #define SPC_SK_RECOVERED_ERROR 0x1 #define SPC_SK_NOT_READY 0x2 #define SPC_SK_MEDIUM_ERROR 0x3 #define SPC_SK_HARDWARE_ERROR 0x4 #define SPC_SK_ILLEGAL_REQUEST 0x5 #define SPC_SK_UNIT_ATTENTION 0x6 #define SPC_SK_DATA_PROTECT 0x7 #define SPC_SK_BLANK_CHECK 0x8 #define SPC_SK_COPY_ABORTED 0xa #define SPC_SK_ABORTED_COMMAND 0xb #define SPC_SK_VOLUME_OVERFLOW 0xd #define SPC_SK_MISCOMPARE 0xe #define SPC_SK_COMPLETED 0xf /* Transport protocol identifiers or just Protocol identifiers */ #define TPROTO_FCP 0 #define TPROTO_SPI 1 #define TPROTO_SSA 2 #define TPROTO_1394 3 #define TPROTO_SRP 4 #define TPROTO_ISCSI 5 #define TPROTO_SAS 6 #define TPROTO_ADT 7 #define TPROTO_ATA 8 #define TPROTO_UAS 9 #define TPROTO_SOP 0xa #define TPROTO_NONE 0xf /* The format of the version string is like this: "1.47 20090201" */ extern const char * sg_lib_version(); /* Returns length of SCSI command given the opcode (first byte). * Yields the wrong answer for variable length commands (opcode=0x7f) * and potentially some vendor specific commands. */ extern int sg_get_command_size(unsigned char cdb_byte0); /* Command name given pointer to the cdb. Certain command names * depend on peripheral type (give 0 if unknown). Places command * name into buff and will write no more than buff_len bytes. */ extern void sg_get_command_name(const unsigned char * cdbp, int peri_type, int buff_len, char * buff); /* Command name given only the first byte (byte 0) of a cdb and * peripheral type. */ extern void sg_get_opcode_name(unsigned char cdb_byte0, int peri_type, int buff_len, char * buff); /* Command name given opcode (byte 0), service action and peripheral type. * If no service action give 0, if unknown peripheral type give 0. */ extern void sg_get_opcode_sa_name(unsigned char cdb_byte0, int service_action, int peri_type, int buff_len, char * buff); /* Fetch scsi status string. */ extern void sg_get_scsi_status_str(int scsi_status, int buff_len, char * buff); /* This is a slightly stretched SCSI sense "descriptor" format header. * The addition is to allow the 0x70 and 0x71 response codes. The idea * is to place the salient data of both "fixed" and "descriptor" sense * format into one structure to ease application processing. * The original sense buffer should be kept around for those cases * in which more information is required (e.g. the LBA of a MEDIUM ERROR). */ struct sg_scsi_sense_hdr { unsigned char response_code; /* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ unsigned char sense_key; unsigned char asc; unsigned char ascq; unsigned char byte4; unsigned char byte5; unsigned char byte6; unsigned char additional_length; }; /* Maps the salient data from a sense buffer which is in either fixed or * descriptor format into a structure mimicking a descriptor format * header (i.e. the first 8 bytes of sense descriptor format). * If zero response code returns 0. Otherwise returns 1 and if 'sshp' is * non-NULL then zero all fields and then set the appropriate fields in * that structure. sshp::additional_length is always 0 for response * codes 0x70 and 0x71 (fixed format). */ extern int sg_scsi_normalize_sense(const unsigned char * sensep, int sense_len, struct sg_scsi_sense_hdr * sshp); /* Attempt to find the first SCSI sense data descriptor that matches the * given 'desc_type'. If found return pointer to start of sense data * descriptor; otherwise (including fixed format sense data) returns NULL. */ extern const unsigned char * sg_scsi_sense_desc_find( const unsigned char * sensep, int sense_len, int desc_type); /* Yield string associated with sense_key value. Returns 'buff'. */ extern char * sg_get_sense_key_str(int sense_key, int buff_len, char * buff); /* Yield string associated with ASC/ASCQ values. Returns 'buff'. */ extern char * sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff); /* Returns 1 if valid bit set, 0 if valid bit clear. Irrespective the * information field is written out via 'info_outp' (except when it is * NULL). Handles both fixed and descriptor sense formats. */ extern int sg_get_sense_info_fld(const unsigned char * sensep, int sb_len, uint64_t * info_outp); /* Returns 1 if any of the 3 bits (i.e. FILEMARK, EOM or ILI) are set. * In descriptor format if the stream commands descriptor not found * then returns 0. Writes 1 or 0 corresponding to these bits to the * last three arguments if they are non-NULL. */ extern int sg_get_sense_filemark_eom_ili(const unsigned char * sensep, int sb_len, int * filemark_p, int * eom_p, int * ili_p); /* Returns 1 if SKSV is set and sense key is NO_SENSE or NOT_READY. Also * returns 1 if progress indication sense data descriptor found. Places * progress field from sense data where progress_outp points. If progress * field is not available returns 0. Handles both fixed and descriptor * sense formats. N.B. App should multiply by 100 and divide by 65536 * to get percentage completion from given value. */ extern int sg_get_sense_progress_fld(const unsigned char * sensep, int sb_len, int * progress_outp); /* Closely related to sg_print_sense(). Puts decoded sense data in 'buff'. * Usually multiline with multiple '\n' including one trailing. If * 'raw_sinfo' set appends sense buffer in hex. */ extern void sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer, int sb_len, int raw_sinfo, int buff_len, char * buff); /* Yield string associated with peripheral device type (pdt). Returns * 'buff'. If 'pdt' out of range yields "bad pdt" string. */ extern char * sg_get_pdt_str(int pdt, int buff_len, char * buff); /* Yield string associated with transport protocol identifier (tpi). Returns * 'buff'. If 'tpi' out of range yields "bad tpi" string. */ extern char * sg_get_trans_proto_str(int tpi, int buff_len, char * buff); extern FILE * sg_warnings_strm; extern void sg_set_warnings_strm(FILE * warnings_strm); /* The following "print" functions send ACSII to 'sg_warnings_strm' file * descriptor (default value is stderr) */ extern void sg_print_command(const unsigned char * command); extern void sg_print_sense(const char * leadin, const unsigned char * sense_buffer, int sb_len, int raw_info); extern void sg_print_scsi_status(int scsi_status); /* Utilities can use these process status values for syntax errors and * file (device node) problems (e.g. not found or permissions). */ #define SG_LIB_SYNTAX_ERROR 1 #define SG_LIB_FILE_ERROR 15 /* The sg_err_category_sense() function returns one of the following. * These may be used as process status values (on exit). Notice that * some of the lower values correspond to SCSI sense key values. */ #define SG_LIB_CAT_CLEAN 0 /* No errors or other information */ /* Value 1 left unused for utilities to use SG_LIB_SYNTAX_ERROR */ #define SG_LIB_CAT_NOT_READY 2 /* interpreted from sense buffer */ /* [sk,asc,ascq: 0x2,*,*] */ #define SG_LIB_CAT_MEDIUM_HARD 3 /* medium or hardware error, blank check */ /* [sk,asc,ascq: 0x3/0x4/0x8,*,*] */ #define SG_LIB_CAT_ILLEGAL_REQ 5 /* Illegal request (other than invalid */ /* opcode): [sk,asc,ascq: 0x5,*,*] */ #define SG_LIB_CAT_UNIT_ATTENTION 6 /* interpreted from sense buffer */ /* [sk,asc,ascq: 0x6,*,*] */ /* was SG_LIB_CAT_MEDIA_CHANGED earlier [sk,asc,ascq: 0x6,0x28,*] */ #define SG_LIB_CAT_INVALID_OP 9 /* (Illegal request,) Invalid opcode: */ /* [sk,asc,ascq: 0x5,0x20,0x0] */ #define SG_LIB_CAT_ABORTED_COMMAND 11 /* interpreted from sense buffer */ /* [sk,asc,ascq: 0xb,*,*] */ #define SG_LIB_CAT_NO_SENSE 20 /* sense data with key of "no sense" */ /* [sk,asc,ascq: 0x0,*,*] */ #define SG_LIB_CAT_RECOVERED 21 /* Successful command after recovered err */ /* [sk,asc,ascq: 0x1,*,*] */ #define SG_LIB_CAT_MALFORMED 97 /* Response to SCSI command malformed */ #define SG_LIB_CAT_SENSE 98 /* Something else is in the sense buffer */ #define SG_LIB_CAT_OTHER 99 /* Some other error/warning has occurred */ /* (e.g. a transport or driver error) */ /* Returns a SG_LIB_CAT_* value. If cannot decode sense_buffer or a less * common sense key then return SG_LIB_CAT_SENSE .*/ extern int sg_err_category_sense(const unsigned char * sense_buffer, int sb_len); /* Here are some additional sense data categories that are not returned * by sg_err_category_sense() but are returned by some related functions. */ #define SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO 17 /* Illegal request (other than */ /* invalid opcode) plus 'info' field: */ /* [sk,asc,ascq: 0x5,*,*] */ #define SG_LIB_CAT_MEDIUM_HARD_WITH_INFO 18 /* medium or hardware error */ /* sense key plus 'info' field: */ /* [sk,asc,ascq: 0x3/0x4,*,*] */ #define SG_LIB_CAT_TIMEOUT 33 /* Iterates to next designation descriptor in the device identification * VPD page. The 'initial_desig_desc' should point to start of first * descriptor with 'page_len' being the number of valid bytes in that * and following descriptors. To start, 'off' should point to a negative * value, thereafter it should point to the value yielded by the previous * call. If 0 returned then 'initial_desig_desc + *off' should be a valid * descriptor; returns -1 if normal end condition and -2 for an abnormal * termination. Matches association, designator_type and/or code_set when * any of those values are greater than or equal to zero. */ extern int sg_vpd_dev_id_iter(const unsigned char * initial_desig_desc, int page_len, int * off, int m_assoc, int m_desig_type, int m_code_set); /* <<< General purpose (i.e. not SCSI specific) utility functions >>> */ /* Always returns valid string even if errnum is wild (or library problem). * If errnum is negative, flip its sign. */ extern char * safe_strerror(int errnum); /* Print (to stdout) 'str' of bytes in hex, 16 bytes per line optionally * followed at the right hand side of the line with an ASCII interpretation. * Each line is prefixed with an address, starting at 0 for str[0]..str[15]. * All output numbers are in hex. 'no_ascii' allows for 3 output types: * > 0 each line has address then up to 16 ASCII-hex bytes * = 0 in addition, the bytes are listed in ASCII to the right * < 0 only the ASCII-hex bytes are listed (i.e. without address) */ extern void dStrHex(const char* str, int len, int no_ascii); /* Returns 1 when executed on big endian machine; else returns 0. * Useful for displaying ATA identify words (which need swapping on a * big endian machine). */ extern int sg_is_big_endian(); /* Extract character sequence from ATA words as in the model string * in a IDENTIFY DEVICE response. Returns number of characters * written to 'ochars' before 0 character is found or 'num' words * are processed. */ extern int sg_ata_get_chars(const unsigned short * word_arr, int start_word, int num_words, int is_big_endian, char * ochars); /* Print (to stdout) 16 bit 'words' in hex, 8 words per line optionally * followed at the right hand side of the line with an ASCII interpretation * (pairs of ASCII characters in big endian order (upper first)). * Each line is prefixed with an address, starting at 0. * All output numbers are in hex. 'no_ascii' allows for 3 output types: * > 0 each line has address then up to 8 ASCII-hex words * = 0 in addition, the words are listed in ASCII pairs to the right * = -1 only the ASCII-hex words are listed (i.e. without address) * = -2 only the ASCII-hex words, formatted for "hdparm --Istdin" * < -2 same as -1 * If 'swapb' non-zero then bytes in each word swapped. Needs to be set * for ATA IDENTIFY DEVICE response on big-endian machines. */ extern void dWordHex(const unsigned short* words, int num, int no_ascii, int swapb); /* If the number in 'buf' can not be decoded or the multiplier is unknown * then -1 is returned. Accepts a hex prefix (0x or 0X) or a 'h' (or 'H') * suffix. Otherwise a decimal multiplier suffix may be given. Recognised * multipliers: c C *1; w W *2; b B *512; k K KiB *1,024; * KB *1,000; m M MiB *1,048,576; MB *1,000,000; g G GiB *1,073,741,824; * GB *1,000,000,000 and x which multiplies by . */ extern int sg_get_num(const char * buf); /* If the number in 'buf' can not be decoded then -1 is returned. Accepts a * hex prefix (0x or 0X) or a 'h' (or 'H') suffix; otherwise decimal is * assumed. Does not accept multipliers. Accept a comma (","), a whitespace * or newline as terminator. */ extern int sg_get_num_nomult(const char * buf); /* If the number in 'buf' can not be decoded or the multiplier is unknown * then -1LL is returned. Accepts a hex prefix (0x or 0X) or a 'h' (or 'H') * suffix. Otherwise a decimal multiplier suffix may be given. In addition * to supporting the multipliers of sg_get_num(), this function supports: * t T TiB *(2**40); TB *(10**12); p P PiB *(2**50); PB *(10**15) . */ extern int64_t sg_get_llnum(const char * buf); /* <<< Architectural support functions [is there a better place?] >>> */ /* Non Unix OSes distinguish between text and binary files. * Set text mode on fd. Does nothing in Unix. Returns negative number on * failure. */ extern int sg_set_text_mode(int fd); /* Set binary mode on fd. Does nothing in Unix. Returns negative number on * failure. */ extern int sg_set_binary_mode(int fd); #ifdef __cplusplus } #endif #endif sdparm-1.08/include/sg_pt_win32.h0000664000175000017500000001107612061626602015666 0ustar douggdougg#ifndef SG_PT_WIN32_H #define SG_PT_WIN32_H /* * The information in this file was obtained from scsi-wnt.h by * Richard Stemmer, rs@epost.de . He in turn gives credit to * Jay A. Key (for scsipt.c). * The plscsi program (by Pat LaVarre ) has * also been used as a reference. * Much of the information in this header can also be obtained * from msdn.microsoft.com . * Updated for cygwin version 1.7.17 changes 20121026 */ #include #define SCSI_MAX_SENSE_LEN 64 #define SCSI_MAX_CDB_LEN 16 #define SCSI_MAX_INDIRECT_DATA 16384 typedef struct { USHORT Length; UCHAR ScsiStatus; UCHAR PathId; UCHAR TargetId; UCHAR Lun; UCHAR CdbLength; UCHAR SenseInfoLength; UCHAR DataIn; ULONG DataTransferLength; ULONG TimeOutValue; ULONG_PTR DataBufferOffset; /* was ULONG; problem in 64 bit */ ULONG SenseInfoOffset; UCHAR Cdb[SCSI_MAX_CDB_LEN]; } SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH; typedef struct { USHORT Length; UCHAR ScsiStatus; UCHAR PathId; UCHAR TargetId; UCHAR Lun; UCHAR CdbLength; UCHAR SenseInfoLength; UCHAR DataIn; ULONG DataTransferLength; ULONG TimeOutValue; PVOID DataBuffer; ULONG SenseInfoOffset; UCHAR Cdb[SCSI_MAX_CDB_LEN]; } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT; typedef struct { SCSI_PASS_THROUGH spt; /* plscsi shows a follow on 16 bytes allowing 32 byte cdb */ ULONG Filler; UCHAR ucSenseBuf[SCSI_MAX_SENSE_LEN]; UCHAR ucDataBuf[SCSI_MAX_INDIRECT_DATA]; } SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS; typedef struct { SCSI_PASS_THROUGH_DIRECT spt; ULONG Filler; UCHAR ucSenseBuf[SCSI_MAX_SENSE_LEN]; } SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER; typedef struct { UCHAR NumberOfLogicalUnits; UCHAR InitiatorBusId; ULONG InquiryDataOffset; } SCSI_BUS_DATA, *PSCSI_BUS_DATA; typedef struct { UCHAR NumberOfBusses; SCSI_BUS_DATA BusData[1]; } SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO; typedef struct { UCHAR PathId; UCHAR TargetId; UCHAR Lun; BOOLEAN DeviceClaimed; ULONG InquiryDataLength; ULONG NextInquiryDataOffset; UCHAR InquiryData[1]; } SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA; typedef struct { ULONG Length; UCHAR PortNumber; UCHAR PathId; UCHAR TargetId; UCHAR Lun; } SCSI_ADDRESS, *PSCSI_ADDRESS; /* * method codes */ #define METHOD_BUFFERED 0 #define METHOD_IN_DIRECT 1 #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 /* * file access values */ #define FILE_ANY_ACCESS 0 #ifndef FILE_READ_ACCESS #define FILE_READ_ACCESS 0x0001 #endif #ifndef FILE_WRITE_ACCESS #define FILE_WRITE_ACCESS 0x0002 #endif #define IOCTL_SCSI_BASE 0x00000004 /* * constants for DataIn member of SCSI_PASS_THROUGH* structures */ #define SCSI_IOCTL_DATA_OUT 0 #define SCSI_IOCTL_DATA_IN 1 #define SCSI_IOCTL_DATA_UNSPECIFIED 2 /* * Standard IOCTL define */ #ifndef CTL_CODE #define CTL_CODE(DevType, Function, Method, Access) \ (((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) #endif #define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, \ METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, \ METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, \ METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, \ METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, \ METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) #define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, \ METHOD_BUFFERED, FILE_ANY_ACCESS) #endif sdparm-1.08/COPYING0000664000175000017500000000263711505200742012765 0ustar douggdouggCopyright (c) 2005-2010 Douglas Gilbert. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sdparm-1.08/ChangeLog0000664000175000017500000003163712154112737013515 0ustar douggdouggThe version number is hardcoded into sdparm.c (in a C string); the rpm spec file: sdparm.spec ; the debian/changelog file; and the configure.ac file (in the AC_INIT item). ChangeLog for sdparm-1.08 [20130606] [svn: r215] - device id VPD: add protocol specific port identifier - control extension mpage: add max sense data length - power condition mpage: FIDCPC->CCF_IDLE, FSBCPC->CCF_STAND, FSTCPC->CCF_STOPP (spc4r34+) - caching mpage: add SYNC_PROG field (sbc3r33) - block device characteristics VPD page additions sbc3r34 - extended inquiry vpd page: add max supported sense data length - protocol-specific port information VPD page for SAS SSP, persistent connection (spl3r2), power disable (spl3r3) - allow --readonly with --set= and --clear= - add placeholder for third party copy VPD page - supply more information if a UA occurs - add Makefile so scripts/sas_disk_blink installed - scripts/scsi_ch_swp: new, uses sdparm and blockdev - ./configure options: - change --enable-no-linux-bsg to --disable-linuxbsg - add --disable-scsistrings to reduce utility size with non-libsgutils build - point svn:externals to rev 498 of sg3_utils - report sdat_ovfl bit (if set) in sense data - sg_pt_linux: expand DID_ (host_byte) codes - cope with a transport error plus sense data - prefer major() over MAJOR() macro - win32: fixes for cygwin version 1.7.17 headers ChangeLog for sdparm-1.07 [20120121] [svn: r188] - LB provisioning + Block limits VPD pages to sbc3r27 - Enhanced phy control page: optical mode enabled (spl-r07) - Phy control and discover page: sync to spl2r02 - sync with spc4r31+32 (handle status good with sense) - extended inquiry VPD: add POA_SUP, HRA_SUP and VSA_SUP - application tag mode page subcode 0xf0->0x2 (sbc3r28) - add 'sinq' pseudo VPD page for standard inquiry response - add power consumption mode and VPD pages (spc4r33) - point out some mode page numbers are vendor specific ChangeLog for sdparm-1.06 [20101031] [svn: r166] - allow upper and lower case in field, (mode and vpd) page, vendor, transport or command matching - control mode page: add ATMPE and RWWP fields (spc4r27) - extended inquiry vpd page: add extended self test completion minutes field (spc4r27) - power control mode page: PM_BG_PRECEDENCE field (spc4r24) - FIDCPC, FSBCPC, FSTCPC fields (spc4r25) - sbc3r25 renames 'thin' provisioning' to 'logical block provisioning'; changes mode+vpd page and field names - add Application tag mode page - add SITPUA bit to logical block provisioning mode page - fix '-eal' problem with vendor pages - point svn:externals to rev 334 of sg3_utils ChangeLog for sdparm-1.05 [20100413] [svn: r149] - add '--readonly' option especially for '-C start' and '-C stop' on ATA disks. - Control mode page updates (spc4r23) - add Control data protection mode page (ssc4r01) - block device characteristics VPD page: decode form factor - extended inquiry VPD page: activate_microcode+r_sup (spc4r23) - Automation device serial number and Data transfer device element address VPD pages (ssc4r01) - add SBC Referrals VPD page (sbc3r22) - expand SBC Thin provisioning VPD page (sbc3r22) - expand SBC Block limits VPD page (sbc3r22) - SAS-2.1 specification split, upper layers placed in SPL - add enable_slumber and enable_partial fields to Enhanced phy control mode page - add AM_MAINTAINER_MODE to configure.ac to lessen build issues - build infrastructure change to use libsgutils2 if available ChangeLog for sdparm-1.04 [20090920] [svn: r129] - add SAT ATA Power condition mode page (sat2r06) - add SBC Thin provisioning mode page (sbc3r20) - add SBC Thin provisioning VPD page (sbc3r20) - sync with spc4r21 - add Power condition, update extended inquiry VPD pages - smc3: add Device capabilities + Extended device capabilities + Transport geometry parameters mode pages - prepare for Thin provisioning VPD and mode pages - expand block limits VPD page - update Power condition mode page - rename SAS-2 phy mode page to Enhanced phy control (SAS) - add ADC mode (sub)page place holders - print mode page descriptors in full in more contexts - add linux bsg support - scripts/sas_disk_blink: moved here from sg3_utils package - rework the '-w' option (win32) per sg_scan in sg3_utils - change SDPARM_* constants to SG_LIB_* - remove sdparm.html, refer to its url in sdparm.8 - sdparm.spec: correction to configure call ChangeLog for sdparm-1.03 [20080623] [svn: r96] - allow more than one DEVICE argument on command line - add speed[=val] and profile commands for MMC - update Extended Inquiry VPD page to spc4r15 - 'di' VPD page: decode "NAA Locally assigned" - SAS protocol-specific port mpage (subpage=0) - add CAWT (sas2r13) and RTOL (sas2r14) - change 'long long' to int64_t to stress only require 64 bit integers (similar change to uint64_t) - cleanup to use sg_cmds_mmc and PDT_* defines - define SDPARM_MINGW when configure detects it - sync with debian unstable files: debian/rules+changelog ChangeLog for sdparm-1.02 [20071008] [svn: r59] - support mode page descriptors with [." type entries replaced by new syntax - support medium partition mpage (SSC) with partitions as descriptors - append relative target port identifier to SAS target port address with '-iq' option - add solaris port - place vendor specific data in sdparm_data_vendor.c - in the absence of an explicit transport or vendor, and if no match on mode page name or field, then try SAS transport - add block device characteristics VPD page - add protocol-specific logical unit information VPD page (SAS) - use new sg_lib sg_get_num_nomult() - place source in subversion repository - use svn:externals property to point to sg3_utils' include/ and lib/ directories - move some files around (e.g. sdparm.8 to doc/) ChangeLog for sdparm-1.01 [20070405] - add element address assignment mode page (smc) - improve error handling in lk 2.4 series mapping to sg devices - add configure.ac rule for mingw (Windows) - include to use PRIx64 instead of %llx - add LUICLR bit to extended inquiry VPD page - correct some headers for C++ inclusion - fix some C code to compile under C++ - fix bug when unusual transport or vendor given - add a Fujitsu vendor mode page - add "initial priority" to control extension mpage - add "disconnect-reconnect" mpage to generic list; there are still transport specific versions - extend block limits VPD page (sbc3r09) - sync with sg3_utils-1.24 pass-through code ChangeLog for sdparm-1.00 [20061016] - update Background control mode subpage (SBC-3) - fix EN_BMS and EN_PS swap - add 'extra' information to Caching mode page (SBC-3) - substitute sg_cmds_basic.[hc] for sg_cmds.[hc] - add '--vendor=' ('-M ') option for vendor specific mode pages (start with Seagate, Hitachi and Maxtor) - fix '--save' so has no effect without '--set' or '--clear' - win32 port based on SCSI Pass Through (SPT) interface - add '--wscan' option in win32 port to scan for available device names - re-arrange some exits status values to be that same as those used by sg3_utils-1.22 ChangeLog for sdparm-0.99 [20060708] - add old power condition page for disks only (0xd) - zero whole device specific parameter field for disks (not just the DPOFUA bit). - revert REQUEST SENSE prior to mode page access change added in sdparm-0.98 (libata doesn't support REQUEST SENSE) - expand exit status values to be more expressive (and the same as those used by the sg3_utils-1.21 package) - warn if value to change a mode page field exceeds the field size - sync with spc4r05a - for ATA information VPD page, decode IDENTIFY response strings - add mode page acronym to first line when '--long' given ChangeLog for sdparm-0.98 [20060518] - add decode for Medium configuration mode page, "mco" (ssc) - sync with SPC-4 rev 04 - fix trailing "h" parsing (e.g. "-p 19h,1") - fix vpd 0x83 designator code 8 name - clean vpd 0x83 output format - fix tape vpd page 0xb0 and 0xb2 mix-up - fix unit serial number vpd length - add di_asis to output device identification designators in the order they appear in the VPD page - when doing mode page work, start with a REQUEST SENSE to flush out any Unit Attention pending - fix '--quiet' option which was consuming next argument ChangeLog for sdparm-0.97 [20060127] - add decode for SAT pATA control mode subpage - add decode for Medium partition mode page (ssc) - add decode for Device configuration extension mode subpage (ssc) - add decode for Software interface identification VPD page - rename 'timeout and protect' mode page acronym to "tp" (mmc) - clear DPOFUA bit for disks in mode select parameters - make '-q' trim output of '-p di' and its components: di_lu, di_port and di_target - allow 'h' suffix as hex indicator (still accept '0x' prefix) - rework sg_lib.[hc] and sg_cmds.[hc] to be less linux specific, add sg_pt.h and sg_pt_linux.c - add logic for FreeBSD port (via sg_pt_freebsd.c) - add logic for Tru64 port (via sg_pt_osf1.c) ChangeLog for sdparm-0.96 [20051119] - add di_lu, di_port and di_target variants of di VPD - re-factor sdparm.c: add sdparm_access.c + sdparm_vpd.c + sdparm_cmd.c - add CORR_D_SUP to Extended INQUIRY VPD page - for ATA information VPD page, '-HHH' output is suitable for "hdparm --Istdin" to decode - add s; 'capacity', 'sense" and 'sync' for READ CAPACITY, REQUEST SENSE and SYNCHRONIZE CACHE respectively - 'ready' command gives progress indication if available - add '--quiet' option to suppress output of INQUIRY strings - add decode for Control extension mode page - add decode for SAS SSP shared port mode subpage - change '-ll' to add explanation of some complex mode page attribute values (e.g. MRIE in Informational exceptions mp) - decode disk specific parameters (wp+dpofua) when '-l' given for full mode page ChangeLog for sdparm-0.95 [20050920] - add debian directory (for builds) - add decode for extended inquiry data VPD page - add decode for management network addresses VPD page - add decode for mode page policy VPD page - add decode for ATA information VPD page - add decode for Block limits VPD page - fix DRA and LBCSS bits in caching mode page - sync with SPC-4 rev 02 - add EBACKERR in Informational exceptions mode page - add some defensive code into SCSI INQUIRY response processing - about 10 fixes to mode page items as a result of chk_sdparm_data - when changing mode pages, check modification position does not exceed actual page length - process '-p' option last since it depends on '-t' and '-i' - output available arguments when '-p' or '-t' arguments don't match - fix command line problem with '--dbd', '--defaults' and '--dummy' ChangeLog for sdparm-0.94 [20050728] - add CD/DVD (MM) capabilities and mechanical status mode page - add Background medium scan (SBC-3) mode subpage - add '--command=' option with these s: ready, start, stop, load, eject and unlock - add decoding for SCSI Ports VPD page - updated to automake version 1.9.5 - copy of sdparm.html placed in doc directory ChangeLog for sdparm-0.93 [20050602] - add '--dbd' option for those pesky RBC devices - add '--transport=' option for transport (protocol) specific mode pages. - add transport (protocol) specific mode pages for fcp, spi, srp and sas - refactor sdparm.c adding the sdparm_data.c file - [Changeable: def: saved: ] -> [cha: def: sav: ] - increase maximum num_bits from 32 to 64 - more sanity checks (e.g. only set/get fields up to mode page length); '--flexible' can override in some cases ChangeLog for sdparm-0.92 [20050520] - add data compression and device configuration mode pages (ssc3) - add timeout + protect plus write parameters mode pages (mmc5) - add XOR control mode page (sbc2) - add SES Management mode page (ses2) - discriminate mode pages based on device's peripheral device type - disallow set/clear acronyms whose pdt doesn't match current device - with option "-ll" decode more of INQUIRY standard response - improve error checking when getting non-existent fields - use double fetch technique when fetching mode pages - add RBC device parameters mode page (rbc) - add '--flexible' option for mode sense 6/10 response mixup - '--inquiry --all' now outputs supported VPD pages page ChangeLog for sdparm-0.91 [20050506] - if lk 2.4 detected, map primary SCSI node to sg node for ease of use - add support for '--inquiry' (VPD pages, defaults to device identification) - decode format and rigid disk mode pages (sbc2) (obsolete but common) ChangeLog for sdparm-0.90 [20050418] - initial version sdparm-1.08/autogen.sh0000775000175000017500000013014111173703555013736 0ustar douggdougg#!/bin/sh # a u t o g e n . s h # # Copyright (c) 2005-2007 United States Government as represented by # the U.S. Army Research Laboratory. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # # 3. The name of the author may not be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ### # # Script for automatically preparing the sources for compilation by # performing the myrid of necessary steps. The script attempts to # detect proper version support, and outputs warnings about particular # systems that have autotool peculiarities. # # Basically, if everything is set up and installed correctly, the # script will validate that minimum versions of the GNU Build System # tools are installed, account for several common configuration # issues, and then simply run autoreconf for you. # # If autoreconf fails, which can happen for many valid configurations, # this script proceeds to run manual preparation steps effectively # providing a POSIX shell script (mostly complete) reimplementation of # autoreconf. # # The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER # environment variables and corresponding _OPTIONS variables (e.g. # AUTORECONF_OPTIONS) may be used to override the default automatic # detection behaviors. Similarly the _VERSION variables will override # the minimum required version numbers. # # Examples: # # To obtain help on usage: # ./autogen.sh --help # # To obtain verbose output: # ./autogen.sh --verbose # # To skip autoreconf and prepare manually: # AUTORECONF=false ./autogen.sh # # To verbosely try running with an older (unsupported) autoconf: # AUTOCONF_VERSION=2.50 ./autogen.sh --verbose # # Author: Christopher Sean Morrison # ###################################################################### # set to minimum acceptible version of autoconf if [ "x$AUTOCONF_VERSION" = "x" ] ; then AUTOCONF_VERSION=2.52 fi # set to minimum acceptible version of automake if [ "x$AUTOMAKE_VERSION" = "x" ] ; then AUTOMAKE_VERSION=1.6.0 fi # set to minimum acceptible 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,v 14.97 2007/06/18 22:25:02 brlcad Exp $" __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 "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] [--version]" echo " --help Help on $NAME_OF_AUTOGEN usage" echo " --verbose Verbose progress output" echo " --quiet Quiet suppressed progress output" 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$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 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-[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 # 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 #################### # 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 ######################## # 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. if test -f COPYING ; then if test -f COPYING.$$.protect_from_automake.backup ; then $VERBOSE_ECHO "Already backed up COPYING in `pwd`" else $VERBOSE_ECHO "Backing up COPYING in `pwd`" $VERBOSE_ECHO "cp -p COPYING COPYING.$$.protect_from_automake.backup" cp -p COPYING COPYING.$$.protect_from_automake.backup fi fi if test -f INSTALL ; then if test -f INSTALL.$$.protect_from_automake.backup ; then $VERBOSE_ECHO "Already backed up INSTALL in `pwd`" else $VERBOSE_ECHO "Backing up INSTALL in `pwd`" $VERBOSE_ECHO "cp -p INSTALL INSTALL.$$.protect_from_automake.backup" cp -p INSTALL INSTALL.$$.protect_from_automake.backup fi fi } ############################## # 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 # COPYING if test -f COPYING.$$.protect_from_automake.backup ; then if test -f COPYING ; then # compare entire content, restore if needed if test "x`cat COPYING`" != "x`cat COPYING.$$.protect_from_automake.backup`" ; then if test "x$spacer" = "xno" ; then $VERBOSE_ECHO spacer=yes fi # restore the backup $VERBOSE_ECHO "Restoring COPYING from backup (automake -f likely clobbered it)" $VERBOSE_ECHO "rm -f COPYING" rm -f COPYING $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING" mv COPYING.$$.protect_from_automake.backup COPYING fi # check contents elif test -f COPYING.$$.protect_from_automake.backup ; then $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING" mv COPYING.$$.protect_from_automake.backup COPYING fi # -f COPYING # just in case $VERBOSE_ECHO "rm -f COPYING.$$.protect_from_automake.backup" rm -f COPYING.$$.protect_from_automake.backup fi # -f COPYING.$$.protect_from_automake.backup # INSTALL if test -f INSTALL.$$.protect_from_automake.backup ; then if test -f INSTALL ; then # compare entire content, restore if needed if test "x`cat INSTALL`" != "x`cat INSTALL.$$.protect_from_automake.backup`" ; then if test "x$spacer" = "xno" ; then $VERBOSE_ECHO spacer=yes fi # restore the backup $VERBOSE_ECHO "Restoring INSTALL from backup (automake -f likely clobbered it)" $VERBOSE_ECHO "rm -f INSTALL" rm -f INSTALL $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL" mv INSTALL.$$.protect_from_automake.backup INSTALL fi # check contents elif test -f INSTALL.$$.protect_from_automake.backup ; then $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL" mv INSTALL.$$.protect_from_automake.backup INSTALL fi # -f INSTALL # just in case $VERBOSE_ECHO "rm -f INSTALL.$$.protect_from_automake.backup" rm -f INSTALL.$$.protect_from_automake.backup fi # -f INSTALL.$$.protect_from_automake.backup 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 file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do if test ! -f $file ; then $VERBOSE_ECHO "Touching ${file} since it does not exist" touch $file fi done ################################################## # 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 ############################################ # 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 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 # ############## need_libtoolize=no for feature in AC_PROG_LIBTOOL LT_INIT ; do $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" found="`grep \"^$feature.*\" $CONFIGURE`" if [ ! "x$found" = "x" ] ; then need_libtoolize=yes break fi done if [ "x$need_libtoolize" = "xyes" ] ; 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 fi # need_libtoolize ############ # 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 `echo $CONFIGURE | basename` 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 <