Imported Upstream version 5.39.1+svn3060

This commit is contained in:
Giuseppe Iuculano 2010-02-04 08:10:32 +01:00
parent f4ebf3d14d
commit a23d51175f
55 changed files with 9417 additions and 17358 deletions

135
CHANGELOG
View File

@ -1,6 +1,6 @@
CHANGELOG for smartmontools
$Id: CHANGELOG 3054 2010-01-28 20:48:28Z chrfranke $
$Id: CHANGELOG 3060 2010-02-03 22:16:40Z chrfranke $
The most recent version of this file is:
http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/trunk/smartmontools/CHANGELOG?view=markup
@ -43,6 +43,139 @@ NOTES FOR FUTURE RELEASES: see TODO file.
<DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
[CF] drivedb.h update:
- Patriot Torqx SSD (patch provided by Gianpaolo Cugola)
[CF] Makefile.am: Avoid duplication of man page filter script.
[CF] smartd: Add option '-C, --capabilities' if libcap-ng is available
(ticket #45).
Support is added if libcap-ng is found during build. This can
be overridden by configure option '--with-libcap-ng=[auto|yes|no]'.
Based on Debian patch:
http://patch-tracker.debian.org/patch/series/view/smartmontools/5.39-3/62_lowcap.patch
Modified to fix regression (ticket #41, Debian bug 564876).
[CF] Bugfix release 5.39.1.
[CF] Linux: Fix spin-up of SATA drive if '-n standby' is used
(ticket #37). For some reason, this happens if the SCSI/SAT
device is opened with O_RDWR instead of O_RDONLY.
[CF] Windows: Fix parsing of 'tw_cli' output for 3ware 9.5.x release
(ticket #43).
[CF] Add USB IDs of Seagate FreeAgent Go, Seagate Expansion Portable
and WD My Passport (IDE).
[CF] autogen.sh: Fix version regexp, allow automake 1.11.1.
[CF] Linux: Allow smartd 'DEVICESCAN -d sat' (ticket #13).
Detects (S)ATA devices behind a standard SAT layer
(Vendor ID: "ATA "), but not USB bridges with SAT support.
Only added for backward compatibility with 5.38.
No longer needed as 'DEVICESCAN' without '-d' includes these devices.
[CF] Add USB ID of Seagate FreeAgent Desktop.
[CF] smartd: Fix directive '-l selftest' (ticket #36)
Regression was introduced with r2773.
[CF] smartd: Don't disable attribute tracking if read thresholds fails.
Windows: Don't return dummy thresholds if IOCTL_STORAGE_QUERY_PROPERTY
or 3ware CLI is used to read SMART data.
[CF] Windows: Print warning if admin rights are missing.
[CF] Replace some 'EXIT(status)' calls by 'return status'.
Remove unnecessary casts from 'nonempty()' calls.
[CF] Windows: Set ata_device::ata_identify_is_cached() return value
according to I/O-control actually used.
[CF] Print ATA output registers if SMART status command returns bogus
register values.
[CF] Windows: Don't return false ATA version info if IDENTIFY data
is build from IOCTL_STORAGE_QUERY_PROPERTY result or from 3ware CLI
output.
smartctl: Handle missing info about ATA version in '-i' output.
[CF] smartctl: Don't print log directory if '-q errorsonly' is specified.
[CF] smartctl: Fix option '-q, --quietmode' (ticket #11).
Regression was introduced with r2807.
[CF] drivedb.h update:
- SAMSUNG SpinPoint F2 EG series
[CF] Add USB ID of Samsung Story Station.
[MS] drivedb.h update:
- Hitachi Travelstar 5K320: some EA models miss last 2 "0"
in model string
- Seagate Barracuda LP series
[CF] drivedb.h update:
- Crucial M225 SSD
[CF] drivedb.h updates:
- WDC Scorpio Blue Serial ATA (640GB, 750GB, 1TB)
- WDC My Passport Essential SE
[CF] Add USB ID of Toshiba PX1270E-1G16.
[CF] Happy New Year! Update copyright year in version info.
[CF] drivedb.h update:
- SAMSUNG SpinPoint M40/60/80 series
[CF] Add direct access to 48-bit LBA register in 'ata_in/out_regs_48bit'.
[DL] drivedb.h updates:
- WDC My Passport Essential/USB (capacity 250GB, 400GB & 500GB)
[DL] -r ataioctl,2: print text representation of data also (ticket #32)
[DL] FreeBSD: freebsd_ata_device::ata_pass_through implemented (part of ticket #18)
[CF] drivedb.h updates:
- Hitachi Travelstar 7K320 (ticket #28)
- Hitachi Travelstar 7K500
[DL] -l gpllog,...: print text representation of data also (ticket #30)
[DL] FreeBSD: check reallocf() result for failures
[AS] FreeBSD: fixing crash on kFreeBSD (#29), patch provided by Petr Salinger
[CF] Makefile.am: 'make check' now tests the syntax of drivedb.h.
[CF] Cygwin: Open drive database files in text mode.
[CF] Cygwin: Check for 'syslogd' and 'syslog-ng' in initd script.
[CF] Windows: Disable Win9x/ME specific code if no longer supported
by compiler.
[CF] Add '-v ID,FORMAT:BYTEORDER[,NAME]' to specify byte order
of attribute raw value.
[CF] configure.in: Change --with-docdir default from
'PREFIX/share/doc/smartmontools-VERSION' to
'DATADIR/doc/smartmontools' to make it consistent with
--docdir option added in autoconf 2.6x (ticket #24).
Autoconf 2.5x is still supported.
[CF] Move drive database entries from 'knowndrives.cpp' to new file
'drivedb.h'. This allows to update the drive database from SVN
if installation was configured with '--enable-drivedb'.
Remove the Makefile target to create 'drivedb.h'.
[CF] do_release: Add support to release from a dir below 'branches'.
Accept partial checkouts.
smartmontools 5.39.1 2010-01-28
[CF] Linux: Fix spin-up of SATA drive if '-n standby' is used

241
Doxyfile Normal file
View File

@ -0,0 +1,241 @@
# Doxyfile 1.5.5
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = smartmontools
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = YES
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT =
INPUT_ENCODING = UTF-8
FILE_PATTERNS = dev*.h \
dev*.cpp \
scsiata.cpp
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = NO
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = YES
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

20
INSTALL
View File

@ -1,7 +1,7 @@
Smartmontools installation instructions
=======================================
$Id: INSTALL 2967 2009-10-23 21:45:56Z chrfranke $
$Id: INSTALL 3057 2010-02-03 20:56:41Z chrfranke $
Please also see the smartmontools home page:
http://smartmontools.sourceforge.net/
@ -242,7 +242,7 @@ Table of contents:
--sbindir=/usr/local/sbin
--sysconfdir=/usr/local/etc
--mandir=/usr/local/share/man
--with-docdir=/usr/local/share/doc/smartmontools-VERSION
--with-docdir=/usr/local/share/doc/smartmontools
--with-initscriptdir=/usr/local/etc/rc.d/init.d
--disable-sample
@ -415,7 +415,7 @@ Same as Red Hat:
--sysconfdir=/etc \
--mandir=/usr/share/man \
--with-initscriptdir=/etc/rc.d/init.d \
--with-docdir=/usr/share/doc/smartmontools-VERSION
--with-docdir=/usr/share/doc/smartmontools
Using DOS text file type as default for the working directories ("textmode"
mount option) is not recommended. Building the binaries and man pages using
@ -655,18 +655,22 @@ OPTIONS DEFAULT AFFECTS
--prefix /usr/local Please see below
--sbindir ${prefix}/sbin Directory for smartd/smartctl executables;
Contents of smartd/smartctl man pages
--docdir ${prefix}/share/doc/smartmontools Location of the documentation
(autoconf >= 2.60 only, see also --with-docdir below)
--mandir ${prefix}/share/man Directory for smartctl/smartd/smartd.conf man pages
--sysconfdir ${prefix}/etc Directory for smartd.conf;
Contents of smartd executable;
Contents of smartd/smartd.conf man pages;
Directory for rc.d/init.d/smartd init script
--with-initscriptdir ${sysconfdir}/init.d/rc.d Location of init scripts
--with-docdir ${prefix}/share/doc/smartmontools-5.X Location of the documentation
--with-docdir ${prefix}/share/doc/smartmontools Location of the documentation
--enable-sample --disable-sample Adds the string '.sample' to the names of the smartd.conf file and the smartd RC file
--with-os-deps os_<guessed>.o OS dependent module(s)
--with-selinux <not set> Enables SELinux support. If smartmontools has to create the /dev/tw[ae] device
nodes for 3ware/AMCC controllers, this option ensures that the nodes are created
with correct SELinux file contexts.
--with-libcap-ng --with-libcap-ng=auto Enables/disables libcap-ng support. If enabled and libcap-ng is
available, option --capabilities is added to smartd.
--enable-drivedb --disable-drivedb Enables default drive database file '${drivedbdir}/drivedb.h'
--with-drivedbdir ${prefix}/share/smartmontools Directory for 'drivedb.h' (implies --enable-drivedb)
--enable-savestates --disable-savestates Enables default smartd state files '${savestates}MODEL-SERIAL.ata.state'
@ -674,6 +678,12 @@ OPTIONS DEFAULT AFFECTS
--enable-attributelog --disable-attributelog Enables default smartd attribute log files
--with-attributelog ${prefix}/var/lib/smartmontools/attrlog. Prefix for smartd attribute log files (implies --enable-attributelog)
Please note that in previous versions of smartmontools (<= 5.39) the
default for --with-docdir was
${prefix}/share/doc/smartmontools-VERSION
This was changed to make it consistent with the default of the
new --docdir option added in autoconf 2.60.
Here's an example:
If you set --prefix=/home/joe and none of the other four
variables then the different directories that are used would be:
@ -681,7 +691,7 @@ variables then the different directories that are used would be:
--mandir /home/joe/share/man
--sysconfdir /home/joe/etc
--with-initscriptdir /home/joe/etc/init.d/rc.d
--with-docdir /home/joe/doc/smartmontools-5.X
--with-docdir /home/joe/doc/smartmontools
This is useful for test installs in a harmless subdirectory somewhere.

View File

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
#
# $Id: Makefile.am 2878 2009-08-26 20:03:06Z chrfranke $
# $Id: Makefile.am 3059 2010-02-03 21:42:09Z chrfranke $
#
@SET_MAKE@
@ -35,6 +35,7 @@ smartd_SOURCES = smartd.cpp \
dev_interface.cpp \
dev_interface.h \
dev_tunnelled.h \
drivedb.h \
extern.h \
int64.h \
knowndrives.cpp \
@ -45,7 +46,7 @@ smartd_SOURCES = smartd.cpp \
utility.cpp \
utility.h
smartd_LDADD = @os_deps@ @os_libs@
smartd_LDADD = @os_deps@ @os_libs@ @CAPNG_LDADD@
smartd_DEPENDENCIES = @os_deps@
EXTRA_smartd_SOURCES = os_darwin.cpp \
@ -104,6 +105,7 @@ smartctl_SOURCES= smartctl.cpp \
dev_interface.cpp \
dev_interface.h \
dev_tunnelled.h \
drivedb.h \
extern.h \
int64.h \
knowndrives.cpp \
@ -242,8 +244,7 @@ EXTRA_DIST = smartd.initd.in \
os_win32/installer.nsi \
$(docs_DATA)
CLEANFILES = drivedb.h \
smartd.conf.5 \
CLEANFILES = smartd.conf.5 \
smartd.conf.4 \
smartd.8 \
smartd.1m \
@ -301,11 +302,6 @@ svnversion.h: CHANGELOG Makefile
endif
# Drive Database
drivedb.h: knowndrives.cpp Makefile
echo '/* drivedb.h. Generated from knowndrives.cpp by Makefile. */' > $@
sed '1,/^\/\/ BEGIN drivedb.h/d;/^\/\/ END drivedb.h/,$$d;s/^ //' $(srcdir)/knowndrives.cpp >> $@
if ENABLE_DRIVEDB
drivedb_DATA = drivedb.h
endif
@ -409,6 +405,12 @@ install-initdDATA : $(initd_DATA_install)
uninstall-initdDATA: $(initd_DATA_uninstall)
if ENABLE_CAPABILITIES
MAN_CAPABILITIES = cat
else
MAN_CAPABILITIES = sed '/BEGIN ENABLE_CAPABILITIES/,/END ENABLE_CAPABILITIES/d'
endif
if ENABLE_DRIVEDB
MAN_DRIVEDB = sed "s|/usr/local/share/smartmontools/drivedb\\.h|$(drivedbdir)/drivedb.h|g"
else
@ -427,36 +429,29 @@ else
MAN_ATTRIBUTELOG = sed '/BEGIN ENABLE_ATTRIBUTELOG/,/END ENABLE_ATTRIBUTELOG/d'
endif
MAN_FILTER = \
sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
s|/usr/local/share/man/|$(mandir)/|g; \
s|/usr/local/sbin/|$(sbindir)/|g; \
s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g; \
s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
$(MAN_CAPABILITIES) | \
$(MAN_DRIVEDB) | \
$(MAN_SAVESTATES) | \
$(MAN_ATTRIBUTELOG)
if OS_FREEBSD
.for file in $(man_MANS)
${file}: $(srcdir)/${file}.in Makefile svnversion.h
sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
s|/usr/local/share/man/|$(mandir)/|g; \
s|/usr/local/sbin/|$(sbindir)/|g; \
s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g; \
s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g; \
s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" ${.ALLSRC:M*.in} | \
$(MAN_DRIVEDB) | \
$(MAN_SAVESTATES) | \
$(MAN_ATTRIBUTELOG) > $@
cat ${.ALLSRC:M*.in} | $(MAN_FILTER) > $@
.endfor
else
smart%: $(srcdir)/smart%.in Makefile svnversion.h
sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g" $< | \
sed "s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" | \
sed "s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" | \
sed "s|/usr/local/share/man/|$(mandir)/|g" | \
sed "s|/usr/local/sbin/|$(sbindir)/|g" | \
sed "s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g" | \
sed "s|/usr/local/share/doc/smartmontools-5.1/|$(docsdir)/|g" | \
sed "s|/usr/local/etc/smartd\\.conf|$(sysconfdir)/smartd.conf|g" | \
sed "s|/usr/local/etc/smart_drivedb\\.h|$(sysconfdir)/smart_drivedb\\.h|g" | \
$(MAN_DRIVEDB) | \
$(MAN_SAVESTATES) | \
$(MAN_ATTRIBUTELOG) > $@
cat $< | $(MAN_FILTER) > $@
endif
# Commands to convert man pages into .html and .txt
@ -501,6 +496,14 @@ endif
$(MAN2TXT) $< > $@
# Check drive database syntax
check:
@if ./smartctl -B $(srcdir)/drivedb.h -P showall >/dev/null; then \
echo "$(srcdir)/drivedb.h: OK"; \
else \
echo "$(srcdir)/drivedb.h: Syntax check failed"; exit 1; \
fi
if OS_WIN32_MINGW
# Definitions for Windows distribution

File diff suppressed because it is too large Load Diff

11
NEWS
View File

@ -1,10 +1,19 @@
smartmontools NEWS
------------------
$Id: NEWS 3054 2010-01-28 20:48:28Z chrfranke $
$Id: NEWS 3057 2010-02-03 20:56:41Z chrfranke $
The most up-to-date version of this file is:
http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/trunk/smartmontools/NEWS?view=markup
Date <Not released yet, please try current SVN>
Summary: smartmontools release 5.40
-----------------------------------------------------------
- Option '-v' allows to specify byte order of attribute raw value
- configure: New default value for '--with-docdir'.
- Drive database is in a separate source file 'drivedb.h'
which can be downloaded from SVN.
- smartd libcap-ng support, option '-C, --capabilities'.
Date 2010-01-28
Summary: smartmontools release 5.39.1
-----------------------------------------------------------

10
TODO
View File

@ -1,6 +1,9 @@
TODO list for smartmontools:
$Id: TODO 2966 2009-10-23 21:05:16Z chrfranke $
$Id: TODO 3006 2009-12-19 21:04:17Z chrfranke $
See also the list of active tickets:
http://sourceforge.net/apps/trac/smartmontools/report/1
USB devices under Linux
-----------------------
@ -16,11 +19,6 @@ Add ability to print counters/values from "Device Statistics" pages
(General Purpose Log address 0x04).
See ATA ACS-2 T13/2015-D Revision 1, Section A.5.
smartctl/smartd
---------------
Add additional -v options (corresponding to comments in
atacmds.c:ataPrintSmartAttribName().
smartctl:
---------
Parse and print additional Attribute flag meanings (IBM ones, eg

1025
aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,8 @@
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2002-10 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2008-10 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
* Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org>
*
@ -37,7 +37,7 @@
#include "utility.h"
#include "dev_ata_cmd_set.h" // for parsed_ata_device
const char * atacmds_cpp_cvsid = "$Id: atacmds.cpp 3046 2010-01-22 21:30:02Z chrfranke $"
const char * atacmds_cpp_cvsid = "$Id: atacmds.cpp 3040 2010-01-18 20:57:39Z chrfranke $"
ATACMDS_H_CVSID;
// for passing global control variables
@ -58,7 +58,8 @@ extern smartmonctrl *con;
// that SMART was first added into the ATA/ATAPI-3 Standard with
// Revision 3 of the document, July 25, 1995. Look at the "Document
// Status" revision commands at the beginning of
// http://www.t13.org/project/d2008r6.pdf to see this.
// http://www.t13.org/Documents/UploadedDocuments/project/d2008r7b-ATA-3.pdf
// to see this.
#define NOVAL_0 0x0000
#define NOVAL_1 0xffff
/* word 81: minor version number */
@ -271,6 +272,19 @@ bool parse_attribute_def(const char * opt, ata_vendor_attr_defs & defs,
flags = ATTRFLAG_INCREASING;
}
// Split "format[:byteorder]"
char byteorder[8+1] = "";
if (strchr(fmtname, ':')) {
if (!( sscanf(fmtname, "%*[^:]%n:%8[012345rvwz]%n", &n1, byteorder, &n2) >= 1
&& n2 == (int)strlen(fmtname)))
return false;
fmtname[n1] = 0;
if (strchr(byteorder, 'v'))
flags |= (ATTRFLAG_NO_NORMVAL|ATTRFLAG_NO_WORSTVAL);
if (strchr(byteorder, 'w'))
flags |= ATTRFLAG_NO_WORSTVAL;
}
// Find format name
for (i = 0; ; i++) {
if (i >= num_format_names)
@ -280,9 +294,9 @@ bool parse_attribute_def(const char * opt, ata_vendor_attr_defs & defs,
}
ata_attr_raw_format format = format_names[i].format;
// 64-bit formats use the normalized value bytes.
if (format == RAWFMT_RAW64 || format == RAWFMT_HEX64)
flags |= ATTRFLAG_NO_NORMVAL;
// 64-bit formats use the normalized and worst value bytes.
if (!*byteorder && (format == RAWFMT_RAW64 || format == RAWFMT_HEX64))
flags |= (ATTRFLAG_NO_NORMVAL|ATTRFLAG_NO_WORSTVAL);
if (!id) {
// "N,format" -> set format for all entries
@ -294,6 +308,7 @@ bool parse_attribute_def(const char * opt, ata_vendor_attr_defs & defs,
defs[i].priority = priority;
defs[i].raw_format = format;
defs[i].flags = flags;
strcpy(defs[i].byteorder, byteorder);
}
}
else if (defs[id].priority <= priority) {
@ -303,6 +318,7 @@ bool parse_attribute_def(const char * opt, ata_vendor_attr_defs & defs,
defs[id].raw_format = format;
defs[id].priority = priority;
defs[id].flags = flags;
strcpy(defs[id].byteorder, byteorder);
}
return true;
@ -317,7 +333,7 @@ std::string create_vendor_attribute_arg_list()
std::string s;
unsigned i;
for (i = 0; i < num_format_names; i++)
s += strprintf("%s\tN,%s[,ATTR_NAME]",
s += strprintf("%s\tN,%s[:012345rvwz][,ATTR_NAME]",
(i>0 ? "\n" : ""), format_names[i].name);
for (i = 0; i < num_old_vendor_opts; i++)
s += strprintf("\n\t%s", map_old_vendor_opts[i][0]);
@ -420,12 +436,19 @@ void print_regs(const char * prefix, const ata_out_regs & r, const char * suffix
static void prettyprint(const unsigned char *p, const char *name){
pout("\n===== [%s] DATA START (BASE-16) =====\n", name);
for (int i=0; i<512; i+=16, p+=16)
#define P(n) (isprint((int)(p[n]))?(int)(p[n]):'.')
// print complete line to avoid slow tty output and extra lines in syslog.
pout("%03d-%03d: %02x %02x %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x\n",
"%02x %02x %02x %02x %02x %02x %02x %02x"
" |%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c|"
"%c",
i, i+16-1,
p[ 0], p[ 1], p[ 2], p[ 3], p[ 4], p[ 5], p[ 6], p[ 7],
p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15]);
p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15],
P( 0), P( 1), P( 2), P( 3), P( 4), P( 5), P( 6), P( 7),
P( 8), P( 9), P(10), P(11), P(12), P(13), P(14), P(15),
'\n');
#undef P
pout("===== [%s] DATA END (512 Bytes) =====\n\n", name);
}
@ -600,8 +623,10 @@ int smartcommandhandler(ata_device * device, smart_command_set command, int sele
"probable SAT/USB truncation\n");
} else {
// We haven't gotten output that makes sense; print out some debugging info
pout("Error SMART Status command failed\n"
"Please get assistance from %s\n", PACKAGE_HOMEPAGE);
pout("Error SMART Status command failed\n");
pout("Please get assistance from %s\n", PACKAGE_HOMEPAGE);
pout("Register values returned from SMART Status command are:\n");
print_regs(" ", out.out_regs);
errno = EIO;
retval = -1;
}
@ -837,7 +862,7 @@ int ataVersionInfo(const char ** description, const ata_identify_device * drive,
// First check if device has ANY ATA version information in it
if (major==NOVAL_0 || major==NOVAL_1) {
*description=NULL;
return -1;
return 0; // No info found
}
// The minor revision number has more information - try there first
@ -1736,8 +1761,8 @@ ata_attr_state ata_get_attr_state(const ata_smart_attribute & attr,
if (attr.current <= thre.threshold)
return ATTRSTATE_FAILED_NOW;
// Failed in the passed if worst value is below threshold
if (attr.worst <= thre.threshold)
// Failed in the past if worst value is below threshold
if (!(defs[attr.id].flags & ATTRFLAG_NO_WORSTVAL) && attr.worst <= thre.threshold)
return ATTRSTATE_FAILED_PAST;
return ATTRSTATE_OK;
@ -1767,24 +1792,36 @@ static ata_attr_raw_format get_default_raw_format(unsigned char id)
uint64_t ata_get_attr_raw_value(const ata_smart_attribute & attr,
const ata_vendor_attr_defs & defs)
{
// Get 48 bit raw value
const unsigned char * raw = attr.raw;
uint64_t rawvalue;
rawvalue = raw[0]
| ( raw[1] << 8)
| ( raw[2] << 16)
| ((uint64_t)raw[3] << 24)
| ((uint64_t)raw[4] << 32)
| ((uint64_t)raw[5] << 40);
const ata_vendor_attr_defs::entry & def = defs[attr.id];
if (defs[attr.id].flags & ATTRFLAG_NO_NORMVAL) {
// Some SSD vendors use bytes 3-10 from the Attribute
// Data Structure to store a 64-bit raw value.
rawvalue <<= 8;
rawvalue |= attr.worst;
rawvalue <<= 8;
rawvalue |= attr.current;
// Use default byteorder if not specified
const char * byteorder = def.byteorder;
if (!*byteorder) {
if (def.raw_format == RAWFMT_RAW64 || def.raw_format == RAWFMT_HEX64)
byteorder = "543210wv";
else
byteorder = "543210";
}
// Build 64-bit value from selected bytes
uint64_t rawvalue = 0;
for (int i = 0; byteorder[i]; i++) {
unsigned char b;
switch (byteorder[i]) {
case '0': b = attr.raw[0]; break;
case '1': b = attr.raw[1]; break;
case '2': b = attr.raw[2]; break;
case '3': b = attr.raw[3]; break;
case '4': b = attr.raw[4]; break;
case '5': b = attr.raw[5]; break;
case 'r': b = attr.reserv; break;
case 'v': b = attr.current; break;
case 'w': b = attr.worst; break;
default : b = 0; break;
}
rawvalue <<= 8; rawvalue |= b;
}
return rawvalue;
}
@ -1793,7 +1830,7 @@ uint64_t ata_get_attr_raw_value(const ata_smart_attribute & attr,
std::string ata_format_attr_raw_value(const ata_smart_attribute & attr,
const ata_vendor_attr_defs & defs)
{
// Get 48 bit or64 bit raw value
// Get 48 bit or 64 bit raw value
uint64_t rawvalue = ata_get_attr_raw_value(attr, defs);
// Get 16 bit words
@ -1821,6 +1858,7 @@ std::string ata_format_attr_raw_value(const ata_smart_attribute & attr,
break;
case RAWFMT_RAW48:
case RAWFMT_RAW64:
s = strprintf("%"PRIu64, rawvalue);
break;
@ -1828,10 +1866,6 @@ std::string ata_format_attr_raw_value(const ata_smart_attribute & attr,
s = strprintf("0x%012"PRIx64, rawvalue);
break;
case RAWFMT_RAW64:
s = strprintf("%"PRIu64, rawvalue);
break;
case RAWFMT_HEX64:
s = strprintf("0x%016"PRIx64, rawvalue);
break;
@ -2198,7 +2232,7 @@ int ataReadSCTTempHist(ata_device * device, ata_sct_temperature_history_table *
return -1;
if (!(sts->ext_status_code == 0 && sts->action_code == 5 && sts->function_code == 1)) {
pout("Error unexcepted SCT status 0x%04x (action_code=%u, function_code=%u)\n",
pout("Error unexpected SCT status 0x%04x (action_code=%u, function_code=%u)\n",
sts->ext_status_code, sts->action_code, sts->function_code);
return -1;
}

View File

@ -26,7 +26,7 @@
#ifndef ATACMDS_H_
#define ATACMDS_H_
#define ATACMDS_H_CVSID "$Id: atacmds.h 2983 2009-11-14 21:41:41Z chrfranke $"
#define ATACMDS_H_CVSID "$Id: atacmds.h 3020 2009-12-31 01:11:51Z dlukes $"
#include "dev_interface.h" // ata_device
@ -656,8 +656,9 @@ enum ata_attr_raw_format
// Attribute flags
enum {
ATTRFLAG_INCREASING = 0x01, // Value not reset (for reallocated/pending counts)
ATTRFLAG_NO_NORMVAL = 0x02 // Normalized value not valid
ATTRFLAG_INCREASING = 0x01, // Value not reset (for reallocated/pending counts)
ATTRFLAG_NO_NORMVAL = 0x02, // Normalized value not valid
ATTRFLAG_NO_WORSTVAL = 0x04 // Worst value not valid
};
// Vendor attribute display defs for all attribute ids
@ -670,12 +671,13 @@ public:
ata_attr_raw_format raw_format; // Raw value print format
ata_vendor_def_prior priority; // Setting priority
unsigned flags; // ATTRFLAG_*
char byteorder[8+1]; // String [012345rvwz] to define byte order
entry()
: raw_format(RAWFMT_DEFAULT),
priority(PRIOR_DEFAULT),
flags(0)
{ }
{ byteorder[0] = 0; }
};
entry & operator[](unsigned char id)

View File

@ -44,7 +44,7 @@
#include "utility.h"
#include "knowndrives.h"
const char * ataprint_cpp_cvsid = "$Id: ataprint.cpp 3046 2010-01-22 21:30:02Z chrfranke $"
const char * ataprint_cpp_cvsid = "$Id: ataprint.cpp 3037 2010-01-16 20:07:13Z chrfranke $"
ATAPRINT_H_CVSID;
// for passing global control variables
@ -490,26 +490,29 @@ static bool PrintDriveInfo(const ata_identify_device * drive, bool fix_swapped_i
const char *description; unsigned short minorrev;
int version = ataVersionInfo(&description, drive, &minorrev);
// unrecognized minor revision code
char unknown[64];
if (!description){
if (!minorrev)
sprintf(unknown, "Exact ATA specification draft version not indicated");
else
sprintf(unknown,"Not recognized. Minor revision code: 0x%02hx", minorrev);
description=unknown;
}
// SMART Support was first added into the ATA/ATAPI-3 Standard with
// Revision 3 of the document, July 25, 1995. Look at the "Document
// Status" revision commands at the beginning of
// http://www.t13.org/project/d2008r6.pdf to see this. So it's not
// enough to check if we are ATA-3. Version=-3 indicates ATA-3
// BEFORE Revision 3.
pout("ATA Version is: %d\n",(int)abs(version));
pout("ATA Standard is: %s\n",description);
// http://www.t13.org/Documents/UploadedDocuments/project/d2008r7b-ATA-3.pdf
// to see this. So it's not enough to check if we are ATA-3.
// Version=-3 indicates ATA-3 BEFORE Revision 3.
// Version=0 indicates that no info is found. This may happen if
// the OS provides only part of the IDENTIFY data.
std::string majorstr, minorstr;
if (version) {
majorstr = strprintf("%d", abs(version));
if (description)
minorstr = description;
else if (!minorrev)
minorstr = "Exact ATA specification draft version not indicated";
else
minorstr = strprintf("Not recognized. Minor revision code: 0x%04x", minorrev);
}
pout("ATA Version is: %s\n", infofound(majorstr.c_str()));
pout("ATA Standard is: %s\n", infofound(minorstr.c_str()));
// print current time and date and timezone
char timedatetz[DATEANDEPOCHLEN]; dateandtimezone(timedatetz);
pout("Local Time is: %s\n", timedatetz);
@ -518,7 +521,7 @@ static bool PrintDriveInfo(const ata_identify_device * drive, bool fix_swapped_i
if (dbentry && *dbentry->warningmsg)
pout("\n==> WARNING: %s\n\n", dbentry->warningmsg);
if (version>=3)
if (!version || version >= 3)
return !!dbentry;
pout("SMART is only available in ATA Version 3 Revision 3 or greater.\n");
@ -836,11 +839,15 @@ static void PrintSmartAttribWithThres(const ata_smart_values * data,
}
// Format value, worst, threshold
std::string valstr, threstr;
std::string valstr, worstr, threstr;
if (state > ATTRSTATE_NO_NORMVAL)
valstr = strprintf("%.3d %.3d", attr.current, attr.worst);
valstr = strprintf("%.3d", attr.current);
else
valstr = "--- ---";
valstr = "---";
if (!(defs[attr.id].flags & ATTRFLAG_NO_WORSTVAL))
worstr = strprintf("%.3d", attr.worst);
else
worstr = "---";
if (state > ATTRSTATE_NO_THRESHOLD)
threstr = strprintf("%.3d", thre.threshold);
else
@ -848,9 +855,9 @@ static void PrintSmartAttribWithThres(const ata_smart_values * data,
// Print line for each valid attribute
std::string attrname = ata_get_smart_attr_name(attr.id, defs);
pout("%3d %-24s0x%04x %-9s %-3s %-10s%-9s%-12s%s\n",
pout("%3d %-24s0x%04x %-3s %-3s %-3s %-10s%-9s%-12s%s\n",
attr.id, attrname.c_str(), attr.flags,
valstr.c_str(), threstr.c_str(),
valstr.c_str(), worstr.c_str(), threstr.c_str(),
(ATTRIBUTE_FLAGS_PREFAILURE(attr.flags)? "Pre-fail" : "Old_age"),
(ATTRIBUTE_FLAGS_ONLINE(attr.flags)? "Always" : "Offline"),
(state == ATTRSTATE_FAILED_NOW ? "FAILING_NOW" :
@ -1012,10 +1019,16 @@ static void PrintLogPages(const char * type, const unsigned char * data,
for (unsigned i = 0; i < num_pages * 512; i += 16) {
const unsigned char * p = data+i;
pout("%07x: %02x %02x %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x\n",
"%02x %02x %02x %02x %02x %02x %02x %02x ",
(page * 512) + i,
p[ 0], p[ 1], p[ 2], p[ 3], p[ 4], p[ 5], p[ 6], p[ 7],
p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15]);
#define P(n) (isprint((int)(p[n]))?(int)(p[n]):'.')
pout("|%c%c%c%c%c%c%c%c"
"%c%c%c%c%c%c%c%c|\n",
P( 0), P( 1), P( 2), P( 3), P( 4), P( 5), P( 6), P( 7),
P( 8), P( 9), P(10), P(11), P(12), P(13), P(14), P(15));
#undef P
if ((i & 0x1ff) == 0x1f0)
pout("\n");
}
@ -1159,7 +1172,7 @@ static int PrintSmartErrorlog(const ata_smart_errorlog *data,
const ata_smart_errorlog_error_struct * summary = &(elog->error_struct);
// Spec says: unused error log structures shall be zero filled
if (nonempty((unsigned char*)elog,sizeof(*elog))){
if (nonempty(elog, sizeof(*elog))){
// Table 57 of T13/1532D Volume 1 Revision 3
const char *msgstate = get_error_log_state_desc(summary->state);
int days = (int)summary->timestamp/24;
@ -1195,7 +1208,7 @@ static int PrintSmartErrorlog(const ata_smart_errorlog *data,
const ata_smart_errorlog_command_struct * thiscommand = elog->commands+j;
// Spec says: unused data command structures shall be zero filled
if (nonempty((unsigned char*)thiscommand,sizeof(*thiscommand))) {
if (nonempty(thiscommand, sizeof(*thiscommand))) {
char timestring[32];
// Convert integer milliseconds to a text-format string
@ -1763,7 +1776,7 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
// If requested, show which presets would be used for this drive and exit.
if (options.show_presets) {
show_presets(&drive, options.fix_swapped_id);
EXIT(0);
return 0;
}
// Use preset vendor attribute options unless user has requested otherwise.

View File

@ -26,7 +26,7 @@
#ifndef ATAPRINT_H_
#define ATAPRINT_H_
#define ATAPRINT_H_CVSID "$Id: ataprint.h 2975 2009-10-29 22:52:38Z chrfranke $\n"
#define ATAPRINT_H_CVSID "$Id: ataprint.h 3020 2009-12-31 01:11:51Z dlukes $\n"
#include <vector>

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $Id: autogen.sh 2844 2009-07-18 12:59:21Z chrfranke $
# $Id: autogen.sh 3043 2010-01-22 19:24:59Z chrfranke $
#
# Generate ./configure from config.in and Makefile.in from Makefile.am.
# This also adds files like missing,depcomp,install-sh to the source
@ -64,7 +64,7 @@ case "$AUTOMAKE" in
*automake-1.8)
ver=1.8 ;;
*)
ver="`$AUTOMAKE --version | sed -n '1s,^.*\([12]\.[.0-9]*[-pl0-9]*\).*$,\1,p'`"
ver="`$AUTOMAKE --version | sed -n '1s,^.*[^.0-9]\([12]\.[0-9][-.0-9pl]*\).*$,\1,p'`"
ver="${ver:-?.?.?}"
esac
@ -83,7 +83,7 @@ case "$ver" in
rm -f casetest.tmp
;;
1.9.[1-6]|1.10|1.10.[12]|1.11)
1.9.[1-6]|1.10|1.10.[12]|1.11|1.11.1)
# OK
;;

1501
config.guess vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,169 +0,0 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* smartmontools CVS Tag */
#undef CONFIG_H_CVSID
/* use mailx as default mailer */
#undef DEFAULT_MAILER
/* Define to 1 if you have the `ata_identify_is_cached' function in os_*.c. */
#undef HAVE_ATA_IDENTIFY_IS_CACHED
/* Define to 1 if C++ compiler supports __attribute__((packed)) */
#undef HAVE_ATTR_PACKED
/* Define to 1 if you have the <dev/ata/atavar.h> header file. */
#undef HAVE_DEV_ATA_ATAVAR_H
/* Define to 1 if you have the <dev/ciss/cissio.h> header file. */
#undef HAVE_DEV_CISS_CISSIO_H
/* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO
/* Define to 1 if you have the `getdomainname' function. */
#undef HAVE_GETDOMAINNAME
/* Define to 1 if you have the `gethostbyname' function. */
#undef HAVE_GETHOSTBYNAME
/* Define to 1 if you have the `gethostname' function. */
#undef HAVE_GETHOSTNAME
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
/* Define to 1 if you have the `get_os_version_str' function in os_*.c. */
#undef HAVE_GET_OS_VERSION_STR
/* Define to 1 if the system has the type `int64_t'. */
#undef HAVE_INT64_T
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `usb' library (-lusb). */
#undef HAVE_LIBUSB
/* Define to 1 if you have the <linux/cciss_ioctl.h> header file. */
#undef HAVE_LINUX_CCISS_IOCTL_H
/* Define to 1 if you have the <linux/compiler.h> header file. */
#undef HAVE_LINUX_COMPILER_H
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define to 1 if you have the <selinux/selinux.h> header file. */
#undef HAVE_SELINUX_SELINUX_H
/* Define to 1 if you have the `sigset' function. */
#undef HAVE_SIGSET
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoull' function. */
#undef HAVE_STRTOULL
/* Define to 1 if you have the <sys/inttypes.h> header file. */
#undef HAVE_SYS_INTTYPES_H
/* Define to 1 if you have the <sys/int_types.h> header file. */
#undef HAVE_SYS_INT_TYPES_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/tweio.h> header file. */
#undef HAVE_SYS_TWEIO_H
/* Define to 1 if you have the <sys/twereg.h> header file. */
#undef HAVE_SYS_TWEREG_H
/* Define to 1 if you have the <sys/tw_osl_ioctl.h> header file. */
#undef HAVE_SYS_TW_OSL_IOCTL_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if the system has the type `uint64_t'. */
#undef HAVE_UINT64_T
/* Define to 1 if you have the `uname' function. */
#undef HAVE_UNAME
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if the `snprintf' function is sane */
#undef HAVE_WORKING_SNPRINTF
/* need assembly code os_solaris_ata.s */
#undef NEED_SOLARIS_ATA_CODE
/* Define to 1 if os_*.cpp still uses the old interface */
#undef OLD_INTERFACE
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* smartmontools Home Page */
#undef PACKAGE_HOMEPAGE
/* 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
/* smartmontools Build Host */
#undef SMARTMONTOOLS_BUILD_HOST
/* smartmontools Configure Arguments */
#undef SMARTMONTOOLS_CONFIGURE_ARGS
/* smartmontools Configure Date */
#undef SMARTMONTOOLS_CONFIGURE_DATE
/* smartmontools Release Date */
#undef SMARTMONTOOLS_RELEASE_DATE
/* smartmontools Release Time */
#undef SMARTMONTOOLS_RELEASE_TIME
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to 1 if SELinux support is enabled */
#undef WITH_SELINUX

1705
config.sub vendored

File diff suppressed because it is too large Load Diff

7490
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
#
# $Id: configure.in 3054 2010-01-28 20:48:28Z chrfranke $
# $Id: configure.in 3057 2010-02-03 20:56:41Z chrfranke $
#
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(smartmontools, 5.39.1, smartmontools-support@lists.sourceforge.net)
AC_INIT(smartmontools, 5.40, smartmontools-support@lists.sourceforge.net)
AC_CONFIG_SRCDIR(smartctl.cpp)
smartmontools_configure_date=`date -u +'%Y-%m-%d %T %Z'`
smartmontools_cvs_tag=`echo '$Id: configure.in 3054 2010-01-28 20:48:28Z chrfranke $'`
smartmontools_release_date=2010-01-28
smartmontools_release_time="20:46:44 UTC"
smartmontools_cvs_tag=`echo '$Id: configure.in 3057 2010-02-03 20:56:41Z chrfranke $'`
smartmontools_release_date=2009-12-09
smartmontools_release_time="21:00:32 UTC"
AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date])
@ -157,11 +157,25 @@ AC_SUBST(ASFLAGS)
AC_SUBST([exampledir], ['${docdir}/examplescripts'])
AC_ARG_WITH(initscriptdir,[AC_HELP_STRING([--with-initscriptdir=dir],[Location of init scripts (default is ${sysconfdir}/rc.d/init.d)])],[initddir="$withval"],[initddir='${sysconfdir}/rc.d/init.d'])
AC_ARG_WITH(initscriptdir,
[AC_HELP_STRING([--with-initscriptdir=DIR],[Location of init scripts [SYSCONFDIR/rc.d/init.d]])],
[initddir="$withval"],[initddir='${sysconfdir}/rc.d/init.d'])
AC_SUBST(initddir)
AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"])
AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir=dir],[Location of documentation (default is ${prefix}/share/doc/smartmontools-5.X)])],[docdir="$withval"],[docdir='${prefix}/share/doc/${PACKAGE}-${VERSION}'])
docdir_is_default=no
AC_ARG_WITH(docdir,
[AC_HELP_STRING([--with-docdir=DIR],[Location of documentation [DATADIR/doc/smartmontools]])],
[docdir="$withval"],
[ if test -z "$docdir"; then
# autoconf 2.5x without '--docdir' support
docdir='${datadir}/doc/${PACKAGE}'
docdir_is_default=yes
elif test "$docdir" = '${datarootdir}/doc/${PACKAGE_TARNAME}'; then
# autoconf 2.6x '--docdir' default
docdir_is_default=yes
fi
])
AC_SUBST(docdir)
AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])])
@ -219,6 +233,29 @@ if test "$with_selinux" = "yes"; then
AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled])
fi
AC_ARG_WITH(libcap-ng,
[AC_HELP_STRING([--with-libcap-ng=[auto|yes|no]], [Add Libcap-ng support to smartd [auto]])],
[with_libcap_ng="$withval"],
[with_libcap_ng=auto])
use_libcap_ng=no
if test "$with_libcap_ng" != "no"; then
AC_CHECK_LIB(cap-ng, capng_clear,
[AC_DEFINE(HAVE_LIBCAP_NG, 1, [Define to 1 if you have the `cap-ng' library (-lcap-ng).])
CAPNG_LDADD="-lcap-ng"; use_libcap_ng=yes])
if test "$use_libcap_ng" = "yes"; then
AC_CHECK_HEADER(cap-ng.h, [], [AC_MSG_ERROR([libcap-ng libraries found but headers are missing])])
elif test "$with_libcap_ng" = "yes"; then
AC_MSG_ERROR([libcap-ng support was requested but the library was not found])
fi
fi
AC_MSG_CHECKING([whether to use libcap-ng])
AC_SUBST(CAPNG_LDADD)
AM_CONDITIONAL(ENABLE_CAPABILITIES, [test "$use_libcap_ng" = "yes"])
AC_MSG_RESULT([$use_libcap_ng])
if test "$prefix" = "NONE"; then
dnl no prefix and no mandir, so use ${prefix}/share/man as default
if test "$mandir" = '${prefix}/man'; then
@ -368,3 +405,16 @@ AC_SUBST(CXXFLAGS)
AC_OUTPUT(Makefile examplescripts/Makefile)
AC_PROG_MAKE_SET
# Print note that the docdir default value has changed
# TODO: Remove this after next release
if test "$docdir_is_default" = "yes"; then
old_def_docdir='${prefix}/share/doc/${PACKAGE}-${VERSION}'
old_def_docdir_eval="`eval eval eval echo $old_def_docdir`"
docdir_eval="`eval eval eval echo $docdir`"
AC_MSG_NOTICE([********** PLEASE NOTE **********])
AC_MSG_NOTICE(['docdir' default has changed])
AC_MSG_NOTICE([from: $old_def_docdir_eval])
AC_MSG_NOTICE([to: $docdir_eval])
AC_MSG_NOTICE([*********************************])
fi

630
depcomp
View File

@ -1,630 +0,0 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2009-04-28.21; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 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 <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# 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 <oliva@dcc.unicamp.br>.
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 outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
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
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 ' ' '
' < "$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.
## 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"
;;
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 ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
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"
;;
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"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -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 understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -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 "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
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"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#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:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
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"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
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:: \1 \\:p' >> "$depfile"
echo " " >> "$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:

View File

@ -25,7 +25,7 @@
#include <stdexcept>
const char * dev_interface_cpp_cvsid = "$Id: dev_interface.cpp 2971 2009-10-26 22:05:54Z chrfranke $"
const char * dev_interface_cpp_cvsid = "$Id: dev_interface.cpp 3015 2009-12-30 16:25:59Z chrfranke $"
DEV_INTERFACE_H_CVSID;
/////////////////////////////////////////////////////////////////////////////
@ -89,7 +89,9 @@ ata_in_regs_48bit::ata_in_regs_48bit()
sector_count_16(sector_count, prev.sector_count),
lba_low_16(lba_low, prev.lba_low),
lba_mid_16(lba_mid, prev.lba_mid),
lba_high_16(lba_high, prev.lba_high)
lba_high_16(lba_high, prev.lba_high),
lba_48( lba_low, lba_mid, lba_high,
prev.lba_low, prev.lba_mid, prev.lba_high)
{
}
@ -97,7 +99,9 @@ ata_out_regs_48bit::ata_out_regs_48bit()
: sector_count_16(sector_count, prev.sector_count),
lba_low_16(lba_low, prev.lba_low),
lba_mid_16(lba_mid, prev.lba_mid),
lba_high_16(lba_high, prev.lba_high)
lba_high_16(lba_high, prev.lba_high),
lba_48( lba_low, lba_mid, lba_high,
prev.lba_low, prev.lba_mid, prev.lba_high)
{
}

View File

@ -18,7 +18,7 @@
#ifndef DEV_INTERFACE_H
#define DEV_INTERFACE_H
#define DEV_INTERFACE_H_CVSID "$Id: dev_interface.h 2973 2009-10-26 22:38:19Z chrfranke $\n"
#define DEV_INTERFACE_H_CVSID "$Id: dev_interface.h 3015 2009-12-30 16:25:59Z chrfranke $\n"
#include <stdarg.h>
#include <stdexcept>
@ -325,6 +325,50 @@ private:
};
/// 48-bit alias to six 8-bit ATA registers (for LBA).
class ata_reg_alias_48
{
public:
ata_reg_alias_48(ata_register & ll, ata_register & lm, ata_register & lh,
ata_register & hl, ata_register & hm, ata_register & hh)
: m_ll(ll), m_lm(lm), m_lh(lh),
m_hl(hl), m_hm(hm), m_hh(hh)
{ }
ata_reg_alias_48 & operator=(uint64_t val)
{
m_ll = (unsigned char) val;
m_lm = (unsigned char)(val >> 8);
m_lh = (unsigned char)(val >> 16);
m_hl = (unsigned char)(val >> 24);
m_hm = (unsigned char)(val >> 32);
m_hh = (unsigned char)(val >> 40);
return * this;
}
uint64_t val() const
{
return ( (unsigned)m_ll
| ((unsigned)m_lm << 8)
| ((unsigned)m_lh << 16)
| ((unsigned)m_hl << 24)
| ((uint64_t)m_hm << 32)
| ((uint64_t)m_hh << 40));
}
operator uint64_t() const
{ return val(); }
private:
ata_register & m_ll, & m_lm, & m_lh,
& m_hl, & m_hm, & m_hh;
// References must not be copied.
ata_reg_alias_48(const ata_reg_alias_48 &);
void operator=(const ata_reg_alias_48 &);
};
/// ATA Input registers for 48-bit commands
// See section 4.14 of T13/1532D Volume 1 Revision 4b
//
@ -348,6 +392,9 @@ struct ata_in_regs_48bit
ata_reg_alias_16 lba_mid_16;
ata_reg_alias_16 lba_high_16;
// 48-bit alias to all 8-bit LBA registers.
ata_reg_alias_48 lba_48;
/// Return true if 48-bit command
bool is_48bit_cmd() const
{ return prev.is_set(); }
@ -373,6 +420,9 @@ struct ata_out_regs_48bit
ata_reg_alias_16 lba_mid_16;
ata_reg_alias_16 lba_high_16;
// 48-bit alias to all 8-bit LBA registers.
ata_reg_alias_48 lba_48;
ata_out_regs_48bit();
};

139
do_release Executable file
View File

@ -0,0 +1,139 @@
#!/bin/bash
#
# do a smartmontools release
# (C) 2003-9 Bruce Allen <ballen4705@users.sourceforge.net>,
# Guido Guenther <agx@sigxcpu.org>
# Christian Franke <smartmontools-support@lists.sourceforge.net>
# $Id: do_release 2997 2009-12-11 21:25:59Z chrfranke $
# Notes on generating releases:
# (1) update NEWS
# (2) update CHANGELOG -- put in release number
# (3) update release number in configure.in
# (4) to test, run without '--commit'
# (5) when satisfied, add option '--commit'
set -e
inc_release()
{
MINOR=`echo $VERSION | cut -d. -f2`
MAJOR=`echo $VERSION | cut -d. -f1`
PERL_OLD=$MAJOR\\.$MINOR
((MINOR++))
NEW_VERSION=$MAJOR.$MINOR
PERL_NEW=$MAJOR\\.$MINOR
NEW_RELEASE="RELEASE_${NEW_VERSION//\./_}"
echo "New Version: $NEW_VERSION"
echo "New Release: $NEW_RELEASE"
}
COMMIT=
RC=
case "$1" in
--commit) COMMIT=yes; shift ;;
esac
case "$*" in
RC[1-9]) RC="$1" ;;
FINAL) ;;
*) echo "Usage: $0 [--commit] RC[1-9]|FINAL"; exit 1 ;;
esac
# Check workdir
case "`/bin/pwd`" in
*/trunk/smartmontools) WDROOT="../.."; DIRPAT="trunk" ;;
*/branches/*/smartmontools) WDROOT="../../.."; DIRPAT="branches/*" ;;
*) echo "`/bin/pwd`: no trunk or branch working dir"; exit 1 ;;
esac
if [ ! -d "$WDROOT/tags" ]; then
echo "tags directory missing"; exit 1
fi
REVX="`(cd $WDROOT && svnversion)`" || exit 1
REV="${REVX/%[PM]/}"; REV="${REV/%[PM]/}"
if [ -n "${REV//[0-9]/}" ]; then
echo "Working directory not clean: $REVX"; exit 1
fi
(cd $WDROOT && svn status) | while read s; do
case "$s" in
"M "$DIRPAT/smartmontools/CHANGELOG) echo "$s: OK";;
"M "$DIRPAT/smartmontools/NEWS) echo "$s: OK";;
"M "$DIRPAT/smartmontools/configure.in) echo "$s: OK";;
*) echo "$s: not allowed"; exit 1;;
esac
done
if [ $? -ne 0 ]; then
exit 1
fi
# Get release number
VERSION=`sed -n 's|^AC_INIT[^,]*, *\([0-9.]*\) *,.*$|\1|p' configure.in`
if [ -z "$VERSION" ]; then
echo "AC_INIT not found in configure.in"; exit 1
fi
VERSIONRC="$VERSION"
RELEASE="RELEASE_${VERSION//\./_}"
if [ "$RC" ]; then
VERSIONRC="${VERSION}-${RC/#RC/rc}"
RELEASE="${RELEASE}_${RC}"
fi
if [ -e "$WDROOT/tags/$RELEASE" ]; then
echo "tags/$RELEASE exists"; exit 1
fi
echo "r$REV: Release $VERSIONRC $RELEASE"
# Update timestamp
smartmontools_release_date=`date -u +"%Y-%m-%d"`
smartmontools_release_time=`date -u +"%T %Z"`
cat configure.in | sed "s|smartmontools_release_date=.*|smartmontools_release_date=${smartmontools_release_date}|" > configure.tmp
cat configure.tmp | sed "s|smartmontools_release_time=.*|smartmontools_release_time=\"${smartmontools_release_time}\"|" > configure.in
rm -f configure.tmp
# Review changes
svn diff
echo "==================================================================="
echo ">>> Continuing in 20 seconds ..."
sleep 20
set -v
# Create tag and commit
if [ "$COMMIT" = "yes" ]; then
svn mkdir $WDROOT/tags/$RELEASE
svn copy ../smartmontools $WDROOT/tags/$RELEASE/smartmontools
svn commit -m "Release $VERSIONRC $RELEASE" $WDROOT
fi
# Build
./autogen.sh
mkdir build
cd build
../configure
make distcheck || exit 1
make maintainer-clean
cd ..
TARFILE=smartmontools-$VERSIONRC.tar.gz
mv -f build/smartmontools-$VERSION.tar.gz $TARFILE
rm -rvf build
md5sum $TARFILE > $TARFILE.md5
sha1sum $TARFILE > $TARFILE.sha1
# Increase release number
if [ -z "$RC" -a "$DIRPAT" = "trunk" ]; then
inc_release
if [ "$COMMIT" = "yes" ]; then
perl -p -i.bak -e "s/$PERL_OLD/$PERL_NEW/" configure.in
# svn commit -m "Bump release number to $NEW_VERSION" configure.in
fi
fi

1445
drivedb.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,448 +0,0 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@
#
# $Id: Makefile.am 2846 2009-07-18 14:18:51Z chrfranke $
#
VPATH = @srcdir@
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 = examplescripts
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
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__installdirs = "$(DESTDIR)$(examplesdir)" \
"$(DESTDIR)$(examplesdir)"
SCRIPTS = $(examples_SCRIPTS)
SOURCES =
DIST_SOURCES =
DATA = $(examples_DATA)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
ASFLAGS = @ASFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
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@
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@
ac_ct_CXX = @ac_ct_CXX@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
attributelog = @attributelog@
attributelogdir = @attributelogdir@
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@
drivedbdir = @drivedbdir@
dvidir = @dvidir@
exampledir = @exampledir@
exec_prefix = @exec_prefix@
gcc_have_attr_packed = @gcc_have_attr_packed@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
initddir = @initddir@
install_sh = @install_sh@
libc_have_working_snprintf = @libc_have_working_snprintf@
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@
releaseversion = @releaseversion@
savestates = @savestates@
savestatesdir = @savestatesdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
smartd_suffix = @smartd_suffix@
smartmontools_release_date = @smartmontools_release_date@
smartmontools_release_time = @smartmontools_release_time@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
with_selinux = @with_selinux@
examplesdir = $(exampledir)
examples_DATA = README
examples_SCRIPTS = Example1 \
Example2 \
Example3 \
Example4
EXTRA_DIST = $(examples_SCRIPTS)
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
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) --foreign examplescripts/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign examplescripts/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-examplesSCRIPTS: $(examples_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)"
@list='$(examples_SCRIPTS)'; test -n "$(examplesdir)" || 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"; 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)$(examplesdir)$$dir'"; \
$(INSTALL_SCRIPT) $$files "$(DESTDIR)$(examplesdir)$$dir" || exit $$?; \
} \
; done
uninstall-examplesSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(examples_SCRIPTS)'; test -n "$(examplesdir)" || exit 0; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 's,.*/,,;$(transform)'`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(examplesdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(examplesdir)" && rm -f $$files
install-examplesDATA: $(examples_DATA)
@$(NORMAL_INSTALL)
test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)"
@list='$(examples_DATA)'; test -n "$(examplesdir)" || list=; \
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_DATA) $$files '$(DESTDIR)$(examplesdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(examplesdir)" || exit $$?; \
done
uninstall-examplesDATA:
@$(NORMAL_UNINSTALL)
@list='$(examples_DATA)'; test -n "$(examplesdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(examplesdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(examplesdir)" && rm -f $$files
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) $(DATA)
installdirs:
for dir in "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(examplesdir)"; 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:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
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."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
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-examplesDATA install-examplesSCRIPTS
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
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-examplesDATA uninstall-examplesSCRIPTS
.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-examplesDATA install-examplesSCRIPTS \
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-examplesDATA \
uninstall-examplesSCRIPTS
# 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:

View File

@ -1,520 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2009-04-28.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
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
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
trap '(exit $?); exit' 1 2 13 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names starting with `-'.
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
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst;;
esac
# 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 -z "$d" && 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:

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
* Home page of code is: http://smartmontools.sourceforge.net
* Address of support mailing list: smartmontools-support@lists.sourceforge.net
*
* Copyright (C) 2003-8 Philip Williams, Bruce Allen
* Copyright (C) 2008 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2003-9 Philip Williams, Bruce Allen
* Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
*
* 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
@ -21,27 +21,9 @@
#ifndef KNOWNDRIVES_H_
#define KNOWNDRIVES_H_
#define KNOWNDRIVES_H_CVSID "$Id: knowndrives.h 2975 2009-10-29 22:52:38Z chrfranke $\n"
#define KNOWNDRIVES_H_CVSID "$Id: knowndrives.h 2998 2009-12-11 22:51:04Z chrfranke $\n"
/* Structure used to store settings for specific drives in knowndrives[]. The
* elements are used in the following ways:
*
* modelfamily Informal string about the model family/series of a
* device. Set to "" if no info (apart from device id)
* known.
* modelregexp POSIX regular expression to match the model of a device.
* This should never be "".
* firmwareregexp POSIX regular expression to match a devices's firmware
* version. This is optional and should be "" if it is not
* to be used. If it is nonempty then it will be used to
* narrow the set of devices matched by modelregexp.
* warningmsg A message that may be displayed for matching drives. For
* example, to inform the user that they may need to apply a
* firmware patch.
* presets String with vendor-specific attribute ('-v') and firmware
* bug fix ('-F') options. Same syntax as in smartctl command
* line. The user's own settings override these.
*/
// Structure to store drive database entries, see drivedb.h for a description.
struct drive_settings {
const char * modelfamily;
const char * modelregexp;

376
missing
View File

@ -1,376 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2009-04-28.21; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 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 <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# 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
tar try tar, gnutar, gtar, then tar without non-portable flags
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 <bug-automake@gnu.org>."
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.
;;
tar*)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $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
;;
tar*)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
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:

View File

@ -3,7 +3,7 @@
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2003-8 Eduard Martinescu <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2003-10 Eduard Martinescu <smartmontools-support@lists.sourceforge.net>
*
* 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
@ -71,9 +71,9 @@
#define PATHINQ_SETTINGS_SIZE 128
#endif
static __unused const char *filenameandversion="$Id: os_freebsd.cpp 3046 2010-01-22 21:30:02Z chrfranke $";
static __unused const char *filenameandversion="$Id: os_freebsd.cpp 3037 2010-01-16 20:07:13Z chrfranke $";
const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp 3046 2010-01-22 21:30:02Z chrfranke $" \
const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp 3037 2010-01-16 20:07:13Z chrfranke $" \
ATACMDS_H_CVSID CCISS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_FREEBSD_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
extern smartmonctrl * con;
@ -121,7 +121,7 @@ void printwarning(int msgNo, const char* extra) {
// global variable holding byte count of allocated memory
long long bytes;
const char * dev_freebsd_cpp_cvsid = "$Id: os_freebsd.cpp 3046 2010-01-22 21:30:02Z chrfranke $"
const char * dev_freebsd_cpp_cvsid = "$Id: os_freebsd.cpp 3037 2010-01-16 20:07:13Z chrfranke $"
DEV_INTERFACE_H_CVSID;
extern smartmonctrl * con; // con->reportscsiioctl
@ -231,17 +231,17 @@ bool freebsd_smart_device::close()
}
/////////////////////////////////////////////////////////////////////////////
/// Implement standard ATA support with old functions
/// Implement standard ATA support
class freebsd_ata_device
: public /*implements*/ ata_device_with_command_set,
: public /*implements*/ ata_device,
public /*extends*/ freebsd_smart_device
{
public:
freebsd_ata_device(smart_interface * intf, const char * dev_name, const char * req_type);
virtual bool ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out);
protected:
virtual int ata_command_interface(smart_command_set command, int select, char * data);
virtual int do_cmd(struct ata_ioc_request* request);
};
@ -257,6 +257,90 @@ int freebsd_ata_device::do_cmd( struct ata_ioc_request* request)
return ioctl(fd, IOCATAREQUEST, request);
}
bool freebsd_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
{
if (!ata_cmd_is_ok(in, true, true, true)) // data_out_support
return false;
struct ata_ioc_request request;
bzero(&request,sizeof(struct ata_ioc_request));
request.timeout=SCSI_TIMEOUT_DEFAULT;
request.u.ata.command=in.in_regs.command;
request.u.ata.feature=in.in_regs.features;
request.u.ata.count = in.in_regs.sector_count_16;
request.u.ata.lba = in.in_regs.lba_48;
switch (in.direction) {
case ata_cmd_in::no_data:
request.flags=ATA_CMD_CONTROL;
break;
case ata_cmd_in::data_in:
request.flags=ATA_CMD_READ;
request.data=(char *)in.buffer;
request.count=in.size;
break;
case ata_cmd_in::data_out:
request.flags=ATA_CMD_WRITE;
request.data=(char *)in.buffer;
request.count=in.size;
break;
default:
return set_err(ENOSYS);
}
clear_err();
errno = 0;
if (do_cmd(&request))
return set_err(errno);
if (request.error)
return set_err(EIO, "request failed, error code 0x%02x", request.error);
out.out_regs.error = request.error;
out.out_regs.sector_count_16 = request.u.ata.count;
out.out_regs.lba_48 = request.u.ata.lba;
// Command specific processing
if (in.in_regs.command == ATA_SMART_CMD
&& in.in_regs.features == ATA_SMART_STATUS
&& in.out_needed.lba_high)
{
unsigned const char normal_lo=0x4f, normal_hi=0xc2;
unsigned const char failed_lo=0xf4, failed_hi=0x2c;
#if (FREEBSDVER < 502000)
printwarning(NO_RETURN,NULL);
#endif
// Cyl low and Cyl high unchanged means "Good SMART status"
if (!(out.out_regs.lba_mid==normal_lo && out.out_regs.lba_high==normal_hi)
// These values mean "Bad SMART status"
&& !(out.out_regs.lba_mid==failed_lo && out.out_regs.lba_high==failed_hi))
{
// We haven't gotten output that makes sense; print out some debugging info
char buf[512];
sprintf(buf,"CMD=0x%02x\nFR =0x%02x\nNS =0x%02x\nSC =0x%02x\nCL =0x%02x\nCH =0x%02x\nRETURN =0x%04x\n",
(int)request.u.ata.command,
(int)request.u.ata.feature,
(int)request.u.ata.count,
(int)((request.u.ata.lba) & 0xff),
(int)((request.u.ata.lba>>8) & 0xff),
(int)((request.u.ata.lba>>16) & 0xff),
(int)request.error);
printwarning(BAD_SMART,buf);
out.out_regs.lba_high = failed_hi;
out.out_regs.lba_mid = failed_lo;
}
}
return true;
}
#if FREEBSDVER > 800100
class freebsd_atacam_device : public freebsd_ata_device
{
@ -341,168 +425,6 @@ int freebsd_atacam_device::do_cmd( struct ata_ioc_request* request)
#endif
int freebsd_ata_device::ata_command_interface(smart_command_set command, int select, char * data)
{
int retval, copydata=0;
struct ata_ioc_request request;
unsigned char buff[512];
bzero(buff,512);
bzero(&request,sizeof(struct ata_ioc_request));
bzero(buff,512);
request.u.ata.command=ATA_SMART_CMD;
request.timeout=SCSI_TIMEOUT_DEFAULT;
switch (command){
case READ_VALUES:
request.u.ata.feature=ATA_SMART_READ_VALUES;
request.u.ata.lba=0xc24f<<8;
request.flags=ATA_CMD_READ;
request.data=(char *)buff;
request.count=512;
copydata=1;
break;
case READ_THRESHOLDS:
request.u.ata.feature=ATA_SMART_READ_THRESHOLDS;
request.u.ata.count=1;
request.u.ata.lba=1|(0xc24f<<8);
request.flags=ATA_CMD_READ;
request.data=(char *)buff;
request.count=512;
copydata=1;
break;
case READ_LOG:
request.u.ata.feature=ATA_SMART_READ_LOG_SECTOR;
request.u.ata.lba=select|(0xc24f<<8);
request.u.ata.count=1;
request.flags=ATA_CMD_READ;
request.data=(char *)buff;
request.count=512;
copydata=1;
break;
case IDENTIFY:
request.u.ata.command=ATA_IDENTIFY_DEVICE;
request.flags=ATA_CMD_READ;
request.data=(char *)buff;
request.count=512;
copydata=1;
break;
case PIDENTIFY:
request.u.ata.command=ATA_IDENTIFY_PACKET_DEVICE;
request.flags=ATA_CMD_READ;
request.data=(char *)buff;
request.count=512;
copydata=1;
break;
case ENABLE:
request.u.ata.feature=ATA_SMART_ENABLE;
request.u.ata.lba=0xc24f<<8;
request.flags=ATA_CMD_CONTROL;
break;
case DISABLE:
request.u.ata.feature=ATA_SMART_DISABLE;
request.u.ata.lba=0xc24f<<8;
request.flags=ATA_CMD_CONTROL;
break;
case AUTO_OFFLINE:
// NOTE: According to ATAPI 4 and UP, this command is obsolete
request.u.ata.feature=ATA_SMART_AUTO_OFFLINE;
request.u.ata.lba=0xc24f<<8;
request.u.ata.count=select;
request.flags=ATA_CMD_CONTROL;
break;
case AUTOSAVE:
request.u.ata.feature=ATA_SMART_AUTOSAVE;
request.u.ata.lba=0xc24f<<8;
request.u.ata.count=select;
request.flags=ATA_CMD_CONTROL;
break;
case IMMEDIATE_OFFLINE:
request.u.ata.feature=ATA_SMART_IMMEDIATE_OFFLINE;
request.u.ata.lba = select|(0xc24f<<8); // put test in sector
request.flags=ATA_CMD_CONTROL;
break;
case STATUS_CHECK: // same command, no HDIO in FreeBSD
case STATUS:
// this command only says if SMART is working. It could be
// replaced with STATUS_CHECK below.
request.u.ata.feature=ATA_SMART_STATUS;
request.u.ata.lba=0xc24f<<8;
request.flags=ATA_CMD_CONTROL;
break;
case CHECK_POWER_MODE:
request.u.ata.command=ATA_CHECK_POWER_MODE;
request.u.ata.feature=0;
request.flags=ATA_CMD_CONTROL;
break;
case WRITE_LOG:
memcpy(buff, data, 512);
request.u.ata.feature=ATA_SMART_WRITE_LOG_SECTOR;
request.u.ata.lba=select|(0xc24f<<8);
request.u.ata.count=1;
request.flags=ATA_CMD_WRITE;
request.data=(char *)buff;
request.count=512;
break;
default:
pout("Unrecognized command %d in ata_command_interface()\n"
"Please contact " PACKAGE_BUGREPORT "\n", command);
errno=ENOSYS;
return -1;
}
if (command==STATUS_CHECK){
unsigned const char normal_lo=0x4f, normal_hi=0xc2;
unsigned const char failed_lo=0xf4, failed_hi=0x2c;
unsigned char low,high;
if ((retval=do_cmd(&request)) || request.error)
return -1;
#if (FREEBSDVER < 502000)
printwarning(NO_RETURN,NULL);
#endif
high = (request.u.ata.lba >> 16) & 0xff;
low = (request.u.ata.lba >> 8) & 0xff;
// Cyl low and Cyl high unchanged means "Good SMART status"
if (low==normal_lo && high==normal_hi)
return 0;
// These values mean "Bad SMART status"
if (low==failed_lo && high==failed_hi)
return 1;
// We haven't gotten output that makes sense; print out some debugging info
char buf[512];
sprintf(buf,"CMD=0x%02x\nFR =0x%02x\nNS =0x%02x\nSC =0x%02x\nCL =0x%02x\nCH =0x%02x\nRETURN =0x%04x\n",
(int)request.u.ata.command,
(int)request.u.ata.feature,
(int)request.u.ata.count,
(int)((request.u.ata.lba) & 0xff),
(int)((request.u.ata.lba>>8) & 0xff),
(int)((request.u.ata.lba>>16) & 0xff),
(int)request.error);
printwarning(BAD_SMART,buf);
return 0;
}
if ((retval=do_cmd(&request)) || request.error)
{
return -1;
}
//
if (command == CHECK_POWER_MODE) {
data[0] = request.u.ata.count & 0xff;
return 0;
}
if (copydata)
memcpy(data, buff, 512);
return 0;
}
/////////////////////////////////////////////////////////////////////////////
/// Implement AMCC/3ware RAID support with old functions
@ -780,7 +702,7 @@ int freebsd_escalade_device::ata_command_interface(smart_command_set command, in
*data=*(char *)&(ata->sector_count);
// look for nonexistent devices/ports
if (command==IDENTIFY && !nonempty((unsigned char *)data, 512)) {
if (command==IDENTIFY && !nonempty(data, 512)) {
errno=ENODEV;
return -1;
}

View File

@ -3,12 +3,12 @@
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2003-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2003-8 Doug Gilbert <dougg@torque.net>
* Copyright (C) 2008 Hank Wu <hank@areca.com.tw>
* Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net>
* Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2008 Jordan Hargrave <jordan_hargrave@dell.com>
* Copyright (C) 2003-10 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2003-10 Doug Gilbert <dougg@torque.net>
* Copyright (C) 2008 Hank Wu <hank@areca.com.tw>
* Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net>
* Copyright (C) 2008-10 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2008 Jordan Hargrave <jordan_hargrave@dell.com>
*
* Parts of this file are derived from code that was
*
@ -90,7 +90,7 @@
#define ARGUSED(x) ((void)(x))
const char *os_XXXX_c_cvsid="$Id: os_linux.cpp 3053 2010-01-28 20:05:33Z chrfranke $" \
const char *os_XXXX_c_cvsid="$Id: os_linux.cpp 3052 2010-01-28 19:51:24Z chrfranke $" \
ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_LINUX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
/* for passing global control variables */
@ -1629,7 +1629,7 @@ bool linux_escalade_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out
// look for nonexistent devices/ports
if ( in.in_regs.command == ATA_IDENTIFY_DEVICE
&& !nonempty((unsigned char *)in.buffer, in.size)) {
&& !nonempty(in.buffer, in.size)) {
return set_err(ENODEV, "No drive on port %d", m_disknum);
}

555
os_os2.cpp Normal file
View File

@ -0,0 +1,555 @@
/*
* os_os2.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2004-8 Yuri Dario <smartmontools-support@lists.sourceforge.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* (for example COPYING); if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
*
* Thanks to Daniela Engert for providing sample code for SMART ioctl access.
*
*/
// These are needed to define prototypes for the functions defined below
#include <errno.h>
#include "atacmds.h"
#include "scsicmds.h"
#include "utility.h"
// This is to include whatever prototypes you define in os_generic.h
#include "os_os2.h"
// Needed by '-V' option (CVS versioning) of smartd/smartctl
const char *os_XXXX_c_cvsid="$Id: os_os2.cpp,v 1.9 2008/06/12 21:46:31 ballen4705 Exp $" \
ATACMDS_H_CVSID OS_XXXX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
// global handle to device driver
static HFILE hDevice;
// Please eliminate the following block: both the two #includes and
// the 'unsupported()' function. They are only here to warn
// unsuspecting users that their Operating System is not supported! If
// you wish, you can use a similar warning mechanism for any of the
// functions in this file that you can not (or choose not to)
// implement.
#include "config.h"
typedef struct _IDEREGS {
UCHAR bFeaturesReg;
UCHAR bSectorCountReg;
UCHAR bSectorNumberReg;
UCHAR bCylLowReg;
UCHAR bCylHighReg;
UCHAR bDriveHeadReg;
UCHAR bCommandReg;
UCHAR bReserved;
} IDEREGS, *PIDEREGS, *LPIDEREGS;
static void unsupported(int which){
static int warninggiven[4];
if (which<0 || which>3)
return;
if (!warninggiven[which]) {
char msg;
debugmode=1;
warninggiven[which]=1;
switch (which) {
case 0:
msg="generate a list of devices";
break;
case 1:
msg="interface to Marvell-based SATA controllers";
break;
case 2:
msg="interface to 3ware-based RAID controllers";
break;
case 3:
msg="interface to SCSI devices";
break;
}
pout("Under OS/2, smartmontools can not %s\n");
}
return;
}
// print examples for smartctl. You should modify this function so
// that the device paths are sensible for your OS, and to eliminate
// unsupported commands (eg, 3ware controllers).
void print_smartctl_examples(){
printf("=================================================== SMARTCTL EXAMPLES =====\n\n");
#ifdef HAVE_GETOPT_LONG
printf(
" smartctl -a /dev/hda (Prints all SMART information)\n\n"
" smartctl --smart=on --offlineauto=on --saveauto=on /dev/hda\n"
" (Enables SMART on first disk)\n\n"
" smartctl -t long /dev/hda (Executes extended disk self-test)\n\n"
" smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hda\n"
" (Prints Self-Test & Attribute errors)\n"
" smartctl -a --device=3ware,2 /dev/sda\n"
" (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n"
);
#else
printf(
" smartctl -a /dev/hda (Prints all SMART information)\n"
" smartctl -s on -o on -S on /dev/hda (Enables SMART on first disk)\n"
" smartctl -t long /dev/hda (Executes extended disk self-test)\n"
" smartctl -A -l selftest -q errorsonly /dev/hda\n"
" (Prints Self-Test & Attribute errors)\n"
" smartctl -a -d 3ware,2 /dev/sda\n"
" (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n"
);
#endif
return;
}
static const char * skipdev(const char * s)
{
return (!strncmp(s, "/dev/", 5) ? s + 5 : s);
}
// tries to guess device type given the name (a path). See utility.h
// for return values.
int guess_device_type (const char* dev_name) {
//printf( "dev_name %s\n", dev_name);
dev_name = skipdev(dev_name);
if (!strncmp(dev_name, "hd", 2))
return CONTROLLER_ATA;
if (!strncmp(dev_name, "scsi", 4))
return CONTROLLER_SCSI;
return CONTROLLER_UNKNOWN;
}
// makes a list of ATA or SCSI devices for the DEVICESCAN directive of
// smartd. Returns number N of devices, or -1 if out of
// memory. Allocates N+1 arrays: one of N pointers (devlist); the
// other N arrays each contain null-terminated character strings. In
// the case N==0, no arrays are allocated because the array of 0
// pointers has zero length, equivalent to calling malloc(0).
int make_device_names (char*** devlist, const char* name) {
unsupported(0);
return 0;
}
// Like open(). Return non-negative integer handle, only used by the
// functions below. type=="ATA" or "SCSI". If you need to store
// extra information about your devices, create a private internal
// array within this file (see os_freebsd.cpp for an example). If you
// can not open the device (permission denied, does not exist, etc)
// set errno as open() does and return <0.
int deviceopen(const char *pathname, char *type){
int fd;
APIRET rc;
ULONG ActionTaken;
//printf( "deviceopen pathname %s\n", pathname);
rc = DosOpen ("\\DEV\\IBMS506$", &hDevice, &ActionTaken, 0, FILE_SYSTEM,
OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
if (rc) {
char errmsg[256];
snprintf(errmsg,256,"Smartctl open driver IBMS506$ failed (%d)", rc);
errmsg[255]='\0';
syserror(errmsg);
return -1;
}
pathname = skipdev(pathname);
fd = tolower(pathname[2]) - 'a';
return fd;
}
// Like close(). Acts only on integer handles returned by
// deviceopen() above.
int deviceclose(int fd){
DosClose( hDevice);
hDevice = NULL;
return 0;
}
static void print_ide_regs(const IDEREGS * r, int out)
{
pout("%s=0x%02x,%s=0x%02x, SC=0x%02x, NS=0x%02x, CL=0x%02x, CH=0x%02x, SEL=0x%02x\n",
(out?"STS":"CMD"), r->bCommandReg, (out?"ERR":" FR"), r->bFeaturesReg,
r->bSectorCountReg, r->bSectorNumberReg, r->bCylLowReg, r->bCylHighReg, r->bDriveHeadReg);
}
//
// OS/2 direct ioctl interface to IBMS506$
//
int dani_ioctl( int device, int request, void* arg)
{
unsigned char* buff = (unsigned char*) arg;
APIRET rc;
DSKSP_CommandParameters Parms;
ULONG PLen = 1;
ULONG DLen = 512; //sizeof (*buf);
UCHAR temp;
ULONG value = 0;
IDEREGS regs;
//printf( "device %d, request 0x%x, arg[0] 0x%x, arg[2] 0x%x\n", device, request, buff[0], buff[2]);
Parms.byPhysicalUnit = device;
switch( buff[0]) {
case WIN_IDENTIFY:
rc = DosDevIOCtl (hDevice, DSKSP_CAT_GENERIC, DSKSP_GET_INQUIRY_DATA,
(PVOID)&Parms, PLen, &PLen, (PVOID)arg+4, DLen, &DLen);
if (rc != 0)
{
printf ("DANIS506 ATA GET HD Failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
case WIN_SMART:
switch( buff[2]) {
case SMART_STATUS:
DLen = sizeof(value);
// OS/2 already checks CL/CH in IBM1S506 code!! see s506rte.c (ddk)
// value: -1=not supported, 0=ok, 1=failing
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_GETSTATUS,
(PVOID)&Parms, PLen, &PLen, (PVOID)&value, DLen, &DLen);
if (rc)
{
printf ("DANIS506 ATA GET SMART_STATUS failed (%d,0x%x)\n", rc, rc);
return -1;
}
buff[4] = (unsigned char)value;
break;
case SMART_READ_VALUES:
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_GET_ATTRIBUTES,
(PVOID)&Parms, PLen, &PLen, (PVOID)arg+4, DLen, &DLen);
if (rc)
{
printf ("DANIS506 ATA GET DSKSP_SMART_GET_ATTRIBUTES failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
case SMART_READ_THRESHOLDS:
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_GET_THRESHOLDS,
(PVOID)&Parms, PLen, &PLen, (PVOID)arg+4, DLen, &DLen);
if (rc)
{
printf ("DANIS506 ATA GET DSKSP_SMART_GET_THRESHOLDS failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
case SMART_READ_LOG_SECTOR:
buff[4] = buff[1]; // copy select field
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_READ_LOG,
(PVOID)&Parms, PLen, &PLen, (PVOID)arg+4, DLen, &DLen);
if (rc)
{
printf ("DANIS506 ATA GET DSKSP_SMART_READ_LOG failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
case SMART_ENABLE:
buff[0] = 1; // enable
DLen = 1;
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_ONOFF,
(PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
if (rc) {
printf ("DANIS506 ATA GET DSKSP_SMART_ONOFF failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
case SMART_DISABLE:
buff[0] = 0; // disable
DLen = 1;
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_ONOFF,
(PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
if (rc) {
printf ("DANIS506 ATA GET DSKSP_SMART_ONOFF failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
#if 0
case SMART_AUTO_OFFLINE:
buff[0] = buff[3]; // select field
DLen = 1;
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_AUTO_OFFLINE,
(PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
if (rc) {
printf ("DANIS506 ATA GET DSKSP_SMART_ONOFF failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
#endif
case SMART_AUTOSAVE:
buff[0] = buff[3]; // select field
DLen = 1;
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_AUTOSAVE_ONOFF,
(PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
if (rc) {
printf ("DANIS506 ATA DSKSP_SMART_AUTOSAVE_ONOFF failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
case SMART_IMMEDIATE_OFFLINE:
buff[0] = buff[1]; // select field
DLen = 1;
rc = DosDevIOCtl (hDevice, DSKSP_CAT_SMART, DSKSP_SMART_EOLI,
(PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
if (rc) {
printf ("DANIS506 ATA GET DSKSP_SMART_EXEC_OFFLINE failed (%d,0x%x)\n", rc, rc);
return -1;
}
break;
default:
fprintf( stderr, "device %d, request 0x%x, arg[0] 0x%x, arg[2] 0x%x\n", device, request, buff[0], buff[2]);
fprintf( stderr, "unknown ioctl\n");
return -1;
break;
}
break;
//case WIN_PIDENTIFY:
// break;
default:
fprintf( stderr, "unknown ioctl\n");
return -1;
break;
}
// ok
return 0;
}
// Interface to ATA devices. See os_linux.cpp for the cannonical example.
// DETAILED DESCRIPTION OF ARGUMENTS
// device: is the integer handle provided by deviceopen()
// command: defines the different operations, see atacmds.h
// select: additional input data IF NEEDED (which log, which type of
// self-test).
// data: location to write output data, IF NEEDED (1 or 512 bytes).
// Note: not all commands use all arguments.
// RETURN VALUES (for all commands BUT command==STATUS_CHECK)
// -1 if the command failed
// 0 if the command succeeded,
// RETURN VALUES if command==STATUS_CHECK
// -1 if the command failed OR the disk SMART status can't be determined
// 0 if the command succeeded and disk SMART status is "OK"
// 1 if the command succeeded and disk SMART status is "FAILING"
// huge value of buffer size needed because HDIO_DRIVE_CMD assumes
// that buff[3] is the data size. Since the ATA_SMART_AUTOSAVE and
// ATA_SMART_AUTO_OFFLINE use values of 0xf1 and 0xf8 we need the space.
// Otherwise a 4+512 byte buffer would be enough.
#define STRANGE_BUFFER_LENGTH (4+512*0xf8)
int ata_command_interface(int device, smart_command_set command, int select, char *data){
unsigned char buff[STRANGE_BUFFER_LENGTH];
// positive: bytes to write to caller. negative: bytes to READ from
// caller. zero: non-data command
int copydata=0;
const int HDIO_DRIVE_CMD_OFFSET = 4;
// See struct hd_drive_cmd_hdr in hdreg.h. Before calling ioctl()
// buff[0]: ATA COMMAND CODE REGISTER
// buff[1]: ATA SECTOR NUMBER REGISTER == LBA LOW REGISTER
// buff[2]: ATA FEATURES REGISTER
// buff[3]: ATA SECTOR COUNT REGISTER
// Note that on return:
// buff[2] contains the ATA SECTOR COUNT REGISTER
// clear out buff. Large enough for HDIO_DRIVE_CMD (4+512 bytes)
memset(buff, 0, STRANGE_BUFFER_LENGTH);
//printf( "command, select %d,%d\n", command, select);
buff[0]=ATA_SMART_CMD;
switch (command){
case CHECK_POWER_MODE:
buff[0]=ATA_CHECK_POWER_MODE;
copydata=1;
break;
case READ_VALUES:
buff[2]=ATA_SMART_READ_VALUES;
buff[3]=1;
copydata=512;
break;
case READ_THRESHOLDS:
buff[2]=ATA_SMART_READ_THRESHOLDS;
buff[1]=buff[3]=1;
copydata=512;
break;
case READ_LOG:
buff[2]=ATA_SMART_READ_LOG_SECTOR;
buff[1]=select;
buff[3]=1;
copydata=512;
break;
case WRITE_LOG:
break;
case IDENTIFY:
buff[0]=ATA_IDENTIFY_DEVICE;
buff[3]=1;
copydata=512;
break;
case PIDENTIFY:
buff[0]=ATA_IDENTIFY_PACKET_DEVICE;
buff[3]=1;
copydata=512;
break;
case ENABLE:
buff[2]=ATA_SMART_ENABLE;
buff[1]=1;
break;
case DISABLE:
buff[2]=ATA_SMART_DISABLE;
buff[1]=1;
break;
case STATUS:
case STATUS_CHECK:
// this command only says if SMART is working. It could be
// replaced with STATUS_CHECK below.
buff[2]=ATA_SMART_STATUS;
buff[4]=0;
break;
case AUTO_OFFLINE:
buff[2]=ATA_SMART_AUTO_OFFLINE;
buff[3]=select; // YET NOTE - THIS IS A NON-DATA COMMAND!!
break;
case AUTOSAVE:
buff[2]=ATA_SMART_AUTOSAVE;
buff[3]=select; // YET NOTE - THIS IS A NON-DATA COMMAND!!
break;
case IMMEDIATE_OFFLINE:
buff[2]=ATA_SMART_IMMEDIATE_OFFLINE;
buff[1]=select;
break;
//case STATUS_CHECK:
// // This command uses HDIO_DRIVE_TASK and has different syntax than
// // the other commands.
// buff[1]=ATA_SMART_STATUS;
// break;
default:
pout("Unrecognized command %d in linux_ata_command_interface()\n"
"Please contact " PACKAGE_BUGREPORT "\n", command);
errno=ENOSYS;
return -1;
}
#if 0
// This command uses the HDIO_DRIVE_TASKFILE ioctl(). This is the
// only ioctl() that can be used to WRITE data to the disk.
if (command==WRITE_LOG) {
unsigned char task[sizeof(ide_task_request_t)+512];
ide_task_request_t *reqtask=(ide_task_request_t *) task;
task_struct_t *taskfile=(task_struct_t *) reqtask->io_ports;
int retval;
memset(task, 0, sizeof(task));
taskfile->data = 0;
taskfile->feature = ATA_SMART_WRITE_LOG_SECTOR;
taskfile->sector_count = 1;
taskfile->sector_number = select;
taskfile->low_cylinder = 0x4f;
taskfile->high_cylinder = 0xc2;
taskfile->device_head = 0;
taskfile->command = ATA_SMART_CMD;
reqtask->data_phase = TASKFILE_OUT;
reqtask->req_cmd = IDE_DRIVE_TASK_OUT;
reqtask->out_size = 512;
reqtask->in_size = 0;
// copy user data into the task request structure
memcpy(task+sizeof(ide_task_request_t), data, 512);
if ((retval=dani_ioctl(device, HDIO_DRIVE_TASKFILE, task))) {
if (retval==-EINVAL)
pout("Kernel lacks HDIO_DRIVE_TASKFILE support; compile kernel with CONFIG_IDE_TASKFILE_IO set\n");
return -1;
}
return 0;
}
#endif // 0
// We are now doing the HDIO_DRIVE_CMD type ioctl.
if ((dani_ioctl(device, HDIO_DRIVE_CMD, buff)))
return -1;
// There are two different types of ioctls(). The HDIO_DRIVE_TASK
// one is this:
if (command==STATUS_CHECK){
int retval;
// Cyl low and Cyl high unchanged means "Good SMART status"
if (buff[4]==0)
return 0;
// These values mean "Bad SMART status"
if (buff[4]==1)
return 1;
// We haven't gotten output that makes sense; print out some debugging info
syserror("Error SMART Status command failed");
pout("Please get assistance from " PACKAGE_HOMEPAGE "\n");
return -1;
}
// CHECK POWER MODE command returns information in the Sector Count
// register (buff[3]). Copy to return data buffer.
if (command==CHECK_POWER_MODE)
buff[HDIO_DRIVE_CMD_OFFSET]=buff[2];
// if the command returns data then copy it back
if (copydata)
memcpy(data, buff+HDIO_DRIVE_CMD_OFFSET, copydata);
return 0;
}
int marvell_command_interface(int fd, smart_command_set command, int select, char *data){
unsupported(1);
return -1;
}
int highpoint_command_interface(int fd, smart_command_set command, int select, char *data)
{
unsupported(1);
return -1;
}
// Interface to ATA devices behind 3ware escalade RAID controller
// cards. Same description as ata_command_interface() above except
// that 0 <= disknum <= 15 specifies the ATA disk attached to the
// controller.
int escalade_command_interface(int fd, int disknum, int escalade_type, smart_command_set command, int select, char *data){
unsupported(2);
return -1;
}
int areca_command_interface(int fd, int disknum, smart_command_set command, int select, char *data){
unsupported(2);
return -1;
}
// Interface to SCSI devices. See os_linux.c
int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) {
unsupported(3);
return -ENOSYS;
}

70
os_os2.h Normal file
View File

@ -0,0 +1,70 @@
/*
* os_os2.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2004-8 Yuri Dario <smartmontools-support@lists.sourceforge.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* (for example COPYING); if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef OS_OS2_H_
#define OS_OS2_H_
#define OS_XXXX_H_CVSID "$Id: os_os2.h,v 1.5 2008/03/04 22:09:47 ballen4705 Exp $\n"
// Additional material should start here. Note: to keep the '-V' CVS
// reporting option working as intended, you should only #include
// system include files <something.h>. Local #include files
// <"something.h"> should be #included in os_generic.c
#define INCL_DOS
#include <os2.h>
#include "os_os2\hdreg.h"
#include "os_linux.h"
#pragma pack(1)
#define DSKSP_CAT_SMART 0x80 /* SMART IOCTL category */
#define DSKSP_SMART_ONOFF 0x20 /* turn SMART on or off */
#define DSKSP_SMART_AUTOSAVE_ONOFF 0x21 /* turn SMART autosave on or off */
#define DSKSP_SMART_SAVE 0x22 /* force save of SMART data */
#define DSKSP_SMART_GETSTATUS 0x23 /* get SMART status (pass/fail) */
#define DSKSP_SMART_GET_ATTRIBUTES 0x24 /* get SMART attributes table */
#define DSKSP_SMART_GET_THRESHOLDS 0x25 /* get SMART thresholds table */
#define DSKSP_SMART_READ_LOG 0x26
#define DSKSP_SMART_WRITE_LOG 0x27
#define DSKSP_SMART_READ_LOG_EXT 0x28
#define DSKSP_SMART_WRITE_LOG_EXT 0x29
#define DSKSP_SMART_EOLI 0x30 /* EXECUTE OFF-LINE IMMEDIATE */
#define SMART_CMD_ON 1 /* on value for related SMART functions */
#define SMART_CMD_OFF 0 /* off value for related SMART functions */
#define DSKSP_CAT_GENERIC 0x90 /* generic IOCTL category */
#define DSKSP_GET_INQUIRY_DATA 0x42 /* get ATA/ATAPI inquiry data */
typedef struct _DSKSP_CommandParameters {
BYTE byPhysicalUnit; /* physical unit number 0-n */
/* 0 = 1st disk, 1 = 2nd disk, ...*/
/* 0x80 = Pri/Mas, 0x81=Pri/Sla, 0x82=Sec/Mas,*/
} DSKSP_CommandParameters, *PDSKSP_CommandParameters;
struct SMART_ParamExt {
UCHAR byPhysicalUnit; // 0=Pri/Mas, 1=Pri/Sla, 2=Sec/Mas, etc.
ULONG LogAddress; // valid values 0-255. See ATA/ATPI standard
// for details
ULONG SectorCount; // valid values 0-255 See ATA/ATPI standard
// for details
ULONG reserved; // reserved. must be set to 0
};
#endif /* OS_GENERIC_H_ */

9
os_os2/configure.os2 Normal file
View File

@ -0,0 +1,9 @@
#! /bin/sh
CFLAGS="-s -Zomf -O3 -march=pentium -mcpu=pentium3" \
CXXFLAGS="-s -Zomf -O3 -march=pentium -mcpu=pentium3" \
LDFLAGS="-s -Zmap -Zhigh-mem -Zomf -Zexe -Zstack 0x100" \
LIBS=" -lsyslog -lsocket" \
LN_CP_F="cp.exe" \
RANLIB="echo" \
AR="emxomfar" \
./configure --prefix=/usr/local/smartmontools

333
os_os2/hdreg.h Normal file
View File

@ -0,0 +1,333 @@
#ifndef _LINUX_HDREG_H
#define _LINUX_HDREG_H
/*
* This file contains some defines for the AT-hd-controller.
* Various sources.
*/
#define HD_IRQ 14 /* the standard disk interrupt */
/* ide.c has its own port definitions in "ide.h" */
/* Hd controller regs. Ref: IBM AT Bios-listing */
#define HD_DATA 0x1f0 /* _CTL when writing */
#define HD_ERROR 0x1f1 /* see err-bits */
#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
#define HD_SECTOR 0x1f3 /* starting sector */
#define HD_LCYL 0x1f4 /* starting cylinder */
#define HD_HCYL 0x1f5 /* high byte of starting cyl */
#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
#define HD_STATUS 0x1f7 /* see status-bits */
#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */
#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */
#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
#define HD_CMD 0x3f6 /* used for resets */
#define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */
/* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */
/* Bits of HD_STATUS */
#define ERR_STAT 0x01
#define INDEX_STAT 0x02
#define ECC_STAT 0x04 /* Corrected error */
#define DRQ_STAT 0x08
#define SEEK_STAT 0x10
#define WRERR_STAT 0x20
#define READY_STAT 0x40
#define BUSY_STAT 0x80
/* Values for HD_COMMAND */
#define WIN_RESTORE 0x10
#define WIN_READ 0x20
#define WIN_WRITE 0x30
#define WIN_WRITE_VERIFY 0x3C
#define WIN_VERIFY 0x40
#define WIN_FORMAT 0x50
#define WIN_INIT 0x60
#define WIN_SEEK 0x70
#define WIN_DIAGNOSE 0x90
#define WIN_SPECIFY 0x91 /* set drive geometry translation */
#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */
#define WIN_SETIDLE1 0xE3
#define WIN_SETIDLE2 0x97
#define WIN_STANDBYNOW1 0xE0
#define WIN_STANDBYNOW2 0x94
#define WIN_SLEEPNOW1 0xE6
#define WIN_SLEEPNOW2 0x99
#define WIN_CHECKPOWERMODE1 0xE5
#define WIN_CHECKPOWERMODE2 0x98
#define WIN_DOORLOCK 0xDE /* lock door on removable drives */
#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */
#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode */
#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */
#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */
#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */
#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */
#define WIN_SETFEATURES 0xEF /* set special drive features */
#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */
#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */
#define WIN_QUEUED_SERVICE 0xA2 /* */
#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */
#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */
#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */
#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */
#define WIN_SMART 0xB0 /* self-monitoring and reporting */
/* Additional drive command codes used by ATAPI devices. */
#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */
#define WIN_SRST 0x08 /* ATAPI soft reset command */
#define WIN_PACKETCMD 0xA0 /* Send a packet command. */
#define DISABLE_SEAGATE 0xFB
#define EXABYTE_ENABLE_NEST 0xF0
/* WIN_SMART sub-commands */
#define SMART_READ_VALUES 0xd0
#define SMART_READ_THRESHOLDS 0xd1
#define SMART_AUTOSAVE 0xd2
#define SMART_SAVE 0xd3
#define SMART_IMMEDIATE_OFFLINE 0xd4
#define SMART_READ_LOG_SECTOR 0xd5
#define SMART_WRITE_LOG_SECTOR 0xd6
#define SMART_ENABLE 0xd8
#define SMART_DISABLE 0xd9
#define SMART_STATUS 0xda
#define SMART_AUTO_OFFLINE 0xdb
/* WIN_SETFEATURES sub-commands */
#define SETFEATURES_EN_WCACHE 0x02 /* Enable write cache */
#define SETFEATURES_XFER 0x03 /* Set transfer mode */
# define XFER_UDMA_7 0x47 /* 0100|0111 */
# define XFER_UDMA_6 0x46 /* 0100|0110 */
# define XFER_UDMA_5 0x45 /* 0100|0101 */
# define XFER_UDMA_4 0x44 /* 0100|0100 */
# define XFER_UDMA_3 0x43 /* 0100|0011 */
# define XFER_UDMA_2 0x42 /* 0100|0010 */
# define XFER_UDMA_1 0x41 /* 0100|0001 */
# define XFER_UDMA_0 0x40 /* 0100|0000 */
# define XFER_MW_DMA_2 0x22 /* 0010|0010 */
# define XFER_MW_DMA_1 0x21 /* 0010|0001 */
# define XFER_MW_DMA_0 0x20 /* 0010|0000 */
# define XFER_SW_DMA_2 0x12 /* 0001|0010 */
# define XFER_SW_DMA_1 0x11 /* 0001|0001 */
# define XFER_SW_DMA_0 0x10 /* 0001|0000 */
# define XFER_PIO_4 0x0C /* 0000|1100 */
# define XFER_PIO_3 0x0B /* 0000|1011 */
# define XFER_PIO_2 0x0A /* 0000|1010 */
# define XFER_PIO_1 0x09 /* 0000|1001 */
# define XFER_PIO_0 0x08 /* 0000|1000 */
# define XFER_PIO_SLOW 0x00 /* 0000|0000 */
#define SETFEATURES_DIS_DEFECT 0x04 /* Disable Defect Management */
#define SETFEATURES_EN_APM 0x05 /* Enable advanced power management */
#define SETFEATURES_DIS_MSN 0x31 /* Disable Media Status Notification */
#define SETFEATURES_DIS_RLA 0x55 /* Disable read look-ahead feature */
#define SETFEATURES_EN_RI 0x5D /* Enable release interrupt */
#define SETFEATURES_EN_SI 0x5E /* Enable SERVICE interrupt */
#define SETFEATURES_DIS_RPOD 0x66 /* Disable reverting to power on defaults */
#define SETFEATURES_DIS_WCACHE 0x82 /* Disable write cache */
#define SETFEATURES_EN_DEFECT 0x84 /* Enable Defect Management */
#define SETFEATURES_DIS_APM 0x85 /* Disable advanced power management */
#define SETFEATURES_EN_MSN 0x95 /* Enable Media Status Notification */
#define SETFEATURES_EN_RLA 0xAA /* Enable read look-ahead feature */
#define SETFEATURES_PREFETCH 0xAB /* Sets drive prefetch value */
#define SETFEATURES_EN_RPOD 0xCC /* Enable reverting to power on defaults */
#define SETFEATURES_DIS_RI 0xDD /* Disable release interrupt */
#define SETFEATURES_DIS_SI 0xDE /* Disable SERVICE interrupt */
/* WIN_SECURITY sub-commands */
#define SECURITY_SET_PASSWORD 0xBA /* 0xF1 */
#define SECURITY_UNLOCK 0xBB /* 0xF2 */
#define SECURITY_ERASE_PREPARE 0xBC /* 0xF3 */
#define SECURITY_ERASE_UNIT 0xBD /* 0xF4 */
#define SECURITY_FREEZE_LOCK 0xBE /* 0xF5 */
#define SECURITY_DISABLE_PASSWORD 0xBF /* 0xF6 */
/* Bits for HD_ERROR */
#define MARK_ERR 0x01 /* Bad address mark */
#define TRK0_ERR 0x02 /* couldn't find track 0 */
#define ABRT_ERR 0x04 /* Command aborted */
#define MCR_ERR 0x08 /* media change request */
#define ID_ERR 0x10 /* ID field not found */
#define ECC_ERR 0x40 /* Uncorrectable ECC error */
#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
#define HDIO_GETGEO 0x0301 /* get device geometry */
#define HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
#define HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
#define HDIO_OBSOLETE_IDENTITY 0x0307 /* OBSOLETE, DO NOT USE: returns 142 bytes */
#define HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
#define HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
#define HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
#define HDIO_GET_DMA 0x030b /* get use-dma flag */
#define HDIO_GET_NICE 0x030c /* get nice flags */
#define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
#define HDIO_DRIVE_RESET 0x031c /* execute a device reset */
#define HDIO_TRISTATE_HWIF 0x031d /* execute a channel tristate */
#ifndef __EMX__
#define HDIO_DRIVE_TASK 0x031e /* execute task and special drive command */
#endif
#define HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
#define HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
#define HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
#define HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
#define HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
#define HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
#define HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
#define HDIO_SET_DMA 0x0326 /* change use-dma flag */
#define HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
#define HDIO_SCAN_HWIF 0x0328 /* register and (re)scan interface */
#define HDIO_SET_NICE 0x0329 /* set nice flags */
#define HDIO_UNREGISTER_HWIF 0x032a /* unregister interface */
/* BIG GEOMETRY */
struct hd_big_geometry {
unsigned char heads;
unsigned char sectors;
unsigned int cylinders;
unsigned long start;
};
/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */
#define HDIO_GETGEO_BIG 0x0330 /* */
#define HDIO_GETGEO_BIG_RAW 0x0331 /* */
#define __NEW_HD_DRIVE_ID
/* structure returned by HDIO_GET_IDENTITY, as per ANSI ATA2 rev.2f spec */
struct hd_driveid {
unsigned short config; /* lots of obsolete bit flags */
unsigned short cyls; /* "physical" cyls */
unsigned short reserved2; /* reserved (word 2) */
unsigned short heads; /* "physical" heads */
unsigned short track_bytes; /* unformatted bytes per track */
unsigned short sector_bytes; /* unformatted bytes per sector */
unsigned short sectors; /* "physical" sectors per track */
unsigned short vendor0; /* vendor unique */
unsigned short vendor1; /* vendor unique */
unsigned short vendor2; /* vendor unique */
unsigned char serial_no[20]; /* 0 = not_specified */
unsigned short buf_type;
unsigned short buf_size; /* 512 byte increments; 0 = not_specified */
unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */
unsigned char fw_rev[8]; /* 0 = not_specified */
unsigned char model[40]; /* 0 = not_specified */
unsigned char max_multsect; /* 0=not_implemented */
unsigned char vendor3; /* vendor unique */
unsigned short dword_io; /* 0=not_implemented; 1=implemented */
unsigned char vendor4; /* vendor unique */
unsigned char capability; /* bits 0:DMA 1:LBA 2:IORDYsw 3:IORDYsup*/
unsigned short reserved50; /* reserved (word 50) */
unsigned char vendor5; /* vendor unique */
unsigned char tPIO; /* 0=slow, 1=medium, 2=fast */
unsigned char vendor6; /* vendor unique */
unsigned char tDMA; /* 0=slow, 1=medium, 2=fast */
unsigned short field_valid; /* bits 0:cur_ok 1:eide_ok */
unsigned short cur_cyls; /* logical cylinders */
unsigned short cur_heads; /* logical heads */
unsigned short cur_sectors; /* logical sectors per track */
unsigned short cur_capacity0; /* logical total sectors on drive */
unsigned short cur_capacity1; /* (2 words, misaligned int) */
unsigned char multsect; /* current multiple sector count */
unsigned char multsect_valid; /* when (bit0==1) multsect is ok */
unsigned int lba_capacity; /* total number of sectors */
unsigned short dma_1word; /* single-word dma info */
unsigned short dma_mword; /* multiple-word dma info */
unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */
unsigned short eide_dma_min; /* min mword dma cycle time (ns) */
unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */
unsigned short eide_pio; /* min cycle time (ns), no IORDY */
unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */
unsigned short words69_70[2]; /* reserved words 69-70 */
/* HDIO_GET_IDENTITY currently returns only words 0 through 70 */
unsigned short words71_74[4]; /* reserved words 71-74 */
unsigned short queue_depth; /* */
unsigned short words76_79[4]; /* reserved words 76-79 */
unsigned short major_rev_num; /* */
unsigned short minor_rev_num; /* */
unsigned short command_set_1; /* bits 0:Smart 1:Security 2:Removable 3:PM */
unsigned short command_set_2; /* bits 14:Smart Enabled 13:0 zero */
unsigned short cfsse; /* command set-feature supported extensions */
unsigned short cfs_enable_1; /* command set-feature enabled */
unsigned short cfs_enable_2; /* command set-feature enabled */
unsigned short csf_default; /* command set-feature default */
unsigned short dma_ultra; /* */
unsigned short word89; /* reserved (word 89) */
unsigned short word90; /* reserved (word 90) */
unsigned short CurAPMvalues; /* current APM values */
unsigned short word92; /* reserved (word 92) */
unsigned short hw_config; /* hardware config */
unsigned short words94_125[32];/* reserved words 94-125 */
unsigned short last_lun; /* reserved (word 126) */
unsigned short word127; /* reserved (word 127) */
unsigned short dlf; /* device lock function
* 15:9 reserved
* 8 security level 1:max 0:high
* 7:6 reserved
* 5 enhanced erase
* 4 expire
* 3 frozen
* 2 locked
* 1 en/disabled
* 0 capability
*/
unsigned short csfo; /* current set features options
* 15:4 reserved
* 3 auto reassign
* 2 reverting
* 1 read-look-ahead
* 0 write cache
*/
unsigned short words130_155[26];/* reserved vendor words 130-155 */
unsigned short word156;
unsigned short words157_159[3];/* reserved vendor words 157-159 */
unsigned short words160_255[95];/* reserved words 160-255 */
};
/*
* IDE "nice" flags. These are used on a per drive basis to determine
* when to be nice and give more bandwidth to the other devices which
* share the same IDE bus.
*/
#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */
#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */
#define IDE_NICE_0 (2) /* when sure that it won't affect us */
#define IDE_NICE_1 (3) /* when probably won't affect us much */
#define IDE_NICE_2 (4) /* when we know it's on our expense */
#ifdef __KERNEL__
/*
* These routines are used for kernel command line parameters from main.c:
*/
#include <linux/config.h>
#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
int ide_register(int io_port, int ctl_port, int irq);
void ide_unregister(unsigned int);
#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
#endif /* __KERNEL__ */
#endif /* _LINUX_HDREG_H */

643
os_qnxnto.cpp Normal file
View File

@ -0,0 +1,643 @@
// This is needed for the various HAVE_* macros and PROJECT_* macros.
#include "config.h"
// These are needed to define prototypes and structures for the
// functions defined below
#include "int64.h"
#include "atacmds.h"
#include "scsicmds.h"
#include "utility.h"
// This is to include whatever structures and prototypes you define in
// os_generic.h
#include "os_qnxnto.h"
// Needed by '-V' option (CVS versioning) of smartd/smartctl. You
// should have one *_H_CVSID macro appearing below for each file
// appearing with #include "*.h" above. Please list these (below) in
// alphabetic/dictionary order.
const char *os_XXXX_c_cvsid="$Id: os_qnxnto.cpp,v 1.3 2008/06/12 21:46:31 ballen4705 Exp $" \
ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_QNXNTO_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
// This is here to prevent compiler warnings for unused arguments of
// functions.
#define ARGUSED(x) ((void)(x))
// Please eliminate the following block: both the #include and
// the 'unsupported()' function. They are only here to warn
// unsuspecting users that their Operating System is not supported! If
// you wish, you can use a similar warning mechanism for any of the
// functions in this file that you can not (or choose not to)
// implement.
#ifdef HAVE_UNAME
#include <sys/utsname.h>
#endif
//----------------------------------------------------------------------------------------------
// private Functions
static int ata_sense_data(void *sdata,int *error,int *key,int *asc,int *ascq);
static int ata_interpret_sense(struct cam_pass_thru *cpt,void *sense,int *status,int rcount);
static int ata_pass_thru(int fd,struct cam_pass_thru *pcpt);
//----------------------------------------------------------------------------------------------
static void unsupported(){
static int warninggiven;
if (!warninggiven) {
char *osname;
extern unsigned char debugmode;
unsigned char savedebugmode=debugmode;
#ifdef HAVE_UNAME
struct utsname ostype;
uname(&ostype);
osname=ostype.sysname;
#else
osname="host's";
#endif
debugmode=1;
pout("\n"
"############################################################################\n"
"WARNING: smartmontools has not been ported to the %s Operating System.\n"
"Please see the files os_generic.cpp and os_generic.h for porting instructions.\n"
"############################################################################\n\n",
osname);
debugmode=savedebugmode;
warninggiven=1;
}
return;
}
// End of the 'unsupported()' block that you should eliminate.
// print examples for smartctl. You should modify this function so
// that the device paths are sensible for your OS, and to eliminate
// unsupported commands (eg, 3ware controllers).
void print_smartctl_examples(){
printf("=================================================== SMARTCTL EXAMPLES =====\n\n");
#ifdef HAVE_GETOPT_LONG
printf(
" smartctl -a /dev/hd0 (Prints all SMART information)\n\n"
" smartctl --smart=on --offlineauto=on --saveauto=on /dev/hd0\n"
" (Enables SMART on first disk)\n\n"
" smartctl -t long /dev/hd0 (Executes extended disk self-test)\n\n"
" smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hd0\n"
" (Prints Self-Test & Attribute errors)\n"
" smartctl -a --device=3ware,2 /dev/sda\n"
" (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n"
);
#else
printf(
" smartctl -a /dev/hd0 (Prints all SMART information)\n"
" smartctl -s on -o on -S on /dev/hd0 (Enables SMART on first disk)\n"
" smartctl -t long /dev/hd0 (Executes extended disk self-test)\n"
" smartctl -A -l selftest -q errorsonly /dev/hd0\n"
" (Prints Self-Test & Attribute errors)\n"
" smartctl -a -d 3ware,2 /dev/sda\n"
" (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n"
);
#endif
return;
}
// tries to guess device type given the name (a path). See utility.h
// for return values.
static const char *net_dev_prefix = "/dev/";
static const char *net_dev_ata_disk = "hd";
int guess_device_type (const char* dev_name)
{
int len,dev_prefix_len;
dev_prefix_len=strlen(net_dev_prefix);
if(!dev_name||!(len=strlen(dev_name)))
return(CONTROLLER_UNKNOWN);
if (!strncmp(net_dev_prefix,dev_name,dev_prefix_len))
{
if(len<=dev_prefix_len)
return(CONTROLLER_UNKNOWN);
else
dev_name += dev_prefix_len;
}
if(!strncmp(net_dev_ata_disk,dev_name,strlen(net_dev_ata_disk)))
return(CONTROLLER_ATA);
return(CONTROLLER_UNKNOWN);
}
// makes a list of ATA or SCSI devices for the DEVICESCAN directive of
// smartd. Returns number N of devices, or -1 if out of
// memory. Allocates N+1 arrays: one of N pointers (devlist); the
// other N arrays each contain null-terminated character strings. In
// the case N==0, no arrays are allocated because the array of 0
// pointers has zero length, equivalent to calling malloc(0).
int make_device_names (char*** devlist, const char* name) {
ARGUSED(devlist);
ARGUSED(name);
unsupported();
return 0;
}
// Like open(). Return non-negative integer handle, only used by the
// functions below. type=="ATA" or "SCSI". If you need to store
// extra information about your devices, create a private internal
// array within this file (see os_freebsd.cpp for an example). If you
// can not open the device (permission denied, does not exist, etc)
// set errno as open() does and return <0.
int deviceopen(const char *pathname, char *type)
{
if(!strcmp(type, "ATA"))
return(open(pathname,O_RDWR|O_NONBLOCK));
else
return(-1);
}
// Like close(). Acts only on integer handles returned by
// deviceopen() above.
int deviceclose(int fd)
{
return(close(fd));
}
//----------------------------------------------------------------------------------------------
// Interface to ATA devices. See os_linux.cpp for the cannonical example.
// DETAILED DESCRIPTION OF ARGUMENTS
// device: is the integer handle provided by deviceopen()
// command: defines the different operations, see atacmds.h
// select: additional input data IF NEEDED (which log, which type of
// self-test).
// data: location to write output data, IF NEEDED (1 or 512 bytes).
// Note: not all commands use all arguments.
// RETURN VALUES (for all commands BUT command==STATUS_CHECK)
// -1 if the command failed
// 0 if the command succeeded,
// RETURN VALUES if command==STATUS_CHECK
// -1 if the command failed OR the disk SMART status can't be determined
// 0 if the command succeeded and disk SMART status is "OK"
// 1 if the command succeeded and disk SMART status is "FAILING"
int ata_command_interface(int fd,smart_command_set command,int select,char *data)
{
struct cam_pass_thru cpt;
ATA_SENSE sense;
CDB *cdb;
int status,rc;
memset(&cpt,0x00,sizeof(struct cam_pass_thru));
cdb=(CDB *)cpt.cam_cdb;
rc=-1;
switch(command)
{
case READ_VALUES:
cpt.cam_flags = CAM_DIR_IN;
cpt.cam_cdb_len = 16;
cpt.cam_dxfer_len = 512;
cpt.cam_data_ptr = (uint32_t)data;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN;
cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_READ_VALUES;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case READ_THRESHOLDS:
cpt.cam_flags = CAM_DIR_IN;
cpt.cam_cdb_len = 16;
cpt.cam_dxfer_len = 512;
cpt.cam_data_ptr = (uint32_t)data;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN;
cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_READ_THRESHOLDS;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case READ_LOG:
cpt.cam_flags = CAM_DIR_IN;
cpt.cam_cdb_len = 16;
cpt.cam_dxfer_len = 512;
cpt.cam_data_ptr = (uint32_t)data;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN;
cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_READ_LOG_SECTOR;
cdb->ata_pass_thru.sector_count= 1;
cdb->ata_pass_thru.lba_low = select;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case WRITE_LOG:
return(-1);
break;
case IDENTIFY:
cpt.cam_flags = CAM_DIR_IN;
cpt.cam_cdb_len = 16;
cpt.cam_dxfer_len = 512;
cpt.cam_data_ptr = (uint32_t)data;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN;
cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU;
cdb->ata_pass_thru.command = ATA_IDENTIFY_DEVICE;
break;
case PIDENTIFY:
cpt.cam_flags = CAM_DIR_IN;
cpt.cam_cdb_len = 16;
cpt.cam_dxfer_len = 512;
cpt.cam_data_ptr = (uint32_t)data;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN;
cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU;
cdb->ata_pass_thru.command = ATA_IDENTIFY_PACKET_DEVICE;
break;
case ENABLE:
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_ENABLE;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case DISABLE:
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_DISABLE;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case AUTO_OFFLINE:
// NOTE: According to ATAPI 4 and UP, this command is obsolete
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_AUTO_OFFLINE;
cdb->ata_pass_thru.lba_low = select;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case AUTOSAVE:
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_AUTOSAVE;
cdb->ata_pass_thru.sector_count= select;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case IMMEDIATE_OFFLINE:
// NOTE: According to ATAPI 4 and UP, this command is obsolete
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_IMMEDIATE_OFFLINE;
cdb->ata_pass_thru.lba_low = select;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case STATUS_CHECK:
// same command, no HDIO in NetBSD
case STATUS:
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.flags = ATA_FLG_CK_COND;
cdb->ata_pass_thru.command = ATA_SMART_CMD;
cdb->ata_pass_thru.features = ATA_SMART_STATUS;
cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG;
cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG;
break;
case CHECK_POWER_MODE:
cpt.cam_flags = CAM_DIR_NONE;
cpt.cam_cdb_len = 16;
cpt.cam_sense_len = sizeof(sense);
cpt.cam_sense_ptr = (uint32_t)&sense;
cdb->ata_pass_thru.opcode = SC_ATA_PT16;
cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE;
cdb->ata_pass_thru.flags = ATA_FLG_CK_COND;
cdb->ata_pass_thru.command = ATA_CHECK_POWER_MODE;
break;
default:
pout("Unrecognized command %d in ata_command_interface()\n", command);
errno=ENOSYS;
return(-1);
}
// execute now
if((status=ata_pass_thru(fd,&cpt))==EOK)
{
rc=status==EOK?0:-1;
if(cpt.cam_status!=CAM_REQ_CMP)
{
ata_interpret_sense(&cpt,&sense,&status,0);
if(command==STATUS||command==STATUS_CHECK)
rc=((sense.desc.lba_high<<8)|sense.desc.lba_mid)==ATA_SMART_SIG?0:1;
}
}
if(command==CHECK_POWER_MODE)
data[0]=cdb->ata_pass_thru.sector_count;
// finish
return(rc);
}
//----------------------------------------------------------------------------------------------
int marvell_command_interface(int fd, smart_command_set command, int select, char *data)
{
ARGUSED(fd);
ARGUSED(command);
ARGUSED(select);
ARGUSED(data);
unsupported();
return -1;
}
//----------------------------------------------------------------------------------------------
int highpoint_command_interface(int fd, smart_command_set command, int select, char *data)
{
ARGUSED(fd);
ARGUSED(command);
ARGUSED(select);
ARGUSED(data);
unsupported();
return -1;
}
//----------------------------------------------------------------------------------------------
// Interface to ATA devices behind 3ware escalade/apache RAID
// controller cards. Same description as ata_command_interface()
// above except that 0 <= disknum <= 15 specifies the ATA disk
// attached to the controller, and controller_type specifies the
// precise type of 3ware controller. See os_linux.c
int escalade_command_interface(int fd,int disknum,int controller_type,smart_command_set command,int select,char *data)
{
ARGUSED(fd);
ARGUSED(disknum);
ARGUSED(controller_type);
ARGUSED(command);
ARGUSED(select);
ARGUSED(data);
unsupported();
return -1;
}
int areca_command_interface(int fd,int disknum,smart_command_set command,int select,char *data)
{
ARGUSED(fd);
ARGUSED(disknum);
ARGUSED(command);
ARGUSED(select);
ARGUSED(data);
unsupported();
return -1;
}
//----------------------------------------------------------------------------------------------
#include <errno.h>
// Interface to SCSI devices. See os_linux.c
int do_scsi_cmnd_io(int fd,struct scsi_cmnd_io * iop,int report)
{
ARGUSED(fd);
ARGUSED(iop);
ARGUSED(report);
unsupported();
return -ENOSYS;
}
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
static int ata_sense_data(void *sdata,int *error,int *key,int *asc,int *ascq)
{
SCSI_SENSE *sf;
SCSI_SENSE_DESCRIPTOR *sd;
sf=(SCSI_SENSE *)sdata;
sd=(SCSI_SENSE_DESCRIPTOR *)sdata;
*error=sf->error;
if(*error & SENSE_DATA_FMT_DESCRIPTOR)
{
*key=sd->sense & SK_MSK;
*asc=sd->asc;
*ascq=sd->ascq;
}
else
{
*key=sf->sense & SK_MSK;
*asc=sf->asc;
*ascq=sf->ascq;
}
return(CAM_SUCCESS);
}
//----------------------------------------------------------------------------------------------
static int ata_interpret_sense(struct cam_pass_thru *cpt,void *sense,int *status,int rcount)
{
int retry;
int key;
int asc;
int ascq;
int error;
*status=EIO;
retry=CAM_TRUE;
if(cpt->cam_status&CAM_AUTOSNS_VALID)
{
ata_sense_data(sense,&error,&key,&asc,&ascq);
switch(key)
{
case SK_NO_SENSE: // No sense data (no error)
retry=CAM_FALSE;
*status=EOK;
break;
case SK_RECOVERED: // Recovered error
switch(asc)
{
case ASC_ATA_PASS_THRU:
switch(ascq)
{
case ASCQ_ATA_PASS_THRU_INFO_AVAIL:
break;
default:
break;
}
break;
default:
break;
}
retry=CAM_FALSE;
*status=EOK;
break;
case SK_NOT_RDY: // Device not ready
*status=EAGAIN;
switch(asc)
{
case ASC_NOT_READY:
switch(ascq)
{
case ASCQ_BECOMING_READY:
case ASCQ_CAUSE_NOT_REPORTABLE:
default:
retry=CAM_FALSE;
break;
}
break;
case ASC_MEDIA_NOT_PRESENT:
*status=ENXIO;
retry=CAM_FALSE;
break;
}
break;
case SK_MEDIUM: // Medium error
case SK_HARDWARE: // Hardware error
retry=CAM_FALSE;
*status=EIO;
break;
case SK_ILLEGAL: // Illegal Request (bad command)
retry=CAM_FALSE;
*status=EINVAL;
break;
case SK_UNIT_ATN: // Unit Attention
switch(asc)
{
case ASC_MEDIUM_CHANGED:
*status=ESTALE;
retry=CAM_FALSE;
break;
case ASC_BUS_RESET:
break;
}
break;
case SK_DATA_PROT: // Data Protect
retry=CAM_FALSE;
*status=EROFS;
break;
case SK_VENDOR: // Vendor Specific
case SK_CPY_ABORT: // Copy Aborted
retry=CAM_FALSE;
*status=EIO;
break;
case SK_CMD_ABORT: // Aborted Command
retry=CAM_FALSE;
*status=ECANCELED;
break;
case SK_EQUAL: // Equal
case SK_VOL_OFL: // Volume Overflow
case SK_MISCMP: // Miscompare
case SK_RESERVED: // Reserved
break;
}
if(*status==EOK)
{
switch(cpt->cam_status&CAM_STATUS_MASK)
{
case CAM_REQ_CMP_ERR: // CCB request completed with an err
retry=CAM_FALSE;
*status=EIO;
break;
case CAM_BUSY: // CAM subsystem is busy
*status=EAGAIN;
break;
case CAM_REQ_INVALID: // CCB request is invalid
case CAM_PATH_INVALID: // Path ID supplied is invalid
case CAM_DEV_NOT_THERE: // SCSI device not installed/there
case CAM_SEL_TIMEOUT: // Target selection timeout
case CAM_LUN_INVALID: // LUN supplied is invalid
case CAM_TID_INVALID: // Target ID supplied is invalid
retry=CAM_FALSE;
*status=ENXIO;
break;
case CAM_CMD_TIMEOUT: // Command timeout
*status=rcount?EAGAIN:EIO;
break;
case CAM_MSG_REJECT_REC: // Message reject received
case CAM_SCSI_BUS_RESET: // SCSI bus reset sent/received
case CAM_UNCOR_PARITY: // Uncorrectable parity err occurred
case CAM_AUTOSENSE_FAIL: // Autosense: Request sense cmd fail
case CAM_NO_HBA: // No HBA detected Error
case CAM_DATA_RUN_ERR: // Data overrun/underrun error
retry=CAM_FALSE;
*status=EIO;
break;
case CAM_UNEXP_BUSFREE: // Unexpected BUS free
case CAM_SEQUENCE_FAIL: // Target bus phase sequence failure
*status=EIO;
break;
case CAM_PROVIDE_FAIL: // Unable to provide requ. capability
retry=CAM_FALSE;
*status=ENOTTY;
break;
case CAM_CCB_LEN_ERR: // CCB length supplied is inadequate
case CAM_BDR_SENT: // A SCSI BDR msg was sent to target
case CAM_REQ_TERMIO: // CCB request terminated by the host
case CAM_FUNC_NOTAVAIL: // The requ. func is not available
case CAM_NO_NEXUS: // Nexus is not established
case CAM_IID_INVALID: // The initiator ID is invalid
case CAM_CDB_RECVD: // The SCSI CDB has been received
retry=CAM_FALSE;
*status=EIO;
break;
case CAM_SCSI_BUSY: // SCSI bus busy
*status=EAGAIN;
break;
}
}
}
return(retry);
}
//----------------------------------------------------------------------------------------------
static int ata_pass_thru(int fd,struct cam_pass_thru *pcpt)
{
int icnt;
int status;
iov_t iov[3];
struct cam_pass_thru cpt;
cpt=*pcpt;
icnt=1;
SETIOV(&iov[0],&cpt,sizeof(cpt));
cpt.cam_timeout=cpt.cam_timeout?cpt.cam_timeout:CAM_TIME_DEFAULT;
if(cpt.cam_sense_len)
{
SETIOV(&iov[1],cpt.cam_sense_ptr,cpt.cam_sense_len);
cpt.cam_sense_ptr=sizeof(cpt);
icnt++;
}
if(cpt.cam_dxfer_len)
{
SETIOV(&iov[2],(void *)cpt.cam_data_ptr,cpt.cam_dxfer_len);
cpt.cam_data_ptr=(paddr_t)sizeof(cpt)+cpt.cam_sense_len;
icnt++;
}
if((status=devctlv(fd,DCMD_CAM_PASS_THRU,icnt,icnt,iov,iov,NULL)))
pout("ata_pass_thru devctl: %s\n",strerror(status));
pcpt->cam_status=cpt.cam_status;
pcpt->cam_scsi_status=cpt.cam_scsi_status;
return(status);
}
//----------------------------------------------------------------------------------------------

896
os_qnxnto.h Normal file
View File

@ -0,0 +1,896 @@
/*
* os_generic.h
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) Joerg Hering <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2003-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* (for example COPYING); if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* This code was originally developed as a Senior Thesis by Michael Cornwell
* at the Concurrent Systems Laboratory (now part of the Storage Systems
* Research Center), Jack Baskin School of Engineering, University of
* California, Santa Cruz. http://ssrc.soe.ucsc.edu/
*
*/
#ifndef OS_QNXNTO_H_
#define OS_QNXNTO_H_
#define OS_QNXNTO_H_CVSID "$Id: os_qnxnto.h,v 1.2 2008/03/04 22:09:47 ballen4705 Exp $\n"
// Additional material should start here. Note: to keep the '-V' CVS
// reporting option working as intended, you should only #include
// system include files <something.h>. Local #include files
// <"something.h"> should be #included in os_generic.c
#include <sys/cpt.h>
#ifndef __TYPES_H_INCLUDED
#include <sys/types.h>
#endif
#include <stdio.h>
#include <fcntl.h>
#include <gulliver.h>
#include <sys/cpt.h>
#include <sys/dcmd_cam.h>
#include <sys/cam_device.h>
#include "atacmds.h"
//----------------------------------------------------------------------------------------------------------
typedef struct _ata_pass_thru ATA_PASS_THRU;
typedef struct _eide_identify EIDE_IDENTIFY;
typedef struct _ata_sense ATA_SENSE;
typedef void CCB;
struct _sim_hba;
struct _resmgr_context;
typedef struct _drive_attribute
{
int id;
int threshold;
char *name;
}DRIVE_ATTRIBUTE;
//----------------------------------------------------------------------------------------------------------
/* UNIVOS OSD defines and data structures. */
#define INQLEN 36 /* Inquiry string length to store. */
#define CAM_SUCCESS 0 /* For signaling general success */
#define CAM_FAILURE 1 /* For signaling general failure */
#define CAM_FALSE 0 /* General purpose flag value */
#define CAM_TRUE 1 /* General purpose flag value */
//----------------------------------------------------------------------------------------------------------
// Group 3 and 4, command codes 60H-9FH are reserved
#define SC_ATA_PT16 0x85 // ATA Pass-through
//----------------------------------------------------------------------------------------------------------
#define ATA_SMART_LBA_MID_SIG 0x4f
#define ATA_SMART_LBA_HI_SIG 0xc2
#define ATA_SMART_SIG 0xc24f
//----------------------------------------------------------------------------------------------------------
struct _ata_pass_thru {
uchar_t opcode;
#define ATA_PROTO_MSK 0x1e
#define ATA_PROTO_RESPONSE (15 << 1)
#define ATA_PROTO_FPDMA (12 << 1)
#define ATA_PROTO_UDMA_DATA_OUT (11 << 1)
#define ATA_PROTO_UDMA_DATA_IN (10 << 1)
#define ATA_PROTO_DEVICE_RESET (9 << 1)
#define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1)
#define ATA_PROTO_DMA_QUEUED (7 << 1)
#define ATA_PROTO_DMA (6 << 1)
#define ATA_PROTO_PIO_DATA_OUT (5 << 1)
#define ATA_PROTO_PIO_DATA_IN (4 << 1)
#define ATA_PROTO_DATA_NONE (3 << 1)
#define ATA_PROTO_SRST (1 << 1)
#define ATA_PROTO_HRST (0 << 1)
#define ATA_PROTO_EXTEND 0x01
uchar_t protocol; // multiple count, protocol
#define ATA_MCOUNT_MSK 0xe0
#define ATA_FLG_CK_COND 0x20
#define ATA_FLG_T_DIR 0x08 // data from device
#define ATA_FLG_BYT_BLOK 0x04
#define ATA_FLG_TLEN_STPSIU 0x03
#define ATA_FLG_TLEN_SECTOR_COUNT 0x02
#define ATA_FLG_TLEN_FEATURE 0x01
uchar_t flags;
uchar_t efeatures;
uchar_t features;
uchar_t esector_count;
uchar_t sector_count;
uchar_t elba_low;
uchar_t lba_low;
uchar_t elba_mid;
uchar_t lba_mid;
uchar_t elba_high;
uchar_t lba_high;
uchar_t device;
uchar_t command;
uchar_t control;
} ata_pass_thru_;
//----------------------------------------------------------------------------------------------------------
#define SENSE_DATA_FMT_DESCRIPTOR 0x02
// Fixed Format Sense Data Structure
// Note: The field "error" has the following format:
// bit 7 - Address valid bit
// bits 6-4 - Error class
// bits 3-0 - Error code
//
// Error classes 0-6 are vendor unique and also indicate that the
// sense data is in _nonextended_ format. (i.e. not usually used)
// struct _scsi_nonextended_sense {
// uchar_t sd_err;
// ulong_t sd_block_address;
// };
//
// An error class of 7 and an error code of 0 (70H) indicate SCSI-1
// extended sense data format (or SCSI-2 sense data format).
//
// An error class of 7 and an error code of 1 (71H) indicate SCSI-2
// deferred errors.
//
// Error codes 74H to 7EH are reserved and error code 7FH indicates
// a vendor-specific sense data format.
typedef struct _scsi_sense {
uchar_t error; // Error Code
uchar_t segment; // Segment number
uchar_t sense; // Sense key/flags
uchar_t info[4]; // Information (32bit big-endian value)
uchar_t asl; // Additional Sense Length
uchar_t csinfo[4]; // Command-Specific Information
uchar_t asc; // Additional Sense Code
uchar_t ascq; // Additional Sense Code Qualifier
uchar_t fruc; // Field Replaceable Unit Code
uchar_t sks; // Sense Key Specific
ushort_t sks_data; // Sense Key Specific Data (16bit big-endian)
ushort_t asb; // Additional Sense uchar_ts (Max 256-18)
} SCSI_SENSE;
// Descriptor Format Sense Data Structure
// error code of 72 current, 73 deferred
// extended sense data format (or SCSI-2 sense data format).
typedef struct _scsi_sense_descriptor {
uchar_t error; // Error Code
uchar_t sense; // Sense key/flags
uchar_t asc; // Additional Sense Code
uchar_t ascq; // Additional Sense Code Qualifier
uchar_t rsvd[3];
uchar_t asl; // Additional Sense Length
} SCSI_SENSE_DESCRIPTOR;
typedef struct _scsi_sense_desriptor_header {
uchar_t descriptor_type;
uchar_t descriptor_len;
} SCSI_SENSE_DESCRIPTOR_HEADER;
#define SENSE_DTYPE_INFORMATION 0x00
#define SENSE_DTYPE_CSI 0x01 // Command Specific Information
#define SENSE_DTYPE_SKS 0x02 // Sense Key Specific
#define SENSE_DTYPE_FRU 0x03 // Field Replaceable Unit
#define SENSE_DTYPE_STREAM 0x04
#define SENSE_DTYPE_BLOCK 0x05
#define SENSE_DTYPE_OSD_OBJ_IDENT 0x06 // OSD Object Identification
#define SENSE_DTYPE_OSD_INTEGRITY 0x07 // OSD Response Integrity Check Value
#define SENSE_DTYPE_OSD_ATR_IDENT 0x08 // OSD Attribute Identification
#define SENSE_DTYPE_ATA 0x09
typedef struct _ata_status_descriptor {
uchar_t descriptor_type;
#define ATA_SD_DLEN 0x0c
uchar_t descriptor_len; /* 0xc */
#define ATA_SD_FLG_EXTEND 0x01
uchar_t flags;
uchar_t error;
uchar_t esector_count; /* (15:8) */
uchar_t sector_count; /* (7:0) */
uchar_t elba_low; /* (15:8) */
uchar_t lba_low; /* (7:0) */
uchar_t elba_mid; /* (15:8) */
uchar_t lba_mid; /* (7:0) */
uchar_t elba_high; /* (15:8) */
uchar_t lba_high; /* (7:0) */
uchar_t device;
uchar_t status;
} ATA_STATUS_DESCRIPTOR;
//----------------------------------------------------------------------------------------------------------
// Sense Keys
#define SK_MSK 0x0F // mask to sd_sense field for key
#define SK_NO_SENSE 0 // No sense data (no error)
#define ASCQ_FILEMARK_DETECTED 0x01
#define ASCQ_EOPM_DETECTED 0x02 // End of Partition/Medium Detected
#define ASCQ_SETMARK_DETECTED 0x03
#define ASCQ_BOPM_DETECTED 0x04 // Beginning of Partition/Medium Detected
#define SK_RECOVERED 1 // Recovered error
#define ASC_ATA_PASS_THRU 0x00
#define ASCQ_ATA_PASS_THRU_INFO_AVAIL 0x1d
#define SK_NOT_RDY 2 // Device not ready
#define ASC_NO_SEEK_COMPLETE 0x02
#define ASC_NOT_READY 0x04
#define ASCQ_CAUSE_NOT_REPORTABLE 0x00
#define ASCQ_BECOMING_READY 0x01
#define ASCQ_INIT_COMMAND_REQUIRED 0x02
#define ASCQ_MANUAL_INTERVENTION_REQUIRED 0x03
#define ASCQ_FORMAT_IN_PROGRESS 0x04
#define ASCQ_UNKNOWN_CHANGED 0xff // NTO extension for fdc's
#define ASC_MEDIA_FORMAT 0x30 // bad format
#define ASC_MEDIA_NOT_PRESENT 0x3a
#define ASC_NOT_CONFIGURED 0x3e
#define SK_MEDIUM 3 // Medium error
#define ASC_UNRECOVERABLE_READ_ERROR 0x11
#define ASC_RECORD_NOT_FOUND 0x14
#define ASCQ_RECORD_NOT_FOUND 0x01
#define ASC_UNABLE_TO_RECOVER_TOC 0x57
#define ASC_INCOMPATIBLE_MEDIUM 0x64
#define SK_HARDWARE 4 // Hardware error
#define ASC_INTERNAL_TARGET_FAILURE 0x44
#define ASC_MEDIA_LOAD_EJECT_FAILURE 0x53
#define ASCQ_UNRECOVERABLE_CIRC 0x06
#define SK_ILLEGAL 5 // Illegal Request (bad command)
#define ASC_INVALID_COMMAND 0x20
#define ASC_INVALID_FIELD 0x24
#define ASC_INVALID_FIELD_PARAMETER 0x26
#define ASC_COMMAND_SEQUENCE_ERROR 0x2c
#define ASCQ_READ_SCRAMBLED 0x03
#define ASC_ILLEGAL_MODE 0x64
#define ASC_COPY_PROTECTION 0x6f
#define SK_UNIT_ATN 6 // Unit Attention
#define ASC_MEDIUM_CHANGED 0x28
#define ASC_BUS_RESET 0x29
#define ASC_INSUFFICIENT_TIME_FOR_OPERATION 0x2e
#define ASC_OPERATOR_REQUEST 0x5a
#define ASCQ_OPERATOR_MEDIUM_REMOVAL 0x01
#define SK_DATA_PROT 7 // Data Protect
#define ASC_WRITE_PROTECTED 0x27
#define SK_BLNK_CHK 8 // Blank Check
#define SK_VENDOR 9 // Vendor Specific
#define SK_CPY_ABORT 10 // Copy Aborted
#define SK_CMD_ABORT 11 // Aborted Command
#define SK_EQUAL 12 // Equal
#define SK_VOL_OFL 13 // Volume Overflow
#define SK_MISCMP 14 // Miscompare
#define SK_RESERVED 15 // Reserved
//----------------------------------------------------------------------------------------------------------
// Command Descriptor Block structure definitions
// CDB Flags
#define CF_LINK 0x01 // Linked-command indication
#define CF_FLAG 0x02 // Linked-command with flag bit
#define CF_VENDOR0 0x40 // Vendor unique bits
#define CF_VENDOR1 0x80
#define CF_FUA 0x08
#define CF_DPO 0x10
typedef union _cdb {
// generic 6 byte command descriptor block
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t lba_byte1;
uchar_t lba_byte0; // LSB
uchar_t transfer_len;
uchar_t control;
} gen6;
// generic 10 byte command descriptor block
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t lba_byte3;
uchar_t lba_byte4;
uchar_t lba_byte1;
uchar_t lba_byte0;
uchar_t rsvd;
uchar_t transfer_len[2];
uchar_t control;
} gen10;
// generic 12 byte command descriptor block
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t lba_byte3;
uchar_t lba_byte4;
uchar_t lba_byte1;
uchar_t lba_byte0;
uchar_t transfer_len[4];
uchar_t rsvd10;
uchar_t control;
} gen12;
struct _format_unit {
uchar_t op_code;
#define FU_RSVD0 0xc0 // reserved bits
#define FU_FMTDAT 0x10
#define FU_CMPLIST 0x08
uchar_t defect_list_fmt;
uchar_t track_num;
ushort_t interleave;
uchar_t rsvd1[7];
} format_unit;
struct _format_unit_old {
uchar_t op_code;
uchar_t rsvd0;
uchar_t medium_type_code;
uchar_t rsvd1;
uchar_t interleave;
uchar_t rsvd2;
#define FMT_RSVD3 0x80
#define FMT_SECT_SIZE_CD 0x70
#define FMT_IMMED 0x08
#define FMT_HEAD 0x04
#define FMT_ST 0x02
#define FMT_CERT 0x01
uchar_t cert;
uchar_t track_addr;
uchar_t rsvd4[4];
} format_unit_old;
#define RW_OPT_RELADR 0x01
#define RW_OPT_CORRCT 0x02 // Disable Corrections
#define RW_OPT_FUA 0x08 // Force Unit Access
#define RW_OPT_DPO 0x10 // Disable Page Out
struct {
uchar_t opcode;
uchar_t lun_lba;
uchar_t lba[2];
uchar_t transfer_len;
uchar_t control;
} read_write6;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t lba[4];
uchar_t rsvd2;
uchar_t transfer_len[2];
uchar_t control;
} read_write10;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t lba[4];
uchar_t transfer_len[4];
uchar_t rsvd2;
uchar_t control;
} read_write12;
#define MSEL_OPT_PF 0x10 // Page Format
#define MSEL_OPT_SP 0x01 // Save Page
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t param_length;
uchar_t control;
} mode_select;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t param_length[2];
uchar_t control;
} mode_select10;
struct {
uchar_t opcode;
#define LS_OPT_SP 0x01 // Save Parameters
#define LS_OPT_PCR 0x02 // Parameter Code Reset
uchar_t lun_opt;
#define LS_PC_CUR_THRESHOLD 0x00
#define LS_PC_CUR_CUMULATIVE 0x01
#define LS_PC_DFLT_THRESHOLD 0x02
#define LS_PC_DFLT_CUMULATIVE 0x03
uchar_t pc; // Page Control
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t param_length[2];
uchar_t control;
} log_select;
struct {
uchar_t opcode;
#define MSNS_OPT_DBD 0x08 // Disable Block Descriptors
uchar_t lun_opt;
#define PC_CURRENT 0x00
#define PC_CHANGEABLE 0x40
#define PC_DEFAULT 0x80
#define PC_SAVED 0xC0
#define PC_MSK 0xC0
uchar_t pc_page;
uchar_t subpage;
uchar_t allocation_length;
uchar_t control;
} mode_sense;
struct _mode_sense10 {
uchar_t opcode;
uchar_t lun_opt;
uchar_t pc_page;
uchar_t subpage;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t allocation_length[2];
uchar_t control;
} mode_sense10;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t pc_page;
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t parameter_pointer[2];
uchar_t allocation_length[2];
uchar_t control;
} log_sense;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t prevent;
uchar_t control;
} removal;
struct {
uchar_t opcode;
#define LD_OPT_IMMED 0x01
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
#define LD_CMD_START 0x01
#define LD_CMD_LOEJ 0x02
#define LD_CMD_STOP 0x00
#define LD_CMD_EJECT 0x02
#define LD_CMD_LOAD 0x03
// Sequential-Access
#define LD_CMD_SA_HOLD 0x08
#define LD_CMD_SA_EOT 0x04
#define LD_CMD_SA_RT 0x02 // re-tension
#define LD_CMD_SA_LOEJ 0x01
// Block
#define LD_CMD_PC_MSK 0xf0
#define LD_CMD_PC_NC 0
#define LD_CMD_PC_ACTIVE 1
#define LD_CMD_PC_IDLE 2
#define LD_CMD_PC_STANDBY 3
#define LD_CMD_PC_SLEEP 5
uchar_t cmd;
uchar_t control;
} load;
struct {
uchar_t opcode;
uchar_t lun_opt;
#define SC_OPT_RELADR 0x01
#define SC_OPT_IMMED 0x02
uchar_t lba[4];
uchar_t num_blocks[2];
uchar_t control;
} synchronize_cache;
// cdrom commands
struct {
uchar_t opcode;
uchar_t rsvd1;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t allocation_length[2];
uchar_t control;
} read_disc_information;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t rsvd7;
uchar_t resume;
uchar_t control;
} pause_resume;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t start_minute;
uchar_t start_second;
uchar_t start_frame;
uchar_t end_minute;
uchar_t end_second;
uchar_t end_frame;
uchar_t control;
} play_audio_msf;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t start_track;
uchar_t start_index;
uchar_t rsvd6;
uchar_t end_track;
uchar_t end_index;
uchar_t control;
} play_audio_ti;
struct {
uchar_t opcode;
#define CD_SCAN_DIR_FORWARD 0x00
#define CD_SCAN_DIR_REVERSE 0x10
uchar_t opt;
uchar_t start_address[4];
#define CD_SCAN_TYPE_LBA 0x00
#define CD_SCAN_TYPE_MSF 0x40
#define CD_SCAN_TYPE_TRK 0x80
#define CD_SCAN_TYPE_MSK 0xc0
uchar_t rsvd6;
uchar_t rsvd7;
uchar_t rsvd8;
uchar_t type;
uchar_t rsvd10;
uchar_t rsvd11;
} cd_scan;
struct {
uchar_t opcode;
#define RTOC_OPT_MSF 0x02
uchar_t lun_opt;
#define RTOC_FMT_TOC 0x0
#define RTOC_FMT_SESSION 0x1
#define RTOC_FMT_QSUBCODE 0x2
#define RTOC_FMT_QSUBCHNL 0x3
#define RTOC_FMT_ATIP 0x4
#define RTOC_FMT_CDTEXT 0x5
uchar_t format;
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t start_track;
uchar_t allocation_length[2];
#define RTOC_CNTL_FMT_SESSION 0x40
uchar_t control_format;
} read_toc;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2[6];
uchar_t allocation_length[2];
uchar_t rsvd3[2];
} mechanism_status;
struct {
uchar_t opcode;
#define EXCHANGE_OPT_IMMED 0x01
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
#define EXCHANGE_CMD_START 0x01
#define EXCHANGE_CMD_LOEJ 0x02
uchar_t cmd;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t rsvd7;
uchar_t slot;
uchar_t rsvd9;
uchar_t rsvd10;
uchar_t rsvd11;
} exchange;
struct {
uchar_t opcode;
uchar_t rt;
uchar_t feature_number[2];
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t allocation_length[2];
uchar_t control;
} get_configuration;
struct {
uchar_t opcode;
#define GE_OPT_POLLED 0x01
uchar_t opt;
uchar_t rsvd2;
uchar_t rsvd3;
#define NCR_OPERATIONAL_CHANGE 0x02
#define NCR_POWER_MANAGEMENT 0x04
#define NCR_EXTERNAL_REQUEST 0x08
#define NCR_MEDIA 0x10
#define NCR_MULTI_INITIATOR 0x20
#define NCR_DEVICE_BUSY 0x40
uchar_t ncr; // notification class request
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t allocation_length[2];
uchar_t control;
} get_event;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2;
uchar_t rsvd3;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t rsvd6;
uchar_t allocation_length[2];
uchar_t control;
} read_formated_capacities;
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t read_speed[2];
uchar_t write_speed[2];
uchar_t rsvd2[6];
} cd_speed;
struct {
uchar_t opcode;
#define RSCHNL_OPT_MSF 0x02
uchar_t lun_opt;
#define RSCHNL_DATA_SUBQ 0x40
uchar_t data;
uchar_t data_format;
uchar_t rsvd4;
uchar_t rsvd5;
uchar_t track;
uchar_t allocation_length[2];
uchar_t control;
} read_subchannel;
#define CD_FRAME_SYNC_SIZE 12
#define CD_FRAME_HDR_SIZE 4
#define CD_FRAME_SUB_HDR_SIZE 8
#define CD_FRAME_EDC_SIZE 4
#define CD_FRAME_ECC_SIZE 276
#define CD_FRAME_AUX_SIZE 8
#define CD_FRAME_ZERO_SIZE 8
#define CD_FRAME_SPARE_SIZE 4
#define CD_FRAME_C2_ERR_SIZE 294
#define CD_FRAME_BLOCK_ERR_SIZE 2
struct {
uchar_t opcode;
uchar_t lun_stype;
// expected sector type
#define RDCD_EST_ANY_SECTOR (0 << 2)
#define RDCD_EST_CDDA_SECTOR (1 << 2)
#define RDCD_EST_YELLOW_MODE1_SECTOR (2 << 2)
#define RDCD_EST_YELLOW_MODE2_SECTOR (3 << 2)
#define RDCD_EST_XA_SECTOR (4 << 2)
#define RDCD_EST_XA_FORM2_SECTOR (5 << 2)
#define RDCD_EST_MSK (7 << 2)
uchar_t lba[4];
uchar_t transfer_len[3];
uchar_t flags;
#define RDCD_FLG_SYNC 0x80
#define RDCD_FLG_UDATA 0x10
#define RDCD_FLG_ECC 0x08
#define RDCD_FLG_CD_ERR 0x02
#define RDCD_FLG_CD_BLOCK_ERR 0x04
#define RDCD_FLG_HC_NONE ( 0x00 << 5 )
#define RDCD_FLG_HC_HDR ( 0x01 << 5 )
#define RDCD_FLG_HC_SUBHEADER ( 0x02 << 5 )
#define RDCD_FLG_HC_ALL_HEADERS ( 0x03 << 5 )
uchar_t subch_selection;
uchar_t rsvd3;
} read_cd;
struct {
uchar_t opcode;
uchar_t lun_stype;
uchar_t rsvd2;
uchar_t start_minute;
uchar_t start_second;
uchar_t start_frame;
uchar_t end_minute;
uchar_t end_second;
uchar_t end_frame;
uchar_t flags;
uchar_t subch_selection;
uchar_t rsvd11;
} read_cd_msf;
struct _ata_pass_thru {
uchar_t opcode;
#define ATA_PROTO_MSK 0x1e
#define ATA_PROTO_RESPONSE (15 << 1)
#define ATA_PROTO_FPDMA (12 << 1)
#define ATA_PROTO_UDMA_DATA_OUT (11 << 1)
#define ATA_PROTO_UDMA_DATA_IN (10 << 1)
#define ATA_PROTO_DEVICE_RESET (9 << 1)
#define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1)
#define ATA_PROTO_DMA_QUEUED (7 << 1)
#define ATA_PROTO_DMA (6 << 1)
#define ATA_PROTO_PIO_DATA_OUT (5 << 1)
#define ATA_PROTO_PIO_DATA_IN (4 << 1)
#define ATA_PROTO_DATA_NONE (3 << 1)
#define ATA_PROTO_SRST (1 << 1)
#define ATA_PROTO_HRST (0 << 1)
#define ATA_PROTO_EXTEND 0x01
uchar_t protocol; // multiple count, protocol
#define ATA_MCOUNT_MSK 0xe0
#define ATA_FLG_CK_COND 0x20
#define ATA_FLG_T_DIR 0x08 // data from device
#define ATA_FLG_BYT_BLOK 0x04
#define ATA_FLG_TLEN_STPSIU 0x03
#define ATA_FLG_TLEN_SECTOR_COUNT 0x02
#define ATA_FLG_TLEN_FEATURE 0x01
uchar_t flags;
uchar_t efeatures;
uchar_t features;
uchar_t esector_count;
uchar_t sector_count;
uchar_t elba_low;
uchar_t lba_low;
uchar_t elba_mid;
uchar_t lba_mid;
uchar_t elba_high;
uchar_t lba_high;
uchar_t device;
uchar_t command;
uchar_t control;
} ata_pass_thru;
// sequential access commands
struct {
uchar_t opcode;
#define ERASE_OPT_LONG 0x01
uchar_t opt;
uchar_t rsvd[3];
uchar_t control;
} erase;
struct {
uchar_t opcode;
#define LOCATE_OPT_CP 0x2
#define LOCATE_OPT_BT 0x4
uchar_t opt;
uchar_t rsvd2;
uchar_t ba[4]; // block address
uchar_t rsvd7;
uchar_t partition;
uchar_t control;
} locate;
struct {
uchar_t opcode;
uchar_t opt;
uchar_t rsvd2[3];
uchar_t control;
} read_block_limits;
#define RP_OPT_BT 0x01 // block address type
#define RP_OPT_LNG 0x02 // long format
#define RP_OPT_TCLP 0x04 // total current logical position
struct {
uchar_t opcode;
uchar_t lun_opt;
uchar_t rsvd2[7];
uchar_t control;
} read_position;
#define SRW_OPT_FIXED 0x01
#define SRW_OPT_SILI 0x02
struct {
uchar_t opcode;
uchar_t opt;
uchar_t transfer_len[3];
uchar_t control;
} sa_read_write;
struct {
uchar_t opcode;
uchar_t opt;
uchar_t rsvd[3];
uchar_t control;
} rewind;
struct {
uchar_t opcode;
#define SPACE_CODE_BLOCKS 0x00
#define SPACE_CODE_FMRKS 0x01
#define SPACE_CODE_SEQ_FMRKS 0x02
#define SPACE_CODE_EOD 0x03
#define SPACE_CODE_SMRKS 0x04
#define SPACE_CODE_SEQ_SMRKS 0x05
uchar_t lun_code;
uchar_t count[3];
uchar_t control;
} space;
struct {
uchar_t opcode;
#define WF_OPT_IMMED 0x01
#define WF_OPT_WSMK 0x02
uchar_t opt;
uchar_t transfer_length[3];
uchar_t control;
} write_filemarks;
struct {
uchar_t opcode;
#define RD_OPT_MEDIA 0x01
uchar_t opt;
uchar_t rsvd[5];
uchar_t allocation_length[2];
uchar_t control;
} report_density;
struct {
uchar_t opcode;
#define FM_OPT_IMMED 0x01
#define FM_OPT_VERIFY 0x02
uchar_t opt;
#define FM_FMT_DFLT 0x00
#define FM_FMT_PARTITION 0x01
#define FM_FMT_FORMAT_PARTITION 0x02
uchar_t format;
uchar_t transfer_length[2];
uchar_t control;
} format_media;
} CDB;
//----------------------------------------------------------------------------------------------------------
struct _ata_sense
{
SCSI_SENSE_DESCRIPTOR sense;
ATA_STATUS_DESCRIPTOR desc;
};
//----------------------------------------------------------------------------------------------------------
#endif /* OS_QNXNTO_H_ */

View File

@ -3,7 +3,7 @@
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2004-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2004-10 Christian Franke <smartmontools-support@lists.sourceforge.net>
*
* 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
@ -32,7 +32,7 @@ extern smartmonctrl * con; // con->permissive,reportataioctl
#include <assert.h>
#else
#undef assert
#define assert(x) /**/
#define assert(x) /* */
#endif
#define WIN32_LEAN_AND_MEAN
@ -40,17 +40,28 @@ extern smartmonctrl * con; // con->permissive,reportataioctl
#include <stddef.h> // offsetof()
#include <io.h> // access()
#ifdef __CYGWIN__
#include <cygwin/version.h> // CYGWIN_VERSION_DLL_MAJOR
#endif
// Macro to check constants at compile time using a dummy typedef
#define ASSERT_CONST(c, n) \
typedef char assert_const_##c[((c) == (n)) ? 1 : -1]
#define ASSERT_SIZEOF(t, n) \
typedef char assert_sizeof_##t[(sizeof(t) == (n)) ? 1 : -1]
const char * os_win32_cpp_cvsid = "$Id: os_win32.cpp 3049 2010-01-27 19:47:09Z chrfranke $";
// Needed by '-V' option (CVS versioning) of smartd/smartctl
const char *os_XXXX_c_cvsid="$Id: os_win32.cpp 3050 2010-01-27 19:58:38Z chrfranke $"
ATACMDS_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
// Disable Win9x/ME specific code if no longer supported by compiler.
#ifndef WIN9X_SUPPORT
#if defined(CYGWIN_VERSION_DLL_MAJOR) && (CYGWIN_VERSION_DLL_MAJOR >= 1007)
// Win9x/ME support was dropped in Cygwin 1.7
#elif defined(_MSC_VER) && (_MSC_VER >= 1500)
// Win9x/ME support was dropped in MSVC9 (cl.exe 15.0)
#else
#define WIN9X_SUPPORT 1
#endif
#endif
/////////////////////////////////////////////////////////////////////////////
@ -60,6 +71,16 @@ namespace os_win32 { // no need to publish anything, name provided for Doxygen
#pragma warning(disable:4250)
#endif
// Running on Win9x/ME ?
#if WIN9X_SUPPORT
// Set true in win9x_smart_interface ctor.
static bool win9x = false;
#else
// Never true (const allows compiler to remove dead code).
const bool win9x = false;
#endif
class win_smart_device
: virtual public /*implements*/ smart_device
{
@ -112,6 +133,7 @@ private:
std::string m_options;
bool m_usr_options; // options set by user?
bool m_admin; // open with admin access?
bool m_id_is_cached; // ata_identify_is_cached() return value.
int m_drive, m_port;
int m_smartver_state;
};
@ -137,6 +159,8 @@ private:
/////////////////////////////////////////////////////////////////////////////
#if WIN9X_SUPPORT
class win_aspi_device
: public /*implements*/ scsi_device
{
@ -156,6 +180,7 @@ private:
unsigned char m_id;
};
#endif // WIN9X_SUPPORT
//////////////////////////////////////////////////////////////////////
@ -208,10 +233,16 @@ protected:
virtual bool scsi_scan(smart_device_list & devlist) = 0;
};
#if WIN9X_SUPPORT
// Win9x/ME reduced functionality
class win9x_smart_interface
: public /*extends*/ win_smart_interface
{
public:
win9x_smart_interface()
{ win9x = true; }
protected:
virtual scsi_device * get_scsi_device(const char * name, const char * type);
@ -220,6 +251,8 @@ protected:
virtual bool scsi_scan(smart_device_list & devlist);
};
#endif // WIN9X_SUPPORT
// WinNT,2000,XP,...
class winnt_smart_interface
: public /*extends*/ win_smart_interface
@ -237,12 +270,6 @@ protected:
//////////////////////////////////////////////////////////////////////
// Running on Win9x/ME ?
static inline bool is_win9x()
{
return !!(GetVersion() & 0x80000000);
}
// Running on 64-bit Windows as 32-bit app ?
static bool is_wow64()
{
@ -369,16 +396,24 @@ ata_device * win_smart_interface::get_ata_device(const char * name, const char *
return new win_ata_device(this, name, type);
}
#ifdef WIN9X_SUPPORT
scsi_device * win9x_smart_interface::get_scsi_device(const char * name, const char * type)
{
return new win_aspi_device(this, name, type);
}
#endif
scsi_device * winnt_smart_interface::get_scsi_device(const char * name, const char * type)
{
const char * testname = skipdev(name);
if (!strncmp(testname, "scsi", 4))
#if WIN9X_SUPPORT
return new win_aspi_device(this, name, type);
#else
return (set_err(EINVAL, "ASPI interface not supported"), (scsi_device *)0);
#endif
return new win_scsi_device(this, name, type);
}
@ -416,8 +451,10 @@ smart_device * win_smart_interface::autodetect_smart_device(const char * name)
const char * testname = skipdev(name);
if (!strncmp(testname, "hd", 2))
return new win_ata_device(this, name, "");
#if WIN9X_SUPPORT
if (!strncmp(testname, "scsi", 4))
return new win_aspi_device(this, name, "");
#endif
if (!strncmp(testname, "tw_cli", 6))
return new win_tw_cli_device(this, name, "");
return 0;
@ -778,7 +815,7 @@ static int smart_ioctl(HANDLE hdevice, int drive, IDEREGS * regs, char * data, u
if (datasize)
memcpy(data, outpar->bBuffer, 512);
else if (regs->bFeaturesReg == ATA_SMART_STATUS) {
if (nonempty(const_cast<unsigned char *>(outpar->bBuffer), sizeof(IDEREGS)))
if (nonempty(outpar->bBuffer, sizeof(IDEREGS)))
*regs = *(const IDEREGS *)(outpar->bBuffer);
else { // Workaround for driver not returning regs
if (con->reportataioctl)
@ -1599,7 +1636,6 @@ bool win_tw_cli_device::open()
id->words047_079[60-47] = (unsigned short)(nblocks ); // secs_16
id->words047_079[61-47] = (unsigned short)(nblocks>>16); // secs_32
}
id->major_rev_num = 0x1<<3; // ATA-3
id->command_set_1 = 0x0001; id->command_set_2 = 0x4000; // SMART supported, words 82,83 valid
id->cfs_enable_1 = 0x0001; id->csf_default = 0x4000; // SMART enabled, words 85,87 valid
@ -1674,20 +1710,6 @@ int win_tw_cli_device::ata_command_interface(smart_command_set command, int /*se
break;
memcpy(data, &m_smart_buf, 512);
return 0;
case READ_THRESHOLDS:
if (!m_smart_valid)
break;
// Fake zero thresholds
{
const ata_smart_values * sv = &m_smart_buf;
ata_smart_thresholds_pvt * tr = (ata_smart_thresholds_pvt *)data;
memset(tr, 0, 512);
// TODO: Indicate missing thresholds in ataprint.cpp:PrintSmartAttribWithThres()
// (ATA_SMART_READ_THRESHOLDS is marked obsolete since ATA-5)
for (int i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++)
tr->chksum -= tr->thres_entries[i].id = sv->vendor_attributes[i].id;
}
return 0;
case ENABLE:
case STATUS:
case STATUS_CHECK: // Fake "good" SMART status
@ -1949,7 +1971,6 @@ static int get_identify_from_device_property(HANDLE hdevice, ata_identify_device
copy_swapped(id->model, data.raw+data.desc.ProductIdOffset, sizeof(id->model));
if (data.desc.ProductRevisionOffset)
copy_swapped(id->fw_rev, data.raw+data.desc.ProductRevisionOffset, sizeof(id->fw_rev));
id->major_rev_num = 0x1<<3; // ATA-3
id->command_set_1 = 0x0001; id->command_set_2 = 0x4000; // SMART supported, words 82,83 valid
id->cfs_enable_1 = 0x0001; id->csf_default = 0x4000; // SMART enabled, words 85,87 valid
return 0;
@ -2150,6 +2171,7 @@ static int get_device_power_state(HANDLE hdevice)
/////////////////////////////////////////////////////////////////////////////
#if WIN9X_SUPPORT
// Print SMARTVSD error message, return errno
static int smartvsd_error()
@ -2197,6 +2219,7 @@ static int smartvsd_error()
}
}
#endif // WIN9X_SUPPORT
// Get default ATA device options
@ -2241,6 +2264,7 @@ win_ata_device::win_ata_device(smart_interface * intf, const char * dev_name, co
: smart_device(intf, dev_name, "ata", req_type),
m_usr_options(false),
m_admin(false),
m_id_is_cached(false),
m_drive(0),
m_port(-1),
m_smartver_state(0)
@ -2289,7 +2313,6 @@ bool win_ata_device::open()
bool win_ata_device::open(int phydrive, int logdrive, const char * options, int port)
{
// path depends on Windows Version
bool win9x = is_win9x(); // TODO: Member variable
char devpath[30];
if (win9x && 0 <= phydrive && phydrive <= 7)
// Use patched "smartvse.vxd" for drives 4-7, see INSTALL file for details
@ -2319,9 +2342,12 @@ bool win_ata_device::open(int phydrive, int logdrive, const char * options, int
}
if (h == INVALID_HANDLE_VALUE) {
long err = GetLastError();
pout("Cannot open device %s, Error=%ld\n", devpath, err);
#if WIN9X_SUPPORT
if (win9x && phydrive <= 3 && err == ERROR_FILE_NOT_FOUND)
smartvsd_error();
#endif
if (err == ERROR_FILE_NOT_FOUND)
set_err((win9x && phydrive <= 3 ? smartvsd_error() : ENOENT), "%s: not found", devpath);
set_err(ENOENT, "%s: not found", devpath);
else if (err == ERROR_ACCESS_DENIED)
set_err(EACCES, "%s: access denied", devpath);
else
@ -2330,6 +2356,15 @@ bool win_ata_device::open(int phydrive, int logdrive, const char * options, int
}
set_fh(h);
// Warn once if admin rights are missing
if (!m_admin) {
static bool noadmin_warning = false;
if (!noadmin_warning) {
pout("Warning: Limited functionality due to missing admin rights\n");
noadmin_warning = true;
}
}
if (con->reportataioctl > 1)
pout("%s: successfully opened%s\n", devpath, (!m_admin ? " (without admin rights)" :""));
@ -2415,6 +2450,8 @@ bool win_ata_device::open(int phydrive, int logdrive, const char * options, int
}
#if WIN9X_SUPPORT
// Scan for ATA drives on Win9x/ME
bool win9x_smart_interface::ata_scan(smart_device_list & devlist)
@ -2447,6 +2484,8 @@ bool win9x_smart_interface::ata_scan(smart_device_list & devlist)
return true;
}
#endif // WIN9X_SUPPORT
// Scan for ATA drives
@ -2531,7 +2570,7 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
case ATA_SMART_IMMEDIATE_OFFLINE:
// SMART_SEND_DRIVE_COMMAND supports ABORT_SELF_TEST only on Win9x/ME
valid_options = (m_usr_options || in.in_regs.lba_low != 127/*ABORT*/ || is_win9x() ?
valid_options = (m_usr_options || in.in_regs.lba_low != 127/*ABORT*/ || win9x ?
"saicm3" : "aicm3");
break;
@ -2540,7 +2579,7 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
// Try SCSI_MINIPORT also to skip buggy class driver
// SMART functions do not support multi sector I/O.
if (in.size == 512)
valid_options = (m_usr_options || is_win9x() ? "saicm3" : "aicm3");
valid_options = (m_usr_options || win9x ? "saicm3" : "aicm3");
else
valid_options = "a";
break;
@ -2642,6 +2681,7 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
// Try all valid ioctls in the order specified in m_options
bool powered_up = false;
bool out_regs_set = false;
bool id_is_cached = false;
const char * options = m_options.c_str();
for (int i = 0; ; i++) {
@ -2689,9 +2729,11 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
}
rc = smart_ioctl(get_fh(), m_drive, &regs, data, datasize, m_port);
out_regs_set = (in.in_regs.features == ATA_SMART_STATUS);
id_is_cached = (m_port < 0 && !win9x); // Not cached by 3ware or Win9x/ME driver
break;
case 'm':
rc = ata_via_scsi_miniport_smart_ioctl(get_fh(), &regs, data, datasize);
id_is_cached = (m_port < 0 && !win9x);
break;
case 'a':
rc = ata_pass_through_ioctl(get_fh(), &regs,
@ -2709,6 +2751,7 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
case 'f':
if (in.in_regs.command == ATA_IDENTIFY_DEVICE) {
rc = get_identify_from_device_property(get_fh(), (ata_identify_device *)data);
id_is_cached = true;
}
else if (in.in_regs.command == ATA_SMART_CMD) switch (in.in_regs.features) {
case ATA_SMART_READ_VALUES:
@ -2716,31 +2759,19 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
if (rc > 0)
rc = 0;
break;
case ATA_SMART_READ_THRESHOLDS:
{
ata_smart_values sv;
rc = storage_predict_failure_ioctl(get_fh(), (char *)&sv);
if (rc < 0)
break;
rc = 0;
// Fake zero thresholds
ata_smart_thresholds_pvt * tr = (ata_smart_thresholds_pvt *)data;
memset(tr, 0, 512);
for (int i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++)
tr->chksum -= tr->thres_entries[i].id = sv.vendor_attributes[i].id;
}
break;
case ATA_SMART_ENABLE:
rc = 0;
break;
case ATA_SMART_STATUS:
rc = storage_predict_failure_ioctl(get_fh());
if (rc >= 0) {
if (rc > 0) {
regs.bCylHighReg = 0x2c; regs.bCylLowReg = 0xf4;
rc = 0;
}
out_regs_set = true;
if (rc == 0) {
// Good SMART status
out.out_regs.lba_high = 0xc2; out.out_regs.lba_mid = 0x4f;
}
else if (rc > 0) {
// Bad SMART status
out.out_regs.lba_high = 0x2c; out.out_regs.lba_mid = 0xf4;
rc = 0;
}
break;
default:
@ -2803,22 +2834,28 @@ bool win_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
hi.lba_high = prev_regs.bCylHighReg;
}
}
if ( in.in_regs.command == ATA_IDENTIFY_DEVICE
|| in.in_regs.command == ATA_IDENTIFY_PACKET_DEVICE)
// Update ata_identify_is_cached() result according to ioctl used.
m_id_is_cached = id_is_cached;
return true;
}
// Return true if OS caches the ATA identify sector
bool win_ata_device::ata_identify_is_cached() const
{
// Not RAID and WinNT4/2000/XP => true, RAID or Win9x/ME => false
// TODO: Set according to ioctl used.
return (m_port < 0 && !is_win9x());
return m_id_is_cached;
}
/////////////////////////////////////////////////////////////////////////////
// ASPI Interface (for SCSI devices)
// ASPI Interface (for SCSI devices on 9x/ME)
/////////////////////////////////////////////////////////////////////////////
#if WIN9X_SUPPORT
#pragma pack(1)
#define ASPI_SENSE_SIZE 18
@ -3348,6 +3385,7 @@ bool win_aspi_device::scsi_pass_through(scsi_cmnd_io * iop)
return true;
}
#endif // WIN9X_SUPPORT
/////////////////////////////////////////////////////////////////////////////
// SPT Interface (for SCSI devices and ATA devices behind SATLs)
@ -3567,7 +3605,7 @@ bool win_scsi_device::scsi_pass_through(struct scsi_cmnd_io * iop)
sb.spt.DataTransferLength = iop->dxfer_len;
sb.spt.DataBuffer = iop->dxferp;
// IOCTL_SCSI_PASS_THROUGH_DIRECT does not support single byte
// transfers (needed for SMART STATUS check of JMicron USB briges)
// transfers (needed for SMART STATUS check of JMicron USB bridges)
if (sb.spt.DataTransferLength == 1)
direct = false;
break;
@ -3645,9 +3683,13 @@ bool win_scsi_device::scsi_pass_through(struct scsi_cmnd_io * iop)
void smart_interface::init()
{
// Select interface for Windows flavor
if (os_win32::is_win9x()) {
if (GetVersion() & 0x80000000) {
#if WIN9X_SUPPORT
static os_win32::win9x_smart_interface the_win9x_interface;
smart_interface::set(&the_win9x_interface);
#else
throw std::runtime_error("Win9x/ME not supported");
#endif
}
else {
static os_win32::winnt_smart_interface the_winnt_interface;

1055
os_win32/smartctl_vc8.vcproj Normal file

File diff suppressed because it is too large Load Diff

1007
os_win32/smartd_vc8.vcproj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smartctl_vc8", "smartctl_vc8.vcproj", "{3AFEDCDD-D289-4543-A91D-EFBA6C710247}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smartd_vc8", "smartd_vc8.vcproj", "{C0762191-C2AC-40B6-A2EB-F1658BBDC4C6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "syslogevt_vc8", "syslogevt_vc8.vcproj", "{FAB7557B-86EA-405D-B49D-33AB3F4D3E33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3AFEDCDD-D289-4543-A91D-EFBA6C710247}.Debug|Win32.ActiveCfg = Debug|Win32
{3AFEDCDD-D289-4543-A91D-EFBA6C710247}.Debug|Win32.Build.0 = Debug|Win32
{3AFEDCDD-D289-4543-A91D-EFBA6C710247}.Release|Win32.ActiveCfg = Release|Win32
{3AFEDCDD-D289-4543-A91D-EFBA6C710247}.Release|Win32.Build.0 = Release|Win32
{C0762191-C2AC-40B6-A2EB-F1658BBDC4C6}.Debug|Win32.ActiveCfg = Debug|Win32
{C0762191-C2AC-40B6-A2EB-F1658BBDC4C6}.Debug|Win32.Build.0 = Debug|Win32
{C0762191-C2AC-40B6-A2EB-F1658BBDC4C6}.Release|Win32.ActiveCfg = Release|Win32
{C0762191-C2AC-40B6-A2EB-F1658BBDC4C6}.Release|Win32.Build.0 = Release|Win32
{FAB7557B-86EA-405D-B49D-33AB3F4D3E33}.Debug|Win32.ActiveCfg = Debug|Win32
{FAB7557B-86EA-405D-B49D-33AB3F4D3E33}.Debug|Win32.Build.0 = Debug|Win32
{FAB7557B-86EA-405D-B49D-33AB3F4D3E33}.Release|Win32.ActiveCfg = Release|Win32
{FAB7557B-86EA-405D-B49D-33AB3F4D3E33}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

156
os_win32/syslogevt.c Normal file
View File

@ -0,0 +1,156 @@
/*
* os_win32/syslogevt.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2004-8 Christian Franke <smartmontools-support@lists.sourceforge.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* (for example COPYING); if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
static char rcsid[] = "$Id: syslogevt.c,v 1.5 2008/03/04 22:09:48 ballen4705 Exp $";
#include <stdio.h>
#include <string.h>
#include <process.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef _DEBUG
#include "syslogevt.h"
#endif
static int usage()
{
puts(
"syslogevt $Revision: 1.5 $ Copyright (C) 2004-8 Christian Franke\n"
"Home page is http://smartmontools.sourceforge.net/\n"
"\n"
"Usage: syslogevt [-ru] name [ident ...]\n"
"\n"
"Creates registry files \"name-r.reg\" and \"name-u.reg\" to (un)register\n"
"this program as an event message file for message source(s) \"ident\".\n"
"If \"ident\" is ommited, \"name\" is used. Options:\n"
"\n"
" -r run \"regedit name-r.reg\" after creating files\n"
" -u run \"regedit name-u.reg\" after creating files\n"
"\n"
"Examples:\n"
"\n"
"syslogevt smartd (Create smartd-r.reg and smartd-u.reg)\n"
"regedit smartd-r.reg (Register syslogevt.exe for smartd messages)\n"
"\n"
"syslogevt -r smartd (Same as above in one step)\n"
"\n"
"regedit smartd-u.reg (Undo the registration)\n"
"\n"
"CAUTION: A registry entry of an existing event source with the same \"ident\"\n"
" will be overwritten by regedit without notice."
);
return 1;
}
main(int argc, char ** argv)
{
int regedit, a1, ai;
char name1[30+1], name2[30+1], mypath[MAX_PATH+1];
const char * ident;
FILE * f1, * f2;
#ifdef _DEBUG
if (!(MSG_SYSLOG == 0 && MSG_SYSLOG_01 == 1 && MSG_SYSLOG_10 == 10)) {
puts("Internal error: MSG_SYSLOG_n != n"); return 1;
}
#endif
if (argc < 2)
return usage();
a1 = 1;
regedit = 0;
if (!strcmp(argv[a1], "-r")) {
regedit = 1; a1++;
}
else if (!strcmp(argv[a1], "-u")) {
regedit = -1; a1++;
}
for (ai = a1; ai < argc; ai++) {
ident = argv[ai];
if (!(ident[0] && strlen(ident) < sizeof(name1)-10
&& strcspn(ident, "-.:/\\") == strlen(ident) )) {
return usage();
}
}
if (!GetModuleFileName(NULL, mypath, sizeof(mypath)-1)) {
fputs("GetModuleFileName failed\n", stderr);
return 1;
}
ident = argv[a1];
strcpy(name1, ident); strcat(name1, "-r.reg");
strcpy(name2, ident); strcat(name2, "-u.reg");
if (!(f1 = fopen(name1, "w"))) {
perror(name1); return 1;
}
if (!(f2 = fopen(name2, "w"))) {
perror(name2); unlink(name1); return 1;
}
fputs("REGEDIT4\n\n", f1);
fputs("REGEDIT4\n\n", f2);
for (ai = (argc > a1+1 ? a1+1 : a1); ai < argc; ai++) {
int i;
ident = argv[ai];
fputs("[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\", f1);
fputs(ident, f1); fputs("]\n\"EventMessageFile\"=\"", f1);
for (i = 0; mypath[i]; i++) {
if (mypath[i] == '\\')
fputc('\\', f1);
fputc(mypath[i], f1);
}
fputs("\"\n\"TypesSupported\"=dword:00000007\n\n", f1);
fputs("[-HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\", f2);
fputs(ident, f2); fputs("]\n\n", f2);
}
fclose(f1);
fclose(f2);
if (GetVersion() & 0x80000000) {
puts("Warning: Event log not supported on Win9x/ME\n");
if (regedit)
return 1;
}
if (regedit) {
if (spawnlp(P_WAIT, "regedit", "regedit", (regedit > 0 ? name1 : name2), (const char *)0) == -1) {
fputs("regedit: cannot execute\n", stderr);
return 1;
}
}
else {
fputs("Files generated. Use\n\n regedit ", stdout);
puts(name1);
fputs("\nto register event message file, and\n\n regedit ", stdout);
puts(name2);
fputs("\nto remove registration later.\n\n"
"Do not remove this program when registered.\n", stdout);
}
return 0;
}

161
os_win32/syslogevt.mc Normal file
View File

@ -0,0 +1,161 @@
;/*
; * os_win32/syslogevt.mc
; *
; * Home page of code is: http://smartmontools.sourceforge.net
; *
; * Copyright (C) 2004-8 Christian Franke <smartmontools-support@lists.sourceforge.net>
; *
; * 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.
; *
; * You should have received a copy of the GNU General Public License
; * (for example COPYING); if not, write to the Free
; * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
; *
; */
;
;// $Id: syslogevt.mc,v 1.5 2008/03/04 22:09:48 ballen4705 Exp $
;
;// Use message compiler "mc" to generate
;// syslogevt.rc, syslogevt.h, msg00001.bin
;// from this file.
;// MSG_SYSLOG in syslogmsg.h must be zero
;// MSG_SYSLOG_nn must be == nn
;
;
MessageId=0x0
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG
Language=English
%1
.
;// 1-10 Line SYSLOG Messages
;// %1=Ident, %2=PID, %3=Severity, %[4-13]=Line 1-10
MessageId=0x1
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_01
Language=English
%1[%2]:%3: %4
.
MessageId=0x2
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_02
Language=English
%1[%2]:%3%n
%4%n
%5
.
MessageId=0x3
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_03
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6
.
MessageId=0x4
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_04
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7
.
MessageId=0x5
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_05
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7%n
%8
.
MessageId=0x6
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_06
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7%n
%8%n
%9
.
MessageId=0x7
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_07
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7%n
%8%n
%9%n
%10
.
MessageId=0x8
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_08
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7%n
%8%n
%9%n
%10%n
%11
.
MessageId=0x9
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_09
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7%n
%8%n
%9%n
%10%n
%11%n
%12
.
MessageId=0xa
Severity=Success
Facility=Application
SymbolicName=MSG_SYSLOG_10
Language=English
%1[%2]:%3%n
%4%n
%5%n
%6%n
%7%n
%8%n
%9%n
%10%n
%11%n
%12%n
%13
.

View File

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="syslogevt_vc8"
ProjectGUID="{FAB7557B-86EA-405D-B49D-33AB3F4D3E33}"
RootNamespace="syslogevt_vc8"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="syslogevt_vc8.d"
IntermediateDirectory="syslogevt_vc8.d"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="syslogevt_vc8.r"
IntermediateDirectory="syslogevt_vc8.r"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="syslogevt.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(IntDir)\$(TargetName).pdb"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\syslogevt.c"
>
</File>
<File
RelativePath=".\syslogevt.mc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="mc -r $(IntDir) syslogevt.mc"
CommandLine="mc -r $(IntDir) syslogevt.mc&#x0D;&#x0A;"
Outputs="$(IntDir)\syslogevt.rc;$(IntDir)\msg00001.bin;syslogevt.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="mc -r $(IntDir) syslogevt.mc"
CommandLine="mc -r $(IntDir) syslogevt.mc&#x0D;&#x0A;"
Outputs="$(IntDir)\syslogevt.rc;$(IntDir)\msg00001.bin;syslogevt.h"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

1277
posix/getopt.c Normal file

File diff suppressed because it is too large Load Diff

181
posix/getopt.h Normal file
View File

@ -0,0 +1,181 @@
/* Declarations for getopt.
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
/* If __GNU_LIBRARY__ is not already defined, either we are being used
standalone, or this is the first header included in the source file.
If we are being used with glibc, we need to include <features.h>, but
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
not defined, include <ctype.h>, which will pull in <features.h> for us
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
doesn't flood the namespace with stuff the way some other headers do.) */
#if !defined __GNU_LIBRARY__
# include <ctype.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
# if (defined __STDC__ && __STDC__) || defined __cplusplus
const char *name;
# else
char *name;
# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `--', then non-option arguments are treated as
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if (defined __STDC__ && __STDC__) || defined __cplusplus
# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
# else /* not __GNU_LIBRARY__ */
extern int getopt ();
# endif /* __GNU_LIBRARY__ */
# ifndef __need_getopt
extern int getopt_long (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
extern int getopt_long_only (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only);
# endif
#else /* not __STDC__ */
extern int getopt ();
# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */

196
posix/getopt1.c Normal file
View File

@ -0,0 +1,196 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef _LIBC
# include <getopt.h>
#else
# include "getopt.h"
#endif
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
# ifdef _LIBC
libc_hidden_def (getopt_long)
libc_hidden_def (getopt_long_only)
# endif
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

View File

@ -3,8 +3,8 @@
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2006-9 Douglas Gilbert <dougg@torque.net>
* Copyright (C) 2009 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2006-10 Douglas Gilbert <dougg@torque.net>
* Copyright (C) 2009-10 Christian Franke <smartmontools-support@lists.sourceforge.net>
*
* 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
@ -61,7 +61,7 @@
#include "dev_ata_cmd_set.h" // ata_device_with_command_set
#include "dev_tunnelled.h" // tunnelled_device<>
const char * scsiata_cpp_cvsid = "$Id: scsiata.cpp 2988 2009-11-29 16:21:07Z samm2 $";
const char * scsiata_cpp_cvsid = "$Id: scsiata.cpp 3048 2010-01-23 17:54:42Z chrfranke $";
/* for passing global control variables */
extern smartmonctrl *con;
@ -1341,6 +1341,8 @@ const usb_id_entry usb_ids[] = {
//{ 0x04b4, 0x6831, -1, d_cypress }, // Cypress CY7C68310 (ISD-300LP)
// Myson Century
{ 0x04cf, 0x8818, 0xb007, d_unsup }, // Myson Century CS8818
// Samsung
{ 0x04e8, 0x5f06, -1, d_sat }, // Samsung Story Station
// Sunplus
{ 0x04fc, 0x0c15, 0xf615, d_sunplus }, // SunPlus SPDIF215
{ 0x04fc, 0x0c25, 0x0103, d_sunplus }, // SunPlus SPDIF225 (USB+SATA->SATA)
@ -1360,10 +1362,14 @@ const usb_id_entry usb_ids[] = {
// Freecom
{ 0x07ab, 0xfc8e, 0x010f, d_sunplus }, // Freecom Hard Drive XS
// Toshiba
{ 0x0930, 0x0b03, -1, d_sunplus }, // Toshiba PX1270E-1G16
{ 0x0930, 0x0b09, -1, d_sunplus }, // Toshiba PX1396E-3T01 (similar to Dura Micro 501)
// Seagate
{ 0x0bc2, 0x2000, -1, d_sat }, // Seagate FreeAgent Go
{ 0x0bc2, 0x2100, -1, d_sat }, // Seagate FreeAgent Go
{ 0x0bc2, 0x2101, -1, d_sat }, // Seagate FreeAgent Go
{ 0x0bc2, 0x2300, -1, d_sat }, // Seagate Expansion Portable
{ 0x0bc2, 0x3000, -1, d_sat }, // Seagate FreeAgent Desktop
{ 0x0bc2, 0x3001, -1, d_sat }, // Seagate FreeAgent Desk
// Dura Micro
{ 0x0c0b, 0xb159, 0x0103, d_sunplus }, // Dura Micro 509
@ -1373,7 +1379,8 @@ const usb_id_entry usb_ids[] = {
{ 0x0d49, 0x7410, 0x0122, d_sat }, // Maxtor Basics Desktop
{ 0x0d49, 0x7450, 0x0122, d_sat }, // Maxtor Basics Portable
// Western Digital
{ 0x1058, 0x0702, 0x0104, d_sat }, // WD My Passport Portable
{ 0x1058, 0x0701, 0x0240, d_cypress }, // WD My Passport (IDE)
{ 0x1058, 0x0702, 0x0102, d_sat }, // WD My Passport Portable
{ 0x1058, 0x0704, 0x0175, d_sat }, // WD My Passport Essential
{ 0x1058, 0x0705, 0x0175, d_sat }, // WD My Passport Elite
{ 0x1058, 0x070a, 0x1028, d_sat }, // WD My Passport 070A

View File

@ -1,7 +1,7 @@
.ig
Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net>
$Id: smartctl.8.in 2978 2009-10-30 23:20:39Z chrfranke $
$Id: smartctl.8.in 3001 2009-12-19 15:25:27Z chrfranke $
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
@ -1017,14 +1017,26 @@ writes a binary representation of the one sector log 0x11
(SATA Phy Event Counters) to file log.bin.
.TP
.B \-v ID,FORMAT[,NAME], \-\-vendorattribute=ID,FORMAT[,NAME]
[ATA only] Sets a vendor\-specific raw value print FORMAT and
optional NAME for Attribute ID.
.B \-v ID,FORMAT[:BYTEORDER][,NAME], \-\-vendorattribute=ID,FORMAT[:BYTEORDER][,NAME]
[ATA only] Sets a vendor\-specific raw value print FORMAT, an optional
BYTEORDER and an optional NAME for Attribute ID.
This option may be used multiple times.
The Attribute ID can be in the range 1 to 255. If \'N\' is specified as
ID, the settings for all Attributes are changed. The NAME is a string of
letters, digits and underscore.
ID, the settings for all Attributes are changed.
The optional BYTEORDER consists of 1 to 8 characters from the
set \'012345rvwz\'. The characters \'0\' to \'5\' select the byte 0
to 5 from the 48\-bit raw value, \'r\' selects the reserved byte of
the attribute data block, \'v\' selects the normalized value, \'w\'
selects the worst value and \'z\' inserts a zero byte.
The default BYTEORDER is \'543210\' for all 48-bit formats,
and \'543210wv\' for the 64-bit formats.
For example, \'\-v 5,raw48:012345\' prints the raw value of
attribute 5 with big endian instead of little endian
byte ordering.
The NAME is a string of letters, digits and underscore.
.I \-v help
\- Prints (to STDOUT) a list of all valid arguments to this option,
@ -1828,7 +1840,7 @@ these documents may be found in the References section of the
.SH
SVN ID OF THIS PAGE:
$Id: smartctl.8.in 2978 2009-10-30 23:20:39Z chrfranke $
$Id: smartctl.8.in 3001 2009-12-19 15:25:27Z chrfranke $
.\" Local Variables:
.\" mode: nroff
.\" End:

View File

@ -56,7 +56,7 @@
#include "smartctl.h"
#include "utility.h"
const char * smartctl_cpp_cvsid = "$Id: smartctl.cpp 3046 2010-01-22 21:30:02Z chrfranke $"
const char * smartctl_cpp_cvsid = "$Id: smartctl.cpp 3032 2010-01-16 13:04:55Z chrfranke $"
CONFIG_H_CVSID EXTERN_H_CVSID SMARTCTL_H_CVSID;
// This is a block containing all the "control variables". We declare

View File

@ -1,7 +1,7 @@
.ig
Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
$Id: smartd.8.in 2977 2009-10-30 22:29:05Z chrfranke $
$Id: smartd.8.in 3057 2010-02-03 20:56:41Z chrfranke $
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
@ -174,6 +174,14 @@ input. This is useful for commands like:
.fi
to perform quick and simple checks without a configuration file.
.\" BEGIN ENABLE_CAPABILITIES
.TP
.B \-C, \-\-capabilities
Use \fBcapabilities(7)\fP (EXPERIMENTAL).
Warning: Mail notification does not work when used.
.\" END ENABLE_CAPABILITIES
.TP
.B \-d, \-\-debug
Runs \fBsmartd\fP in "debug" mode. In this mode, it displays status
@ -1605,9 +1613,9 @@ values for \'\-F\' (see the \'\-P\' option below).
[Please see the \fBsmartctl \-F\fP command-line option.]
.TP
.B \-v ID,FORMAT[,NAME]
[ATA only] Sets a vendor\-specific raw value print FORMAT and
optional NAME for Attribute ID.
.B \-v ID,FORMAT[:BYTEORDER][,NAME]
[ATA only] Sets a vendor\-specific raw value print FORMAT, an optional
BYTEORDER and an optional NAME for Attribute ID.
This directive may be used multiple times.
Please see \fBsmartctl -v\fP command-line option for further details.
@ -2067,4 +2075,4 @@ smartmontools home page at \fBhttp://smartmontools.sourceforge.net/#references\f
.SH
SVN ID OF THIS PAGE:
$Id: smartd.8.in 2977 2009-10-30 22:29:05Z chrfranke $
$Id: smartd.8.in 3057 2010-02-03 20:56:41Z chrfranke $

View File

@ -1,7 +1,7 @@
.ig
Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
$Id: smartd.conf.5.in 2977 2009-10-30 22:29:05Z chrfranke $
$Id: smartd.conf.5.in 3001 2009-12-19 15:25:27Z chrfranke $
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
@ -1167,9 +1167,9 @@ values for \'\-F\' (see the \'\-P\' option below).
[Please see the \fBsmartctl \-F\fP command-line option.]
.TP
.B \-v ID,FORMAT[,NAME]
[ATA only] Sets a vendor\-specific raw value print FORMAT and
optional NAME for Attribute ID.
.B \-v ID,FORMAT[:BYTEORDER][,NAME]
[ATA only] Sets a vendor\-specific raw value print FORMAT, an optional
BYTEORDER and an optional NAME for Attribute ID.
This directive may be used multiple times.
Please see \fBsmartctl -v\fP command-line option for further details.
@ -1399,4 +1399,4 @@ SEE ALSO:
.SH
SVN ID OF THIS PAGE:
$Id: smartd.conf.5.in 2977 2009-10-30 22:29:05Z chrfranke $
$Id: smartd.conf.5.in 3001 2009-12-19 15:25:27Z chrfranke $

View File

@ -1,10 +1,10 @@
/*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
* Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net>
* Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2002-10 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
* Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net>
* Copyright (C) 2008-10 Christian Franke <smartmontools-support@lists.sourceforge.net>
*
* 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
@ -77,6 +77,10 @@ extern "C" int __stdcall FreeConsole(void);
#include <io.h> // setmode()
#endif // __CYGWIN__
#ifdef HAVE_LIBCAP_NG
#include <cap-ng.h>
#endif // LIBCAP_NG
// locally included files
#include "int64.h"
#include "atacmds.h"
@ -122,7 +126,7 @@ extern "C" int getdomainname(char *, int); // no declaration in header files!
#define ARGUSED(x) ((void)(x))
const char * smartd_cpp_cvsid = "$Id: smartd.cpp 2984 2009-11-14 22:46:31Z chrfranke $"
const char * smartd_cpp_cvsid = "$Id: smartd.cpp 3058 2010-02-03 21:04:24Z chrfranke $"
CONFIG_H_CVSID EXTERN_H_CVSID;
extern const char *reportbug;
@ -190,6 +194,11 @@ static int facility=LOG_DAEMON;
static bool do_fork=true;
#endif
#ifdef HAVE_LIBCAP_NG
// command-line: enable capabilities?
static bool enable_capabilities = false;
#endif
// used for control of printing, passing arguments to atacmds.c
smartmonctrl *con=NULL;
@ -918,6 +927,14 @@ static void MailWarning(const dev_config & cfg, dev_state & state, int which, co
return;
}
#ifdef HAVE_LIBCAP_NG
if (enable_capabilities) {
PrintOut(LOG_ERR, "Sending a mail was supressed. "
"Mails can't be send when capabilites are enabled\n");
return;
}
#endif
// record the time of this mail message, and the first mail message
if (!mail->logged)
mail->firstsent=epoch;
@ -1464,6 +1481,11 @@ void Usage (void){
PrintOut(LOG_INFO,"\n");
PrintOut(LOG_INFO," -c NAME|-, --configfile=NAME|-\n");
PrintOut(LOG_INFO," Read configuration file NAME or stdin [default is %s]\n\n", configfile);
#ifdef HAVE_LIBCAP_NG
PrintOut(LOG_INFO," -C, --capabilities\n");
PrintOut(LOG_INFO," Use capabilities (EXPERIMENTAL).\n"
" Warning: Mail notification does not work when used.\n\n");
#endif
PrintOut(LOG_INFO," -d, --debug\n");
PrintOut(LOG_INFO," Start smartd in debug mode\n\n");
PrintOut(LOG_INFO," -D, --showdirectives\n");
@ -1698,23 +1720,29 @@ static int ATADeviceScan(dev_config & cfg, dev_state & state, ata_device * atade
// information was ALSO reproduced in the IDENTIFY DEVICE response,
// but sadly not for ATA-5. Sigh.
// do we need to retain SMART data after returning from this routine?
bool retainsmartdata = (cfg.usagefailed || cfg.prefail || cfg.usage || cfg.tempdiff || cfg.tempinfo || cfg.tempcrit);
// do we need to get SMART data?
bool smart_val_ok = false;
if ( retainsmartdata || cfg.autoofflinetest || cfg.selftest || cfg.errorlog
|| cfg.curr_pending_id || cfg.offl_pending_id ) {
if ( cfg.autoofflinetest || cfg.errorlog || cfg.selftest
|| cfg.usagefailed || cfg.prefail || cfg.usage
|| cfg.tempdiff || cfg.tempinfo || cfg.tempcrit
|| cfg.curr_pending_id || cfg.offl_pending_id ) {
if (ataReadSmartValues(atadev, &state.smartval) ||
ataReadSmartThresholds (atadev, &state.smartthres)) {
PrintOut(LOG_INFO,"Device: %s, Read SMART Values and/or Thresholds Failed\n",name);
retainsmartdata = cfg.usagefailed = cfg.prefail = cfg.usage = false;
if (ataReadSmartValues(atadev, &state.smartval)) {
PrintOut(LOG_INFO, "Device: %s, Read SMART Values failed\n", name);
cfg.usagefailed = cfg.prefail = cfg.usage = false;
cfg.tempdiff = cfg.tempinfo = cfg.tempcrit = 0;
cfg.curr_pending_id = cfg.offl_pending_id = 0;
}
else
else {
smart_val_ok = true;
if (ataReadSmartThresholds(atadev, &state.smartthres)) {
PrintOut(LOG_INFO, "Device: %s, Read SMART Thresholds failed%s\n",
name, (cfg.usagefailed ? ", ignoring -f Directive" : ""));
cfg.usagefailed = false;
// Let ata_get_attr_state() return ATTRSTATE_NO_THRESHOLD:
memset(&state.smartthres, 0, sizeof(state.smartthres));
}
}
// see if the necessary Attribute is there to monitor offline or
// current pending sectors or temperature
@ -3701,7 +3729,11 @@ void ParseOpts(int argc, char **argv){
char *tailptr;
long lchecktime;
// Please update GetValidArgList() if you edit shortopts
const char *shortopts = "c:l:q:dDni:p:r:s:A:B:Vh?";
static const char shortopts[] = "c:l:q:dDni:p:r:s:A:B:Vh?"
#ifdef HAVE_LIBCAP_NG
"C"
#endif
;
char *arg;
// Please update GetValidArgList() if you edit longopts
struct option longopts[] = {
@ -3727,6 +3759,9 @@ void ParseOpts(int argc, char **argv){
{ "copyright", no_argument, 0, 'V' },
{ "help", no_argument, 0, 'h' },
{ "usage", no_argument, 0, 'h' },
#ifdef HAVE_LIBCAP_NG
{ "capabilities", no_argument, 0, 'C' },
#endif
{ 0, 0, 0, 0 }
};
@ -3885,6 +3920,12 @@ void ParseOpts(int argc, char **argv){
PrintOut(LOG_INFO, "%s", format_version_info("smartd", true /*full*/).c_str());
EXIT(0);
break;
#ifdef HAVE_LIBCAP_NG
case 'C':
// enable capabilities
enable_capabilities = true;
break;
#endif
case 'h':
// help: print summary of command-line options
debugmode=1;
@ -4224,6 +4265,16 @@ int main_worker(int argc, char **argv)
bool write_states_always = true;
#ifdef HAVE_LIBCAP_NG
// Drop capabilities
if (enable_capabilities) {
capng_clear(CAPNG_SELECT_BOTH);
capng_updatev(CAPNG_ADD, (capng_type_t)(CAPNG_EFFECTIVE|CAPNG_PERMITTED),
CAP_SYS_ADMIN, CAP_MKNOD, CAP_SYS_RAWIO, -1);
capng_apply(CAPNG_SELECT_BOTH);
}
#endif
// the main loop of the code
for (;;) {
@ -4293,8 +4344,7 @@ int main_worker(int argc, char **argv)
}
else {
// exit with configuration file error status
int status = (entries==-3 ? EXIT_READCONF : entries==-2 ? EXIT_NOCONF : EXIT_BADCONF);
EXIT(status);
return (entries==-3 ? EXIT_READCONF : entries==-2 ? EXIT_NOCONF : EXIT_BADCONF);
}
}
@ -4310,15 +4360,26 @@ int main_worker(int argc, char **argv)
}
else {
PrintOut(LOG_INFO,"Unable to monitor any SMART enabled devices. Try debug (-d) option. Exiting...\n");
EXIT(EXIT_NODEV);
return EXIT_NODEV;
}
if (quit==4) {
// user has asked to print test schedule
PrintTestSchedule(configs, states, devices);
EXIT(0);
return 0;
}
#ifdef HAVE_LIBCAP_NG
if (enable_capabilities) {
for (unsigned i = 0; i < configs.size(); i++) {
if (!configs[i].emailaddress.empty() || !configs[i].emailcmdline.empty()) {
PrintOut(LOG_WARNING, "Mail can't be enabled together with --capabilities. All mail will be suppressed.\n");
break;
}
}
}
#endif
// reset signal
caughtsigHUP=0;
@ -4343,7 +4404,7 @@ int main_worker(int argc, char **argv)
if (quit==3) {
PrintOut(LOG_INFO,"Started with '-q onecheck' option. All devices sucessfully checked once.\n"
"smartd is exiting (exit status 0)\n");
EXIT(0);
return 0;
}
// fork into background if needed

View File

@ -2,7 +2,7 @@
# smartmontools init file for smartd
# Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
# $Id: smartd.initd.in,v 1.38 2008/03/04 22:09:47 ballen4705 Exp $
# $Id: smartd.initd.in 3003 2009-12-19 18:47:47Z chrfranke $
# For RedHat and cousins:
# chkconfig: 2345 40 40
@ -439,15 +439,30 @@ http://smartmontools.sourceforge.net/"
install)
shift
[ $# -eq 0 ] || smartd_opts="$*"
dep=
dep=; dep2=
if cygrunsrv -L 2>/dev/null | grep "^syslogd$" >/dev/null 2>&1; then
dep="-y syslogd"
else
echo "Warning: syslogd service not installed, smartd will write to windows event log.";
dep="syslogd"
fi
echo "Installing service ${smartd_svcname}${smartd_opts+ with options '$smartd_opts'}:"
cygrunsrv -I "$smartd_svcname" -d "$smartd_svcdisp" -f "$smartd_svcdesc" $dep \
-e CYGWIN="$CYGWIN" -p $SMARTD_BIN -a "-n -p ${PID_FILE}${smartd_opts+ }$smartd_opts"
if cygrunsrv -L 2>/dev/null | grep "^syslog-ng" >/dev/null 2>&1; then
dep2="syslog-ng"
fi
if [ -z "$dep" ]; then
if [ -z "$dep2" ]; then
echo "Warning: no syslog service installed, smartd will write to windows event log.";
else
dep="$dep2"
fi
else
if [ -z "$dep2" ]; then
:
else
dep=
echo "Warning: both syslogd and syslog-ng installed, dependency not set."
fi
fi
echo "Installing service ${smartd_svcname}${dep:+ (depending on '$dep')}${smartd_opts:+ with options '$smartd_opts'}:"
cygrunsrv -I "$smartd_svcname" -d "$smartd_svcdisp" -f "$smartd_svcdesc" ${dep:+-y} $dep \
-e CYGWIN="$CYGWIN" -p $SMARTD_BIN -a "-n -p ${PID_FILE}${smartd_opts:+ }$smartd_opts"
RETVAL=$?
;;
remove)

View File

@ -50,7 +50,7 @@
#include "atacmds.h"
#include "dev_interface.h"
const char * utility_cpp_cvsid = "$Id: utility.cpp 3046 2010-01-22 21:30:02Z chrfranke $"
const char * utility_cpp_cvsid = "$Id: utility.cpp 3022 2010-01-01 17:02:00Z chrfranke $"
UTILITY_H_CVSID INT64_H_CVSID;
const char * packet_types[] = {
@ -778,3 +778,4 @@ int safe_snprintf(char *buf, int size, const char *fmt, ...)
}
#endif

View File

@ -26,7 +26,7 @@
#ifndef UTILITY_H_
#define UTILITY_H_
#define UTILITY_H_CVSID "$Id: utility.h 2848 2009-07-18 20:14:38Z chrfranke $"
#define UTILITY_H_CVSID "$Id: utility.h 3020 2009-12-31 01:11:51Z dlukes $"
#include <time.h>
#include <sys/types.h> // for regex.h (according to POSIX)
@ -335,3 +335,4 @@ private:
#endif
#endif