s.m.a.r.t dll library api

35
PassMark ® Software S.M.A.R.T. DLL Library API Page 1 of 35 PassMark Software 11-Nov-08 Copyright PassMark 2008 SDK S.M.A.R.T. DLL Library API PassMark’s SmartDisk DLL API functions for obtaining S.M.A.R.T Attributes Document: S.M.A.R.T. DLL Library API Author: S.K. Tan Company: PassMark Software (http://www.passmark.com) Date: 11 November 2008 Edition: Ed 1.6 File: SmartDiskSDK.pdf

Upload: others

Post on 12-Sep-2021

28 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 1 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

SDK

S.M.A.R.T. DLL Library API

PassMark’s SmartDisk DLL API functions for obtaining S.M.A.R.T Attributes

Document: S.M.A.R.T. DLL Library API

Author: S.K. Tan

Company: PassMark Software (http://www.passmark.com)

Date: 11 November 2008

Edition: Ed 1.6

File: SmartDiskSDK.pdf

Page 2: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 2 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

TABLE OF CONTENTS

TABLE OF CONTENTS ................................................................................................................................................................................................................................................... 2

REVISION HISTORY ....................................................................................................................................................................................................................................................... 4

1.0 INTRODUCTION .................................................................................................................................................................................................................................................. 4

1.1 SMARTDISK DLL BUILD ENVIRONMENT .............................................................................................................................................................................................................. 4

2.0 SMARTDISK DLL OVERVIEW ......................................................................................................................................................................................................................... 5

2.1 WHAT IS INCLUDED IN THE SMARTDISK DLL PACKAGE? ..................................................................................................................................................................................... 5 2.2 MICROSOFT VISUAL STUDIO C/C++ PROJECT PROPERTIES ................................................................................................................................................................................... 5 2.3 USING SMARTDISK DLL IN VISUAL BASIC ........................................................................................................................................................................................................... 7 2.4 USING SMARTDISK DLL IN C# ............................................................................................................................................................................................................................. 7 2.5 SYSTEM REQUIREMENTS ....................................................................................................................................................................................................................................... 7

3.0 SMARTDISK DLL APIS ...................................................................................................................................................................................................................................... 8

3.1 MEANING OF “DEVICE ID” AND “DRIVE NUMBER” WHEN CALLING SMARTDISK_XXX API FUNCTIONS ............................................................................................................... 8 3.2 SMARTDISK DLL API FUNCTION CALLS (SMARTDLL_XXX) ................................................................................................................................................................................ 9

SmartDll_GetVersion ................................................................................................................................................................................................................................................... 9 SmartDll_Init................................................................................................................................................................................................................................................................ 9 SmartDll_Cleanup ........................................................................................................................................................................................................................................................ 9 SmartDll_Refresh ....................................................................................................................................................................................................................................................... 10 SmartDll_GetNumSmartDevices ................................................................................................................................................................................................................................ 10 SmartDll_GetNumDetectedDrives ............................................................................................................................................................................................................................. 10 SmartDll_IsValidSmartDevice ................................................................................................................................................................................................................................... 10 SmartDll_GetDevicePartitionInfo .............................................................................................................................................................................................................................. 11 SmartDll_GetDriveLetterFromDriveNum ................................................................................................................................................................................................................. 11 SmartDll_GetDeviceSerialNumber ............................................................................................................................................................................................................................ 11 SmartDll_GetDeviceVendorUnique ........................................................................................................................................................................................................................... 12 SmartDll_GetDeviceFirmwareRev ............................................................................................................................................................................................................................ 12 SmartDll_GetDeviceModelNumber ........................................................................................................................................................................................................................... 12 SmartDll_GetDeviceCapacity .................................................................................................................................................................................................................................... 12 SmartDll_GetVolumeCapacity ................................................................................................................................................................................................................................... 13 SmartDll_GetSmartDeviceIDFirst ............................................................................................................................................................................................................................. 13 SmartDll_GetSmartDeviceIDNext ............................................................................................................................................................................................................................. 13 SmartDll_GetNumSmartAttr ...................................................................................................................................................................................................................................... 13

Page 3: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 3 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

SmartDll_GetSmartAttributeIDFirst .......................................................................................................................................................................................................................... 14 SmartDll_GetSmartAttributeIDNext .......................................................................................................................................................................................................................... 14 SmartDll_GetSmartAttributeByID ............................................................................................................................................................................................................................. 14 SmartDll_GetAttrDescByID ....................................................................................................................................................................................................................................... 15 SmartDll_GetDeviceInfo ............................................................................................................................................................................................................................................ 15 SmartDll_ExportReport ............................................................................................................................................................................................................................................. 15 SmartDll_RecordTECData ........................................................................................................................................................................................................................................ 16 SmartDll_GetTECDataSetCount ................................................................................................................................................................................................................................ 16 SmartDll_ExportTECData ......................................................................................................................................................................................................................................... 16 SmartDll_GetTECDataAtIndex .................................................................................................................................................................................................................................. 17 SmartDll_EstimateTECByAttributeID ....................................................................................................................................................................................................................... 17 SmartDll_EstimateTEC .............................................................................................................................................................................................................................................. 18

3.3 EXAMPLE USAGE OF SMARTDISK DLL APIS ...................................................................................................................................................................................................... 18 3.4 EXAMPLE EXPORTED SMARTDISK DLL REPORT ................................................................................................................................................................................................. 18

4.0 DRIVE INFORMATION AND S.M.A.R.T. ATTRIBUTES ............................................................................................................................................................................ 19

4.1 UNDERSTANDING THE DEVICE INFORMATION...................................................................................................................................................................................................... 19 4.2 WHAT IS S.M.A.R.T.? ......................................................................................................................................................................................................................................... 20 4.2.2 UNDERSTANDING S.M.A.R.T. ATTRIBUTES .................................................................................................................................................................................................... 21

Attribute Types (as defined in “SmartDisk.h”) .......................................................................................................................................................................................................... 21 The Attributes (as defined in “SmartDisk.h”) ............................................................................................................................................................................................................ 21

5.0 PREDICTING TEC (THRESHOLD EXCEED CONDITION) WITH S.M.A.R.T ATTRIBUTES ............................................................................................................ 27

5.1 HOW DOES IT PREDICT? ....................................................................................................................................................................................................................................... 27 5.2 IMPORTANT INFORMATION ON FAILURE PREDICTION ......................................................................................................................................................................................... 29

6.0 SMARTDISK DLL ERROR CODES ................................................................................................................................................................................................................ 30

7.0 LICENSE & INTELLECTUAL PROPERTY RIGHTS .................................................................................................................................................................................. 33

8.0 SPECIFIC DISCLAIMER ON FAILURE PREDICTIONS ............................................................................................................................................................................ 33

9.0 PURCHASING INFORMATION ...................................................................................................................................................................................................................... 33

10.0 CONTACTING PASSMARK® SOFTWARE ................................................................................................................................................................................................... 34

INDEX OF API FUNCTION NAMES ........................................................................................................................................................................................................................... 35

Page 4: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 4 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

REVISION HISTORY

Revision Revision History Author Date

Ed 1.6 Updated description of SmartDll_GetNumDetectedDrives() to match new

behavior. (Now detects unformatted drives)

MF 11/Nov/2008

Ed 1.5 Added note about C# example project. MF 18/Dec/2007

Ed 1.4 Added several extra SMART attribute descriptions. MF 16/Jul/2007

Ed 1.3 Added “STATUS_ERR_NO_ADMIN_RIGHTS” in “SmartDisk DLL Error

Codes” chapter.

SK 04/Dec/2006

Ed 1.2 Updated description of functions. Added “2.4 System Requirements” and “5.2

Important Information on Failure Prediction”. Added function

SmartDll_GetNumSmartAttr.

SK 18/Oct/2006

Ed 1.1 Added additional parameter to SmartDll_Init that allow user to specify name of

debug file to write to.

SK 04/Oct/2006

Ed 1.0 Released for public. SK 26/Sep/2006

1.0 Introduction

PassMark™ Software produces a DLL (dynamic link library) that allows application to gather S.M.A.R.T. (Self-Monitoring Analysis and Reporting Technology) attributes for your

system‟s S.M.A.R.T. enabled ATA (or IDE) and SATA (Serial-ATA) drive(s).

This document details PassMark‟s SmartDisk DLL library, instructions (and settings) on how to use it and its API (Application Programming Interface) function calls.

1.1 SmartDisk DLL Build Environment

The API has been designed and tested to run on Windows 2000, Server 2003, XP and Vista. Non-Windows operating systems are not supported. The example source code and the

DLL were built using Microsoft Visual Studio 2005 but any development language that can call a Windows DLL should be compatible. Example code is provided in C/C++, VB

(Visual Basic) and C#.

Page 5: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 5 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

2.0 SmartDisk DLL Overview

SmartDisk DLL is a dynamic loadable library that you can add to your application development to gather S.M.A.R.T. attributes for S.M.A.R.T. enabled ATA (IDE) and SATA

(Serial-ATA) drives. It provides a set of easy to use API functions that can easily be integrated into your software.

2.1 What is included in the SmartDisk DLL package?

The SmartDisk DLL package consists of the following files:

1) SmartDisk.dll (dynamic loadable library – contains the codes for the library)

2) SmartDisk.lib (imports certain SmartDisk DLL symbols and tells your project that it needs to load “SmartDisk.dll”)

