smartmontools SVN Rev 5602
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Macros | Typedefs | Enumerations | Functions | Variables
knowndrives.cpp File Reference
#include "config.h"
#include <stdio.h>
#include "atacmds.h"
#include "knowndrives.h"
#include "utility.h"
#include <stdexcept>
#include "drivedb.h"
Include dependency graph for knowndrives.cpp:

Go to the source code of this file.

Classes

class  drive_database
 Drive database class. More...
 
class  stdin_iterator
 
struct  token_info
 

Macros

#define MODEL_STRING_LENGTH   40
 
#define FIRMWARE_STRING_LENGTH   8
 
#define TABLEPRINTWIDTH   19
 

Typedefs

typedef stdin_iterator parse_ptr
 

Enumerations

enum  dbentry_type { DBENTRY_VERSION , DBENTRY_ATA_DEFAULT , DBENTRY_ATA , DBENTRY_USB }
 

Functions

static dbentry_type get_modelfamily_type (const char *modelfamily)
 
static dbentry_type get_dbentry_type (const drive_settings *dbentry)
 
static void parse_version (std::string &dbversion, const char *verstr)
 
static bool compile (regular_expression &regex, const char *pattern)
 
static bool match (const char *pattern, const char *str)
 
static const drive_settingslookup_drive (const char *model, const char *firmware, std::string *dbversion=nullptr)
 
static bool parse_db_presets (const char *presets, ata_vendor_attr_defs *defs, firmwarebug_defs *firmwarebugs, std::string *type)
 
static bool parse_default_presets (const char *presets, ata_vendor_attr_defs &defs)
 
static bool parse_presets (const char *presets, ata_vendor_attr_defs &defs, firmwarebug_defs &firmwarebugs)
 
static bool parse_usb_type (const char *presets, std::string &type)
 
static void parse_usb_names (const char *names, usb_dev_info &info)
 
int lookup_usb_device (int vendor_id, int product_id, int bcd_device, usb_dev_info &info, usb_dev_info &info2)
 
static int showonepreset (const drive_settings *dbentry)
 
int showallpresets ()
 
int showmatchingpresets (const char *model, const char *firmware)
 
void show_presets (const ata_identify_device *drive)
 
const drive_settingslookup_drive_apply_presets (const ata_identify_device *drive, ata_vendor_attr_defs &defs, firmwarebug_defs &firmwarebugs, std::string &dbversion)
 
static parse_ptr skip_white (parse_ptr src, const char *path, int &line)
 
static parse_ptr get_token (parse_ptr src, token_info &token, const char *path, int &line)
 
static bool parse_drive_database (parse_ptr src, drive_database &db, const char *path)
 
bool read_drive_database (const char *path)
 
const char * get_drivedb_path_add ()
 
static bool read_default_drive_databases ()
 
static bool init_default_attr_defs ()
 
bool init_drive_database (bool use_default_db)
 
const ata_vendor_attr_defsget_default_attr_defs ()
 

Variables

const char * knowndrives_cpp_cvsid
 
const drive_settings builtin_knowndrives []
 
const unsigned builtin_knowndrives_size
 
static drive_database knowndrives
 The drive database.
 
static ata_vendor_attr_defs default_attr_defs
 

Macro Definition Documentation

◆ FIRMWARE_STRING_LENGTH

#define FIRMWARE_STRING_LENGTH   8

Definition at line 32 of file knowndrives.cpp.

◆ MODEL_STRING_LENGTH

#define MODEL_STRING_LENGTH   40

Definition at line 31 of file knowndrives.cpp.

◆ TABLEPRINTWIDTH

#define TABLEPRINTWIDTH   19

Definition at line 33 of file knowndrives.cpp.

Typedef Documentation

◆ parse_ptr

Definition at line 653 of file knowndrives.cpp.

Enumeration Type Documentation

◆ dbentry_type

Enumerator
DBENTRY_VERSION 
DBENTRY_ATA_DEFAULT 
DBENTRY_ATA 
DBENTRY_USB 

Definition at line 137 of file knowndrives.cpp.

Function Documentation

◆ compile()

static bool compile ( regular_expression regex,
const char *  pattern 
)
static

Definition at line 180 of file knowndrives.cpp.

◆ get_dbentry_type()

static dbentry_type get_dbentry_type ( const drive_settings dbentry)
inlinestatic

Definition at line 157 of file knowndrives.cpp.

◆ get_default_attr_defs()

const ata_vendor_attr_defs & get_default_attr_defs ( )

Definition at line 993 of file knowndrives.cpp.

◆ get_drivedb_path_add()

const char * get_drivedb_path_add ( )

Definition at line 894 of file knowndrives.cpp.

◆ get_modelfamily_type()

