smartmontools SVN Rev 5642
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Namespaces | Macros | Enumerations | Functions | Variables
os_linux.cpp File Reference
#include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <glob.h>
#include <scsi/scsi.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/sg.h>
#include <linux/bsg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/uio.h>
#include <sys/types.h>
#include <dirent.h>
#include "atacmds.h"
#include "os_linux.h"
#include "scsicmds.h"
#include "utility.h"
#include "cciss.h"
#include "megaraid.h"
#include "sssraid.h"
#include "aacraid.h"
#include "nvmecmds.h"
#include "dev_interface.h"
#include "dev_ata_cmd_set.h"
#include "dev_areca.h"
#include "linux_nvme_ioctl.h"
Include dependency graph for os_linux.cpp:

Go to the source code of this file.

Classes

class  os_linux::linux_smart_device
 Shared open/close routines. More...
 
class  os_linux::linux_ata_device
 Linux ATA support. More...
 
class  os_linux::linux_scsi_device
 Standard SCSI support. More...
 
class  os_linux::linux_aacraid_device
 PMC AacRAID support. More...
 
class  os_linux::linux_megaraid_device
 LSI MegaRAID support. More...
 
class  os_linux::linux_sssraid_device
 3SNIC RAID support More...
 
class  os_linux::linux_escalade_device
 CCISS RAID support. More...
 
class  os_linux::linux_areca_ata_device
 Areca RAID support. More...
 
class  os_linux::linux_areca_scsi_device
 
class  os_linux::linux_marvell_device
 Marvell support. More...
 
class  os_linux::linux_highpoint_device
 Highpoint RAID support. More...
 
class  os_linux::linux_nvme_device
 NVMe support. More...
 
class  os_linux::linux_smart_interface
 Linux interface. More...
 

Namespaces

namespace  os_linux
 

Macros

#define ENOTSUP   ENOSYS
 
#define ARGUSED(x)   ((void)(x))
 
#define BUFFER_LENGTH   (4+512)
 
#define MAX_DXFER_LEN   1024 /* can be increased if necessary */
 
#define SEND_IOCTL_RESP_SENSE_LEN   16 /* ioctl limitation */
 
#define SG_IO_RESP_SENSE_LEN   64 /* large enough see buffer */
 
#define LSCSI_DRIVER_MASK   0xf /* mask out "suggestions" */
 
#define LSCSI_DRIVER_SENSE   0x8 /* alternate CHECK CONDITION indication */
 
#define LSCSI_DID_ERROR   0x7 /* Need to work around aacraid driver quirk */
 
#define LSCSI_DRIVER_TIMEOUT   0x6
 
#define LSCSI_DID_TIME_OUT   0x3
 
#define LSCSI_DID_BUS_BUSY   0x2
 
#define LSCSI_DID_NO_CONNECT   0x1
 
#define SRB_STATUS_SUCCESS   0x1
 
#define SRB_STATUS_ERROR   0x4
 
#define SRB_STATUS_NO_DEVICE   0x08
 
#define SRB_STATUS_SELECTION_TIMEOUT   0x0a
 
#define SRB_STATUS_AUTOSENSE_VALID   0x80
 
#define MAJOR_STRING_LENGTH   3
 
#define DEVICE_STRING_LENGTH   32
 
#define NODE_STRING_LENGTH   16
 
#define SCSI_IOCTL_SEND_COMMAND   1
 
#define BUFFER_LEN_678K   ( sizeof(TW_Ioctl) )
 
#define BUFFER_LEN_678K_CHAR   ( sizeof(TW_New_Ioctl)+512-1 )
 
#define BUFFER_LEN_9000   ( sizeof(TW_Ioctl_Buf_Apache)+512-1 )
 
#define TW_IOCTL_BUFFER_SIZE   ( MAX(MAX(BUFFER_LEN_678K, BUFFER_LEN_9000), BUFFER_LEN_678K_CHAR) )
 
#define STRANGE_BUFFER_LENGTH   (4+512*0xf8)
 

Enumerations

enum  os_linux::lk_sg_io_ifc_t { os_linux::SG_IO_USE_DETECT = 0 , os_linux::SG_IO_UNSUPP = 1 , os_linux::SG_IO_USE_V3 = 3 , os_linux::SG_IO_USE_V4 = 4 }
 

Functions

static int os_linux::sg_io_cmnd_io (int dev_fd, struct scsi_cmnd_io *iop, int report, enum lk_sg_io_ifc_t sg_io_ifc)
 
static int os_linux::do_normal_scsi_cmnd_io (int dev_fd, struct scsi_cmnd_io *iop, int report)
 
static int os_linux::setup_3ware_nodes (const char *nodename, const char *driver_name)
 
static int os_linux::find_areca_in_proc ()
 
static bool os_linux::read_id (const std::string &path, unsigned short &id)
 
static bool os_linux::get_usb_id (const char *name, unsigned short &vendor_id, unsigned short &product_id, unsigned short &version)
 
static unsigned os_linux::get_kernel_release ()
 
static bool os_linux::is_hpsa_in_raid_mode (const char *name)
 

Variables

const char * os_linux_cpp_cvsid
 