3) SmartDisk.h (header file for SmartDisk_xxx API functions)

4) SmartDiskSDK.pdf (PDF users guide)

5) SmartDisk.def (Export definition file, showing all exported functions and their ordinal numbers)

6) An “example” folder that contains “TestSmartDiskLib” folder (C/C++ demo project) and “VBSmartDisk” folder (Visual Basic demo project).

2.2 Microsoft Visual Studio C/C++ Project Properties

To integrate SmartDisk DLL into your C/C++ project, your Microsoft Visual Studio project needs to include certain files and know where the DLL is when you build the solution.

The following steps are for VS2005 C++ Win32 Console Application. However, it should be similar for other languages and development environments.

1) Under the “Project:Properties:Configuration Properties:C/C++:General:Additional Include Directories”, include the folder that “SmartDisk.h” is located:

(you can skip this step if you copy “SmartDisk.h” directly into your project directory)

Page 6: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 6 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

2) Under the “Project:Properties:Configuration Properties:Linker:General:Additional Library Directories”, include the folder that “SmartDisk.lib” is located:

(you can skip this step if you copy “SmartDisk.lib” directly into your project directory)

3) Enter “SmartDisk.lib” in “Project:Properties:Configuration Properties:Linker:Input:Additional Dependencies”:

4) Put the path to “SmartDisk.dll” in the environment variable PATH or copy it into the same directory as your application‟s output directory.

That‟s it! You are all set to go!

Page 7: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 7 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

2.3 Using SmartDisk DLL in Visual Basic

It is possible to use SmartDisk DLL in Visual Basic. Many VB users experience difficulty when they need to call a C/C++ function that uses pointers to variables. For your

convenience, we have included a demo project called “VBSmartDisk” that can be found in the “example” folder of the SDK package. Please refer to the comments in the Visual

Basic source file “Form1.vb” on how to use SmartDisk DLL API calls from VB.

2.4 Using SmartDisk DLL in C#

It is also possible to use SmartDisk DLL in C#. Like with Visual Basic, we have included an example project on how to do this called “TestSmartDiskLibCSharp”.

2.5 System requirements

A hard drive and BIOS that supports SMART, plus compatible drivers. Most recent hard drives are OK but drives connected via SCSI or hardware RAID will not work. But drives

connected via SATA (serial ATA) are supported. Drives configured as software RAID (dynamic disks) via Windows Disk Management will also work.

Page 8: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 8 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

3.0 SmartDisk DLL APIs

This section documents SmartDisk DLL‟s Application Programming Interface (API) functions.

3.1 Meaning of “Device ID” and “Drive Number” when calling SmartDisk_xxx API functions

Most of SmartDisk DLL‟s API function uses an argument called “device ID”. The device ID is used to identify the physical device that you wish to get something from. Do not

try and guess the device ID to be passed into the function. Instead, use SmartDll_GetSmartDeviceIDFirst and SmartDll_GetSmartDeviceIDNext to get this number. Quite often, a

physical disk has multiple partitions. To check if a disk has multiple partitions, call SmartDll_GetDevicePartitionInfo by passing in the device ID. The 2nd

parameter stores the

actual number of partitions and the 1st parameter stores an array of all the drive numbers of the partitions. The drive number is an enumeration of all detected drive letters. In short,

the drive number enumeration is such – “A:\” drive correspond to drive number 0, “B:\” drive corresponds to drive number 1, “C:\” drive corresponds to drive number 2

and so on…hence “Z:\” corresponds to drive number 25. To obtain the corresponding drive letters from their drive numbers, call SmartDll_GetDriveLetterFromDriveNum.

For the example below, drive numbers 2 and 3 belong to the same device ID 0.

Page 9: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 9 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

3.2 SmartDisk DLL API function calls (SmartDll_xxx)

All SmartDisk DLL API functions have the naming convention SmartDll_xxx().

SmartDll_GetVersion

const char* SmartDll_GetVersion(void)

Description: Call this function to return the DLL‟s version string. This function returns a pointer to constant characters (via use of a static buffer). Attempting to change the

value(s) of constant characters is an error. No attempt should be made to free the character buffer returned by this function.

Arguments: None

Returns: Version string

Note: This is the only function that can be called without error before SmartDll_Init.

Example output: SmartDisk DLL SDK v1.0 (Build 1000)

SmartDll_Init

int SmartDll_Init(bool debug, char *iDebugFile=NULL, bool iRecordTEC=true)

Description: Call this function to initialize usage of this DLL. This function should only be called once. It makes an initial call to gather the S.M.A.R.T. values and allocates

memory for DLL‟s use. If debug is true, debug messages will be logged to a file. If iDebugFile is not NULL, logs will be written to this file. Otherwise, debug

log will be written to “SmartDisk.log”. If iRecordTEC is true, it records S.M.A.R.T. values for all the available S.M.A.R.T. devices discovered. If SmartDll_Init

is not called first, subsequent SmartDll API calls will fail.

Arguments:

(In) debug - A flag specifying if internal debug messages should be logged (to "SmartDisk.log")

