smartmontools SVN Rev 5409
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 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 SELFTEST_ERRORCOUNT(x)   (x & 0xff)
 
#define SELFTEST_ERRORHOURS(x)   ((x >> 8) & 0xffff)
 
#define SCANDIRECTIVE   "DEVICESCAN"
 

Typedefs

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

Enumerations

enum  quit_t {
  QUIT_NODEV , QUIT_NODEVSTARTUP , QUIT_NEVER , QUIT_ONECHECK ,
  QUIT_SHOWTESTS , QUIT_ERRORS
}
 
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 SelfTestErrorCount (ata_device *device, const char *name, firmwarebug_defs firmwarebugs)
 
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 int nvme_get_max_temp_kelvin (const nvme_smart_log &smart_log)
 
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 CheckSelfTestLogs (const dev_config &cfg, dev_state &state, int newi)
 
static char next_scheduled_test (const dev_config &cfg, dev_state &state, bool scsi, 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 int NVMeCheckDevice (const dev_config &cfg, dev_state &state, nvme_device *nvmedev)
 
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 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 1022 of file smartd.cpp.

◆ EXIT_BADCMD

#define EXIT_BADCMD   1

Definition at line 135 of file smartd.cpp.

◆ EXIT_BADCODE

#define EXIT_BADCODE   10

Definition at line 143 of file smartd.cpp.

◆ EXIT_BADCONF

#define EXIT_BADCONF   2

Definition at line 136 of file smartd.cpp.

◆ EXIT_BADDEV

#define EXIT_BADDEV   16

Definition at line 145 of file smartd.cpp.

◆ EXIT_NOCONF

#define EXIT_NOCONF   5

Definition at line 139 of file smartd.cpp.

◆ EXIT_NODEV

#define EXIT_NODEV   17

Definition at line 146 of file smartd.cpp.

◆ EXIT_NOMEM

#define EXIT_NOMEM   8

Definition at line 142 of file smartd.cpp.

◆ EXIT_PID

#define EXIT_PID   4

Definition at line 138 of file smartd.cpp.

◆ EXIT_READCONF

#define EXIT_READCONF   6

Definition at line 140 of file smartd.cpp.

◆ EXIT_SIGNAL

#define EXIT_SIGNAL   254

Definition at line 148 of file smartd.cpp.

◆ EXIT_STARTUP

#define EXIT_STARTUP   3

Definition at line 137 of file smartd.cpp.

◆ SCANDIRECTIVE

#define SCANDIRECTIVE   "DEVICESCAN"

Definition at line 4728 of file smartd.cpp.

◆ SELFTEST_ERRORCOUNT

#define SELFTEST_ERRORCOUNT (   x)    (x & 0xff)

Definition at line 1792 of file smartd.cpp.

◆ SELFTEST_ERRORHOURS

#define SELFTEST_ERRORHOURS (   x)    ((x >> 8) & 0xffff)

Definition at line 1793 of file smartd.cpp.

◆ SIGQUIT_KEYNAME

#define SIGQUIT_KEYNAME   "CONTROL-\\"

Definition at line 89 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 559 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 562 of file smartd.cpp.

◆ signal_handler_type

typedef void(* signal_handler_type) (int)

Definition at line 96 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 349 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 198 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 3467 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 1940 of file smartd.cpp.

◆ calc_next_wakeuptime()

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

Definition at line 4013 of file smartd.cpp.

◆ capabilities_drop_now()

static void capabilities_drop_now ( )
inlinestatic

Definition at line 981 of file smartd.cpp.

◆ capabilities_log_error_hint()

static void capabilities_log_error_hint ( )
inlinestatic

Definition at line 982 of file smartd.cpp.

◆ check_abs_path()

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

Definition at line 4993 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 3370 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 3254 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 1859 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 3941 of file smartd.cpp.

◆ CheckSelfTestLogs()

static void CheckSelfTestLogs ( const dev_config cfg,
dev_state state,
int  newi 
)
static

Definition at line 2836 of file smartd.cpp.

◆ checksumwarning()

void checksumwarning ( const char *  string)

Definition at line 1380 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 3296 of file smartd.cpp.

◆ CloseDevice()

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

Definition at line 1693 of file smartd.cpp.

◆ daemon_init()

static int daemon_init ( )
static

Definition at line 1412 of file smartd.cpp.

◆ Directives()

static void Directives ( )
static

Definition at line 1515 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 3894 of file smartd.cpp.

◆ DoATASelfTest()

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

Definition at line 3136 of file smartd.cpp.

◆ DoSCSISelfTest()

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

Definition at line 3077 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 4020 of file smartd.cpp.

◆ finish_device_scan()

static void finish_device_scan ( dev_config cfg,
dev_state state 
)
static

Definition at line 1883 of file smartd.cpp.

◆ fmt_temp()

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

Definition at line 3287 of file smartd.cpp.

◆ for()

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

Definition at line 1306 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 1900 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 4187 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 4153 of file smartd.cpp.

◆ GetValidArgList()

static const char * GetValidArgList ( char  opt)
static

Definition at line 1563 of file smartd.cpp.

◆ HUPhandler()

static void HUPhandler ( int  sig)
static

Definition at line 925 of file smartd.cpp.

◆ init_disable_standby_check()

static void init_disable_standby_check ( const dev_config_vector configs)
static

Definition at line 3866 of file smartd.cpp.

◆ install_signal_handlers()

static void install_signal_handlers ( )
static

Definition at line 3970 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 1917 of file smartd.cpp.

◆ is_offl_coll_in_progress()

static bool is_offl_coll_in_progress ( unsigned char  status)
inlinestatic

Definition at line 1796 of file smartd.cpp.

◆ is_self_test_in_progress()

static bool is_self_test_in_progress ( unsigned char  status)
inlinestatic

Definition at line 1802 of file smartd.cpp.

◆ le128_to_uint64()

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

Definition at line 2650 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 1808 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 1831 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 1029 of file smartd.cpp.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 5849 of file smartd.cpp.

◆ main_worker()

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

Definition at line 5650 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 5375 of file smartd.cpp.

◆ next_scheduled_test()

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

Definition at line 2900 of file smartd.cpp.

◆ not_allowed_in_filename()

static bool not_allowed_in_filename ( char  c)
static

Definition at line 1720 of file smartd.cpp.

◆ notify_check()

static void notify_check ( int  )
inlinestatic

Definition at line 341 of file smartd.cpp.

◆ notify_exit()

static void notify_exit ( int  )
inlinestatic

Definition at line 343 of file smartd.cpp.

◆ notify_extend_timeout()

static void notify_extend_timeout ( )
inlinestatic

Definition at line 339 of file smartd.cpp.

◆ notify_init()

static void notify_init ( )
inlinestatic

Definition at line 338 of file smartd.cpp.

◆ notify_msg()

static void notify_msg ( const char *  )
inlinestatic

Definition at line 340 of file smartd.cpp.

◆ notify_post_init()

static void static bool notify_post_init ( )
inlinestatic

Definition at line 327 of file smartd.cpp.

◆ notify_wait()

static void notify_wait ( time_t  ,
int   
)
inlinestatic

Definition at line 342 of file smartd.cpp.

◆ nvme_get_max_temp_kelvin()

static int nvme_get_max_temp_kelvin ( const nvme_smart_log smart_log)
static

Definition at line 2664 of file smartd.cpp.

◆ NVMeCheckDevice()

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

Definition at line 3789 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 2674 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 2773 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 612 of file smartd.cpp.

◆ parse_options()

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

Definition at line 5008 of file smartd.cpp.

◆ ParseConfigFile()

static int ParseConfigFile ( dev_config_vector conf_entries,
smart_devtype_list scan_types 
)
static

Definition at line 4844 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 4739 of file smartd.cpp.

◆ ParseToken()

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

Definition at line 4242 of file smartd.cpp.

◆ pout()

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

Definition at line 1326 of file smartd.cpp.

◆ PrintHead()

static void PrintHead ( )
static

Definition at line 1509 of file smartd.cpp.

◆ PrintOut()

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

Definition at line 1354 of file smartd.cpp.

◆ printoutvaliddirectiveargs()

static void printoutvaliddirectiveargs ( int  priority,
char  d 
)
static

Definition at line 4108 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 3023 of file smartd.cpp.

◆ PrintValidArgs()

static void PrintValidArgs ( char  opt)
static

Definition at line 4979 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 1729 of file smartd.cpp.

◆ read_dev_state()

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

Definition at line 709 of file smartd.cpp.

◆ ReadOrMakeConfigEntries()

static int ReadOrMakeConfigEntries ( dev_config_vector conf_entries,
smart_device_list scanned_devs 
)
static

Definition at line 5419 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 5464 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 5549 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 1272 of file smartd.cpp.

◆ sanitize_dev_idinfo()

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

Definition at line 1704 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 3711 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 2388 of file smartd.cpp.

◆ SelfTestErrorCount()

static int SelfTestErrorCount ( ata_device device,
const char *  name,
firmwarebug_defs  firmwarebugs 
)
static

Definition at line 1753 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 99 of file smartd.cpp.

◆ sighandler()

static void sighandler ( int  sig)
static

Definition at line 935 of file smartd.cpp.

◆ Usage()

static void Usage ( )
static

Definition at line 1601 of file smartd.cpp.

◆ USR1handler()

static void USR1handler ( int  sig)
static

Definition at line 907 of file smartd.cpp.

◆ vsnprintf()

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

◆ WaitForPidFile()

static bool WaitForPidFile ( )
static

Definition at line 1389 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 889 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 868 of file smartd.cpp.

◆ write_dev_attrlog()

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

Definition at line 814 of file smartd.cpp.

◆ write_dev_state()

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

Definition at line 760 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 747 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 753 of file smartd.cpp.

◆ write_pid_file()

static bool write_pid_file ( )
static

Definition at line 1485 of file smartd.cpp.

Variable Documentation

◆ ap

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

Definition at line 1301 of file smartd.cpp.

◆ attrlog_path_prefix

std::string attrlog_path_prefix
static

Definition at line 170 of file smartd.cpp.

◆ caughtsigEXIT

volatile int caughtsigEXIT =0
static

Definition at line 229 of file smartd.cpp.

◆ caughtsigHUP

volatile int caughtsigHUP =0
static

Definition at line 226 of file smartd.cpp.

◆ caughtsigUSR1

volatile int caughtsigUSR1 =0
static

Definition at line 217 of file smartd.cpp.

◆ checktime

int checktime = default_checktime
static

Definition at line 156 of file smartd.cpp.

◆ checktime_min

int checktime_min = 0
static

Definition at line 157 of file smartd.cpp.

◆ configfile

const char* configfile
static

Definition at line 177 of file smartd.cpp.

◆ configfile_alt

std::string configfile_alt
static

Definition at line 181 of file smartd.cpp.

◆ configfile_stdin

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

Definition at line 179 of file smartd.cpp.

◆ debugmode

unsigned char debugmode = 0
static

Definition at line 152 of file smartd.cpp.

◆ default_checktime

constexpr int default_checktime = 1800
staticconstexpr

Definition at line 155 of file smartd.cpp.

◆ do_fork

bool do_fork =true
static

Definition at line 210 of file smartd.cpp.

◆ facility

int facility =LOG_DAEMON
static

Definition at line 206 of file smartd.cpp.

◆ failuretest_permissive

unsigned char failuretest_permissive = 0

Definition at line 214 of file smartd.cpp.

◆ fix_swapped_id

const bool fix_swapped_id = false

Definition at line 1937 of file smartd.cpp.

◆ fmt

const char* fmt

Definition at line 1301 of file smartd.cpp.

◆ MAILTYPE_TEST

const int MAILTYPE_TEST = 0
static

Definition at line 449 of file smartd.cpp.

◆ num_test_types

const unsigned num_test_types = sizeof(test_type_chars)-1
static

Definition at line 2896 of file smartd.cpp.

◆ pid_file

std::string pid_file
static

Definition at line 160 of file smartd.cpp.

◆ quit

quit_t quit = QUIT_NODEV
static

Definition at line 202 of file smartd.cpp.

◆ quit_nodev0

bool quit_nodev0 = false
static

Definition at line 203 of file smartd.cpp.

◆ smartd_cpp_cvsid

const char* smartd_cpp_cvsid
Initial value:
= "$Id: smartd.cpp 5403 2022-08-06 16:09:49Z chrfranke $"
CONFIG_H_CVSID

Definition at line 92 of file smartd.cpp.

◆ SMARTD_NMAIL

const int SMARTD_NMAIL = 13
static

Definition at line 447 of file smartd.cpp.

◆ standby_disable_state

int standby_disable_state = 0
static

Definition at line 3864 of file smartd.cpp.

◆ state_path_prefix

std::string state_path_prefix
static

Definition at line 163 of file smartd.cpp.

◆ test_type_chars

const char test_type_chars[] = "LncrSCO"
static

Definition at line 2895 of file smartd.cpp.

◆ warning_script

std::string warning_script
static

Definition at line 184 of file smartd.cpp.