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

This commit was manufactured by cvs2svn to create tag

'RELEASE_5_1_8'.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/tags/RELEASE_5_1_8@509 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent ad1a0a5f
No related branches found
No related tags found
No related merge requests found
Showing with 0 additions and 6493 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
# 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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* scsiprint.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
*
* 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/
*
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include "extern.h"
#include "scsicmds.h"
#include "scsiprint.h"
#include "smartctl.h"
#include "utility.h"
#define GBUF_SIZE 65535
const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.19 2003/01/16 15:28:57 ballen4705 Exp $"
EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
// control block which points to external global control variables
extern atamainctrl *con;
UINT8 gBuf[GBUF_SIZE];
UINT8 gSmartPage = 0;
UINT8 gTempPage = 0;
UINT8 gSelfTestPage = 0;
UINT8 gStartStopPage = 0;
UINT8 gTapeAlertsPage = 0;
void scsiGetSupportPages ( int device)
{
int i;
if (logsense ( device , SUPPORT_LOG_PAGES, (UINT8 *) &gBuf) != 0)
{
perror ( "Log Sense failed");
exit (1);
}
for ( i = 4; i < gBuf[3] + LOGPAGEHDRSIZE ; i++)
{
switch ( gBuf[i])
{
case TEMPERATURE_PAGE:
gTempPage = 1;
break;
case STARTSTOP_CYCLE_COUNTER_PAGE:
gStartStopPage = 1;
break;
case SELFTEST_RESULTS_PAGE:
gSelfTestPage = 1;
break;
case SMART_PAGE:
gSmartPage = 1;
break;
case TAPE_ALERTS_PAGE:
gTapeAlertsPage = 1;
break;
default:
break;
}
}
}
void scsiGetSmartData (int device)
{
UINT8 returnvalue;
UINT8 currenttemp;
UINT8 triptemp;
if ( scsiCheckSmart(device, gSmartPage,
&returnvalue, &currenttemp, &triptemp ) != 0)
{
perror ( "scsiGetSmartData Failed");
exit (1);
}
if ( returnvalue )
printf("S.M.A.R.T. Sense: (%02x) %s\n", (UINT8) returnvalue,
scsiSmartGetSenseCode(returnvalue));
else
printf("S.M.A.R.T. Sense: Ok!\n");
if ( (currenttemp || triptemp) && !gTempPage)
{
printf("Current Drive Temperature: %d C\n", currenttemp);
printf("Drive Trip Temperature: %d C\n", triptemp);
}
}
void scsiGetTapeAlertsData (int device)
{
unsigned short pagelength;
unsigned short parametercode;
int i;
int failure = 0;
if ( logsense( device, TAPE_ALERTS_PAGE, (UINT8 *) &gBuf) != 0)
{
perror ( "scsiGetSmartData Failed");
exit (1);
}
if ( gBuf[0] != 0x2e )
{
printf("TapeAlerts Log Sense Failed\n");
exit(-1);
}
pagelength = (unsigned short) gBuf[2] << 8 | gBuf[3];
for ( i = 4; i < pagelength;i+=5 )
{
parametercode = (unsigned short) gBuf[i] << 8 | gBuf[i+1];
if (gBuf[i+4])
{
printf("Tape Alerts Error!!!\n%s\n",
scsiTapeAlertsTapeDevice(parametercode));
failure = 1;
}
}
if(!failure)
printf("No Tape Alerts Failure\n");
}
void scsiGetStartStopData ( int device)
{
UINT32 currentStartStop;
UINT32 recommendedStartStop;
if ( logsense( device, STARTSTOP_CYCLE_COUNTER_PAGE, (UINT8 *) &gBuf) != 0)
{
perror ( "scsiGetStartStopData Failed");
exit (1);
}
if ( gBuf[0] != STARTSTOP_CYCLE_COUNTER_PAGE )
{
printf("StartStop Log Sense Failed\n");
exit(-1);
}
recommendedStartStop= (UINT32) gBuf[28]<< 24 | gBuf[29] << 16 |
gBuf[30] << 8 | gBuf[31];
currentStartStop= (UINT32) gBuf[36]<< 24 | gBuf[37] << 16 |
gBuf[38] << 8 | gBuf[39];
printf("Current start stop count: %u times\n", currentStartStop);
printf("Recommended start stop count: %u times\n", recommendedStartStop);
}
const char * self_test_code[] = {
"Default ",
"Background short",
"Background long ",
"Reserved(3) ",
"Abort background",
"Foreground short",
"Foreground long ",
"Reserved(7) "
};
const char * self_test_result[] = {
"Completed ",
"Interrupted ('-X' switch)",
"Interrupted (bus reset ?)",
"Unknown error, incomplete",
"Completed, segment failed",
"Failed in first segment ",
"Failed in second segment ",
"Failed in segment --> ",
"Reserved(8) ",
"Reserved(9) ",
"Reserved(10) ",
"Reserved(11) ",
"Reserved(12) ",
"Reserved(13) ",
"Reserved(14) ",
"Self test in progress ..."
};
// See Working Draft SCSI Primary Commands - 3 (SPC-3) pages 231-233
// T10/1416-D Rev 10
void scsiPrintSelfTest(int device)
{
int num, k, n, res, noheader=1;
UINT8 * ucp;
unsigned long long ull=0;
if (logsense(device, SELFTEST_RESULTS_PAGE, gBuf) != 0)
{
perror ( "scsiPrintSelfTest Failed");
exit (1);
}
if (gBuf[0] != SELFTEST_RESULTS_PAGE)
{
printf("Self-test Log Sense Failed\n");
exit(1);
}
// compute page length
num = (gBuf[2] << 8) + gBuf[3];
// Log sense page length 0x190 bytes
if (num != 0x190) {
printf("Self-test Log Sense length is 0x%x not 0x190 bytes\n",num);
exit(1);
}
// loop through the twenty possible entries
for (k = 0, ucp = gBuf + 4; k < 20; ++k, ucp += 20 ) {
int i;
// timestamp in power-on hours (or zero if test in progress)
n = (ucp[6] << 8) | ucp[7];
// The spec says "all 20 bytes will be zero if no test" but
// DG has found otherwise. So this is a heuristic.
if ((0 == n) && (0 == ucp[4]))
break;
// only print header if needed
if (noheader){
printf("\nSMART Self-test log\n");
printf("Num Test Status segment "
"LifeTime LBA_first_err [SK ASC ASQ]\n");
printf(" Description number "
"(hours)\n");
noheader=0;
}
// print parameter code (test number) & self-test code text
printf("#%2d %s", (ucp[0] << 8) | ucp[1],
self_test_code[(ucp[4] >> 5) & 0x7]);
// self-test result
res = ucp[4] & 0xf;
printf(" %s", self_test_result[res]);
// self-test number identifies test that failed and consists
// of either the number of the segment that failed during
// the test, or the number of the test that failed and the
// number of the segment in which the test was run, using a
// vendor-specific method of putting both numbers into a
// single byte.
if (ucp[5])
printf(" %3d", (int)ucp[5]);
else
printf(" -");
// print time that the self-test was completed
if (n==0 && res==0xf)
// self-test in progress
printf(" NOW");
else
printf(" %5d", n);
// construct 8-byte integer address of first failure
for (i=0; i<8; i++){
ull <<= 8;
ull |= ucp[i+8];
}
// print Address of First Failure, if sensible
if ((0xffffffffffffffffULL != ull) && (res > 0) && ( res < 0xf))
printf(" 0x%16llx", ull);
else
printf(" -");
// if sense key nonzero, then print it, along with
// additional sense code and additional sense code qualifier
if (ucp[16] & 0xf)
printf(" [0x%x 0x%x 0x%x]\n", ucp[16] & 0xf, ucp[17], ucp[18]);
else
printf(" [- - -]\n");
}
// if header never printed, then there was no output
if (noheader)
printf("No self-tests have been logged\n\n");
else
printf("\n");
return;
}
void scsiGetDriveInfo ( int device)
{
char manufacturer[9];
char product[17];
char revision[5];
char timedatetz[64];
UINT8 smartsupport;
if (stdinquiry ( device, (UINT8 *) &gBuf) != 0)
{
perror ( "Standard Inquiry failed");
}
memset ( &manufacturer, 0, 8);
manufacturer[8] = '\0';
strncpy ((char *) &manufacturer, (char *) &gBuf[8], 8);
memset ( &product, 0, 16);
strncpy ((char *) &product, (char *) &gBuf[16], 16);
product[16] = '\0';
memset ( &revision, 0, 4);
strncpy ((char *) &revision, (char *) &gBuf[32], 4);
revision[4] = '\0';
printf("Device: %s %s Version: %s\n", manufacturer, product, revision);
// print current time and date and timezone
dateandtimezone(timedatetz);
printf("Local Time is: %s\n", timedatetz);
if ( scsiSmartSupport( device, (UINT8 *) &smartsupport) != 0)
{
printf("Device does not support %s\n",(gBuf[0] & 0x1f)?
"TapeAlerts": "S.M.A.R.T.");
exit (1);
}
printf("Device supports %s and is %s\n%s\n",
(gBuf[0] & 0x1f)? "TapeAlerts" : "S.M.A.R.T.",
(smartsupport & DEXCPT_ENABLE)? "Disable" : "Enabled",
(smartsupport & EWASC_ENABLE)? "Temperature Warning Enabled":
"Temperature Warning Disabled or Not Supported");
}
void scsiSmartEnable( int device)
{
/* Enable Exception Control */
if ( scsiSmartDEXCPTDisable(device) != 0)
{
exit (1);
}
printf("S.M.A.R.T. enabled\n");
if (scsiSmartEWASCEnable(device) != 0)
{
printf("Temperature Warning not Supported\n");
}
else
{
printf("Temperature Warning Enabled\n");
}
return;
}
void scsiSmartDisable (int device)
{
if ( scsiSmartDEXCPTEnable(device) != 0)
{
exit (1);
}
printf("S.M.A.R.T. Disabled\n");
}
void scsiPrintTemp (int device)
{
UINT8 temp;
UINT8 trip;
if ( scsiGetTemp(device, &temp, &trip) != 0)
{
exit (1);
}
printf("Current Drive Temperature: %d C\n", temp);
printf("Drive Trip Temperature: %d C\n", trip);
}
void scsiPrintStopStart ( int device )
{
/**
unsigned int css;
if ( scsiGetStartStop(device, unsigned int *css) != 0)
{
exit (1);
}
printf ("Start Stop Count: %d\n", css);
**/
}
void scsiPrintMain (char *device, int fd)
{
int checkedsupportlogpages = 0;
// See if unit accepts SCSI commmands from us
if (testunitnotready(fd)){
printf("Smartctl: device %s failed Test Unit Ready\n", device);
exit(1);
}
if (con->driveinfo)
scsiGetDriveInfo(fd);
if (con->smartenable)
scsiSmartEnable(fd);
if (con->smartdisable)
scsiSmartDisable(fd);
if (con->checksmart)
{
scsiGetSupportPages (fd);
checkedsupportlogpages = 1;
if(gTapeAlertsPage)
scsiGetTapeAlertsData (fd);
else
{
scsiGetSmartData(fd);
if(gTempPage)
scsiPrintTemp(fd);
if(gStartStopPage)
scsiGetStartStopData (fd);
}
}
if (con->smartselftestlog) {
if (! checkedsupportlogpages)
scsiGetSupportPages(fd);
if (gSelfTestPage)
scsiPrintSelfTest(fd);
}
if ( con->smartexeoffimmediate )
{
if ( scsiSmartOfflineTest (fd) != 0)
{
printf( "Smartctl: Smart Offline Failed\n");
exit(-1);
}
printf ("Drive Command Successful offline test has begun\n");
printf ("Use smartctl -X to abort test\n");
}
if ( con->smartshortcapselftest )
{
if ( scsiSmartShortCapSelfTest (fd) != 0)
{
printf( "Smartctl: Smart Short Self Test Failed\n");
exit(-1);
}
printf ("Drive Command Successful Short Self test has begun\n");
printf ("Use smartctl -X to abort test\n");
}
if ( con->smartshortselftest )
{
if ( scsiSmartShortSelfTest (fd) != 0)
{
printf( "Smartctl: Smart Short Self Test Failed\n");
exit(-1);
}
printf ("Drive Command Successful Short Self test has begun\n");
printf ("Use smartctl -X to abort test\n");
}
if ( con->smartextendselftest )
{
if ( scsiSmartExtendSelfTest (fd) != 0)
{
printf( "S.M.A.R.T. Extended Self Test Failed\n");
exit(-1);
}
printf ("Drive Command Successful Extended Self test has begun\n");
printf ("Use smartctl -X to abort test\n");
}
if ( con->smartextendcapselftest )
{
if ( scsiSmartExtendCapSelfTest (fd) != 0)
{
printf( "S.M.A.R.T. Extended Self Test Failed\n");
exit(-1);
}
printf ("Drive Command Successful Extended Self test has begun\n");
printf ("Use smartctl -X to abort test\n");
}
if ( con->smartselftestabort )
{
if ( scsiSmartSelfTestAbort (fd) != 0)
{
printf( "S.M.A.R.T. Self Test Abort Failed\n");
exit(-1);
}
printf ("Drive Command Successful self test aborted\n");
}
}
This diff is collapsed.
This diff is collapsed.
/*
* utility.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
*
* 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/
*
*/
// THIS FILE IS INTENDED FOR UTILITY ROUTINES THAT ARE APPLICABLE TO
// BOTH SCSI AND ATA DEVICES, AND THAT MAY BE USED IN SMARTD,
// SMARTCTL, OR BOTH.
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdlib.h>
#include "utility.h"
// Any local header files should be represented by a CVSIDX just below.
const char* utility_c_cvsid="$Id: utility.cpp,v 1.4 2003/02/09 21:12:33 ballen4705 Exp $" UTILITY_H_CVSID;
// Utility function prints date and time and timezone into a character
// buffer of length>=64. All the fuss is needed to get the right
// timezone info (sigh).
void dateandtimezoneepoch(char *buffer, time_t tval){
struct tm *tmval;
char *timezonename;
char datebuffer[64];
// Get the time structure. We need this to determine if we are in
// daylight savings time or not.
tmval=localtime(&tval);
// Convert to an ASCII string, put in datebuffer
asctime_r(tmval, datebuffer);
// Remove newline
datebuffer[strlen(datebuffer)-1]='\0';
// correct timezone name
if (tmval->tm_isdst==0)
// standard time zone
timezonename=tzname[0];
else if (tmval->tm_isdst>0)
// daylight savings in effect
timezonename=tzname[1];
else
// unable to determine if daylight savings in effect
timezonename="";
// Finally put the information into the buffer as needed.
snprintf(buffer, 64, "%s %s", datebuffer, timezonename);
return;
}
// Date and timezone gets printed into string pointed to by buffer
void dateandtimezone(char *buffer){
// Get the epoch (time in seconds since Jan 1 1970)
time_t tval=time(NULL);
dateandtimezoneepoch(buffer, tval);
return;
}
// These are two utility functions for printing CVS IDs. Massagecvs()
// returns distance that it has moved ahead in the input string
int massagecvs(char *out, const char *cvsid){
char *copy,*filename,*date,*version;
const char delimiters[] = " ,$";
// make a copy on stack, go to first token,
if (!(copy=strdup(cvsid)) || !(filename=strtok(copy, delimiters)))
return 0;
// move to first instance of "Id:"
while (strcmp(filename,"Id:"))
if (!(filename=strtok(NULL, delimiters)))
return 0;
// get filename, skip "v", get version and date
if (!( filename=strtok(NULL, delimiters) ) ||
!( strtok(NULL, delimiters) ) ||
!( version=strtok(NULL, delimiters) ) ||
!( date=strtok(NULL, delimiters) ) )
return 0;
sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date);
free(copy);
return (date-copy)+strlen(date);
}
// prints a single set of CVS ids
void printone(char *block, const char *cvsid){
char strings[CVSMAXLEN];
const char *here=cvsid;
int line=1,len=strlen(cvsid)+1;
// check that the size of the output block is sufficient
if (len>=CVSMAXLEN) {
fprintf(stderr,"CVSMAXLEN=%d must be at least %d\n",CVSMAXLEN,len+1);
exit(1);
}
// loop through the different strings
while ((len=massagecvs(strings,here))){
switch (line++){
case 1:
block+=snprintf(block,CVSMAXLEN,"Module:");
break;
default:
block+=snprintf(block,CVSMAXLEN," uses:");
}
block+=snprintf(block,CVSMAXLEN," %s\n",strings);
here+=len;
}
return;
}
// A replacement for perror() that sends output to our choice of
// printing.
void syserror(const char *message){
const char *errormessage;
// Get the correct system error message:
errormessage=strerror(errno);
// Check that caller has handed a sensible string, and provide
// appropriate output. See perrror(3) man page to understand better.
if (message && *message)
pout("%s: %s\n",message, errormessage);
else
pout("%s\n",errormessage);
return;
}
#!/bin/bash
# execute this script in the current shell, using for example
# . cvs_script
unset CVS_SERVER
export CVS_RSH=ssh
export CVSROOT=:ext:ballen4705@cvs.smartmontools.sourceforge.net:/cvsroot/smartmontools
[root@ballen www]# /usr/sbin/smartctl -am /dev/hda
smartctl version 5.0-25 Copyright (C) 2002 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: HITACHI_DK23BA-20
Serial Number: 12H7M8
Firmware Version: 00E0A0D2
ATA Version is: 5
ATA Standard is: ATA/ATAPI-5 T13 1321D revision 1
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
See vendor-specific Attribute list for marginal Attributes.
General SMART Values:
Off-line data collection status: (0x00) Offline data collection activity was
never started.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete off-line
data collection: (1530) seconds.
Offline data collection
capabilities: (0x1b) SMART execute Offline immediate.
Automatic timer ON/OFF support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 26) minutes.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000d 100 083 050 Pre-fail - 677
3 Spin_Up_Time 0x0007 100 100 050 Pre-fail - 0
4 Start_Stop_Count 0x0032 100 100 050 Old_age - 249
5 Reallocated_Sector_Ct 0x0033 099 099 010 Pre-fail - 30
7 Seek_Error_Rate 0x000f 100 100 050 Pre-fail - 319
9 Power_On_Hours 0x0032 099 099 060 Old_age - 701 h + 42 m
10 Spin_Retry_Count 0x0013 100 100 050 Pre-fail - 0
12 Power_Cycle_Count 0x0032 100 100 050 Old_age - 249
192 Power-Off_Retract_Count 0x0032 100 100 050 Old_age - 15
195 Hardware_ECC_Recovered 0x001a 100 001 050 Old_age In_the_past 559
196 Reallocated_Event_Count 0x0032 097 097 001 Old_age - 30
197 Current_Pending_Sector 0x0032 095 095 001 Old_age - 5
198 Offline_Uncorrectable 0x0010 095 095 001 Old_age - 31
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age - 0
221 G-Sense_Error_Rate 0x000a 100 100 050 Old_age - 0
223 Load_Retry_Count 0x0012 100 100 050 Old_age - 0
225 Load_Cycle_Count 0x0032 095 095 050 Old_age - 18446744072753281791
230 Unknown_Attribute 0x0032 100 100 060 Old_age - 18484
250 Unknown_Attribute 0x000a 100 070 050 Old_age - 601
SMART Error Log Version: 1
ATA Error Count: 9 (device log contains only the most recent five errors)
DCR = Device Control Register
FR = Features Register
SC = Sector Count Register
SN = Sector Number Register
CL = Cylinder Low Register
CH = Cylinder High Register
D/H = Device/Head Register
CR = Content written to Command Register
ER = Error register
STA = Status register
Timestamp is seconds since the previous disk power-on.
Note: timestamp "wraps" after 2^32 msec = 49.710 days.
Error 1 occurred at disk power-on lifetime: 458 hours
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER:40 SC:01 SN:15 CL:be CH:2e D/H:e0 ST:51
Sequence of commands leading to the command that caused the error were:
DCR FR SC SN CL CH D/H CR Timestamp
00 00 01 15 be 2e e0 c8 831.599
00 00 01 14 be 2e e0 c8 831.594
00 00 01 13 be 2e e0 c8 831.594
00 00 01 12 be 2e e0 c8 831.594
00 00 01 11 be 2e e0 c8 831.594
Error 2 occurred at disk power-on lifetime: 458 hours
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER:40 SC:45 SN:15 CL:be CH:2e D/H:e0 ST:51
Sequence of commands leading to the command that caused the error were:
DCR FR SC SN CL CH D/H CR Timestamp
00 00 80 da bd 2e e0 c8 829.680
00 00 80 5a bd 2e e0 c8 829.677
00 00 80 da bc 2e e0 c8 829.673
00 00 80 5a bc 2e e0 c8 829.671
00 00 01 58 bc 2e e0 c8 829.671
Error 3 occurred at disk power-on lifetime: 458 hours
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER:40 SC:01 SN:47 CL:bc CH:2e D/H:e0 ST:51
Sequence of commands leading to the command that caused the error were:
DCR FR SC SN CL CH D/H CR Timestamp
00 00 01 47 bc 2e e0 c8 826.962
00 00 01 46 bc 2e e0 c8 826.961
00 00 01 45 bc 2e e0 c8 826.961
00 00 01 44 bc 2e e0 c8 826.961
00 00 01 43 bc 2e e0 c8 826.961
Error 4 occurred at disk power-on lifetime: 458 hours
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER:40 SC:13 SN:47 CL:bc CH:2e D/H:e0 ST:51
Sequence of commands leading to the command that caused the error were:
DCR FR SC SN CL CH D/H CR Timestamp
00 00 80 da bb 2e e0 c8 825.038
00 00 80 5a bb 2e e0 c8 825.033
00 00 80 da ba 2e e0 c8 825.030
00 00 80 5a ba 2e e0 c8 824.940
00 00 80 da b9 2e e0 c8 824.937
Error 5 occurred at disk power-on lifetime: 458 hours
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER:40 SC:01 SN:85 CL:19 CH:2c D/H:e0 ST:51
Sequence of commands leading to the command that caused the error were:
DCR FR SC SN CL CH D/H CR Timestamp
00 00 01 85 19 2c e0 c8 816.487
00 00 01 84 19 2c e0 c8 816.487
00 00 01 83 19 2c e0 c8 816.486
00 00 01 82 19 2c e0 c8 816.486
00 00 01 81 19 2c e0 c8 816.486
SMART Self-test log, version number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short off-line Completed 00% 691
# 2 Extended off-line Completed: read failure 40% 661 0x002c1985
# 3 Extended off-line Completed: read failure 40% 661 0x002c1985
# 4 Short off-line Completed 00% 660
# 5 Extended off-line Completed: read failure 40% 658 0x002c1985
# 6 Short off-line Completed 00% 658
# 7 Short off-line Completed 00% 658
# 8 Extended off-line Completed: read failure 40% 658 0x002c1985
# 9 Extended off-line Completed: read failure 40% 657 0x002c1985
#10 Short off-line Completed 00% 647
#11 Short off-line Completed 00% 587
#12 Short off-line Completed 00% 583
#13 Short off-line Completed 00% 551
#14 Short captive Interrupted (host reset) 40% 551
#15 Short off-line Completed 00% 551
#16 Extended off-line Completed: read failure 40% 550 0x002c1985
#17 Extended off-line Aborted by host 50% 550
#18 Short off-line Completed 00% 550
#19 Short off-line Completed 00% 537
#20 Extended off-line Completed: read failure 40% 536 0x002c1985
#21 Short off-line Completed 00% 536
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment