smartmontools  SVN Rev 4057
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Namespaces | Macros | 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 <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 <sys/sysmacros.h>
#include "int64.h"
#include "atacmds.h"
#include "os_linux.h"
#include "scsicmds.h"
#include "utility.h"
#include "cciss.h"
#include "megaraid.h"
#include "aacraid.h"
#include "dev_interface.h"
#include "dev_ata_cmd_set.h"
#include "dev_areca.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...
 
struct  os_linux::linux_ioctl_send_command
 
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_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_smart_interface
 Linux interface. More...
 

Namespaces

 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 SCSI_IOCTL_SEND_COMMAND   1
 
#define SG_IO_PRESENT_UNKNOWN   0
 
#define SG_IO_PRESENT_YES   1
 
#define SG_IO_PRESENT_NO   2
 
#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 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)
 

Functions

static int os_linux::sg_io_cmnd_io (int dev_fd, struct scsi_cmnd_io *iop, int report, int unknown)
 
static int os_linux::sisc_cmnd_io (int dev_fd, struct scsi_cmnd_io *iop, int report)
 
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 ()
 

Variables

const char * os_linux_cpp_cvsid
 
unsigned char failuretest_permissive
 
static const char os_linux::smartctl_examples []
 
static int os_linux::sg_io_state = SG_IO_PRESENT_UNKNOWN
 

Macro Definition Documentation

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

Definition at line 100 of file os_linux.cpp.

#define BUFFER_LEN_678K   ( sizeof(TW_Ioctl) )

Definition at line 1695 of file os_linux.cpp.

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

Definition at line 1696 of file os_linux.cpp.

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

Definition at line 1697 of file os_linux.cpp.

#define BUFFER_LENGTH   (4+512)

Definition at line 256 of file os_linux.cpp.

#define DEVICE_STRING_LENGTH   32

Definition at line 1503 of file os_linux.cpp.

#define ENOTSUP   ENOSYS

Definition at line 97 of file os_linux.cpp.

#define LSCSI_DID_BUS_BUSY   0x2

Definition at line 506 of file os_linux.cpp.

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

Definition at line 503 of file os_linux.cpp.

#define LSCSI_DID_NO_CONNECT   0x1

Definition at line 507 of file os_linux.cpp.

#define LSCSI_DID_TIME_OUT   0x3

Definition at line 505 of file os_linux.cpp.

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

Definition at line 501 of file os_linux.cpp.

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

Definition at line 502 of file os_linux.cpp.

#define LSCSI_DRIVER_TIMEOUT   0x6

Definition at line 504 of file os_linux.cpp.

#define MAJOR_STRING_LENGTH   3

Definition at line 1502 of file os_linux.cpp.

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

Definition at line 498 of file os_linux.cpp.

#define NODE_STRING_LENGTH   16

Definition at line 1504 of file os_linux.cpp.

#define SCSI_IOCTL_SEND_COMMAND   1

Definition at line 510 of file os_linux.cpp.

#define SEND_IOCTL_RESP_SENSE_LEN   16 /* ioctl limitation */

Definition at line 499 of file os_linux.cpp.

#define SG_IO_PRESENT_NO   2

Definition at line 515 of file os_linux.cpp.

#define SG_IO_PRESENT_UNKNOWN   0

Definition at line 513 of file os_linux.cpp.

#define SG_IO_PRESENT_YES   1

Definition at line 514 of file os_linux.cpp.

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

Definition at line 500 of file os_linux.cpp.

#define SRB_STATUS_AUTOSENSE_VALID   0x80
#define SRB_STATUS_ERROR   0x4
#define SRB_STATUS_NO_DEVICE   0x08
#define SRB_STATUS_SELECTION_TIMEOUT   0x0a
#define SRB_STATUS_SUCCESS   0x1
#define STRANGE_BUFFER_LENGTH   (4+512*0xf8)

Definition at line 2287 of file os_linux.cpp.

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

Definition at line 1698 of file os_linux.cpp.

Variable Documentation

unsigned char failuretest_permissive

Definition at line 1110 of file smartctl.cpp.

const char* os_linux_cpp_cvsid
Initial value:
= "$Id: os_linux.cpp 4047 2015-03-22 16:16:24Z chrfranke $"
#define OS_LINUX_H_CVSID
Definition: os_linux.h:41

Definition at line 102 of file os_linux.cpp.