smartmontools SVN Rev 5632
Utility to control and monitor storage systems with "S.M.A.R.T."
|
The platform interface abstraction. More...
#include <dev_interface.h>
Public Member Functions | |
smart_interface () | |
virtual | ~smart_interface () |
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 bool | disable_system_auto_standby (bool disable) |
Disable/Enable system auto standby/sleep mode. | |
const smart_device::error_info & | get_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 decltype(nullptr) | set_err_np (int no, const char *msg,...) __attribute_format_printf(3 |
Set last error number and message. | |
bool decltype(nullptr) 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_device * | get_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) |
Fill 'devlist' with devices of some 'type' with device names specified by some optional 'pattern'. | |
virtual bool | scan_smart_devices (smart_device_list &devlist, const smart_devtype_list &types, const char *pattern=0) |
Fill 'devlist' with devices of all 'types' with device names specified by some optional 'pattern'. | |
virtual std::string | get_unique_dev_name (const char *name, const char *type) const |
Return unique device name which is (only) suitable for duplicate detection. | |
virtual bool | is_raid_dev_type (const char *type) const |
Return true if the 'type' string contains a RAID drive number. | |
virtual ata_device * | autodetect_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_device * | get_ata_device (const char *name, const char *type)=0 |
Return standard ATA device. | |
virtual scsi_device * | get_scsi_device (const char *name, const char *type)=0 |
Return standard SCSI device. | |
virtual nvme_device * | get_nvme_device (const char *name, const char *type, unsigned nsid) |
Return standard NVMe device. | |
virtual smart_device * | autodetect_smart_device (const char *name)=0 |
Autodetect device if no device type specified. | |
virtual smart_device * | get_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 smart_device * | get_scsi_passthrough_device (const char *type, scsi_device *scsidev) |
Return ATA->SCSI of NVMe->SCSI filter for a SAT, SNT or USB 'type'. | |
virtual ata_device * | get_sat_device (const char *type, scsi_device *scsidev) |
Return ATA->SCSI filter for a SAT or USB 'type'. | |
virtual nvme_device * | get_snt_device (const char *type, scsi_device *scsidev) |
Return NVMe->SCSI filter for a SNT or USB 'type'. | |
virtual ata_device * | get_intelliprop_device (const char *type, ata_device *atadev) |
Return filter for Intelliprop controllers. | |
virtual ata_device * | get_jmb39x_device (const char *type, smart_device *smartdev) |
Return JMB93x->ATA filter. | |
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_interface * | s_instance |
Pointer to the interface object. | |
Friends | |
smart_interface * | smi () |
Global access to the (usually singleton) smart_interface. | |
The platform interface abstraction.
Definition at line 910 of file dev_interface.h.
|
inline |
Definition at line 917 of file dev_interface.h.
|
inlinevirtual |
Definition at line 920 of file dev_interface.h.
|
private |
|
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 1486 of file scsiata.cpp.
|
protectedpure virtual |
Autodetect device if no device type specified.
Implemented in generic::generic_smart_interface, os::legacy_smart_interface, os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
|
inline |
Clear last error info.
Definition at line 978 of file dev_interface.h.
|
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 324 of file dev_interface.cpp.
|
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 generic::generic_smart_interface, os::legacy_smart_interface, os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
Definition at line 319 of file dev_interface.cpp.
|
protectedpure virtual |
Return standard ATA device.
Implemented in generic::generic_smart_interface, os::legacy_smart_interface, os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
|
protectedvirtual |
Return device for platform specific 'type'.
Default implementation returns 0.
Reimplemented in generic::generic_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
Definition at line 538 of file dev_interface.cpp.
|
inline |
Get last error info struct.
Definition at line 950 of file dev_interface.h.
|
inline |
Get last error message.
Definition at line 956 of file dev_interface.h.
|
inline |
Get last error number.
Definition at line 953 of file dev_interface.h.
|
protectedvirtual |
Return filter for Intelliprop controllers.
Definition at line 292 of file dev_intelliprop.cpp.
|
protectedvirtual |
Return JMB93x->ATA filter.
Device 'smartdev' is used for ATA or SCSI R/W access. Return 0 and delete 'scsidev' on error. Override only if platform needs special handling.
Definition at line 684 of file dev_jmb39x_raid.cpp.
|
virtual |
Convert error number into message, used by set_err(no).
Default implementation returns strerror(no).
Definition at line 367 of file dev_interface.cpp.
|
protectedvirtual |
Return standard NVMe device.
Default implementation returns 0.
Reimplemented in os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, and os_win32::win_smart_interface.
Definition at line 533 of file dev_interface.cpp.
|
virtual |
Return info string about build host and/or OS version.
Default implementation returns SMARTMONTOOLS_BUILD_HOST.
Reimplemented in os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
Definition at line 298 of file dev_interface.cpp.
|
protectedvirtual |
Return ATA->SCSI filter for a SAT or USB 'type'.
Device 'scsidev' is used for SCSI access. Return 0 and delete 'scsidev' on error. Override only if platform needs special handling.
Definition at line 1405 of file scsiata.cpp.
|
protectedpure virtual |
Return standard SCSI device.
Implemented in generic::generic_smart_interface, os::legacy_smart_interface, os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
|
protectedvirtual |
Return ATA->SCSI of NVMe->SCSI filter for a SAT, SNT or USB 'type'.
Uses get_sat_device and get_snt_device. Return 0 and delete 'scsidev' on error.
Definition at line 548 of file dev_interface.cpp.
|
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 408 of file dev_interface.cpp.
|
protectedvirtual |
Return NVMe->SCSI filter for a SNT or USB 'type'.
Device 'scsidev' is used for SCSI access. Return 0 and delete 'scsidev' on error. Override only if platform needs special handling.
Definition at line 398 of file scsinvme.cpp.
|
virtual |
Return unique device name which is (only) suitable for duplicate detection.
Default implementation resolves symlinks on POSIX systems and appends " [type]" if is_raid_dev_type(type)' returns true.
Definition at line 372 of file dev_interface.cpp.
|
virtual |
Get type name for USB device with known VENDOR:PRODUCT ID.
Return name if device known and supported, otherwise 0.
Definition at line 1518 of file scsiata.cpp.
|
protectedvirtual |
Return valid 'type' args accepted by above.
This is called in get_valid_dev_types_str(). Default implementation returns empty string.
Reimplemented in generic::generic_smart_interface, os_freebsd::freebsd_smart_interface, os_linux::linux_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
Definition at line 543 of file dev_interface.cpp.
|
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 303 of file dev_interface.cpp.
|
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 334 of file dev_legacy.cpp.
|
virtual |
Return true if the 'type' string contains a RAID drive number.
Default implementation returns true if 'type' starts with '[^,]+,[0-9]' but not with 'sat,'.
Definition at line 392 of file dev_interface.cpp.
|
private |
|
virtual |
Fill 'devlist' with devices of some 'type' with device names specified by some optional 'pattern'.
Use platform specific default if 'type' is empty or 0. Return false on error. Default implementation returns false;
Reimplemented in generic::generic_smart_interface, os::legacy_smart_interface, os::darwin_smart_interface, os_freebsd::freebsd_smart_interface, os_netbsd::netbsd_smart_interface, os_openbsd::openbsd_smart_interface, and os_win32::win_smart_interface.
Definition at line 508 of file dev_interface.cpp.
|
virtual |
Fill 'devlist' with devices of all 'types' with device names specified by some optional 'pattern'.
Use platform specific default if 'types' is empty. Return false on error. Default implementation calls above function for all types and concatenates the results.
Reimplemented in os_linux::linux_smart_interface.
Definition at line 514 of file dev_interface.cpp.
|
inlinestaticprotected |
Set interface to use, must be called from init().
Definition at line 1100 of file dev_interface.h.
|
inline |
Set last error info struct.
Definition at line 974 of file dev_interface.h.
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 353 of file dev_interface.cpp.
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 329 of file dev_interface.cpp.
decltype(nullptr) smart_interface::set_err_np | ( | int | no, |
const char * | msg, | ||
... | |||
) |
Set last error number and message.
Printf()-like formatting is supported. Returns nullptr always to allow use as a return expression of any pointer type.
Definition at line 340 of file dev_interface.cpp.
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 358 of file dev_interface.cpp.
|
friend |
Global access to the (usually singleton) smart_interface.
Definition at line 1120 of file dev_interface.h.
|
private |
Definition at line 1105 of file dev_interface.h.
|
staticprivate |
Pointer to the interface object.
Definition at line 1108 of file dev_interface.h.