smartmontools SVN Rev 5643
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Macros | Typedefs | Enumerations | Functions | Variables
smartd.cpp File Reference
#include "config.h"
#include <inttypes.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
#include <syslog.h>
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <limits.h>
#include <getopt.h>
#include <algorithm>
#include <map>
#include <stdexcept>
#include <string>
#include <vector>
#include <sys/wait.h>
#include "atacmds.h"
#include "dev_interface.h"
#include "knowndrives.h"
#include "scsicmds.h"
#include "nvmecmds.h"
#include "utility.h"
#include "sg_unaligned.h"
Include dependency graph for smartd.cpp:

Go to the source code of this file.

Classes

class  attribute_flags
 
struct  dev_config
 Configuration data for a device. More...
 
struct  mailinfo
 
struct  persistent_dev_state
 Persistent state data for a device. More...
 
struct  persistent_dev_state::ata_attribute
 
struct  persistent_dev_state::scsi_error_counter_t
 
struct  persistent_dev_state::scsi_error_counter_t::errCounter
 
struct  persistent_dev_state::scsi_nonmedium_error_t
 
struct  persistent_dev_state::scsi_nonmedium_error_t::nme
 
struct  temp_dev_state
 Non-persistent state data for a device. More...
 
struct  dev_state
 Runtime state data for a device. More...
 
class  env_buffer
 

Macros

#define __STDC_FORMAT_MACROS   1
 
#define SIGQUIT_KEYNAME   "CONTROL-\\"
 
#define EXIT_BADCMD   1
 
#define EXIT_BADCONF   2
 
#define EXIT_STARTUP   3
 
#define EXIT_PID   4
 
#define EXIT_NOCONF   5
 
#define EXIT_READCONF   6
 
#define EXIT_NOMEM   8
 
#define EXIT_BADCODE   10
 
#define EXIT_BADDEV   16
 
#define EXIT_NODEV   17
 
#define EXIT_SIGNAL   254
 
#define EBUFLEN   1024
 
#define SCANDIRECTIVE   "DEVICESCAN"
 

Typedefs

typedef void(* signal_handler_type) (int)
 
typedef std::vector< dev_configdev_config_vector
 Container for configuration info for each device.
 
typedef std::vector< dev_statedev_state_vector
 Container for state info for each device.
 

Enumerations

enum  quit_t {
  QUIT_NODEV , QUIT_NODEVSTARTUP , QUIT_NEVER , QUIT_ONECHECK ,
  QUIT_SHOWTESTS , QUIT_ERRORS
}
 
enum class  emailfreqs : unsigned char {
  unknown , once , always , daily ,
  diminishing
}
 
enum  {
  MONITOR_IGN_FAILUSE = 0x01 , MONITOR_IGNORE = 0x02 , MONITOR_RAW_PRINT = 0x04 , MONITOR_RAW = 0x08 ,
  MONITOR_AS_CRIT = 0x10 , MONITOR_RAW_AS_CRIT = 0x20
}
 

Functions

static void set_signal_if_not_ignored (int sig, signal_handler_type handler)
 