static dbentry_type get_modelfamily_type ( const char *  modelfamily)
static

Definition at line 145 of file knowndrives.cpp.

◆ get_token()

static parse_ptr get_token ( parse_ptr  src,
token_info token,
const char *  path,
int &  line 
)
static

Definition at line 712 of file knowndrives.cpp.

◆ init_default_attr_defs()

static bool init_default_attr_defs ( )
static

Definition at line 949 of file knowndrives.cpp.

◆ init_drive_database()

bool init_drive_database ( bool  use_default_db)

Definition at line 984 of file knowndrives.cpp.

◆ lookup_drive()

static const drive_settings * lookup_drive ( const char *  model,
const char *  firmware,
std::string *  dbversion = nullptr 
)
static

Definition at line 204 of file knowndrives.cpp.

◆ lookup_drive_apply_presets()

const drive_settings * lookup_drive_apply_presets ( const ata_identify_device drive,
ata_vendor_attr_defs defs,
firmwarebug_defs firmwarebugs,
std::string &  dbversion 
)

Definition at line 584 of file knowndrives.cpp.

◆ lookup_usb_device()

int lookup_usb_device ( int  vendor_id,
int  product_id,
int  bcd_device,
usb_dev_info info,
usb_dev_info info2 
)

Definition at line 314 of file knowndrives.cpp.

◆ match()

static bool match ( const char *  pattern,
const char *  str 
)
static

Definition at line 192 of file knowndrives.cpp.

◆ parse_db_presets()

static bool parse_db_presets ( const char *  presets,
ata_vendor_attr_defs defs,
firmwarebug_defs firmwarebugs,
std::string *  type 
)
static

Definition at line 244 of file knowndrives.cpp.

◆ parse_default_presets()

static bool parse_default_presets ( const char *  presets,
ata_vendor_attr_defs defs 
)
inlinestatic

Definition at line 280 of file knowndrives.cpp.

◆ parse_drive_database()

static bool parse_drive_database ( parse_ptr  src,
drive_database db,
const char *  path 
)
static

Definition at line 770 of file knowndrives.cpp.

◆ parse_presets()

static bool parse_presets ( const char *  presets,
ata_vendor_attr_defs defs,
firmwarebug_defs firmwarebugs 
)
inlinestatic

Definition at line 287 of file knowndrives.cpp.

◆ parse_usb_names()

static void parse_usb_names ( const char *  names,
usb_dev_info info 
)
static

Definition at line 301 of file knowndrives.cpp.

◆ parse_usb_type()

static bool parse_usb_type ( const char *  presets,
std::string &  type 
)
inlinestatic

Definition at line 295 of file knowndrives.cpp.

◆ parse_version()

static void parse_version ( std::string &  dbversion,
const char *  verstr 
)
static

Definition at line 163 of file knowndrives.cpp.

◆ read_default_drive_databases()

static bool read_default_drive_databases ( )
static

Definition at line 920 of file knowndrives.cpp.

◆ read_drive_database()

bool read_drive_database ( const char *  path)

Definition at line 878 of file knowndrives.cpp.

◆ show_presets()

void show_presets ( const ata_identify_device drive)

Definition at line 550 of file knowndrives.cpp.

◆ showallpresets()

int showallpresets ( )

Definition at line 492 of file knowndrives.cpp.

◆ showmatchingpresets()

int showmatchingpresets ( const char *  model,
const char *  firmware 
)

Definition at line 517 of file knowndrives.cpp.

◆ showonepreset()

static int showonepreset ( const drive_settings dbentry)
static

Definition at line 370 of file knowndrives.cpp.

◆ skip_white()

static parse_ptr skip_white ( parse_ptr  src,
const char *  path,
int &  line 
)
static

Definition at line 656 of file knowndrives.cpp.

Variable Documentation

◆ builtin_knowndrives

const drive_settings builtin_knowndrives[]
Initial value:
= {
}

Definition at line 42 of file knowndrives.cpp.

◆ builtin_knowndrives_size

const unsigned builtin_knowndrives_size
Initial value:
=
const drive_settings builtin_knowndrives[]
Definition: knowndrives.cpp:42

Definition at line 46 of file knowndrives.cpp.

◆ default_attr_defs

ata_vendor_attr_defs default_attr_defs
static

Definition at line 946 of file knowndrives.cpp.

◆ knowndrives

drive_database knowndrives
static

The drive database.

Definition at line 134 of file knowndrives.cpp.

◆ knowndrives_cpp_cvsid

const char* knowndrives_cpp_cvsid
Initial value:
= "$Id: knowndrives.cpp 5376 2022-05-01 12:49:30Z chrfranke $"
#define KNOWNDRIVES_H_CVSID
Definition: knowndrives.h:15

Definition at line 28 of file knowndrives.cpp.