smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
smart_interface Class Reference

The platform interface abstraction. More...

#include <dev_interface.h>

Collaboration diagram for smart_interface:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 smart_interface ()
virtual ~smart_interface () throw ()
virtual std::string get_os_version_str ()
 Return info string about build host and/or OS version.
virtual std::string get_valid_dev_types_str ()
 Return valid args for device type option/directive.
virtual std::string get_app_examples (const char *appname)
 Return example string for program 'appname'.
virtual int64_t get_timer_usec ()
 Get microseconds since some unspecified starting point.
virtual bool disable_system_auto_standby (bool disable)
 Disable/Enable system auto standby/sleep mode.
const smart_device::error_infoget_err () const
 Get last error info struct.
int get_errno () const
 Get last error number.
const char * get_errmsg () const
 Get last error message.
bool set_err (int no, const char *msg,...) __attribute_format_printf(3
 Set last error number and message.
bool bool set_err (const smart_device::error_info &err)
 Set last error info struct.
void clear_err ()
 Clear last error info.
bool set_err (int no)
 Set last error number and default message.
bool set_err_var (smart_device::error_info *err, int no)
 Set last error number and default message to any error_info.
virtual const char * get_msg_for_errno (int no)
 Convert error number into message, used by set_err(no).
virtual smart_deviceget_smart_device (const char *name, const char *type)
 Return device object for device 'name' with some 'type'.
virtual bool scan_smart_devices (smart_device_list &devlist, const char *type, const char *pattern=0)=0
 Fill 'devlist' with devices of some 'type' with device names specified by some optional 'pattern'.
virtual ata_deviceautodetect_sat_device (scsi_device *scsidev, const unsigned char *inqdata, unsigned inqsize)
 Try to detect a SAT device behind a SCSI interface.
virtual const char * get_usb_dev_type_by_id (int vendor_id, int product_id, int version=-1)
 Get type name for USB device with known VENDOR:PRODUCT ID.

Static Public Member Functions

static void init ()
 Initialize platform interface and register with smi().

Protected Member Functions

virtual ata_deviceget_ata_device (const char *name, const char *type)=0
 Return standard ATA device.
virtual scsi_deviceget_scsi_device (const char *name, const char *type)=0
 Return standard SCSI device.
virtual smart_deviceautodetect_smart_device (const char *name)=0
 Autodetect device if no device type specified.
virtual smart_deviceget_custom_smart_device (const char *name, const char *type)
 Return device for platform specific 'type'.
virtual std::string get_valid_custom_dev_types_str ()
 Return valid 'type' args accepted by above.
virtual ata_deviceget_sat_device (const char *type, scsi_device *scsidev)
 Return ATA->SCSI filter for SAT or USB.

Static Protected Member Functions

static void set (smart_interface *intf)
 Set interface to use, must be called from init().

Private Member Functions

 smart_interface (const smart_interface &)
void operator= (const smart_interface &)

Private Attributes

smart_device::error_info m_err

Static Private Attributes

static smart_interfaces_instance
 Pointer to the interface object.

Friends

smart_interfacesmi ()
 Global access to the (usually singleton) smart_interface.

Detailed Description

The platform interface abstraction.

Definition at line 731 of file dev_interface.h.


Constructor & Destructor Documentation

smart_interface::smart_interface ( ) [inline]

Definition at line 738 of file dev_interface.h.

virtual smart_interface::~smart_interface ( ) throw () [inline, virtual]

Definition at line 741 of file dev_interface.h.

smart_interface::smart_interface ( const smart_interface ) [private]

Member Function Documentation

ata_device * smart_interface::autodetect_sat_device ( scsi_device scsidev,
const unsigned char *  inqdata,
unsigned  inqsize 
) [virtual]

Try to detect a SAT device behind a SCSI interface.

Inquiry data can be passed if available. Return appropriate device if yes, otherwise 0. Override only if platform needs special handling.

Definition at line 1336 of file scsiata.cpp.

virtual smart_device* smart_interface::autodetect_smart_device ( const char *  name) [protected, pure virtual]
void smart_interface::clear_err ( ) [inline]

Clear last error info.

Definition at line 797 of file dev_interface.h.

bool smart_interface::disable_system_auto_standby ( bool  disable) [virtual]

Disable/Enable system auto standby/sleep mode.

Return false if unsupported or if system is running on battery. Default implementation returns false.

Reimplemented in os_win32::win_smart_interface.

Definition at line 305 of file dev_interface.cpp.

std::string smart_interface::get_app_examples ( const char *  appname) [virtual]

Return example string for program 'appname'.

Default implementation returns empty string. For the migration of print_smartctl_examples(), function is allowed to print examples to stdout. TODO: Remove this hack.

Reimplemented in os::legacy_smart_interface, os_freebsd::freebsd_smart_interface, generic::generic_smart_interface, os_linux::linux_smart_interface, and os_win32::win_smart_interface.

Definition at line 270 of file dev_interface.cpp.

virtual ata_device* smart_interface::get_ata_device ( const char *  name,
const char *  type 
) [protected, pure virtual]
smart_device * smart_interface::get_custom_smart_device ( const char *  name,
const char *  type 
) [protected, virtual]

Return device for platform specific 'type'.

Default implementation returns 0.

Reimplemented in os_freebsd::freebsd_smart_interface, generic::generic_smart_interface, os_linux::linux_smart_interface, and os_win32::win_smart_interface.

Definition at line 403 of file dev_interface.cpp.

const smart_device::error_info& smart_interface::get_err ( ) const [inline]

Get last error info struct.

Definition at line 777 of file dev_interface.h.

const char* smart_interface::get_errmsg ( ) const [inline]

Get last error message.

Definition at line 783 of file dev_interface.h.

int smart_interface::get_errno ( ) const [inline]

Get last error number.

Definition at line 780 of file dev_interface.h.

const char * smart_interface::get_msg_for_errno ( int  no) [virtual]

Convert error number into message, used by set_err(no).

Default implementation returns strerror(no).

Definition at line 335 of file dev_interface.cpp.

std::string smart_interface::get_os_version_str ( ) [virtual]

Return info string about build host and/or OS version.

Default implementation returns SMARTMONTOOLS_BUILD_HOST.

Reimplemented in os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, and os_win32::win_smart_interface.

Definition at line 252 of file dev_interface.cpp.

ata_device * smart_interface::get_sat_device ( const char *  type,
scsi_device scsidev 
) [protected, virtual]

Return ATA->SCSI filter for SAT or USB.

Override only if platform needs special handling.

Definition at line 1274 of file scsiata.cpp.

virtual scsi_device* smart_interface::get_scsi_device ( const char *  name,
const char *  type 
) [protected, pure virtual]
smart_device * smart_interface::get_smart_device ( const char *  name,
const char *  type 
) [virtual]

Return device object for device 'name' with some 'type'.

'type' is 0 if not specified by user. Return 0 on error. Default implementation selects between ata, scsi and custom device.

Definition at line 344 of file dev_interface.cpp.

int64_t smart_interface::get_timer_usec ( ) [virtual]

Get microseconds since some unspecified starting point.

Used only for command duration measurements in debug outputs. Returns -1 if unsupported. Default implementation uses clock_gettime(), gettimeofday() or ftime().

Reimplemented in os_win32::win_smart_interface.

Definition at line 275 of file dev_interface.cpp.

const char * smart_interface::get_usb_dev_type_by_id ( int  vendor_id,
int  product_id,
int  version = -1 
) [virtual]

Get type name for USB device with known VENDOR:PRODUCT ID.

Return name if device known and supported, otherwise 0.

Definition at line 1366 of file scsiata.cpp.

std::string smart_interface::get_valid_custom_dev_types_str ( ) [protected, virtual]

Return valid 'type' args accepted by above.

This is called in get_valid_dev_types_str(). Default implementation returns empty string.

Reimplemented in os_freebsd::freebsd_smart_interface, generic::generic_smart_interface, os_linux::linux_smart_interface, and os_win32::win_smart_interface.

Definition at line 408 of file dev_interface.cpp.

std::string smart_interface::get_valid_dev_types_str ( ) [virtual]

Return valid args for device type option/directive.

Default implementation returns "ata, scsi, sat, usb*..." concatenated with result from get_valid_custom_dev_types_str().

Definition at line 257 of file dev_interface.cpp.

void smart_interface::init ( ) [static]

Initialize platform interface and register with smi().

Initialize platform interface and register with smi()

Must be implemented by platform module and register interface with set()

Definition at line 338 of file dev_legacy.cpp.

void smart_interface::operator= ( const smart_interface ) [private]
virtual bool smart_interface::scan_smart_devices ( smart_device_list devlist,
const char *  type,
const char *  pattern = 0 
) [pure virtual]

Fill 'devlist' with devices of some 'type' with device names specified by some optional 'pattern'.

Return false on error.

Implemented in os::legacy_smart_interface, os_freebsd::freebsd_smart_interface, generic::generic_smart_interface, os_linux::linux_smart_interface, and os_win32::win_smart_interface.

static void smart_interface::set ( smart_interface intf) [inline, static, protected]

Set interface to use, must be called from init().

Definition at line 868 of file dev_interface.h.

bool smart_interface::set_err ( int  no,
const char *  msg,
  ... 
)

Set last error number and message.

Printf()-like formatting is supported. Returns false always to allow use as a return expression.

Definition at line 310 of file dev_interface.cpp.

bool smart_interface::set_err ( int  no)

Set last error number and default message.

Message is retrieved from get_msg_for_errno(no).

Definition at line 321 of file dev_interface.cpp.

bool bool smart_interface::set_err ( const smart_device::error_info err) [inline]

Set last error info struct.

Definition at line 793 of file dev_interface.h.

bool smart_interface::set_err_var ( smart_device::error_info err,
int  no 
)

Set last error number and default message to any error_info.

Used by set_err(no).

Definition at line 326 of file dev_interface.cpp.


Friends And Related Function Documentation

smart_interface* smi ( ) [friend]

Global access to the (usually singleton) smart_interface.

Definition at line 888 of file dev_interface.h.


Member Data Documentation

Definition at line 873 of file dev_interface.h.

Pointer to the interface object.

Definition at line 876 of file dev_interface.h.


The documentation for this class was generated from the following files: