smartmontools SVN Rev 5642
Utility to control and monitor storage systems with "S.M.A.R.T."
|
Base class for all devices. More...
#include <dev_interface.h>
Classes | |
struct | device_info |
Device info strings. More... | |
struct | error_info |
Error (number,message) pair. More... | |
Public Member Functions | |
virtual | ~smart_device () |
bool | is_ata () const |
Return true if ATA device. | |
bool | is_scsi () const |
Return true if SCSI device. | |
bool | is_nvme () const |
Return true if NVMe device. | |
ata_device * | to_ata () |
Downcast to ATA device. | |
const ata_device * | to_ata () const |
Downcast to ATA device (const). | |
scsi_device * | to_scsi () |
Downcast to SCSI device. | |
const scsi_device * | to_scsi () const |
Downcast to SCSI device (const). | |
nvme_device * | to_nvme () |
Downcast to NVMe device. | |
const nvme_device * | to_nvme () const |
Downcast to NVMe device (const). | |
const device_info & | get_info () const |
Get device info struct. | |
const char * | get_dev_name () const |
Get device (path)name. | |
const char * | get_info_name () const |
Get informal name. | |
const char * | get_dev_type () const |
Get device type. | |
const char * | get_req_type () const |
Get type requested by user, empty if none. | |
const 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. | |
virtual bool | is_syscall_unsup () const |
Return true if last error indicates an unsupported system call. | |
bool | set_err (int no, const char *msg,...) __attribute_format_printf(3 |
Set last error number and message. | |
bool bool | set_err (const 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. | |
virtual bool | is_open () const =0 |
Return true if device is open. | |
virtual bool | open ()=0 |
Open device, return false on error. | |
virtual bool | close ()=0 |
Close device, return false on error. | |
virtual smart_device * | autodetect_open () |
Open device with autodetection support. | |
virtual bool | is_powered_down () |
Early test if device is powered up or down. | |
virtual bool | owns (const smart_device *dev) const |
Return true if other device is owned by this device. | |
virtual void | release (const smart_device *dev) |
Release ownership of other device. | |
Static Public Member Functions | |
static int | get_num_objects () |
Get current number of allocated 'smart_device' objects. | |
Protected Types | |
enum | do_not_use_in_implementation_classes { never_called } |
Dummy enum for dummy constructor. More... | |
Protected Member Functions | |
smart_device (smart_interface *intf, const char *dev_name, const char *dev_type, const char *req_type) | |
Constructor to init interface and device info. | |
smart_device (do_not_use_in_implementation_classes) | |
Dummy constructor for abstract classes. | |
device_info & | set_info () |
R/W access to device info struct. | |
smart_interface * | smi () |
Get interface which produced this object. | |
const smart_interface * | smi () const |
Get interface which produced this object (const). | |
Private Member Functions | |
smart_device (const smart_device &) | |
void | operator= (const smart_device &) |
Private Attributes | |
smart_interface * | m_intf |
device_info | m_info |
error_info | m_err |
ata_device * | m_ata_ptr |
scsi_device * | m_scsi_ptr |
nvme_device * | m_nvme_ptr |
Static Private Attributes | |
static int | s_num_objects = 0 |
Friends | |
class | ata_device |
class | scsi_device |
class | nvme_device |
Base class for all devices.
Definition at line 32 of file dev_interface.h.
|
protected |
Dummy enum for dummy constructor.
Enumerator | |
---|---|
never_called |
Definition at line 72 of file dev_interface.h.
|
protected |
Constructor to init interface and device info.
Must be called in implementation classes.
Definition at line 33 of file dev_interface.cpp.
|
explicitprotected |
Dummy constructor for abstract classes.
Must never be called in implementation classes.
Definition at line 41 of file dev_interface.cpp.
|
virtual |
Definition at line 47 of file dev_interface.cpp.
|
private |
|
virtual |
Open device with autodetection support.
May return another device for further access. In this case, the original pointer is no longer valid. Default implementation calls 'open()' and returns 'this'.
Reimplemented in os::legacy_scsi_device, os_freebsd::freebsd_megaraid_device, os_freebsd::freebsd_scsi_device, os_freebsd::freebsd_areca_ata_device, os_freebsd::freebsd_areca_scsi_device, os_linux::linux_scsi_device, os_linux::linux_megaraid_device, os_linux::linux_areca_ata_device, os_linux::linux_areca_scsi_device, os_netbsd::netbsd_scsi_device, os_openbsd::openbsd_scsi_device, os_win32::win_areca_scsi_device, os_win32::win_areca_ata_device, and sat::sat_device.
Definition at line 79 of file dev_interface.cpp.
|
inline |
Clear last error info.
Definition at line 168 of file dev_interface.h.
|
pure virtual |
Close device, return false on error.
Implemented in anonymous_namespace{atacmds.cpp}::parsed_ata_device, os_freebsd::freebsd_smart_device, os_netbsd::netbsd_smart_device, os_openbsd::openbsd_smart_device, os_win32::win_smart_device, jmb39x::jmb39x_device, os::legacy_smart_device, tunnelled_device_base, os::darwin_smart_device, os_freebsd::freebsd_megaraid_device, os_freebsd::freebsd_scsi_device, os_linux::linux_smart_device, os_linux::linux_megaraid_device, os_win32::win_csmi_device, and os_win32::win_tw_cli_device.
|
inline |
Get device (path)name.
Definition at line 122 of file dev_interface.h.
|
inline |
Get device type.
Definition at line 128 of file dev_interface.h.
|
inline |
Get last error info struct.
Definition at line 144 of file dev_interface.h.
|
inline |
Get last error message.
Definition at line 150 of file dev_interface.h.
|
inline |
Get last error number.
Definition at line 147 of file dev_interface.h.
|
inline |
Get device info struct.
Definition at line 118 of file dev_interface.h.
|
inline |
Get informal name.
Definition at line 125 of file dev_interface.h.
|
inlinestatic |
Get current number of allocated 'smart_device' objects.
Definition at line 176 of file dev_interface.h.
|
inline |
Get type requested by user, empty if none.
Definition at line 131 of file dev_interface.h.
|
inline |
Return true if ATA device.
Definition at line 86 of file dev_interface.h.
|
inline |
Return true if NVMe device.
Definition at line 92 of file dev_interface.h.
|
pure virtual |
Return true if device is open.
Implemented in anonymous_namespace{atacmds.cpp}::parsed_ata_device, os_freebsd::freebsd_smart_device, os_netbsd::netbsd_smart_device, os_openbsd::openbsd_smart_device, os_win32::win_smart_device, os::legacy_smart_device, tunnelled_device_base, os::darwin_smart_device, os_linux::linux_smart_device, os_win32::win_csmi_device, and os_win32::win_tw_cli_device.
|
virtual |
Early test if device is powered up or down.
Can be used without calling 'open()' first! Return true when device is powered down, false when powered up. If this function is not implemented or the mode cannot be determined, return false. Default implementation returns false.
Reimplemented in os_win32::win_ata_device.
Definition at line 85 of file dev_interface.cpp.
|
inline |
Return true if SCSI device.
Definition at line 89 of file dev_interface.h.
|
virtual |
Return true if last error indicates an unsupported system call.
Default implementation returns true on ENOSYS and ENOTSUP.
Definition at line 52 of file dev_interface.cpp.
|
pure virtual |
Open device, return false on error.
Implemented in anonymous_namespace{atacmds.cpp}::parsed_ata_device, os_freebsd::freebsd_smart_device, os_netbsd::netbsd_smart_device, os_openbsd::openbsd_smart_device, intelliprop::intelliprop_device, jmb39x::jmb39x_device, os::legacy_smart_device, tunnelled_device_base, os::darwin_smart_device, os_freebsd::freebsd_nvme_device, os_freebsd::freebsd_escalade_device, os_freebsd::freebsd_megaraid_device, os_freebsd::freebsd_highpoint_device, os_freebsd::freebsd_scsi_device, os_freebsd::freebsd_cciss_device, os_linux::linux_smart_device, os_linux::linux_aacraid_device, os_linux::linux_megaraid_device, os_linux::linux_escalade_device, os_linux::linux_nvme_device, os_netbsd::netbsd_nvme_device, os_openbsd::openbsd_nvme_device, os_win32::win_ata_device, os_win32::win_csmi_device, os_win32::win_tw_cli_device, os_win32::win_scsi_device, os_win32::win_areca_scsi_device, os_win32::win_areca_ata_device, os_win32::win_aacraid_device, os_win32::win_nvme_device, os_win32::win10_nvme_device, sat::usbjmicron_device, and snt::sntjmicron_device.
|
private |
|
virtual |
Return true if other device is owned by this device.
Default implementation returns false.
Reimplemented in tunnelled_device_base.
Definition at line 90 of file dev_interface.cpp.
|
virtual |
Release ownership of other device.
Default implementation does nothing.
Reimplemented in tunnelled_device_base, tunnelled_device< BaseDev, TunnelDev >, tunnelled_device< ata_device, ata_device >, tunnelled_device< ata_device, smart_device >, tunnelled_device< ata_device, scsi_device >, tunnelled_device< ata_device_with_command_set, scsi_device >, and tunnelled_device< nvme_device, scsi_device >.
Definition at line 95 of file dev_interface.cpp.
|
inline |
Set last error info struct.
Definition at line 164 of file dev_interface.h.
bool smart_device::set_err | ( | int | no | ) |
Set last error number and default message.
Message is retrieved from interface's get_msg_for_errno(no).
Definition at line 74 of file dev_interface.cpp.
bool smart_device::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 63 of file dev_interface.cpp.
|
inlineprotected |
R/W access to device info struct.
Definition at line 136 of file dev_interface.h.
|
inlineprotected |
Get interface which produced this object.
Definition at line 224 of file dev_interface.h.
|
inlineprotected |
Get interface which produced this object (const).
Definition at line 227 of file dev_interface.h.
|
inline |
Downcast to ATA device.
Definition at line 96 of file dev_interface.h.
|
inline |
Downcast to ATA device (const).
Definition at line 99 of file dev_interface.h.
|
inline |
Downcast to NVMe device.
Definition at line 108 of file dev_interface.h.
|
inline |
Downcast to NVMe device (const).
Definition at line 111 of file dev_interface.h.
|
inline |
Downcast to SCSI device.
Definition at line 102 of file dev_interface.h.
|
inline |
Downcast to SCSI device (const).
Definition at line 105 of file dev_interface.h.
|
friend |
Definition at line 238 of file dev_interface.h.
|
friend |
Definition at line 242 of file dev_interface.h.
|
friend |
Definition at line 240 of file dev_interface.h.
|
private |
Definition at line 239 of file dev_interface.h.
|
private |
Definition at line 234 of file dev_interface.h.
|
private |
Definition at line 233 of file dev_interface.h.
|
private |
Definition at line 232 of file dev_interface.h.
|
private |
Definition at line 243 of file dev_interface.h.
|
private |
Definition at line 241 of file dev_interface.h.
|
staticprivate |
Definition at line 246 of file dev_interface.h.