static void PrintOut (int priority, const char *fmt,...) __attribute_format_printf(2
 
static void static bool notify_post_init ()
 
static void notify_init ()
 
static void notify_extend_timeout ()
 
static void notify_msg (const char *)
 
static void notify_check (int)
 
static void notify_wait (time_t, int)
 
static void notify_exit (int)
 
static bool parse_dev_state_line (const char *line, persistent_dev_state &state)
 
static bool read_dev_state (const char *path, persistent_dev_state &state)
 
static void write_dev_state_line (FILE *f, const char *name, uint64_t val)
 
static void write_dev_state_line (FILE *f, const char *name1, int id, const char *name2, uint64_t val)
 
static bool write_dev_state (const char *path, const persistent_dev_state &state)
 
static bool write_dev_attrlog (const char *path, const dev_state &state)
 
static void write_all_dev_states (const dev_config_vector &configs, dev_state_vector &states, bool write_always=true)
 
static void write_all_dev_attrlogs (const dev_config_vector &configs, dev_state_vector &states)
 
static void USR1handler (int sig)
 
static void HUPhandler (int sig)
 
static void sighandler (int sig)
 
static void capabilities_drop_now ()
 
static void capabilities_log_error_hint ()
 
static void MailWarning (const dev_config &cfg, dev_state &state, int which, const char *fmt,...) __attribute_format_printf(4
 
static void reset_warning_mail (const dev_config &cfg, dev_state &state, int which, const char *fmt,...) __attribute_format_printf(4
 
 __attribute_format_printf (2, 0) static void vsyslog_lines(int priority
 
 vsnprintf (buf, sizeof(buf), fmt, ap)
 
 for (char *p=buf, *q;p &&*p;p=q)
 
void pout (const char *fmt,...)
 
void checksumwarning (const char *string)
 
static bool WaitForPidFile ()
 
static int daemon_init ()
 
static bool write_pid_file ()
 
static void PrintHead ()
 
static void Directives ()
 
static const char * GetValidArgList (char opt)
 
static void Usage ()
 
static int CloseDevice (smart_device *device, const char *name)
 
static bool sanitize_dev_idinfo (std::string &s)
 
static bool not_allowed_in_filename (char c)
 
static int read_ata_error_count (ata_device *device, const char *name, firmwarebug_defs firmwarebugs, bool extended)
 
static int check_ata_self_test_log (ata_device *device, const char *name, firmwarebug_defs firmwarebugs, unsigned &hour)
 
static bool is_offl_coll_in_progress (unsigned char status)
 
static bool is_self_test_in_progress (unsigned char status)
 
static void log_offline_data_coll_status (const char *name, unsigned char status)
 
static void log_self_test_exec_status (const char *name, unsigned char status)
 
static bool check_pending_id (const dev_config &cfg, const dev_state &state, unsigned char id, const char *msg)
 
static void finish_device_scan (dev_config &cfg, dev_state &state)
 
static void format_set_result_msg (std::string &msg, const char *name, bool ok, int set_option=0, bool has_value=false)
 
static bool is_duplicate_dev_idinfo (const dev_config &cfg, const dev_config_vector &prev_cfgs)
 
static int ATADeviceScan (dev_config &cfg, dev_state &state, ata_device *atadev, const dev_config_vector *prev_cfgs)
 
static int SCSIDeviceScan (dev_config &cfg, dev_state &state, scsi_device *scsidev, const dev_config_vector *prev_cfgs)
 
static uint64_t le128_to_uint64 (const unsigned char(&val)[16])
 
static bool check_nvme_error_log (const dev_config &cfg, dev_state &state, nvme_device *nvmedev, uint64_t newcnt=0)
 
static int NVMeDeviceScan (dev_config &cfg, dev_state &state, nvme_device *nvmedev, const dev_config_vector *prev_cfgs)
 
static bool open_device (const dev_config &cfg, dev_state &state, smart_device *device, const char *type)
 
static void report_self_test_log_changes (const dev_config &cfg, dev_state &state, int errcnt, uint64_t hour)
 
static char next_scheduled_test (const dev_config &cfg, dev_state &state, time_t usetime=0)
 
static void PrintTestSchedule (const dev_config_vector &configs, dev_state_vector &states, const smart_device_list &devices)
 
static int DoSCSISelfTest (const dev_config &cfg, dev_state &state, scsi_device *device, char testtype)
 
static int DoATASelfTest (const dev_config &cfg, dev_state &state, ata_device *device, char testtype)
 
static void check_pending (const dev_config &cfg, dev_state &state, unsigned char id, bool increase_only, const ata_smart_values &smartval, int mailtype, const char *msg)
 
static const char * fmt_temp (unsigned char x, char(&buf)[20])
 
static void CheckTemperature (const dev_config &cfg, dev_state &state, unsigned char currtemp, unsigned char triptemp)
 
static void check_attribute (const dev_config &cfg, dev_state &state, const ata_smart_attribute &attr, const ata_smart_attribute &prev, int attridx, const ata_smart_threshold_entry *thresholds)
 
static int ATACheckDevice (const dev_config &cfg, dev_state &state, ata_device *atadev, bool firstpass, bool allow_selftests)
 
static int SCSICheckDevice (const dev_config &cfg, dev_state &state, scsi_device *scsidev, bool allow_selftests)
 
static void log_nvme_self_test_exec_status (const char *name, dev_state &state, bool firstpass, const nvme_self_test_log &self_test_log)
 
static int check_nvme_self_test_log (uint32_t nsid, const nvme_self_test_log &self_test_log, uint64_t &hour)
 
static int start_nvme_self_test (const dev_config &cfg, dev_state &state, nvme_device *device, char testtype, const nvme_self_test_log &self_test_log)
 
static int NVMeCheckDevice (const dev_config &cfg, dev_state &state, nvme_device *nvmedev, bool firstpass, bool allow_selftests)
 
static void init_disable_standby_check (const dev_config_vector &configs)
 
static void do_disable_standby_check (const dev_config_vector &configs, const dev_state_vector &states)
 
static void CheckDevicesOnce (const dev_config_vector &configs, dev_state_vector &states, smart_device_list &devices, bool firstpass, bool allow_selftests)
 
static void install_signal_handlers ()
 
time_t calc_next_wakeuptime (time_t wakeuptime, time_t timenow, int ct)
 
static time_t dosleep (time_t wakeuptime, const dev_config_vector &configs, dev_state_vector &states, bool &sigwakeup)
 
static void printoutvaliddirectiveargs (int priority, char d)
 
static int GetInteger (const char *arg, const char *name, const char *token, int lineno, const char *cfgfile, int min, int max, char *suffix=0)
 
static int Get3Integers (const char *arg, const char *name, const char *token, int lineno, const char *cfgfile, unsigned char *val1, unsigned char *val2, unsigned char *val3)
 
static int ParseToken (char *token, dev_config &cfg, smart_devtype_list &scan_types)
 
static int ParseConfigLine (dev_config_vector &conf_entries, dev_config &default_conf, smart_devtype_list &scan_types, int lineno, char *line)
 
static int ParseConfigFile (dev_config_vector &conf_entries, smart_devtype_list &scan_types)
 
static void PrintValidArgs (char opt)
 
static bool check_abs_path (char option, const std::string &path)
 
static int parse_options (int argc, char **argv)
 
static int MakeConfigEntries (const dev_config &base_cfg, dev_config_vector &conf_entries, smart_device_list &scanned_devs, const smart_devtype_list &types)
 
static int ReadOrMakeConfigEntries (dev_config_vector &conf_entries, smart_device_list &scanned_devs)
 
static bool register_device (dev_config &cfg, dev_state &state, smart_device_auto_ptr &dev, const dev_config_vector *prev_cfgs)
 
static bool register_devices (const dev_config_vector &conf_entries, smart_device_list &scanned_devs, dev_config_vector &configs, dev_state_vector &states, smart_device_list &devices)
 
static int main_worker (int argc, char **argv)
 
int main (int argc, char **argv)
 

Variables

const char * smartd_cpp_cvsid
 
static const int scsiLogRespLen = 252
 
static unsigned char debugmode = 0
 
static constexpr int default_checktime = 1800
 
static int checktime = default_checktime
 
static int checktime_min = 0
 
static std::string pid_file
 
static std::string state_path_prefix
 
static std::string attrlog_path_prefix
 
static const char * configfile
 
static const char *const configfile_stdin = "<stdin>"
 
static std::string configfile_alt
 
static std::string warning_script
 
static quit_t quit = QUIT_NODEV
 
static bool quit_nodev0 = false
 
static int facility =LOG_DAEMON
 
static bool do_fork =true
 
unsigned char failuretest_permissive = 0
 
static volatile int caughtsigUSR1 =0
 
static volatile int caughtsigHUP =0
 
static volatile int caughtsigEXIT =0
 
static const int SMARTD_NMAIL = 13
 
static const int MAILTYPE_TEST = 0
 
const char * fmt
 
const char va_list ap
 
const bool fix_swapped_id = false
 
static const char test_type_chars [] = "LncrSCO"
 
static const unsigned num_test_types = sizeof(test_type_chars)-1
 
static int standby_disable_state = 0
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS   1

Definition at line 13 of file smartd.cpp.

◆ EBUFLEN

#define EBUFLEN   1024

Definition at line 1043 of file smartd.cpp.

◆ EXIT_BADCMD

#define EXIT_BADCMD   1

Definition at line 138 of file smartd.cpp.

◆ EXIT_BADCODE

#define EXIT_BADCODE   10

Definition at line 146 of file smartd.cpp.

◆ EXIT_BADCONF

#define EXIT_BADCONF   2

Definition at line 139 of file smartd.cpp.

◆ EXIT_BADDEV

#define EXIT_BADDEV   16

Definition at line 148 of file smartd.cpp.

◆ EXIT_NOCONF

#define EXIT_NOCONF   5

Definition at line 142 of file smartd.cpp.

◆ EXIT_NODEV

#define EXIT_NODEV   17

Definition at line 149 of file smartd.cpp.

◆ EXIT_NOMEM

#define EXIT_NOMEM   8

Definition at line 145 of file smartd.cpp.

◆ EXIT_PID

#define EXIT_PID   4

Definition at line 141 of file smartd.cpp.

◆ EXIT_READCONF

#define EXIT_READCONF   6

Definition at line 143 of file smartd.cpp.

◆ EXIT_SIGNAL

#define EXIT_SIGNAL   254

Definition at line 151 of file smartd.cpp.

◆ EXIT_STARTUP

#define EXIT_STARTUP   3

Definition at line 140 of file smartd.cpp.

◆ SCANDIRECTIVE

#define SCANDIRECTIVE   "DEVICESCAN"

Definition at line 5035 of file smartd.cpp.

◆ SIGQUIT_KEYNAME

#define SIGQUIT_KEYNAME   "CONTROL-\\"

Definition at line 90 of file smartd.cpp.

Typedef Documentation

◆ dev_config_vector

typedef std::vector<dev_config> dev_config_vector

Container for configuration info for each device.

Definition at line 580 of file smartd.cpp.

◆ dev_state_vector

typedef std::vector<dev_state> dev_state_vector

Container for state info for each device.

Definition at line 583 of file smartd.cpp.

◆ signal_handler_type

typedef void(* signal_handler_type) (int)

Definition at line 97 of file smartd.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MONITOR_IGN_FAILUSE 
MONITOR_IGNORE 
MONITOR_RAW_PRINT 
MONITOR_RAW 
MONITOR_AS_CRIT 
MONITOR_RAW_AS_CRIT 

Definition at line 359 of file smartd.cpp.

◆ emailfreqs

enum class emailfreqs : unsigned char
strong
Enumerator
unknown 
once 
always 
daily 
diminishing 

Definition at line 353 of file smartd.cpp.

◆ quit_t

enum quit_t
Enumerator
QUIT_NODEV 
QUIT_NODEVSTARTUP 
QUIT_NEVER 
QUIT_ONECHECK 
QUIT_SHOWTESTS 
QUIT_ERRORS 

Definition at line 201 of file smartd.cpp.

Function Documentation

◆ __attribute_format_printf()

__attribute_format_printf ( ,
 
)

◆ ATACheckDevice()

static int ATACheckDevice ( const dev_config cfg,
dev_state state,
ata_device atadev,
bool  firstpass,
bool  allow_selftests 
)
static

scsi

Definition at line 3594 of file smartd.cpp.

◆ ATADeviceScan()

static int ATADeviceScan ( dev_config cfg,
dev_state state,
ata_device atadev,
const dev_config_vector prev_cfgs 
)
static

Definition at line 1971 of file smartd.cpp.

◆ calc_next_wakeuptime()

time_t calc_next_wakeuptime ( time_t  wakeuptime,
time_t  timenow,
int  ct 
)

Definition at line 4318 of file smartd.cpp.

◆ capabilities_drop_now()

static void capabilities_drop_now ( )
inlinestatic

Definition at line 1002 of file smartd.cpp.

◆ capabilities_log_error_hint()

static void capabilities_log_error_hint ( )
inlinestatic

Definition at line 1003 of file smartd.cpp.

◆ check_abs_path()

static bool check_abs_path ( char  option,
const std::string &  path 
)
static

Definition at line 5301 of file smartd.cpp.

◆ check_ata_self_test_log()

static int check_ata_self_test_log ( ata_device device,
const char *  name,
firmwarebug_defs  firmwarebugs,
unsigned &  hour 
)
static

Definition at line 1782 of file smartd.cpp.

◆ check_attribute()

static void check_attribute ( const dev_config cfg,
dev_state state,
const ata_smart_attribute attr,
const ata_smart_attribute prev,
int  attridx,
const ata_smart_threshold_entry thresholds 
)
static

Definition at line 3497 of file smartd.cpp.

◆ check_nvme_error_log()

static bool check_nvme_error_log ( const dev_config cfg,
dev_state state,
nvme_device nvmedev,
uint64_t  newcnt = 0 
)
static

lpo_sup

Definition at line 2699 of file smartd.cpp.

◆ check_nvme_self_test_log()

static int check_nvme_self_test_log ( uint32_t  nsid,
const nvme_self_test_log self_test_log,
uint64_t &  hour 
)
static

Definition at line 3989 of file smartd.cpp.

◆ check_pending()

static void check_pending ( const dev_config cfg,
dev_state state,
unsigned char  id,
bool  increase_only,
const ata_smart_values smartval,
int  mailtype,
const char *  msg 
)
static

Definition at line 3381 of file smartd.cpp.

◆ check_pending_id()

static bool check_pending_id ( const dev_config cfg,
const dev_state state,
unsigned char  id,
const char *  msg 
)
static

Definition at line 1887 of file smartd.cpp.

◆ CheckDevicesOnce()

static void CheckDevicesOnce ( const dev_config_vector configs,
dev_state_vector states,
smart_device_list devices,
bool  firstpass,
bool  allow_selftests 
)
static

Definition at line 4246 of file smartd.cpp.

◆ checksumwarning()

void checksumwarning ( const char *  string)

Definition at line 1401 of file smartd.cpp.

◆ CheckTemperature()

static void CheckTemperature ( const dev_config cfg,
dev_state state,
unsigned char  currtemp,
unsigned char  triptemp 
)
static

Definition at line 3423 of file smartd.cpp.

◆ CloseDevice()

static int CloseDevice ( smart_device device,
const char *  name 
)
static

Definition at line 1722 of file smartd.cpp.

◆ daemon_init()

static int daemon_init ( )
static

Definition at line 1433 of file smartd.cpp.

◆ Directives()

static void Directives ( )
static

Definition at line 1544 of file smartd.cpp.

◆ do_disable_standby_check()

static void do_disable_standby_check ( const dev_config_vector configs,
const dev_state_vector states 
)
static

Definition at line 4199 of file smartd.cpp.

◆ DoATASelfTest()

static int DoATASelfTest ( const dev_config cfg,
dev_state state,
ata_device device,
char  testtype 
)
static

Definition at line 3262 of file smartd.cpp.

◆ DoSCSISelfTest()

static int DoSCSISelfTest ( const dev_config cfg,
dev_state state,
scsi_device device,
char  testtype 
)
static

Definition at line 3203 of file smartd.cpp.

◆ dosleep()

static time_t dosleep ( time_t  wakeuptime,
const dev_config_vector configs,
dev_state_vector states,
bool &  sigwakeup 
)
static

Definition at line 4325 of file smartd.cpp.

◆ finish_device_scan()

static void finish_device_scan ( dev_config cfg,
dev_state state 
)
static

Definition at line 1911 of file smartd.cpp.

◆ fmt_temp()

static const char * fmt_temp ( unsigned char  x,
char(&)  buf[20] 
)
static

Definition at line 3414 of file smartd.cpp.

◆ for()

for ( char *  p = buf,
*q;p &&*p;  p = q 
)

Definition at line 1327 of file smartd.cpp.

◆ format_set_result_msg()

static void format_set_result_msg ( std::string &  msg,
const char *  name,
bool  ok,
int  set_option = 0,
bool  has_value = false 
)
static

Definition at line 1928 of file smartd.cpp.

◆ Get3Integers()

static int Get3Integers ( const char *  arg,
const char *  name,
const char *  token,
int  lineno,
const char *  cfgfile,
unsigned char *  val1,
unsigned char *  val2,
unsigned char *  val3 
)
static

Definition at line 4492 of file smartd.cpp.

◆ GetInteger()

static int GetInteger ( const char *  arg,
const char *  name,
const char *  token,
int  lineno,
const char *  cfgfile,
int  min,
int  max,
char *  suffix = 0 
)
static

Definition at line 4458 of file smartd.cpp.

◆ GetValidArgList()

static const char * GetValidArgList ( char  opt)
static

Definition at line 1592 of file smartd.cpp.

◆ HUPhandler()

static void HUPhandler ( int  sig)
static

Definition at line 946 of file smartd.cpp.

◆ init_disable_standby_check()

static void init_disable_standby_check ( const dev_config_vector configs)
static

Definition at line 4171 of file smartd.cpp.

◆ install_signal_handlers()

static void install_signal_handlers ( )
static

Definition at line 4275 of file smartd.cpp.

◆ is_duplicate_dev_idinfo()

static bool is_duplicate_dev_idinfo ( const dev_config cfg,
const dev_config_vector prev_cfgs 
)
static

Definition at line 1945 of file smartd.cpp.

◆ is_offl_coll_in_progress()

static bool is_offl_coll_in_progress ( unsigned char  status)
inlinestatic

Definition at line 1824 of file smartd.cpp.

◆ is_self_test_in_progress()

static bool is_self_test_in_progress ( unsigned char  status)
inlinestatic

Definition at line 1830 of file smartd.cpp.

◆ le128_to_uint64()

static uint64_t le128_to_uint64 ( const unsigned char(&)  val[16])
static

Definition at line 2685 of file smartd.cpp.

◆ log_nvme_self_test_exec_status()

static void log_nvme_self_test_exec_status ( const char *  name,
dev_state state,
bool  firstpass,
const nvme_self_test_log self_test_log 
)
static

Definition at line 3923 of file smartd.cpp.

◆ log_offline_data_coll_status()

static void log_offline_data_coll_status ( const char *  name,
unsigned char  status 
)
static

Definition at line 1836 of file smartd.cpp.

◆ log_self_test_exec_status()

static void log_self_test_exec_status ( const char *  name,
unsigned char  status 
)
static

Definition at line 1859 of file smartd.cpp.

◆ MailWarning()

static void static void MailWarning ( const dev_config cfg,
dev_state state,
int  which,
const char *  fmt,
  ... 
)
static

Definition at line 1050 of file smartd.cpp.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 6155 of file smartd.cpp.

◆ main_worker()

static int main_worker ( int  argc,
char **  argv 
)
static

Definition at line 5959 of file smartd.cpp.

◆ MakeConfigEntries()

static int MakeConfigEntries ( const dev_config base_cfg,
dev_config_vector conf_entries,
smart_device_list scanned_devs,
const smart_devtype_list types 
)
static

Definition at line 5684 of file smartd.cpp.

◆ next_scheduled_test()

static char next_scheduled_test ( const dev_config cfg,
dev_state state,
time_t  usetime = 0 
)
static

Definition at line 3026 of file smartd.cpp.

◆ not_allowed_in_filename()

static bool not_allowed_in_filename ( char  c)
static

Definition at line 1749 of file smartd.cpp.

◆ notify_check()

static void notify_check ( int  )
inlinestatic

Definition at line 346 of file smartd.cpp.

◆ notify_exit()

static void notify_exit ( int  )
inlinestatic

Definition at line 348 of file smartd.cpp.

◆ notify_extend_timeout()

static void notify_extend_timeout ( )
inlinestatic

Definition at line 344 of file smartd.cpp.

◆ notify_init()

static void notify_init ( )
inlinestatic

Definition at line 343 of file smartd.cpp.

◆ notify_msg()

static void notify_msg ( const char *  )
inlinestatic

Definition at line 345 of file smartd.cpp.

◆ notify_post_init()

static void static bool notify_post_init ( )
inlinestatic

Definition at line 332 of file smartd.cpp.

◆ notify_wait()

static void notify_wait ( time_t  ,
int   
)
inlinestatic

Definition at line 347 of file smartd.cpp.

◆ NVMeCheckDevice()

static int NVMeCheckDevice ( const dev_config cfg,
dev_state state,
nvme_device nvmedev,
bool  firstpass,
bool  allow_selftests 
)
static

Definition at line 4062 of file smartd.cpp.

◆ NVMeDeviceScan()

static int NVMeDeviceScan ( dev_config cfg,
dev_state state,
nvme_device nvmedev,
const dev_config_vector prev_cfgs 
)
static

Definition at line 2766 of file smartd.cpp.

◆ open_device()

static bool open_device ( const dev_config cfg,
dev_state state,
smart_device device,
const char *  type 
)
static

Definition at line 2907 of file smartd.cpp.

◆ parse_dev_state_line()

static bool parse_dev_state_line ( const char *  line,
persistent_dev_state state 
)
static

Definition at line 633 of file smartd.cpp.

◆ parse_options()

static int parse_options ( int  argc,
char **  argv 
)
static

Definition at line 5316 of file smartd.cpp.

◆ ParseConfigFile()

static int ParseConfigFile ( dev_config_vector conf_entries,
smart_devtype_list scan_types 
)
static

Definition at line 5152 of file smartd.cpp.

◆ ParseConfigLine()

static int ParseConfigLine ( dev_config_vector conf_entries,
dev_config default_conf,
smart_devtype_list scan_types,
int  lineno,
char *  line 
)
static

Definition at line 5046 of file smartd.cpp.

◆ ParseToken()

static int ParseToken ( char *  token,
dev_config cfg,
smart_devtype_list scan_types 
)
static

Definition at line 4547 of file smartd.cpp.

◆ pout()

void pout ( const char *  fmt,
  ... 
)

Definition at line 1347 of file smartd.cpp.

◆ PrintHead()

static void PrintHead ( )
static

Definition at line 1538 of file smartd.cpp.

◆ PrintOut()

static void PrintOut ( int  priority,
const char *  fmt,
  ... 
)
static

Definition at line 1375 of file smartd.cpp.

◆ printoutvaliddirectiveargs()

static void printoutvaliddirectiveargs ( int  priority,
char  d 
)
static

Definition at line 4413 of file smartd.cpp.

◆ PrintTestSchedule()

static void PrintTestSchedule ( const dev_config_vector configs,
dev_state_vector states,
const smart_device_list devices 
)
static

Definition at line 3149 of file smartd.cpp.

◆ PrintValidArgs()

static void PrintValidArgs ( char  opt)
static

Definition at line 5287 of file smartd.cpp.

◆ read_ata_error_count()

static int read_ata_error_count ( ata_device device,
const char *  name,
firmwarebug_defs  firmwarebugs,
bool  extended 
)
static

Definition at line 1758 of file smartd.cpp.

◆ read_dev_state()

static bool read_dev_state ( const char *  path,
persistent_dev_state state 
)
static

Definition at line 730 of file smartd.cpp.

◆ ReadOrMakeConfigEntries()

static int ReadOrMakeConfigEntries ( dev_config_vector conf_entries,
smart_device_list scanned_devs 
)
static

Definition at line 5728 of file smartd.cpp.

◆ register_device()

static bool register_device ( dev_config cfg,
dev_state state,
smart_device_auto_ptr dev,
const dev_config_vector prev_cfgs 
)
static

Definition at line 5773 of file smartd.cpp.

◆ register_devices()

static bool register_devices ( const dev_config_vector conf_entries,
smart_device_list scanned_devs,
dev_config_vector configs,
dev_state_vector states,
smart_device_list devices 
)
static

Definition at line 5858 of file smartd.cpp.

◆ report_self_test_log_changes()

static void report_self_test_log_changes ( const dev_config cfg,
dev_state state,
int  errcnt,
uint64_t  hour 
)
static

Definition at line 2970 of file smartd.cpp.

◆ reset_warning_mail()

static void static void reset_warning_mail ( const dev_config cfg,
dev_state state,
int  which,
const char *  fmt,
  ... 
)
static

Definition at line 1293 of file smartd.cpp.

◆ sanitize_dev_idinfo()

static bool sanitize_dev_idinfo ( std::string &  s)
static

Definition at line 1733 of file smartd.cpp.

◆ SCSICheckDevice()

static int SCSICheckDevice ( const dev_config cfg,
dev_state state,
scsi_device scsidev,
bool  allow_selftests 
)
static

Definition at line 3838 of file smartd.cpp.

◆ SCSIDeviceScan()

static int SCSIDeviceScan ( dev_config cfg,
dev_state state,
scsi_device scsidev,
const dev_config_vector prev_cfgs 
)
static

Definition at line 2419 of file smartd.cpp.

◆ set_signal_if_not_ignored()

static void set_signal_if_not_ignored ( int  sig,
signal_handler_type  handler 
)
static

Definition at line 100 of file smartd.cpp.

◆ sighandler()

static void sighandler ( int  sig)
static

Definition at line 956 of file smartd.cpp.

◆ start_nvme_self_test()

static int start_nvme_self_test ( const dev_config cfg,
dev_state state,
nvme_device device,
char  testtype,
const nvme_self_test_log self_test_log 
)
static

Definition at line 4024 of file smartd.cpp.

◆ Usage()

static void Usage ( )
static

Definition at line 1630 of file smartd.cpp.

◆ USR1handler()

static void USR1handler ( int  sig)
static

Definition at line 928 of file smartd.cpp.

◆ vsnprintf()

vsnprintf ( buf  ,
sizeof(buf)  ,
fmt  ,
ap   
)

◆ WaitForPidFile()

static bool WaitForPidFile ( )
static

Definition at line 1410 of file smartd.cpp.

◆ write_all_dev_attrlogs()

static void write_all_dev_attrlogs ( const dev_config_vector configs,
dev_state_vector states 
)
static

Definition at line 910 of file smartd.cpp.

◆ write_all_dev_states()

static void write_all_dev_states ( const dev_config_vector configs,
dev_state_vector states,
bool  write_always = true 
)
static

Definition at line 889 of file smartd.cpp.

◆ write_dev_attrlog()

static bool write_dev_attrlog ( const char *  path,
const dev_state state 
)
static

Definition at line 835 of file smartd.cpp.

◆ write_dev_state()

static bool write_dev_state ( const char *  path,
const persistent_dev_state state 
)
static

Definition at line 781 of file smartd.cpp.

◆ write_dev_state_line() [1/2]

static void write_dev_state_line ( FILE *  f,
const char *  name,
uint64_t  val 
)
static

Definition at line 768 of file smartd.cpp.

◆ write_dev_state_line() [2/2]

static void write_dev_state_line ( FILE *  f,
const char *  name1,
int  id,
const char *  name2,
uint64_t  val 
)
static

Definition at line 774 of file smartd.cpp.

◆ write_pid_file()

static bool write_pid_file ( )
static

Definition at line 1514 of file smartd.cpp.

Variable Documentation

◆ ap

const char va_list ap
Initial value:
{
char buf[512+EBUFLEN]
#define EBUFLEN
Definition: smartd.cpp:1043

Definition at line 1322 of file smartd.cpp.

◆ attrlog_path_prefix

std::string attrlog_path_prefix
static

Definition at line 173 of file smartd.cpp.

◆ caughtsigEXIT

volatile int caughtsigEXIT =0
static

Definition at line 232 of file smartd.cpp.

◆ caughtsigHUP

volatile int caughtsigHUP =0
static

Definition at line 229 of file smartd.cpp.

◆ caughtsigUSR1

volatile int caughtsigUSR1 =0
static

Definition at line 220 of file smartd.cpp.

◆ checktime

int checktime = default_checktime
static

Definition at line 159 of file smartd.cpp.

◆ checktime_min

int checktime_min = 0
static

Definition at line 160 of file smartd.cpp.

◆ configfile

const char* configfile
static

Definition at line 180 of file smartd.cpp.

◆ configfile_alt

std::string configfile_alt
static

Definition at line 184 of file smartd.cpp.

◆ configfile_stdin

const char* const configfile_stdin = "<stdin>"
static

Definition at line 182 of file smartd.cpp.

◆ debugmode

unsigned char debugmode = 0
static

Definition at line 155 of file smartd.cpp.

◆ default_checktime

constexpr int default_checktime = 1800
staticconstexpr

Definition at line 158 of file smartd.cpp.

◆ do_fork

bool do_fork =true
static

Definition at line 213 of file smartd.cpp.

◆ facility

int facility =LOG_DAEMON
static

Definition at line 209 of file smartd.cpp.

◆ failuretest_permissive

unsigned char failuretest_permissive = 0

Definition at line 217 of file smartd.cpp.

◆ fix_swapped_id

const bool fix_swapped_id = false

Definition at line 1968 of file smartd.cpp.

◆ fmt

const char* fmt

Definition at line 1322 of file smartd.cpp.

◆ MAILTYPE_TEST

const int MAILTYPE_TEST = 0
static

Definition at line 463 of file smartd.cpp.

◆ num_test_types

const unsigned num_test_types = sizeof(test_type_chars)-1
static

Definition at line 3022 of file smartd.cpp.

◆ pid_file

std::string pid_file
static

Definition at line 163 of file smartd.cpp.

◆ quit

quit_t quit = QUIT_NODEV
static

Definition at line 205 of file smartd.cpp.

◆ quit_nodev0

bool quit_nodev0 = false
static

Definition at line 206 of file smartd.cpp.

◆ scsiLogRespLen

const int scsiLogRespLen = 252
static

Definition at line 135 of file smartd.cpp.

◆ smartd_cpp_cvsid

const char* smartd_cpp_cvsid
Initial value:
= "$Id: smartd.cpp 5636 2024-11-17 15:11:37Z chrfranke $"
CONFIG_H_CVSID

Definition at line 93 of file smartd.cpp.

◆ SMARTD_NMAIL

const int SMARTD_NMAIL = 13
static

Definition at line 461 of file smartd.cpp.

◆ standby_disable_state

int standby_disable_state = 0
static

Definition at line 4169 of file smartd.cpp.

◆ state_path_prefix

std::string state_path_prefix
static

Definition at line 166 of file smartd.cpp.

◆ test_type_chars

const char test_type_chars[] = "LncrSCO"
static

Definition at line 3021 of file smartd.cpp.

◆ warning_script

std::string warning_script
static

Definition at line 187 of file smartd.cpp.