(In) iDebugFile – The name of the debug file to write to. If NULL, "SmartDiskDebug.log" will be used.

(In) iRecordTEC - A flag specifying if we want to record and write all SMART attributes to a binary file for the purpose of TEC prediction. This value defaults to true.

Returns: STATUS_SUCCESS (0) if OK or negative error code

Note: SmartDll_Cleanup must be called afterwards to de-allocate memory.

SmartDll_Cleanup

void SmartDll_Cleanup(void)

Description: Call this function to clean up memory usage of the DLL when done with it. It de-allocates all memory that was allocated and used by SmartDisk DLL. Calling

subsequent SmartDll API calls after SmartDll_Cleanup is an error.

Arguments: None

Returns: None

Note: SmartDll_Cleanup should only be called after SmartDll_Init.

Page 10: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 10 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

SmartDll_Refresh

int SmartDll_Refresh (bool iRecordTEC=false)

Description: Call this function to refresh (and re-probe) all SMART devices. If iRecordTEC is true, it records S.M.A.R.T. values for all the available S.M.A.R.T. devices

discovered.

Arguments:

(In) iRecordTEC - A flag specifying if we want to record and write all SMART attributes to a binary file for the purpose of TEC prediction. This value defaults to true.

Returns: STATUS_SUCCESS (0) if OK or negative error code.

Note: This function should not be called between SmartDll_GetSmartDeviceIDFirst and SmartDll_GetSmartDeviceIDNext and also between

SmartDll_GetSmartAttributeIDFirst and SmartDll_GetSmartAttributeIDNext. As SmartDisk DLL uses iterators to return these values, calling SmartDll_Refresh

between these functions messes up the iterators.

SmartDll_GetNumSmartDevices

int SmartDll_GetNumSmartDevices(void)

Description: Call this function to return the total number of S.M.A.R.T. devices detected

Arguments: None

Returns: Total number of SMART devices detected. If there is an error, a negative error code will be returned.

SmartDll_GetNumDetectedDrives

int SmartDll_GetNumDetectedDrives(void)

Description: Call this function to return the total number of fixed drives, including drives that have no drive letter. A fixed drive is a drive that cannot be removed, for example

a fixed hard drive.

Arguments: None

Returns: Total number of fixed drives, including drives that have no drive letter.

Note: Drives with multiple drive letters assigned will be counted once per drive letter. Unassigned drives will be counted once.

SmartDll_IsValidSmartDevice

int SmartDll_IsValidSmartDevice (int iDeviceID)

Description: Checks if a device ID is a SMART device

Arguments:

(In) iDeviceID – Device ID to check

Returns: STATUS_SUCCESS (0) if OK or negative error code

Page 11: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 11 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

SmartDll_GetDevicePartitionInfo

int SmartDll_GetDevicePartitionInfo (int *ioDriveNumSameDisk, int* ioNumPartition, int iDeviceID)

Description: Checks if the current device ID has multiple partitions. This function is not supported in Windows 95, 98 and ME.

Arguments:

(In/Out) ioDriveNumSameDisk - array of integers that will store the drive numbers of all the volumes that share the same physical disk

(In/Out) ioNumPartition - The buffer size of the integer array. On return, contains the actual number of items on the array. If buffer is not big enough,

STATUS_ERR_BUFFER_TOO_SMALL will be returned.

(In) iDeviceID – Device ID to check

Returns: STATUS_SUCCESS (0) if OK or negative error code

Note: A physical disk can have multiple partitions. For example:

A: (floppy) - drive number 0

C: (1st partition on physcial disk 0) - drive number 2

D: (2nd partition on physcial disk 0) - drive number 3

E: (cdrom) - drive number 4

If we call this function and pass in device ID 0, we will get:

ioDriveNumSameDisk = [2,3],

ioNumPartition = 2

Use SmartDll_GetDriveLetterFromDriveNum to convert the drive number to their corresponding letters.

SmartDll_GetDriveLetterFromDriveNum

int SmartDll_GetDriveLetterFromDriveNum (char* ioDriveLetter, int iDriveNum)

Description: Get the drive letter from the drive number

Arguments:

(In/Out) ioDriveLetter - pointer to a character

(In) iDriveNum - drive number to check

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetDeviceSerialNumber

int SmartDll_GetDeviceSerialNumber (char* ioBuf, int* ioLen, int iDeviceID)

Description: Get the serial number of the SMART device. Use a buffer of size SERIAL_NUM_LEN (as defined in “SmartDisk.h”) to store the serial number string.

Arguments:

(In/Out) ioBuf - Pre-allocated character buffer to hold serial number string

(In/Out) ioLen - Length of buffer. On return, contains actual serial number string length

