forked from allanliu/smartmontools
-
Notifications
You must be signed in to change notification settings - Fork 2
/
libsmartctl.h
168 lines (147 loc) · 4.75 KB
/
libsmartctl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* libsmartctl.h
*
* Home page of code is: http://www.smartmontools.org
*
* Copyright (C) 2002-10 Bruce Allen
* Copyright (C) 2008-10 Christian Franke
* Copyright (C) 2000 Michael Cornwell <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* You should have received a copy of the GNU General Public License
* (for example COPYING); if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This code was originally developed as a Senior Thesis by Michael Cornwell
* at the Concurrent Systems Laboratory (now part of the Storage Systems
* Research Center), Jack Baskin School of Engineering, University of
* California, Santa Cruz. http://ssrc.soe.ucsc.edu/
*
*/
#ifndef LIBSMARTCTL_H_
#define LIBSMARTCTL_H_
#define LIBSMARTCTL_H_CVSID "$Id$\n"
#include <map>
#include <string>
#include <vector>
#include "smartctl_errs.h"
namespace libsmartctl {
struct DevInfoResp {
std::map<std::string, std::string> content;
ctlerr_t err;
DevInfoResp() : err(NOERR) {}
};
struct DevVendorAttrsResp {
std::vector<std::map<std::string, std::string>> content;
ctlerr_t err;
DevVendorAttrsResp() : err(NOERR) {}
};
struct CantIdDevResp {
bool content;
ctlerr_t err;
CantIdDevResp() : err(NOERR) {}
};
class ClientInterface {
public:
/**
* @brief Checks if device name of the param type can be identified.
* Gaurantees if true, the device is not identifiable, but if true, it still
* necessarily mean device is identifiable.
*
* @param String of full path device name.
*
* @param String of device type, if left blank, auto device type detection
* will be used.
*
* @return struct containing an err type and a boolean indicating if the the
* device can't be IDed, meaning if it can't -> return true.
*/
virtual CantIdDevResp cantIdDev(std::string const &devname,
std::string const &type) = 0;
/**
*@brief Retrieves drive information.
*
* @param String of full path device name.
*
* @param String of device type, if left blank, auto device type detection
* will be used.
*
* @return Map of information type and value, both strings.
*/
virtual DevInfoResp getDevInfo(std::string const &devname,
std::string const &type = "") = 0;
/**
*@brief Retrieves drive vendor attributes
*
* @param string of full path device name
*
* @param String of device type, if left blank, auto device type detection
* will be used.
*
* @return a vector maps containing string key and values of vendor attribute
*type name and attribute type values
*/
virtual DevVendorAttrsResp
getDevVendorAttrs(std::string const &devname,
std::string const &type = "") = 0;
public:
virtual ~ClientInterface() {}
};
class Client : public ClientInterface {
public:
/**
* @brief Checks if device name of the param type can be identified.
* Gaurantees if true, the device is not identifiable, but if true, it still
* necessarily mean device is identifiable.
*
* @param String of full path device name.
*
* @param String of device type, if left blank, auto device type detection
* will be used.
*
* @return struct containing an err type and a boolean indicating if the the
* device can't be IDed, meaning if it can't -> return true.
*/
virtual CantIdDevResp cantIdDev(std::string const &devname,
std::string const &type) override;
/**
*@brief Retrieves drive information.
*
* @param String of full path device name.
*
* @param String of device type, if left blank, auto device type detection
* will be used.
*
* @return Map of information type and value, both strings.
*/
virtual DevInfoResp getDevInfo(std::string const &devname,
std::string const &type = "") override;
/**
*@brief Retrieves drive vendor attributes
*
* @param string of full path device name
*
* @param String of device type, if left blank, auto device type detection
* will be used.
*
* @return a vector maps containing string key and values of vendor attribute
*type name and attribute type values
*/
virtual DevVendorAttrsResp
getDevVendorAttrs(std::string const &devname,
std::string const &type = "") override;
public:
Client();
virtual ~Client() {}
private:
class Impl;
Impl &impl_;
};
} // namespace libsmartctl
#endif