smartmontools SVN Rev 5597
Utility to control and monitor storage systems with "S.M.A.R.T."
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
os_linux::linux_smart_device Class Reference

Shared open/close routines. More...

Collaboration diagram for os_linux::linux_smart_device:
Collaboration graph
[legend]

Public Member Functions

 linux_smart_device (int flags, int retry_flags=-1)
 
virtual ~linux_smart_device ()
 
virtual bool is_open () const override
 Return true if device is open.
 
virtual bool open () override
 Open device, return false on error.
 
virtual bool close () override
 Close device, return false on error.
 
- Public Member Functions inherited from smart_device
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_deviceto_ata ()
 Downcast to ATA device.
 
const ata_deviceto_ata () const
 Downcast to ATA device (const).
 
scsi_deviceto_scsi ()
 Downcast to SCSI device.
 
const scsi_deviceto_scsi () const
 Downcast to SCSI device (const).
 
nvme_deviceto_nvme ()
 Downcast to NVMe device.
 
const nvme_deviceto_nvme () const
 Downcast to NVMe device (const).
 
const device_infoget_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_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.
 
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_deviceautodetect_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.
 

Protected Member Functions

int get_fd () const
 Return filedesc for derived classes.
 
void set_fd (int fd)
 
- Protected Member Functions inherited from smart_device
 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_infoset_info ()
 R/W access to device info struct.
 
smart_interfacesmi ()
 Get interface which produced this object.
 
const smart_interfacesmi () const
 Get interface which produced this object (const).
 

Private Attributes

int m_fd
 filedesc, -1 if not open.
 
int m_flags
 Flags for open()
 
int m_retry_flags
 Flags to retry open(), -1 if no retry.
 

Additional Inherited Members

- Static Public Member Functions inherited from smart_device
static int get_num_objects ()
 Get current number of allocated 'smart_device' objects.
 
- Protected Types inherited from smart_device
enum  do_not_use_in_implementation_classes { never_called }
 Dummy enum for dummy constructor. More...
 

Detailed Description

Shared open/close routines.

Definition at line 102 of file os_linux.cpp.

Constructor & Destructor Documentation

◆ linux_smart_device()

os_linux::linux_smart_device::linux_smart_device ( int  flags,
int  retry_flags = -1 
)
inlineexplicit

Definition at line 106 of file os_linux.cpp.

◆ ~linux_smart_device()

os_linux::linux_smart_device::~linux_smart_device ( )
virtual

Definition at line 134 of file os_linux.cpp.

Member Function Documentation

◆ close()

bool os_linux::linux_smart_device::close ( )
overridevirtual

Close device, return false on error.

Implements smart_device.

Reimplemented in os_linux::linux_megaraid_device.

Definition at line 177 of file os_linux.cpp.

◆ get_fd()

int os_linux::linux_smart_device::get_fd ( ) const
inlineprotected

Return filedesc for derived classes.

Definition at line 122 of file os_linux.cpp.

◆ is_open()

bool os_linux::linux_smart_device::is_open ( ) const
overridevirtual

Return true if device is open.

Implements smart_device.

Definition at line 140 of file os_linux.cpp.

◆ open()

bool os_linux::linux_smart_device::open ( )
overridevirtual

Open device, return false on error.

Implements smart_device.

Reimplemented in os_linux::linux_aacraid_device, os_linux::linux_megaraid_device, os_linux::linux_escalade_device, and os_linux::linux_nvme_device.

Definition at line 145 of file os_linux.cpp.

◆ set_fd()

void os_linux::linux_smart_device::set_fd ( int  fd)
inlineprotected

Definition at line 125 of file os_linux.cpp.

Member Data Documentation

◆ m_fd

int os_linux::linux_smart_device::m_fd
private

filedesc, -1 if not open.

Definition at line 129 of file os_linux.cpp.

◆ m_flags

int os_linux::linux_smart_device::m_flags
private

Flags for open()

Definition at line 130 of file os_linux.cpp.

◆ m_retry_flags

int os_linux::linux_smart_device::m_retry_flags
private

Flags to retry open(), -1 if no retry.

Definition at line 131 of file os_linux.cpp.


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