unsigned char failuretest_permissive
 
static const char os_linux::smartctl_examples []
 
static enum lk_sg_io_ifc_t os_linux::sg_io_interface = SG_IO_USE_DETECT
 

Macro Definition Documentation

◆ ARGUSED

#define ARGUSED (   x)    ((void)(x))

Definition at line 91 of file os_linux.cpp.

◆ BUFFER_LEN_678K

#define BUFFER_LEN_678K   ( sizeof(TW_Ioctl) )

Definition at line 1797 of file os_linux.cpp.

◆ BUFFER_LEN_678K_CHAR

#define BUFFER_LEN_678K_CHAR   ( sizeof(TW_New_Ioctl)+512-1 )

Definition at line 1798 of file os_linux.cpp.

◆ BUFFER_LEN_9000

#define BUFFER_LEN_9000   ( sizeof(TW_Ioctl_Buf_Apache)+512-1 )

Definition at line 1799 of file os_linux.cpp.

◆ BUFFER_LENGTH

#define BUFFER_LENGTH   (4+512)

Definition at line 247 of file os_linux.cpp.

◆ DEVICE_STRING_LENGTH

#define DEVICE_STRING_LENGTH   32

Definition at line 1600 of file os_linux.cpp.

◆ ENOTSUP

#define ENOTSUP   ENOSYS

Definition at line 88 of file os_linux.cpp.

◆ LSCSI_DID_BUS_BUSY

#define LSCSI_DID_BUS_BUSY   0x2

Definition at line 497 of file os_linux.cpp.

◆ LSCSI_DID_ERROR

#define LSCSI_DID_ERROR   0x7 /* Need to work around aacraid driver quirk */

Definition at line 494 of file os_linux.cpp.

◆ LSCSI_DID_NO_CONNECT

#define LSCSI_DID_NO_CONNECT   0x1

Definition at line 498 of file os_linux.cpp.

◆ LSCSI_DID_TIME_OUT

#define LSCSI_DID_TIME_OUT   0x3

Definition at line 496 of file os_linux.cpp.

◆ LSCSI_DRIVER_MASK

#define LSCSI_DRIVER_MASK   0xf /* mask out "suggestions" */

Definition at line 492 of file os_linux.cpp.

◆ LSCSI_DRIVER_SENSE

#define LSCSI_DRIVER_SENSE   0x8 /* alternate CHECK CONDITION indication */

Definition at line 493 of file os_linux.cpp.

◆ LSCSI_DRIVER_TIMEOUT

#define LSCSI_DRIVER_TIMEOUT   0x6

Definition at line 495 of file os_linux.cpp.

◆ MAJOR_STRING_LENGTH

#define MAJOR_STRING_LENGTH   3

Definition at line 1599 of file os_linux.cpp.

◆ MAX_DXFER_LEN

#define MAX_DXFER_LEN   1024 /* can be increased if necessary */

Definition at line 489 of file os_linux.cpp.

◆ NODE_STRING_LENGTH

#define NODE_STRING_LENGTH   16

Definition at line 1601 of file os_linux.cpp.

◆ SCSI_IOCTL_SEND_COMMAND

#define SCSI_IOCTL_SEND_COMMAND   1

Definition at line 1770 of file os_linux.cpp.

◆ SEND_IOCTL_RESP_SENSE_LEN

#define SEND_IOCTL_RESP_SENSE_LEN   16 /* ioctl limitation */

Definition at line 490 of file os_linux.cpp.

◆ SG_IO_RESP_SENSE_LEN

#define SG_IO_RESP_SENSE_LEN   64 /* large enough see buffer */

Definition at line 491 of file os_linux.cpp.

◆ SRB_STATUS_AUTOSENSE_VALID

#define SRB_STATUS_AUTOSENSE_VALID   0x80

◆ SRB_STATUS_ERROR

#define SRB_STATUS_ERROR   0x4

◆ SRB_STATUS_NO_DEVICE

#define SRB_STATUS_NO_DEVICE   0x08

◆ SRB_STATUS_SELECTION_TIMEOUT

#define SRB_STATUS_SELECTION_TIMEOUT   0x0a

◆ SRB_STATUS_SUCCESS

#define SRB_STATUS_SUCCESS   0x1

◆ STRANGE_BUFFER_LENGTH

#define STRANGE_BUFFER_LENGTH   (4+512*0xf8)

Definition at line 2385 of file os_linux.cpp.

◆ TW_IOCTL_BUFFER_SIZE

#define TW_IOCTL_BUFFER_SIZE   ( MAX(MAX(BUFFER_LEN_678K, BUFFER_LEN_9000), BUFFER_LEN_678K_CHAR) )

Definition at line 1800 of file os_linux.cpp.

Variable Documentation

◆ failuretest_permissive

unsigned char failuretest_permissive
extern

Definition at line 1457 of file smartctl.cpp.

◆ os_linux_cpp_cvsid

const char* os_linux_cpp_cvsid
Initial value:
= "$Id: os_linux.cpp 5457 2023-02-17 16:21:30Z chrfranke $"
#define OS_LINUX_H_CVSID
Definition: os_linux.h:27

Definition at line 93 of file os_linux.cpp.