(In) iDeviceID - Device ID to get (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Page 12: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 12 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetDeviceVendorUnique

int SmartDll_GetDeviceVendorUnique (USHORT *ioBuf, int* ioLen, int iDeviceID)

Description: Get the vendor unique ID of the SMART device. Use a buffer of size VENDOR_UNIQUE_LEN (as defined in “SmartDisk.h”) to store the vendor unique id.

Arguments:

(In/Out) ioBuf - Pre-allocated character buffer to hold serial number string. Vendor unique ID is 3*sizeof(USHORT) long.

(In/Out) ioLen - Length of buffer. On return, contains actual serial number string length

(In) iDeviceID - Device ID to get (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetDeviceFirmwareRev

int SmartDll_GetDeviceFirmWareRev (char* ioBuf, int* ioLen, int iDeviceID)

Description: Get the firmware revision number of the SMART device. Use a buffer of size FIRMWARE_REV_LEN (as defined in “SmartDisk.h”) to store the firmware

revision string.

Arguments:

(In/Out) ioBuf - Pre-allocated character buffer to hold firmware revision string

(In/Out) ioLen - Length of buffer. On return, contains actual firmware revision string length

(In) iDeviceID - Device ID to get (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetDeviceModelNumber

int SmartDll_GetDeviceModelNumber (char* ioBuf, int* ioLen, int iDeviceID)

Description: Get the drive model number of the SMART device. Use a buffer of size MODEL_NUM_LEN (as defined in “SmartDisk.h”) to store the firmware revision string.

Arguments:

(In/Out) ioBuf - Pre-allocated character buffer to hold drive model number string

(In/Out) ioLen - Length of buffer. On return, contains actual drive model number string length

(In) iDeviceID - Device ID to get (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetDeviceCapacity

int SmartDll_GetDeviceCapacity (int* ioCapacity, int iDeviceID)

Description: Get the capacity in MB of the SMART device. This function is not supported in Windows 95, 98 and ME.

Page 13: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 13 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Arguments:

(In/Out) ioCapacity - Pointer to an integer to hold capacity in MB

(In) iDeviceID - Device ID to get (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetVolumeCapacity

int SmartDll_GetDriveCapacity (int* ioCapacity, int iDriveNum)

Description: Get the capacity in MB of the volume represented by iDriveNum

Arguments:

(In/Out) ioCapacity - Pointer to an integer to hold capacity in MB

(In) iDriveNum - drive number to get (as returned from SmartDll_GetSmartDriveNumFirst or SmartDll_GetSmartDriveNumNext)

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetSmartDeviceIDFirst

int SmartDll_GetSmartDeviceIDFirst (void)

Description: Returns the Device ID of the first SMART device detected. If list is empty, STATUS_ERR_SMART_DEVICE_ID_EMPTY is returned.

Arguments: None

Returns: Device ID (non-negative) of the first discovered SMART device or a negative error code.

Note: Zero (0) is a valid and possible Device ID. To check if Device ID is valid, check that it is not negative.

SmartDll_GetSmartDeviceIDNext

int SmartDll_GetSmartDeviceIDNext (void)

Description: Returns the Device ID of the next SMART device detected (see “Note”). If we have reached last device ID, STATUS_ERR_SMART_DEVICE_ID_EOL will be

returned.

Arguments: None

Returns: Device ID (non-negative) of the next discovered SMART device or a negative error code.

Note: Zero (0) is a valid and possible Device ID. To check if Device ID is valid, check that it is not negative. You must call SmartDll_GetSmartDeviceIDFirst before

calling this function. If you call this function before calling SmartDll_GetSmartDeviceIDFirst, outcome is unpredictable.

SmartDll_GetNumSmartAttr

int SmartDll_GetNumSmartAttr (int iDeviceID)

Page 14: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 14 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Description: Returns the number of SMART attributes of the SMART device..

Arguments:

(In) iDeviceID - Device ID of the SMART device (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmarDeviceIDNext)

Returns: The number of SMART attribute of the device or a negative error code.

SmartDll_GetSmartAttributeIDFirst

int SmartDll_GetSmartAttributeIDFirst (int iDeviceID)

Description: Returns the next discovered attribute ID of the SMART device (see “Note”). If list is empty, STATUS_ERR_SMART_ATTR_ID_EMPTY is returned.

Arguments:

(In) iDeviceID - Device ID of the SMART device (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmarDeviceIDNext)

Returns: First discovered attribute ID (1-255) of the SMART device or a negative error code. Note that zero is not a valid attribute ID.

Note: Zero (0) is an invalid attribute ID. To check if attribute is valid, check for value greater than zero.

SmartDll_GetSmartAttributeIDNext

int SmartDll_GetSmartAttributeIDNext (int iDeviceID)

Description: Returns the next discovered attribute ID of the SMART device (see “Note”). If we have reached last attribute ID, STATUS_ERR_SMART_ATTR_ID_EOL is

returned.

Arguments:

(In) iDeviceID - Device ID of the SMART device (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Returns: Next discovered attribute ID (1-255) of the SMART device or a negative error code.

Note: Zero (0) is an invalid attribute ID. To check if attribute is valid, check for value greater than zero. You must call SmartDll_GetSmartAttributeFirst before calling

this function. If you call this function before calling SmartDll_ GetSmartAttributeFirst, outcome is unpredictable.

SmartDll_GetSmartAttributeByID

int SmartDll_GetSmartAttributeByID (void* ioPtr, int* ioLen, int iAttrID, int inAttrType, int iDeviceID)

Description: Get the attribute "value" of the SMART device according to which attribute ID you want to get

Arguments:

(In/Out) ioPtr - A pre-allocated pointer to the value type you want to get.

ATTR_TYPE_INT_STATUS: Pointer to integer (int*)

Get the integer value of the attribute‟s status (0 if ok, or 1 if threshold exceeded)

ATTR_TYPE_INT_VALUE: Pointer to integer (int*)

Get the integer value of the attribute‟s normalized current value

ATTR_TYPE_INT_RAW: Pointer to integer (int*)

Get the integer value of the attribute‟s raw value

Page 15: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 15 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

ATTR_TYPE_INT_WORST: Pointer to integer (int*)

Get the integer value of the attribute‟s normalized worst value

ATTR_TYPE_INT_THRESHOLD:Pointer to integer (int*)

Get the integer value of the attribute‟s normalized threshold value

ATTR_TYPE_STR_DESC: Pointer to char (char*)

Get string of the ttirbute‟s description

(In/Out) ioLen – (ATTR_TYPE_STR_DESC only) Length of pre-allocated character buffer. On returned, contains actual attribute value length

(In) iAttrID - Attribute ID you want to get (as returned from SmartDll_GetSmartAttributeIDFirst or SmartDll_GetSmartAttributeIDNext or as defined in

"SmartDisk.h")

(In) inAttrType - Attribute type you want to get (as defined in "SmartDisk.h")

(In) iDeviceID - Device ID of the SMART device (as returned from SmartDll_GetSmartDeviceIDFirst or SmartDll_GetSmartDeviceIDNext)

Returns: STATUS_SUCCESS (0) if OK or negative error code

Note: Values returned by this function will not change unless a call to SmartDll_Refresh is made.

SmartDll_GetAttrDescByID

int SmartDll_GetAttrDescByID (char *oBuf, int *ioLen, int iAttrID)

Description: Get the attribute description based on the attribute ID

Arguments:

(Out) oBuf - A pre-allocated buffer to hold the description string

(In/Out) ioLen - Length of buffer. On returned, contains the length of the desc string.

(In) iAttrID - Attribute ID that you want to get the description of

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetDeviceInfo

int SmartDll_GetDeviceInfo (DEVICEINFO *oDeviceInfo, int iDeviceID)

Description: Get the device information

Arguments:

(Out) oDeviceInfo - Pointer to a DEVICEINFO struct to hold the info

(In) iDeviceID - Device ID to get

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_ExportReport

int SmartDll_ExportReport(char *filename, int iDeviceID, char *iHeaderText, int iHeaderTextLen, int iExportFlags = 3,

int iHistoryAttr = 0)

Page 16: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 16 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Description: Exports the ASCII text report of all the SMART attributes of the chosen drive

Arguments:

Arguments:

(In) iDeviceID - Device ID to generate report from

(In) filename - File name to save to

(In) iHeaderText - Additional text that you want written to the start of the report.

(In) iHeaderTextLen - Length of iHeaderText. If zero, will ignore iHeaderText.

(In) iExportFlags - What data to export,

1 - Drive details

2 - SMART attributes

4 - SMART attributes history

Add together to combine (3 exports Drive details + SMART attributes)

(In) iExportFlags - which SMART attribute to export the history for. Or 0 for all attributes. (ignored if not exporting history)

Returns: STATUS_SUCCESS (0) if no error or negative error code

Note: iExportFlags and iExportFlags have default values that give the same behaviour as previous versions of this function.

SmartDll_RecordTECData

int SmartDll_RecordTECData (int iDeviceID)

Description: Records current set of normalized attribute value and raw value to a binary file for use with estimating threshold exceed condition (refer to Section 4.3).

Arguments:

(In) iDeviceID - Device ID that we want its attributes to be written to the binary file

Returns: STATUS_SUCCESS (0) if OK or negative error code

Note: The created binary file is named by appending ".bin" to the serial number of iDeviceID

SmartDll_GetTECDataSetCount

int SmartDll_GetTECDataSetCount (int* ioCount, int iDeviceID)

Description: Get count of TEC data sets recorded so far condition (refer to Section 4.3).

Arguments:

(In) iDeviceID - Device ID

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_ExportTECData

int SmartDll_ExportTECData (time_t* ioTimeArray, int* ioNormValArray, int* ioWorstValArray, int* ioArraySize, int

iAttrID, int iDeviceID)

Page 17: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 17 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Description: Copies the TEC data as specified by iDeviceID and iAttrID to the provided buffer. Both time (in time_t structures, i.e. number of seconds since 1970) and

normalized values are copied to ioTimeArray and ioNormValArray respectively condition (refer to Section 4.3).

Arguments:

(In/Out) ioTimeArray - Buffer to hold time_t values for time

(In/Out) ioNormValArray - Buffer to hold int values for normalized attribute value

(In/Out) ioWorstValArray - Buffer to hold int value for worst attribute value

(In/Out) ioNormValArraySize - Size of ioNormValArray. On successful return, contains actual count.

(In) iAttrID - Attribute ID

(In) iDeviceID - Device ID

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_GetTECDataAtIndex

int SmartDll_GetTECDataAtIndex (time_t* ioTimeArray, int* ioNormValArray, int* ioWorstValArray, int inIndex, int

iAttrID, int iDeviceID)

Description: Get the TEC record at index inIndex and as specified by iDeviceID and iAttrID.

Arguments:

(In/Out) ioTimeArray - Pointer to time_t to hold time

(In/Out) ioNormValArray - Pointer to int value to hold normalized value

(In/Out) ioWorstValArray - Pointer to int value to hold worst value

(In) inIndex - Index of TEC record that you want to get

(In) iAttrID - Attribute ID

(In) iDeviceID - Device ID

Returns: STATUS_SUCCESS (0) if OK or negative error code

SmartDll_EstimateTECByAttributeID

int SmartDll_EstimateTECByAttributeID (time_t* ioEarliest, time_t* ioLatest, int iAttrID, int iDeviceID)

Description: Estimates TEC based on recorded TEC data for iDeviceID and iAttrID.

Arguments:

(In/Out) ioEarliest - Earliest predicted time for failure

(In/Out) ioLatest - Latest predicted time for failure

(In) iAttrID - Attribute ID

(In) iDeviceID - Device ID

Returns: STATUS_SUCCESS (0) if no error or negative error code. However, note that the following is actually a warning rather than an error:

STATUS_WARN_TEC_ATTR_ID_NA: This means that the threshold value corresponding to the attribute ID is zero(0), meaning we have no threshold

value to work with to predict TEC.

Note: If STATUS_SUCCESS is returned, it means ioEarliest is definitely a valid value. ioLatest is valid only if it is not zero. Please check.

Page 18: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 18 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Disclaimer: Please read our disclaimer statement "Specific Disclaimer on Failure Predictions".

SmartDll_EstimateTEC

int SmartDll_EstimateTEC(time_t* ioEarliest, time_t* ioLatest, int* oAttrID, int iDeviceID)

Description: Estimates TEC based on all recorded TEC data and all applicable attributes for iDeviceID.

Arguments:

(In/Out) ioEarliest - Earliest predicted time for failure

(In/Out) ioLatest - Latest predicted time for failure

(Out) oAttrID - Predicted time is based on calculation of this attribute ID

(In) iDeviceID - Device ID

Returns: STATUS_SUCCESS (0) if no error or negative error code. However, note that the following are actually warnings rather than errors:

STATUS_WARN_TEC_NOT_ENOUGH_DATA: This means we do not have at minimum of 3 sets of TEC data to estimate TEC.

STATUS_WARN_TEC_UNABLE_TO_PREDICT: This means that that the TEC data recorded does not show any variance (i.e. they remain constant).

Hence, we cannot predict TEC.

Note: If STATUS_SUCCESS is returned, it means ioEarliest is definitely a valid value. ioLatest is valid only if it is not zero. Please check.

Disclaimer: Please read our disclaimer statement "Specific Disclaimer on Failure Predictions".

3.3 Example usage of SmartDisk DLL APIs

An example project has been packaged with this DLL. Refer to “example:TestSmartDiskLib:TestSmartDiskLib:TestSmartDiskLib.cpp” for a C++ example usage.

3.4 Example exported SmartDisk DLL report

An example report has been packaged with this DLL. Refer to “example:TestSmartDiskLib:release:TestSmartDiskExport_0.txt” for the exported report..

Page 19: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 19 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

4.0 Drive Information and S.M.A.R.T. Attributes

4.1 Understanding the device information

This section explains some of the fields in the DEVICEINFO structure:

sSerialNumber (Serial Number) The drive serial number.

sFirmwareRev (FirmWare Rev) The drive current firmware revision.

sModelNumber (Model Number) The drive model number.

wNumCyls (Cylinders) The amount of cylinders on the manufactured drive.

wNumHeads (Heads) The amount of read/write heads on the manufactured drive.

wSectorsPerTrack (Sectors per track) The number of sectors per track of the manufactured drive.

wNumCurrentCyls (Cur Cyls) The current number of sectors on the drive.

wNumCurrentHeads (Cur Heads) The current number of read/write heads on the drive.

wNumCurrentSectorsPerTrack (Cur Sectors/Track) The current number of sectors per track on the drive.

wBytesPerTrack (Bytes per track)

How many raw bytes of data on each track of the drive.

Page 20: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 20 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

wSectorsPerTrack (Sectors per track)

How many raw sectors of data on each track of the drive.

Bytes per sector (wBytesPerTrack/ wSectorsPerTrack) How many raw bytes of data on each sector of the drive.

wBufferSize (Buffer Size) The size of the disk subsystems data buffer.

4.2 What is S.M.A.R.T.?

S.M.A.R.T. (Self-Monitoring Analysis and Reporting Technology) is an interface between the BIOS and a computers hard disk. It is a feature of the Enhanced Integrated Drive

Electronics (EIDE) technology that controls access to the hard drive. If S.M.A.R.T is enabled when a computer is set up, the BIOS can receive analytical information from the hard

drive and determine whether to send the user a warning message about possible future failure of the hard drive.

SMART monitors a set of drive attributes, such as temperature, throughput performance and the number of hours the drive has been powered on. It compares these attributes to a

corresponding set of thresholds. If an attribute drops below its threshold, the drive is no longer considered fit for use and should be replaced immediately. Not all attributes are

available on all drives, however. It is the responsibility of the drive manufacturer to include SMART support.

A brief description of some SMART terminology follows:

Attribute

An attribute is a particular property of a SMART enabled hard drive. Each attribute contains the following sub properties.

Attribute value

The attribute value is a normalized number measuring the attributes current reliability. The higher this value is, the more reliable the drive is, insofar as this attribute is concerned.

For some attributes, this value is normalized between 1 and 100, for others between 1 and 200 and for others still, such as temperature the attribute value is the actual non-normalized

temperature in degrees Celsius. When an attribute value falls below that attributes threshold, the drive is no longer operating safely.

Worst

This is the lowest attribute value that has been recorded for this attribute and shows the moment when the attribute was closest to falling below its threshold.

Raw value The raw value varies from attribute to attribute, but it generally represents a more meaningful measure of the attribute. It usually shows a count of the number of errors, hours, or

times depending on the attribute in question. For instance, for the temperature attribute, it shows the degrees (in Celsius) of the drive.

Attribute threshold

If the attribute value drops below that attribute threshold for any drive, a Threshold Exceeding Condition (TEC) has occurred and the drive should be replaced. The threshold is thus

a measure of how an attribute can become before the drive is deemed unsafe.

Page 21: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 21 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

4.2.2 Understanding S.M.A.R.T. Attributes

Attribute Types (as defined in “SmartDisk.h”)

ATTR_TYPE_STR_DESC A text description of the attribute. See below for a more detailed description of each attribute.

ATTR_TYPE_INT_STATUS Provided a status for the attribute. OK means the attribute value is well in the safe zone. WARNING means that the attribute value is approaching the attribute threshold and FAIL

means that a Threshold Exceeding Condition has been detected.

ATTR_TYPE_INT_VALUE The current normalized attribute value.

ATTR_TYPE_INT_RAW The attributes current raw value. This may be a count, a number of errors or hours, or even a temperature, depending on the attribute.

ATTR_TYPE_INT_WORST The worst (lowest) value recorded so far. This is an indicator of how close to failure the drive has ever been.

ATTR_TYPE_INT_THRESHOLD The attribute threshold. This value will not change and represents the lowest possible safe attribute value.

The Attributes (as defined in “SmartDisk.h”)

(Note: The name and description of several of these attributes has been taken from various sources on the web including Wikipedia.org)

ATTR_READ_ERROR_RATE (Hex value: 0x01)

(Raw Read Error Rate) Represents the rate of uncorrected read errors. Lower values indicate that there is a problem with either disk surface or read/write heads.

ATTR_THROUGHPUT_PERF (0x02)

(Throughput Performance) Represents the throughput performance of the drive, i.e. The speed at which the drive is reading and writing data.

ATTR_SPIN_UP_TIME (0x03)

(Spin Up Time) Represents the average amount of time required to spin up the drive spindle to operational speed from a stopped state.

Page 22: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 22 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

ATTR_START_STOP_COUNT (0x04)

(Start/Stop Count) Represents the number of start/stop cycles for the drive. The raw value indicates the count of start/stop cycles for the drive. The drive being powered on/off or suspended/woken up

are considered as start/stop cycles.

ATTR_REALLOC_SECTOR_COUNT (0x05)

(Reallocated Sector Count) Represents the amount of spare sector pool available. Spare sectors are used to replace sectors that became bad for some reason (for instance, if a read error occurs). Therefore the

more sectors reallocated, the worse the condition of the drive. A high value represents few reallocated sectors, a low value represents a disk in poor physical condition.

ATTR_READ_CHANNEL_MARGIN (0x06)

(Read Channel Margin)

Margin of a channel while reading data. The function of this attribute is not specified.

ATTR_SEEK_ERROR_RATE (0x07)

(Seek Error Rate) Represents the number of seek errors. Each time the drive attempts a seek operation, but fails to position its head correctly, the seek error rate increases.

ATTR_SEEK_TIME_PERF (0x08)

(Seek Time Performance) Represents how efficiently the drive is performing seek operations. A low value indicates problems with the drive subsystem, for instance the servo responsible for positioning the

head.

ATTR_POWER_ON_HRS_COUNT (0x09)

(Power On Hours Count) This is an informative attribute, the raw value of which displays the number of hours the drive has been powered on for.

ATTR_SPIN_RETRY_COUNT (0x0A)

(Spin Retry Count)

Represents the number of times a drive fails to spin its spindle up to operation speed on the first attempt. The lower the value, the more retries have occurred.

ATTR_CALIBRATION_RETRY_COUNT (0x0B)

(Calibration Retry Count) Calibration is the act of repositioning the drive read/write head to cylinder 0. This value represents the number of times a calibration has failed on the first attempt.

ATTR_POWER_CYCLE_COUNT (0x0C)

Page 23: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 23 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

(Power Cycle Count) Informative attribute, the raw value of which represents the number of drive power on/drive power off cycles for the disk.

ATTR_SOFT_READ_ERROR_RATE (0xD)

(Soft Read Error Rate) Uncorrected read errors reported to the operating system.

ATTR_100_MINUS_TEMPERATURE (0xBE)

(Temperature Difference from 100) The exact specification of this attribute is not quite stable. This is what it is known as on Seagate drives whereas it is called Airflow Temperature on Western Digital hard disks. In

either case this attribute usually has to do with subtracting the temperature from 100 to give a value that is worse when it is lower.

ATTR_GSENSE_ERROR_RATE (0xBF)

(G-Sense Error Rate) Frequency of mistakes as a result of impact loads

ATTR_POWER_OFF_RETRACT_COUNT (0xC0)

(Power-off Retract Count) Number of times the heads are loaded off the media. Heads can be unloaded without actually powering off.

ATTR_LOAD_UNLOAD_CYCLE (0xC1)

(Load/Unload Cycle) Count of load/unload cycles into head landing zone position

ATTR_TEMPERATURE (0xC2)

(Temperature) Informative attribute, the raw value of which represents the current temperature in Celsius of the drive.

ATTR_HARDWARE_ECC_RECOVERED (0xC3)

(Hardware ECC Recovered) Time between ECC-corrected errors.

ATTR_REALLOC_EVENT_COUNT (0xC4)

(Reallocation Event Count) Represents the number of reallocation events, which have taken place. Sometimes multiple sectors are reallocated together – this corresponds to one reallocation event. (See also:

Reallocated Sector Count and Current Pending Sector Count).

ATTR_PENDING_SECTOR_COUNT (0xC5)

Page 24: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 24 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

(Current Pending Sector Count)

Represents the number of sectors currently pending reallocation.

ATTR_OFFLINE_SCAN_INCORRECT (0xC6)

(Uncorrectable Sector Count) The total number of uncorrectable errors when reading/writing a sector.

ATTR_ULTRA_ATA_CRC_ERROR_COUNT (0xC7)

(Ultra ATA CRC Error Count) Represents the number of CRC error found in the Ultra DMA high-speed transfer mode. (CRC stands for Cyclic Redundancy Check and is data verification algorithm which uses

polynomial checksums).

ATTR_WRITE_ERROR_COUNT (0xC8)

(Write Error Count) Represents the rate of uncorrected write errors. Lower values indicate that there is a problem with either disk surface or read/write heads.

ATTR_SOFT_READ_ERROR_RATE_C9 (0xC9)

(Soft Read Error Rate) Number of off-track errors.

ATTR_DATA_ADDRESS_MARK_ERRORS (0xCA)

(Data Address Mark errors) Number of Data Address Mark errors.

ATTR_RUN_OUT_CANCEL (0xCB)

(Run Out Cancel) Number of ECC errors.

ATTR_SOFT_ECC_CORRECTION (0xCC)

(Soft ECC Correction) Number of errors corrected by software ECC.

ATTR_THERMAL_ASPERITY_RATE (0xCD)

(Thermal asperity rate (TAR )) Number of thermal asperity errors.

ATTR_FLYING_HEIGHT (0xCE)

Page 25: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 25 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

(Flying Height) Height of heads above the disk surface.

ATTR_SPIN_HIGH_CURRENT (0xCF)

(Spin High Current) Amount of high current used to spin up the drive.

ATTR_SPIN_BUZZ (0xD0)

(Spin Buzz) Number of buzz routines to spin up the drive.

ATTR_OFFLINE_SEEK_PERFORMANCE (0xD1)

(Offline Seek Performance) Drive‟s seek performance during offline operations.

ATTR_DISK_SHIFT (0xDC)

(Disk Shift) Distance the disk has shifted relative to the spindle (usually due to shock).

ATTR_GSENSE_ERROR_RATE (0xDD)

(GSense Error rate)

The number of errors resulting from externally-induced shock & vibration.

ATTR_LOADED_HOURS (0xDE)

(Loaded Hours)

Time spent operating under data load (movement of magnetic head armature)

ATTR_LOADUNLOAD_RERTY_COUNT (0xDF)

(Load/Unload retry count)

Number of times head changes position.

ATTR_LOAD_FRICTION (0xE0)

(Load Friction)

Resistance caused by friction in mechanical parts while operating.

ATTR_LOADUNLOAD_CYCLE_COUNT (0xE1)

(Load/Unload Cycle Count)

Total number of load cycles

Page 26: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 26 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

ATTR_LOAD_IN_TIME (0xE2)

(Load 'In'-time)

Total time of loading on the magnetic heads actuator (time not spent in parking area).

ATTR_TORQUE_AMPLIFICATION_COUNT (0xE3)

(Torque Amplification Count)

Number of attempts to compensate for platter speed variations.

ATTR_POWEROFF_RETRACT_CYCLE (0xE4)

(Power off retract cycle)

The number of times the magnetic armature was retracted automatically as a result of cutting power.

ATTR_GMR_HEAD_AMPLITUDE (0xE6)

(GMR Head Amplitude)

Amplitude of "thrashing" (distance of repetitive forward/reverse head motion).

ATTR_TEMPERATURE_E7 (0xE7)

(Temperature)

Drive Temperature, unknown units.

ATTR_HEAD_FLYING_HOURS (0xF0)

(Head Flying Hours)

Time while head is positioning.

ATTR_READ_ERROR_RETRY_RATE (0xFA)

(Read Error Retry Rate)

Number of errors while reading from a disk

Page 27: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 27 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

5.0 Predicting TEC (Threshold Exceed Condition) with S.M.A.R.T Attributes1

SmartDisk DLL records the S.M.A.R.T. attributes of available S.M.A.R.T. devices every time you call:

1. SmartDll_Init (on by default and can be turned off);

2. SmartDll_RecordTECData;

3. SmartDll_Refresh (off by default and can be turned on).

Every time a set of values is recorded, it is appended to a binary file (the file is created by appending “.bin” to the serial number of the device). The following information is

recorded:

1. Time the recording was made;

2. Attribute ID;

3. Current attribute value;

4. Current attribute raw value;

5. Current attribute worst value;

Note that threshold values are not recorded because they remain constant with time. By recording the S.M.A.R.T. attributes of your SMART devices, empirical S.M.A.R.T. data is

collected that allows SmartDisk DLL to predict when the threshold S.M.A.R.T. value will be exceeded (the Threshold Exceed Condition).

Alternatively, you can export these values using the SmartDll_GetTECDataSetCount and SmartDll_ExportTECData function calls to, say, an Excel Spreadsheet and derive your

own graphs and charts that will enable you to see the pattern of your S.M.A.R.T. attributes.

5.1 How does it predict?

In the graph below, there are 6 sets of collected data, sample 0 to sample 5, represented by the red line ( ). The threshold value (which remains constant) is represented by the

black line ( ). The blue line ( ) represents the predicted threshold exceed condition date based on the 1st and last sample while the green line ( ) represents the

predicted threshold exceed condition date based on the last 2 samples. Based on the data above, the earliest predicted failure date will occur at sample 8 and the latest predicted

failure date will occur at sample10.

1 Please read our disclaimer statement in Chapter 8 “Specific Disclaimer on Failure Predictions”.

Page 28: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 28 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Threshold Exceed Condition

0

2

4

6

8

10

12

0 2 4 6 8 10 12 14

Sample (Time)

SM

AR

T A

ttri

bu

te

Threshold

Collected value

Predicted earliest

Predicted latest

Page 29: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 29 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

To successfully predict a TEC date and time for an attribute, all the following conditions need to be met:

1. The threshold value of the attribute must not be zero;

2. The must be a minimum of 3 sets of data;

3. There must be a difference in the attribute value between the 1st and last set or between the last 2 sets;

4. There must be a difference in the recording time between the 1st and last set or between the last 2 sets;

If any of the above condition is not met, a negative error code will be returned and the time value will be set as zero (0).

5.2 Important Information on Failure Prediction2

SmartDisk DLL predicts the failure date of your hard drives based on the collected SMART attributes of your hard drives. It computes the failure date by assuming a linear

degradation of the attribute values. This predicted time should be taken as a guide only and should not be considered accurate. There are many contributing factors that might cause

a drive to fail, for example high ambient temperature, electrical short circuits or failure of its mechanical and electrical parts. As such, it is susceptible to sudden failures. This is

why you should always backup your data on a regular basis.

2 Please read our disclaimer statement in Chapter 8 “Specific Disclaimer on Failure Predictions”.

Page 30: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 30 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

6.0 SmartDisk DLL Error Codes

This chapter explains the error codes that SmartDisk DLL‟s API function calls might return. It is defined in “SmartDisk.h”.

STATUS_SUCCESS (0)

No error. Function completed and returned successfully.

STATUS_ERR_DEVICE_ID_DNE (-1000)

The device ID passed in does not exist. Please use SmartDll_GetSmartDeviceIDFirst and SmartDll_GetSmartDeviceIDNext to get the device ID.

STATUS_ERR_DEVICE_ID_NOT_SMART (-1001)

Disk does not support S.M.A.R.T. Older disk that does not support S.M.A.R.T. will get this error.

STATUS_ERR_DRIVE_NUMBER_INVALID (-1100)

Valid drive numbers are from 0 (“A:\”) to 25 (“Z:\”). Any number not in this range will yield this error.

STATUS_ERR_DRIVE_NUMBER_DNE (-1101)

Drive number does not exist. This means there is not physical device that has this drive number.

STATUS_ERR_DRIVE_NUMBER_NOT_FIXED (-1102)

Drive number is not a fixed drive. Floppies and CDROMs are not fixed drives and will get this error.

STATUS_ERR_BUFFER_INVALID (-2000)

Buffer provided points to NULL.

STATUS_ERR_BUFFER_TOO_SMALL (-2001)

Buffer provided is too small to hold all the data.

STATUS_ERR_BUFFER_FAILED_ALLOCATE (-2002)

Failed to allocate buffer in function.

STATUS_ERR_SMART_DEVICE_ID_EMPTY (-3001)

There is no S.M.A.R.T. device ID in the list.

STATUS_ERR_SMART_DEVICE_ID_EOL (-3002)

Page 31: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 31 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

We have reached the end of list for the S.M.A.R.T. device ID(s).

STATUS_ERR_SMART_ATTR_ID_EMPTY (-4001)

There is no S.M.A.R.T. attribute for the drive.

STATUS_ERR_SMART_ATTR_ID_EOL (-4002)

We have reached the end of list for the S.M.A.R.T. attribute(s) for the drive.

STATUS_ERR_SMART_ATTR_ID_INVALID (-4003)

Smart attribute ID is invalid. Attribute ID cannot be zero.

STATUS_WARN_SMART_ATTR_ID_UNKNOWN (-4004)

Smart attribute ID unrecognized by DLL. Possibly a new attribute implemented by certain hard disk manufacturer. The attribute value will still be valid. However, you will get

“Unknown Attribute” if you try and get its description string. This is a warning rather than an error.

STATUS_ERR_FOPEN_FAIL (-5001)

Fail to open file for reading and writing. This happens when the Windows API fopen() returned an error.

STATUS_ERR_FWRITE_FAIL (-5002)

Fail to write to file. This happens when the number of characters written using the Windows API fwrite() is less than what we intended to write.

STATUS_ERR_FREAD_FAIL (-5003)

Fail to read file. This happens when the Windows API fread() returned an error.

STATUS_ERR_ACCESS_RW (-5101)

No read/write permission for file.

STATUS_ERR_ACCESS_RO (-5102)

No read permission for file.

STATUS_ERR_FSEEK_FAIL (-5201)

Fail to seek to a location in file. This happens when the Windows API fseek() returned an error.

STATUS_ERR_GET_PHY_CAPACITY (-6001)

Fail to get device capacity.

STATUS_ERR_BUILD_DRIVES_INFO_NO_ACCESS (-7001)

No access rights when trying to get info for drive.

Page 32: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 32 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

STATUS_ERR_NO_ADMIN_RIGHTS (-7002)

No access rights to gather drive information. In Windows Server and Vista, your application needs to “Run as administrator”.

STATUS_ERR_DLL_NOT_INIT (-10001)

Occur when you try and use SmartDisk DLL‟s APIs without first calling SmartDisk_Init.

STATUS_ERR_DLL_INIT_MEMORY_ALLOC_FAIL (-10002)

SmartDisk_Init failed to allocate memory.

STATUS_ERR_FUNCTION_NOT_SUPPORTED (-10003)

This function is not supported in Windows 98/Me.

STATUS_ERR_EMPTY_STRING (-10004)

Empty string returned from SmartDll_GetXXX functions.

STATUS_ERR_TEC_NO_ATTRIBUTES (-20001)

There are no S.M.A.R.T. attributes to record for the chosen drive number.

STATUS_ERR_TEC_SIGNATURE_HEAD (-20002)

The TEC file does not have “SMDL” in the first 4 bytes of the file stream.

STATUS_ERR_TEC_SIGNATURE_TAIL (-20003)

The TEC file does not have “LDMS” in the last 4 bytes of the file stream.

STATUS_ERR_TEC_FILE_DNE (-20004)

The TEC file for the drive number does not exist.

STATUS_WARN_TEC_NOT_ENOUGH_DATA (-20005)

There are not enough TEC data to predict TEC. We need to have at least 3 sets of data.

STATUS_WARN_TEC_ATTR_ID_NA (-20006)

For given attribute ID, threshold value is 0. It means we have no threshold value to work with to predict TEC.

STATUS_WARN_TEC_UNABLE_TO_PREDICT (-20007)

No changes in attribute values have been detected, making it impossible to predict TEC.

Page 33: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 33 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

7.0 License & Intellectual Property Rights

PassMark will retain all ownership and intellectual property rights for SmartDisk DLL. Purchasing the license for the SmartDisk DLL software library, for the agreed price, allows

you to use the software library as part of your product without paying additional royalties and without limit on the number of products distributed or the time period of the

distribution. The license prohibits the right to on-sell, or give away free of charge, the library separately or to develop any product that may be in competition with the SmartDisk

DLL library using the library itself.

8.0 Specific Disclaimer on Failure Predictions

The SmartDisk DLL SDK utilizes statistical analysis to predict possible failure dates of hard disk drives. Because there are no „certainties‟ in statistical analysis, PassMark®

Software Pty Ltd disclaims all liability for any and all costs incurred by either:

1) The hard disk drive failing before the predicted failure date estimated by the application, or

2) The hard disk drive continuing to function beyond the predicted failure date estimated by the application.

In either situation, PassMark® disclaims liability for any losses due to loss or damage to data. PassMark

® further disclaims any liability for costs incurred in anticipation of a disk

drive failure that does not eventuate (e.g. replacement hard disk drives, transfer time, downtime, etc).

This disclaimer is in addition to the Disclaimer of Warranty and Limitation of Liability mentioned elsewhere in this EULA and on our web site.

9.0 Purchasing Information

Price $399 USD

What happens when you order

After the order is accepted by our sales agent, the SDK (in the form of a ZIP file) will be sent to the e-mail that was provided.

What you get when you purchase the software

Free Technical support via the Web and E-Mail http://www.passmark.com/support

Free minor upgrades & bug fixes as they become available http://www.passmark.com/products/smartdiskdll.htm

Page 34: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 34 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Confidentiality

All personal details supplied when placing an order will be strictly confidential. Online orders will only be accepted over a secure, encrypted connection.

Questions & more information

If you have any questions we would be happy to hear about them. Contact [email protected]

10.0 Contacting PassMark® Software

Address

PassMark Software Pty Ltd

Suite 10, Level 1

38 Waterloo St.

Surry Hills, 2010

Sydney, Australia

ACN 099 321 392

Phone + 61 2 9690 0444

Fax + 61 2 9690 0445

On the Web

You can contact PassMark on the web at http://www.passmark.com

E-Mail

For technical support questions, suggestions [email protected]

For sales & commercial issues [email protected]

For any other issues [email protected]

Page 35: S.M.A.R.T DLL Library API

PassMark® Software

S.M.A.R.T. DLL Library API Page 35 of 35

PassMark Software 11-Nov-08

Copyright PassMark 2008

Index of API Function Names

SmartDll_Cleanup, 9

SmartDll_EstimateTECByAttributeID, 17

SmartDll_ExportReport, 15

SmartDll_ExportTECData, 16

SmartDll_GetAttrDescByID, 15

SmartDll_GetDeviceCapacity, 12

SmartDll_GetDeviceFirmWareRev, 12

SmartDll_GetDeviceInfo, 15

SmartDll_GetDeviceModelNumber, 12

SmartDll_GetDevicePartitionInfo, 11

SmartDll_GetDeviceSerialNumber, 11

SmartDll_GetDeviceVendorUnique, 12

SmartDll_GetDriveCapacity, 13

SmartDll_GetDriveLetterFromDriveNum, 11

SmartDll_GetNumDetectedDrives, 10

SmartDll_GetNumSmartAttr, 13

SmartDll_GetNumSmartDevices, 10

SmartDll_GetSmartAttributeByID, 14

SmartDll_GetSmartAttributeIDFirst, 14

SmartDll_GetSmartAttributeIDNext, 14

SmartDll_GetSmartDeviceIDFirst, 13

SmartDll_GetSmartDeviceIDNext, 13

SmartDll_GetTECDataAtIndex, 17

SmartDll_GetTECDataSetCount, 16

SmartDll_GetVersion, 9

SmartDll_Init, 9

SmartDll_IsValidSmartDevice, 10

SmartDll_RecordTECData, 16

SmartDll_Refresh, 10