smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
smartctl.h
Go to the documentation of this file.
00001 /*
00002  * smartctl.h
00003  *
00004  * Home page of code is: http://smartmontools.sourceforge.net
00005  *
00006  * Copyright (C) 2002-10 Bruce Allen <smartmontools-support@lists.sourceforge.net>
00007  * Copyright (C) 2008-10 Christian Franke <smartmontools-support@lists.sourceforge.net>
00008  * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * (for example COPYING); if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  *
00019  * This code was originally developed as a Senior Thesis by Michael Cornwell
00020  * at the Concurrent Systems Laboratory (now part of the Storage Systems
00021  * Research Center), Jack Baskin School of Engineering, University of
00022  * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
00023  *
00024  */
00025 
00026 #ifndef SMARTCTL_H_
00027 #define SMARTCTL_H_
00028 
00029 #define SMARTCTL_H_CVSID "$Id: smartctl.h 3727 2012-12-13 17:23:06Z samm2 $\n"
00030 
00031 // Return codes (bitmask)
00032 
00033 // command line did not parse, or internal error occured in smartctl
00034 #define FAILCMD   (0x01<<0)
00035 
00036 // device open failed
00037 #define FAILDEV   (0x01<<1)
00038 
00039 // device is in low power mode and -n option requests to exit
00040 #define FAILPOWER (0x01<<1)
00041 
00042 // read device identity (ATA only) failed
00043 #define FAILID    (0x01<<1)
00044 
00045 // smart command failed, or ATA identify device structure missing information
00046 #define FAILSMART (0x01<<2)
00047 
00048 // SMART STATUS returned FAILURE
00049 #define FAILSTATUS (0x01<<3)
00050 
00051 // Attributes found <= threshold with prefail=1
00052 #define FAILATTR (0x01<<4)
00053 
00054 // SMART STATUS returned GOOD but age attributes failed or prefail
00055 // attributes have failed in the past
00056 #define FAILAGE (0x01<<5)
00057 
00058 // Device had Errors in the error log
00059 #define FAILERR (0x01<<6)
00060 
00061 // Device had Errors in the self-test log
00062 #define FAILLOG (0x01<<7)
00063 
00064 // Classes of SMART commands.  Here 'mandatory' means "Required by the
00065 // ATA/ATAPI-5 Specification if the device implements the S.M.A.R.T.
00066 // command set."  The 'mandatory' S.M.A.R.T.  commands are: (1)
00067 // Enable/Disable Attribute Autosave, (2) Enable/Disable S.M.A.R.T.,
00068 // and (3) S.M.A.R.T. Return Status.  All others are optional.
00069 enum failure_type {
00070   OPTIONAL_CMD,
00071   MANDATORY_CMD,
00072 };
00073 
00074 // Globals to set failuretest() policy
00075 extern bool failuretest_conservative;
00076 extern unsigned char failuretest_permissive;
00077 
00078 // Compares failure type to policy in effect, and either exits or
00079 // simply returns to the calling routine.
00080 void failuretest(failure_type type, int returnvalue);
00081 
00082 // Globals to control printing
00083 extern bool printing_is_switchable;
00084 extern bool printing_is_off;
00085 
00086 // Printing control functions
00087 inline void print_on()
00088 {
00089   if (printing_is_switchable)
00090     printing_is_off = false;
00091 }
00092 inline void print_off()
00093 {
00094   if (printing_is_switchable)
00095     printing_is_off = true;
00096 }
00097 
00098 #endif