Skip to content
Snippets Groups Projects
Commit 2c366586 authored by (no author)'s avatar (no author)
Browse files

This commit was manufactured by cvs2svn to create tag 'RELEASE_5_32'.

parent b93aa226
No related branches found
No related tags found
No related merge requests found
Showing with 0 additions and 8075 deletions
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
# [<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list
# of files to check. A non-zero exit of the filter program will
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no
# Put CVS lock files in this directory rather than directly in the repository.
#LockDir=/var/lock/cvs
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no
# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the
# history file, or a subset as needed (ie `TMAR' logs all write operations)
#LogHistory=TOFEWGCMAR
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
# wildcard [option value][option value]...
#
# where option is one of
# -f from cvs filter value: path to filter
# -t to cvs filter value: path to filter
# -m update methodology value: MERGE or COPY
# -k expansion mode value: b, o, kkv, &c
#
# and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'
# The "editinfo" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.
# The "loginfo" file controls where "cvs commit" log information
# is sent. The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT. If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter. The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators. The format
# characters are:
#
# s = file name
# V = old version number (pre-checkin)
# v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
^sm5$ /cvsroot/sitedocs/CVSROOT/cvstools/syncmail -u %{sVv} smartmontools-cvs@lists.sourceforge.net
^sm5/os_win32$ /cvsroot/sitedocs/CVSROOT/cvstools/syncmail -u %{sVv} smartmontools-cvs@lists.sourceforge.net
^www$ /cvsroot/sitedocs/CVSROOT/cvstools/syncmail -u %{sVv} ballen4705@users.sourceforge.net
# Three different line formats are valid:
# key -a aliases...
# key [options] directory
# key [options] directory files...
#
# Where "options" are composed of:
# -i prog Run "prog" on "cvs commit" from top-level of module.
# -o prog Run "prog" on "cvs checkout" of module.
# -e prog Run "prog" on "cvs export" of module.
# -t prog Run "prog" on "cvs rtag" of module.
# -u prog Run "prog" on "cvs update" of module.
# -d dir Place module in directory "dir" instead of module name.
# -l Top-level directory only -- do not recurse.
#
# NOTE: If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias. An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module. This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT. If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT. For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4-> file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
# The "verifymsg" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.
/*
* atacmdnames.c
*
* This module is based on the T13/1532D Volume 1 Revision 3 (ATA/ATAPI-7)
* specification, which is available from http://www.t13.org/#FTP_site
*
* Home page of code is: http://smartmontools.sourceforge.net
* Address of support mailing list: smartmontools-support@lists.sourceforge.net
*
* Copyright (C) 2003-4 Philip Williams
*
* 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.
*
*/
#include "atacmdnames.h"
#include <stdlib.h>
#include <stdio.h>
#define COMMAND_TABLE_SIZE 256
const char *atacmdnames_c_cvsid="$Id: atacmdnames.cpp,v 1.11 2004/01/02 16:05:24 ballen4705 Exp $" ATACMDNAMES_H_CVSID;
const char cmd_reserved[] = "[RESERVED]";
const char cmd_vendor_specific[] = "[VENDOR SPECIFIC]";
const char cmd_reserved_sa[] = "[RESERVED FOR SERIAL ATA]";
const char cmd_reserved_cf[] = "[RESERVED FOR COMPACTFLASH ASSOCIATION]";
const char cmd_reserved_mcpt[] = "[RESERVED FOR MEDIA CARD PASS THROUGH]";
const char cmd_recalibrate_ret4[]= "RECALIBRATE [RET-4]";
const char cmd_seek_ret4[] = "SEEK [RET-4]";
const char *command_table[COMMAND_TABLE_SIZE] = {
/*-------------------------------------------------- 00h-0Fh -----*/
"NOP",
cmd_reserved,
cmd_reserved,
"CFA REQUEST EXTENDED ERROR CODE",
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
"DEVICE RESET",
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
/*-------------------------------------------------- 10h-1Fh -----*/
"RECALIBRATE [OBS-4]",
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
cmd_recalibrate_ret4,
/*-------------------------------------------------- 20h-2Fh -----*/
"READ SECTOR(S)",
"READ SECTOR(S) [OBS-5]",
"READ LONG (w/ retry) [OBS-4]",
"READ LONG (w/o retry) [OBS-4]",
"READ SECTOR(S) EXT",
"READ DMA EXT",
"READ DMA QUEUED EXT",
"READ NATIVE MAX ADDRESS EXT",
cmd_reserved,
"READ MULTIPLE EXT",
"READ STREAM DMA",
"READ STREAM PIO",
cmd_reserved,
cmd_reserved,
cmd_reserved,
"READ LOG EXT",
/*-------------------------------------------------- 30h-3Fh -----*/
"WRITE SECTOR(S)",
"WRITE SECTOR(S) [OBS-5]",
"WRITE LONG(w/ retry) [OBS-4]",
"WRITE LONG(w/o retry) [OBS-4]",
"WRITE SECTORS(S) EXT",
"WRITE DMA EXT",
"WRITE DMA QUEUED EXT",
"SET MAX ADDRESS EXT",
"CFA WRITE SECTORS WITHOUT ERASE",
"WRITE MULTIPLE EXT",
"WRITE STREAM DMA",
"WRITE STREAM PIO",
"WRITE VERIFY [OBS-4]",
"WRITE DMA FUA EXT",
"WRITE DMA QUEUED FUA EXT",
"WRITE LOG EXT",
/*-------------------------------------------------- 40h-4Fh -----*/
"READ VERIFY SECTOR(S)",
"READ VERIFY SECTOR(S) [OBS-5]",
"READ VERIFY SECTOR(S) EXT",
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
/*-------------------------------------------------- 50h-5Fh -----*/
"FORMAT TRACK [OBS-4]",
"CONFIGURE STREAM",
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
/*-------------------------------------------------- 60h-6Fh -----*/
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved_sa,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
/*-------------------------------------------------- 70h-7Fh -----*/
"SEEK [OBS-7]",
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
cmd_seek_ret4,
/*-------------------------------------------------- 80h-8Fh -----*/
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
"CFA TRANSLATE SECTOR [VS IF NO CFA]",
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
/*-------------------------------------------------- 90h-9Fh -----*/
"EXECUTE DEVICE DIAGNOSTIC",
"INITIALIZE DEVICE PARAMETERS [OBS-6]",
"DOWNLOAD MICROCODE",
cmd_reserved,
"STANDBY IMMEDIATE [RET-4]",
"IDLE IMMEDIATE [RET-4]",
"STANDBY [RET-4]",
"IDLE [RET-4]",
"CHECK POWER MODE [RET-4]",
"SLEEP [RET-4]",
cmd_vendor_specific,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
/*-------------------------------------------------- A0h-AFh -----*/
"PACKET",
"IDENTIFY PACKET DEVICE",
"SERVICE",
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
/*-------------------------------------------------- B0h-BFh -----*/
"SMART",
"DEVICE CONFIGURATION",
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved_cf,
cmd_reserved_cf,
cmd_reserved_cf,
cmd_reserved_cf,
cmd_reserved_cf,
cmd_reserved_cf,
cmd_reserved_cf,
cmd_reserved_cf,
/*-------------------------------------------------- C0h-CFh -----*/
"CFA ERASE SECTORS [VS IF NO CFA]",
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
"READ MULTIPLE",
"WRITE MULTIPLE",
"SET MULTIPLE MODE",
"READ DMA QUEUED",
"READ DMA",
"READ DMA [OBS-5]",
"WRITE DMA",
"WRITE DMA [OBS-5]",
"WRITE DMA QUEUED",
"CFA WRITE MULTIPLE WITHOUT ERASE",
"WRITE MULTIPLE FUA EXT",
cmd_reserved,
/*-------------------------------------------------- D0h-DFh -----*/
cmd_reserved,
"CHECK MEDIA CARD TYPE",
cmd_reserved_mcpt,
cmd_reserved_mcpt,
cmd_reserved_mcpt,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
cmd_reserved,
"GET MEDIA STATUS",
"ACKNOWLEDGE MEDIA CHANGE [RET-4]",
"BOOT POST-BOOT [RET-4]",
"BOOT PRE-BOOT [RET-4]",
"MEDIA LOCK",
"MEDIA UNLOCK",
/*-------------------------------------------------- E0h-EFh -----*/
"STANDBY IMMEDIATE",
"IDLE IMMEDIATE",
"STANDBY",
"IDLE",
"READ BUFFER",
"CHECK POWER MODE",
"SLEEP",
"FLUSH CACHE",
"WRITE BUFFER",
"WRITE SAME [RET-4]", /* Warning! This command is retired but the value of
f_reg is used in look_up_ata_command(). If this
command code is reclaimed in a future standard then
be sure to update look_up_ata_command(). */
"FLUSH CACHE EXIT",
cmd_reserved,
"IDENTIFY DEVICE",
"MEDIA EJECT",
"IDENTIFY DEVICE DMA [OBS-4]",
"SET FEATURES",
/*-------------------------------------------------- F0h-FFh -----*/
cmd_vendor_specific,
"SECURITY SET PASSWORD",
"SECURITY UNLOCK",
"SECURITY ERASE PREPARE",
"SECURITY ERASE UNIT",
"SECURITY FREEZE LOCK",
"SECURITY DISABLE PASSWORD",
cmd_vendor_specific,
"READ NATIVE MAX ADDRESS",
"SET MAX",
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific,
cmd_vendor_specific
};
/* Returns the name of the command (and possibly sub-command) with the given
command code and feature register values. For most command codes this
simply returns the corresponding entry in the command_table array, but for
others the value of the feature register specifies a subcommand or
distinguishes commands. */
const char *look_up_ata_command(unsigned char c_code, unsigned char f_reg) {
// check that command table not messed up. The compiler will issue
// warnings if there are too many array elements, but won't issue
// warnings if there are not enough of them.
if (sizeof(command_table) != sizeof(char *)*COMMAND_TABLE_SIZE){
fprintf(stderr,
"Problem in atacmdnames.c. Command Table command_table[] does\n"
"not have %d entries! It has %d entries. Please fix it.\n",
COMMAND_TABLE_SIZE, (int)(sizeof(command_table)/sizeof(char *)));
abort();
}
switch (c_code) {
case 0x00: /* NOP */
switch (f_reg) {
case 0x00:
return "NOP [Abort queued commands]";
case 0x01:
return "NOP [Don't abort queued commands]";
default:
return "NOP [Reserved subcommand]";
}
case 0x92: /* DOWNLOAD MICROCODE */
switch (f_reg) {
case 0x01:
return "DOWNLOAD MICROCODE [Temporary]";
case 0x07:
return "DOWNLOAD MICROCODE [Save]";
default:
return "DOWNLOAD MICROCODE [Reserved subcommand]";
}
case 0xB0: /* SMART */
switch (f_reg) {
case 0xD0:
return "SMART READ DATA";
case 0xD1:
return "SMART READ ATTRIBUTE THRESHOLDS [OBS-4]";
case 0xD2:
return "SMART ENABLE/DISABLE ATTRIBUTE AUTOSAVE";
case 0xD3:
return "SMART SAVE ATTRIBUTE VALUES [OBS-6]";
case 0xD4:
return "SMART EXECUTE OFF-LINE IMMEDIATE";
case 0xD5:
return "SMART READ LOG";
case 0xD6:
return "SMART WRITE LOG";
case 0xD7:
return "SMART WRITE ATTRIBUTE THRESHOLDS [NS, OBS-4]";
case 0xD8:
return "SMART ENABLE OPERATIONS";
case 0xD9:
return "SMART DISABLE OPERATIONS";
case 0xDA:
return "SMART RETURN STATUS";
case 0xDB:
return "SMART EN/DISABLE AUTO OFFLINE [NS (SFF-8035i)]";
default:
if (f_reg >= 0xE0)
return "[Vendor specific SMART command]";
else
return "[Reserved SMART command]";
}
case 0xB1: /* DEVICE CONFIGURATION */
switch (f_reg) {
case 0xC0:
return "DEVICE CONFIGURATION RESTORE";
case 0xC1:
return "DEVICE CONFIGURATION FREEZE LOCK";
case 0xC2:
return "DEVICE CONFIGURATION IDENTIFY";
case 0xC3:
return "DEVICE CONFIGURATION SET";
default:
return "DEVICE CONFIGURATION [Reserved command]";
}
case 0xE9: /* WRITE SAME */
switch (f_reg) {
case 0x22:
return "WRITE SAME [Start specified] [RET-4]";
case 0xDD:
return "WRITE SAME [Start unspecified] [RET-4]";
default:
return "WRITE SAME [Invalid subcommand] [RET-4]";
}
case 0xEF: /* SET FEATURES */
switch (f_reg) {
case 0x01:
return "SET FEATURES [Enable 8-bit PIO]";
case 0x02:
return "SET FEATURES [Enable write cache]";
case 0x03:
return "SET FEATURES [Set transfer mode]";
case 0x04:
return "SET FEATURES [Enable auto DR] [OBS-4]";
case 0x05:
return "SET FEATURES [Enable APM]";
case 0x06:
return "SET FEATURES [Enable Pwr-Up In Standby]";
case 0x07:
return "SET FEATURES [Set device spin-up]";
case 0x09:
return "SET FEATURES [Reserved (address offset)]";
case 0x0A:
return "SET FEATURES [Enable CFA power mode 1]";
case 0x10:
return "SET FEATURES [Reserved for Serial ATA]";
case 0x20:
return "SET FEATURES [Set Time-ltd R/W WCT]";
case 0x21:
return "SET FEATURES [Set Time-ltd R/W EH]";
case 0x31:
return "SET FEATURES [Disable Media Status Notf]";
case 0x33:
return "SET FEATURES [Disable retry] [OBS-4]";
case 0x42:
return "SET FEATURES [Enable AAM]";
case 0x43:
return "SET FEATURES [Set Max Host I/F S Times]";
case 0x44:
return "SET FEATURES [Length of VS data] [OBS-4]";
case 0x54:
return "SET FEATURES [Set cache segs] [OBS-4]";
case 0x55:
return "SET FEATURES [Disable read look-ahead]";
case 0x5D:
return "SET FEATURES [Enable release interrupt]";
case 0x5E:
return "SET FEATURES [Enable SERVICE interrupt]";
case 0x66:
return "SET FEATURES [Disable revert defaults]";
case 0x77:
return "SET FEATURES [Disable ECC] [OBS-4]";
case 0x81:
return "SET FEATURES [Disable 8-bit PIO]";
case 0x82:
return "SET FEATURES [Disable write cache]";
case 0x84:
return "SET FEATURES [Disable auto DR] [OBS-4]";
case 0x85:
return "SET FEATURES [Disable APM]";
case 0x86:
return "SET FEATURES [Disable Pwr-Up In Standby]";
case 0x88:
return "SET FEATURES [Disable ECC] [OBS-4]";
case 0x89:
return "SET FEATURES [Reserved (address offset)]";
case 0x8A:
return "SET FEATURES [Disable CFA power mode 1]";
case 0x90:
return "SET FEATURES [Reserved for Serial ATA]";
case 0x95:
return "SET FEATURES [Enable Media Status Notf]";
case 0x99:
return "SET FEATURES [Enable retries] [OBS-4]";
case 0x9A:
return "SET FEATURES [Set max avg curr] [OBS-4]";
case 0xAA:
return "SET FEATURES [Enable read look-ahead]";
case 0xAB:
return "SET FEATURES [Set max prefetch] [OBS-4]";
case 0xBB:
return "SET FEATURES [4 bytes VS data] [OBS-4]";
case 0xC2:
return "SET FEATURES [Disable AAM]";
case 0xCC:
return "SET FEATURES [Enable revert to defaults]";
case 0xDD:
return "SET FEATURES [Disable release interrupt]";
case 0xDE:
return "SET FEATURES [Disable SERVICE interrupt]";
case 0xE0:
return "SET FEATURES [Obsolete subcommand]";
default:
if (f_reg >= 0xF0)
return "SET FEATURES [Reserved for CFA]";
else
return "SET FEATURES [Reserved subcommand]";
}
case 0xF9: /* SET MAX */
switch (f_reg) {
case 0x00:
return "SET MAX ADDRESS [OBS-6]";
case 0x01:
return "SET MAX SET PASSWORD";
case 0x02:
return "SET MAX LOCK";
case 0x03:
return "SET MAX UNLOCK";
case 0x04:
return "SET MAX FREEZE LOCK";
default:
return "[Reserved SET MAX command]";
}
default:
return command_table[c_code];
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* os_generic.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) YEAR YOUR_NAME <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2003-4 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.
*/
/* PORTING NOTES AND COMMENTS
To port smartmontools to the OS of your choice, please:
[0] Contact smartmontools-support@lists.sourceforge.net to check
that it's not already been done.
[1] Make copies of os_generic.[hc] called os_myOS.[hc].
[2] Modify configure.in so that case "${host}" includes myOS.
[3] Verify that ./autogen.sh && ./configure && make compiles the
code. If not, fix any compilation problems. If your OS lacks
some function that is used elsewhere in the code, then add a
AC_CHECK_FUNCS([missingfunction]) line to configure.in, and
surround uses of the function with:
#ifdef HAVE_MISSINGFUNCTION
...
#endif
where the macro HAVE_MISSINGFUNCTION is (or is not) defined in
config.h.
[4] Provide the functions defined in this file by fleshing out the
skeletons below. Note that for Darwin much of this already
exists. See some partially developed but incomplete code at:
http://cvs.sourceforge.net/viewcvs.py/smartmontools/sm5_Darwin/.
You can entirely eliminate the function 'unsupported()'.
[5] Contact smartmontools-support@lists.sourceforge.net to see
about checking your code into the smartmontools CVS archive.
*/
// These are needed to define prototypes for the functions defined below
#include "atacmds.h"
#include "scsicmds.h"
#include "utility.h"
// This is to include whatever prototypes you define in os_generic.h
#include "os_generic.h"
// Needed by '-V' option (CVS versioning) of smartd/smartctl
const char *os_XXXX_c_cvsid="$Id: os_generic.cpp,v 1.11 2004/03/13 02:32:52 ballen4705 Exp $" \
ATACMDS_H_CVSID OS_XXXX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
// 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"
#ifdef HAVE_UNAME
#include <sys/utsname.h>
#endif
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.c 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/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;
}
// tries to guess device type given the name (a path). See utility.h
// for return values.
int guess_device_type (const char* dev_name) {
unsupported();
return GUESS_DEVTYPE_DONT_KNOW;
}
// 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();
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.c 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){
unsupported();
return -1;
}
// Like close(). Acts only on integer handles returned by
// deviceopen() above.
int deviceclose(int fd){
unsupported();
return 0;
}
// Interface to ATA devices. See os_linux.c 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){
unsupported();
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, smart_command_set command, int select, char *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) {
unsupported();
return -ENOSYS;
}
This diff is collapsed.
/*
* os_netbsd.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2003-4 Sergey Svishchev <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.
*
*/
#include "config.h"
#include "atacmds.h"
#include "scsicmds.h"
#include "utility.h"
#include "os_netbsd.h"
const char *os_XXXX_c_cvsid = "$Id: os_netbsd.cpp,v 1.6 2004/04/19 03:57:38 shattered Exp $" \
ATACMDS_H_CVSID OS_NETBSD_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
/* global variable holding byte count of allocated memory */
extern long long bytes;
enum warnings {
BAD_SMART, NO_3WARE, MAX_MSG
};
/* Utility function for printing warnings */
void
printwarning(int msgNo, const char *extra)
{
static int printed[] = {0, 0};
static const char *message[] = {
"Error: SMART Status command failed.\nPlease get assistance from \n" PACKAGE_HOMEPAGE "\nRegister values returned from SMART Status command are:\n",
PACKAGE_STRING " does not currentlly support twe(4) devices (3ware Escalade)\n",
};
if (msgNo >= 0 && msgNo <= MAX_MSG) {
if (!printed[msgNo]) {
printed[msgNo] = 1;
pout("%s", message[msgNo]);
if (extra)
pout("%s", extra);
}
}
return;
}
static const char *net_dev_prefix = "/dev/";
static const char *net_dev_ata_disk = "wd";
static const char *net_dev_scsi_disk = "sd";
static const char *net_dev_scsi_tape = "enrst";
/* Guess device type(ata or scsi) based on device name */
int
guess_device_type(const char *dev_name)
{
int len;
int dev_prefix_len = strlen(net_dev_prefix);
if (!dev_name || !(len = strlen(dev_name)))
return GUESS_DEVTYPE_DONT_KNOW;
if (!strncmp(net_dev_prefix, dev_name, dev_prefix_len)) {
if (len <= dev_prefix_len)
return GUESS_DEVTYPE_DONT_KNOW;
else
dev_name += dev_prefix_len;
}
if (!strncmp(net_dev_ata_disk, dev_name, strlen(net_dev_ata_disk)))
return GUESS_DEVTYPE_ATA;
if (!strncmp(net_dev_scsi_disk, dev_name, strlen(net_dev_scsi_disk)))
return GUESS_DEVTYPE_SCSI;
if (!strncmp(net_dev_scsi_tape, dev_name, strlen(net_dev_scsi_tape)))
return GUESS_DEVTYPE_SCSI;
return GUESS_DEVTYPE_DONT_KNOW;
}
int
get_dev_names(char ***names, const char *prefix)
{
char *disknames, *p, **mp;
int n = 0;
int sysctl_mib[2];
size_t sysctl_len;
*names = NULL;
sysctl_mib[0] = CTL_HW;
sysctl_mib[1] = HW_DISKNAMES;
if (-1 == sysctl(sysctl_mib, 2, NULL, &sysctl_len, NULL, 0)) {
pout("Failed to get value of sysctl `hw.disknames'\n");
return -1;
}
if (!(disknames = malloc(sysctl_len))) {
pout("Out of memory constructing scan device list\n");
return -1;
}
if (-1 == sysctl(sysctl_mib, 2, disknames, &sysctl_len, NULL, 0)) {
pout("Failed to get value of sysctl `hw.disknames'\n");
return -1;
}
if (!(mp = (char **) calloc(strlen(disknames) / 2, sizeof(char *)))) {
pout("Out of memory constructing scan device list\n");
return -1;
}
for (p = strtok(disknames, " "); p; p = strtok(NULL, " ")) {
if (strncmp(p, prefix, strlen(prefix))) {
continue;
}
mp[n] = malloc(strlen(net_dev_prefix) + strlen(p) + 2);
if (!mp[n]) {
pout("Out of memory constructing scan device list\n");
return -1;
}
sprintf(mp[n], "%s%s%c", net_dev_prefix, p, 'a' + getrawpartition());
bytes += strlen(mp[n]) + 1;
n++;
}
mp = realloc(mp, n * (sizeof(char *)));
bytes += (n) * (sizeof(char *));
*names = mp;
return n;
}
int
make_device_names(char ***devlist, const char *name)
{
if (!strcmp(name, "SCSI"))
return get_dev_names(devlist, net_dev_scsi_disk);
else if (!strcmp(name, "ATA"))
return get_dev_names(devlist, net_dev_ata_disk);
else
return 0;
}
int
deviceopen(const char *pathname, char *type)
{
if (!strcmp(type, "SCSI")) {
int fd = open(pathname, O_RDWR | O_NONBLOCK);
if (fd < 0 && errno == EROFS)
fd = open(pathname, O_RDONLY | O_NONBLOCK);
return fd;
} else if (!strcmp(type, "ATA"))
return open(pathname, O_RDWR | O_NONBLOCK);
else
return -1;
}
int
deviceclose(int fd)
{
return close(fd);
}
int
ata_command_interface(int fd, smart_command_set command, int select, char *data)
{
struct atareq req;
unsigned char inbuf[DEV_BSIZE];
int retval, copydata = 0;
memset(&req, 0, sizeof(req));
memset(&inbuf, 0, sizeof(inbuf));
switch (command) {
case READ_VALUES:
req.flags = ATACMD_READ;
req.features = WDSM_RD_DATA;
req.command = WDCC_SMART;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.cylinder = htole16(WDSMART_CYL);
req.timeout = 1000;
copydata = 1;
break;
case READ_THRESHOLDS:
req.flags = ATACMD_READ;
req.features = WDSM_RD_THRESHOLDS;
req.command = WDCC_SMART;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.cylinder = htole16(WDSMART_CYL);
req.timeout = 1000;
copydata = 1;
break;
case READ_LOG:
req.flags = ATACMD_READ;
req.features = ATA_SMART_READ_LOG_SECTOR; /* XXX missing from wdcreg.h */
req.command = WDCC_SMART;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.cylinder = htole16(WDSMART_CYL);
req.sec_num = select;
req.sec_count = 1;
req.timeout = 1000;
copydata = 1;
break;
case WRITE_LOG:
memcpy(inbuf, data, 512);
req.flags = ATACMD_WRITE;
req.features = ATA_SMART_WRITE_LOG_SECTOR; /* XXX missing from wdcreg.h */
req.command = WDCC_SMART;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.cylinder = htole16(WDSMART_CYL);
req.sec_num = select;
req.sec_count = 1;
req.timeout = 1000;
break;
case IDENTIFY:
req.flags = ATACMD_READ;
req.command = WDCC_IDENTIFY;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.timeout = 1000;
copydata = 1;
break;
case PIDENTIFY:
req.flags = ATACMD_READ;
req.command = ATAPI_IDENTIFY_DEVICE;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.timeout = 1000;
copydata = 1;
break;
case ENABLE:
req.flags = ATACMD_READ;
req.features = WDSM_ENABLE_OPS;
req.command = WDCC_SMART;
req.cylinder = htole16(WDSMART_CYL);
req.timeout = 1000;
break;
case DISABLE:
req.flags = ATACMD_READ;
req.features = WDSM_DISABLE_OPS;
req.command = WDCC_SMART;
req.cylinder = htole16(WDSMART_CYL);
req.timeout = 1000;
break;
case AUTO_OFFLINE:
/* NOTE: According to ATAPI 4 and UP, this command is obsolete */
req.flags = ATACMD_READ;
req.features = ATA_SMART_AUTO_OFFLINE; /* XXX missing from wdcreg.h */
req.command = WDCC_SMART;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.cylinder = htole16(WDSMART_CYL);
req.sec_num = select;
req.sec_count = 1;
req.timeout = 1000;
break;
case AUTOSAVE:
req.flags = ATACMD_READ;
req.features = ATA_SMART_AUTOSAVE; /* XXX missing from wdcreg.h */
req.command = WDCC_SMART;
req.cylinder = htole16(WDSMART_CYL);
req.sec_count = 0xf1;
/* to enable autosave */
req.timeout = 1000;
break;
case IMMEDIATE_OFFLINE:
/* NOTE: According to ATAPI 4 and UP, this command is obsolete */
req.flags = ATACMD_READ;
req.features = ATA_SMART_IMMEDIATE_OFFLINE; /* XXX missing from wdcreg.h */
req.command = WDCC_SMART;
req.databuf = (caddr_t) inbuf;
req.datalen = sizeof(inbuf);
req.cylinder = htole16(WDSMART_CYL);
req.sec_num = select;
req.sec_count = 1;
req.timeout = 1000;
break;
case STATUS_CHECK:
/* same command, no HDIO in NetBSD */
case STATUS:
req.flags = ATACMD_READ;
req.features = WDSM_STATUS;
req.command = WDCC_SMART;
req.cylinder = htole16(WDSMART_CYL);
req.timeout = 1000;
break;
case CHECK_POWER_MODE:
req.flags = ATACMD_READREG;
req.command = WDCC_CHECK_PWR;
req.timeout = 1000;
break;
default:
pout("Unrecognized command %d in ata_command_interface()\n", command);
errno = ENOSYS;
return -1;
}
if (command == STATUS_CHECK) {
char buf[512];
unsigned const short normal = WDSMART_CYL, failed = 0x2cf4;
if ((retval = ioctl(fd, ATAIOCCOMMAND, &req))) {
perror("Failed command");
return -1;
}
/* Cyl low and Cyl high unchanged means "Good SMART status" */
if (le16toh(req.cylinder) == normal)
return 0;
/* These values mean "Bad SMART status" */
if (le16toh(req.cylinder) == failed)
return 1;
/* We haven't gotten output that makes sense;
* print out some debugging info */
snprintf(buf, sizeof(buf),
"CMD=0x%02x\nFR =0x%02x\nNS =0x%02x\nSC =0x%02x\nCL =0x%02x\nCH =0x%02x\nRETURN =0x%04x\n",
(int) req.command, (int) req.features, (int) req.sec_count, (int) req.sec_num,
(int) (le16toh(req.cylinder) & 0xff), (int) ((le16toh(req.cylinder) >> 8) & 0xff),
(int) req.error);
printwarning(BAD_SMART, buf);
return 0;
}
if ((retval = ioctl(fd, ATAIOCCOMMAND, &req))) {
perror("Failed command");
return -1;
}
if (command == CHECK_POWER_MODE)
data[0] = req.sec_count;
if (copydata)
memcpy(data, inbuf, 512);
return 0;
}
int
escalade_command_interface(int fd, int disknum, smart_command_set command, int select, char *data)
{
printwarning(NO_3WARE, NULL);
return -1;
}
int
do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report)
{
struct scsireq sc;
if (report > 0) {
size_t k;
const unsigned char *ucp = iop->cmnd;
const char *np;
np = scsi_get_opcode_name(ucp[0]);
pout(" [%s: ", np ? np : "<unknown opcode>");
for (k = 0; k < iop->cmnd_len; ++k)
pout("%02x ", ucp[k]);
if ((report > 1) &&
(DXFER_TO_DEVICE == iop->dxfer_dir) && (iop->dxferp)) {
int trunc = (iop->dxfer_len > 256) ? 1 : 0;
pout("]\n Outgoing data, len=%d%s:\n", (int) iop->dxfer_len,
(trunc ? " [only first 256 bytes shown]" : ""));
dStrHex(iop->dxferp, (trunc ? 256 : iop->dxfer_len), 1);
} else
pout("]");
}
memset(&sc, 0, sizeof(sc));
memcpy(sc.cmd, iop->cmnd, iop->cmnd_len);
sc.cmdlen = iop->cmnd_len;
sc.databuf = iop->dxferp;
sc.datalen = iop->dxfer_len;
sc.senselen = iop->max_sense_len;
sc.timeout = iop->timeout == 0 ? 60000 : iop->timeout; /* XXX */
sc.flags =
(iop->dxfer_dir == DXFER_NONE ? SCCMD_READ : /* XXX */
(iop->dxfer_dir == DXFER_FROM_DEVICE ? SCCMD_READ : SCCMD_WRITE));
if (ioctl(fd, SCIOCCOMMAND, &sc) < 0) {
warn("error sending SCSI ccb");
return -1;
}
iop->resid = sc.datalen - sc.datalen_used;
iop->scsi_status = sc.status;
if (iop->sensep) {
memcpy(iop->sensep, sc.sense, sc.senselen_used);
iop->resp_sense_len = sc.senselen_used;
}
if (report > 0) {
int trunc;
pout(" status=0\n");
trunc = (iop->dxfer_len > 256) ? 1 : 0;
pout(" Incoming data, len=%d%s:\n", (int) iop->dxfer_len,
(trunc ? " [only first 256 bytes shown]" : ""));
dStrHex(iop->dxferp, (trunc ? 256 : iop->dxfer_len), 1);
}
return 0;
}
/* print examples for smartctl */
void
print_smartctl_examples()
{
char p;
p = 'a' + getrawpartition();
printf("=================================================== SMARTCTL EXAMPLES =====\n\n");
#ifdef HAVE_GETOPT_LONG
printf(
" smartctl -a /dev/wd0%c (Prints all SMART information)\n\n"
" smartctl --smart=on --offlineauto=on --saveauto=on /dev/wd0%c\n"
" (Enables SMART on first disk)\n\n"
" smartctl -t long /dev/wd0%c (Executes extended disk self-test)\n\n"
" smartctl --attributes --log=selftest --quietmode=errorsonly /dev/wd0%c\n"
" (Prints Self-Test & Attribute errors)\n",
p, p, p, p
);
#else
printf(
" smartctl -a /dev/wd0%c (Prints all SMART information)\n"
" smartctl -s on -o on -S on /dev/wd0%c (Enables SMART on first disk)\n"
" smartctl -t long /dev/wd0%c (Executes extended disk self-test)\n"
" smartctl -A -l selftest -q errorsonly /dev/wd0%c"
" (Prints Self-Test & Attribute errors)\n",
p, p, p, p
);
#endif
return;
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment