forked from linuxdeepin/deepin-diskmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceStorage.cpp
More file actions
executable file
·780 lines (652 loc) · 23 KB
/
DeviceStorage.cpp
File metadata and controls
executable file
·780 lines (652 loc) · 23 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only
#include "DeviceStorage.h"
#include <QDebug>
#include <QFile>
#include <QRegularExpression>
#include "utils.h"
namespace DiskManager {
DeviceStorage::DeviceStorage()
: m_model(""), m_vendor(""), m_mediaType(""), m_size(""), m_rotationRate(""), m_interface("")
, m_serialNumber(""), m_version(""), m_capabilities(""), m_description(""), m_KeyToLshw(""), m_KeyFromStorage("")
{
}
bool DeviceStorage::setHwinfoInfo(const QMap<QString, QString> &mapInfo)
{
// 龙芯机器中 hwinfo --disk会列出所有的分区信息
// 存储设备不应包含分区,根据SysFS BusID 来确定是否是分区信息
if (mapInfo.find("SysFS BusID") == mapInfo.end()) {
return false;
}
setAttribute(mapInfo, "Model", m_model);
setAttribute(mapInfo, "Vendor", m_vendor);
setAttribute(mapInfo, "Attached to", m_interface);
QRegExp re(".*\\((.*)\\).*");
if (re.exactMatch(m_interface)) {
m_interface = re.cap(1);
m_interface.replace("Controller", "");
m_interface.replace("controller", "");
}
m_interface = m_interface.trimmed();
setAttribute(mapInfo, "Revision", m_version);
setAttribute(mapInfo, "Hardware Class", m_description);
setAttribute(mapInfo, "Capacity", m_size);
// hwinfo里面显示的内容是 14 GB (15376000000 bytes) 需要处理
m_size.replace(QRegExp("\\(.*\\)"), "").replace(" ", "");
if (m_size.startsWith("0") || m_size == "") {
return false;
}
setAttribute(mapInfo, "Serial ID", m_serialNumber);
///setDiskSerialID(mapInfo["Device Files"]);
setAttribute(mapInfo, "SysFS BusID", m_KeyToLshw);
setAttribute(mapInfo, "Device File", m_DeviceFile);
return true;
}
bool DeviceStorage::setKLUHwinfoInfo(const QMap<QString, QString> &mapInfo)
{
// 龙芯机器中 hwinfo --disk会列出所有的分区信息
// 存储设备不应包含分区,根据SysFS BusID 来确定是否是分区信息
if (mapInfo.find("SysFS BusID") == mapInfo.end()) {
return false;
}
setAttribute(mapInfo, "Model", m_model);
setAttribute(mapInfo, "Vendor", m_vendor);
setAttribute(mapInfo, "Attached to", m_interface);
QRegExp re(".*\\((.*)\\).*");
if (re.exactMatch(m_interface)) {
m_interface = re.cap(1);
m_interface.replace("Controller", "");
m_interface.replace("controller", "");
}
m_interface = m_interface.trimmed();
setAttribute(mapInfo, "Revision", m_version);
setAttribute(mapInfo, "Hardware Class", m_description);
setAttribute(mapInfo, "Capacity", m_size);
// hwinfo里面显示的内容是 14 GB (15376000000 bytes) 需要处理
m_size.replace(QRegExp("\\(.*\\)"), "").replace(" ", "");
if (m_size.startsWith("0") || m_size == "") {
return false;
}
setAttribute(mapInfo, "Serial ID", m_serialNumber);
// setDiskSerialID(mapInfo["Device Files"]);
setAttribute(mapInfo, "SysFS BusID", m_KeyToLshw);
setAttribute(mapInfo, "Device File", m_DeviceFile);
// KLU里面的介质类型的处理方式比较特殊
if (mapInfo["Driver"].contains("usb-storage")) {
m_mediaType = "USB";
}
// loadOtherDeviceInfo(mapInfo);
return true;
}
bool DeviceStorage::addInfoFromlshw(const QMap<QString, QString> &mapInfo)
{
// 先获取需要进行匹配的关键字
QStringList keys = mapInfo["bus info"].split("@");
if (keys.size() != 2) {
return false;
}
QString key = keys[1].trimmed();
key.replace(".", ":");
if (key != m_KeyToLshw) {
return false;
}
// 获取唯一key
QStringList words = mapInfo["bus info"].split(":");
if (words.size() == 2) {
m_KeyFromStorage = words[0];
m_KeyFromStorage.replace("@", "");
}
// 获取基本信息
getInfoFromLshw(mapInfo);
return true;
}
bool DeviceStorage::addInfoFromSmartctl(const QMap<QString, QString> &mapInfo)
{
// 获取基本信息
getInfoFromsmartctl(mapInfo);
return true;
}
bool DeviceStorage::setMediaType(const QString &name, const QString &value)
{
if (!m_DeviceFile.contains(name)) {
return false;
}
if (QString("0") == value) {
m_mediaType = "SSD";
} else if (QString("1") == value) {
m_mediaType = "HDD";
} else {
m_mediaType = "UnKnow";
}
return true;
}
bool DeviceStorage::setKLUMediaType(const QString &name, const QString &value)
{
if (!m_DeviceFile.contains(name)) {
return false;
}
if (m_mediaType == "USB") {
return true;
}
if (QString("0") == value) {
m_mediaType = "SSD";
} else if (QString("1") == value) {
m_mediaType = "HDD";
} else {
m_mediaType = "UnKnow";
}
return true;
}
void DeviceStorage::getInfoFromLshw(const QMap<QString, QString> &mapInfo)
{
setAttribute(mapInfo, "capabilities", m_capabilities);
setAttribute(mapInfo, "version", m_version);
setAttribute(mapInfo, "serial", m_serialNumber, false);
setAttribute(mapInfo, "product", m_model);
setAttribute(mapInfo, "description", m_description);
setAttribute(mapInfo, "size", m_size);
// 223GiB (240GB)
QRegExp re(".*\\((.*)\\)$");
if (re.exactMatch(m_size)) {
m_size = re.cap(1);
}
}
void DeviceStorage::getInfoFromsmartctl(const QMap<QString, QString> &mapInfo)
{
// qDebug() << mapInfo << endl;
// 固件版本
m_firmwareVersion = mapInfo["Firmware Version"];
// 速度
QString sataVersion = mapInfo["SATA Version"];
QStringList strList = sataVersion.split(",");
if (strList.size() == 2) {
m_speed = strList[1].trimmed();
}
setAttribute(mapInfo, "Rotation Rate", m_rotationRate);
// 通电时间
m_powerOnHours = mapInfo["Power_On_Hours"];
if (m_powerOnHours == "") {
m_powerOnHours = mapInfo["Power On Hours"];
}
// 通电次数
m_powerCycleCount = mapInfo["Power_Cycle_Count"];
if (m_powerCycleCount == "") {
m_powerCycleCount = mapInfo["Power Cycles"];
}
// 安装大小
QString capacity = mapInfo["User Capacity"];
if (capacity == "") {
capacity = mapInfo["Total NVM Capacity"];
}
if (capacity != "") {
QRegExp reg(".*\\[(.*)\\]$");
if (reg.exactMatch(capacity)) {
m_size = reg.cap(1);
}
}
// 型号
//SATA
if (mapInfo["Device Model"].isEmpty() == false) {
m_model = mapInfo["Device Model"];
}
//NVME
if (mapInfo["Model Number"].isEmpty() == false) {
m_model = mapInfo["Model Number"];
}
if (mapInfo.find("Serial Number") != mapInfo.end())
setAttribute(mapInfo, "Serial Number", m_serialNumber, true);
else if (mapInfo.find("Serial number") != mapInfo.end()) {
// 某些机型smart命令查询结果为Serial number
setAttribute(mapInfo, "Serial number", m_serialNumber, true);
}
}
void DeviceStorage::setAttribute(const QMap<QString, QString> &mapInfo, const QString &key, QString &variable, bool overwrite)
{
if (mapInfo.find(key) == mapInfo.end()) {
return;
}
if (mapInfo[key] == "") {
return;
}
if (overwrite) {
variable = mapInfo[key].trimmed();
} else {
if (variable.isEmpty()) {
variable = mapInfo[key].trimmed();
}
if (variable.contains("Unknown", Qt::CaseInsensitive)) {
variable = mapInfo[key].trimmed();
}
}
}
bool DeviceStorage::getDiskInfoFromHwinfo(const QString &devicePath)
{
QString cmd = QString("hwinfo --disk --only %1").arg(devicePath);
QProcess proc;
proc.start(cmd);
proc.waitForFinished(-1);
QString outPut = proc.readAllStandardOutput();
QMap<QString, QString> mapInfo;
getMapInfoFromInput(outPut, mapInfo);
setHwinfoInfo(mapInfo);
//部分华为设备读取到是Serial ID为乱码
QString cid = Utils::readContent("/proc/bootdevice/cid");
if (!cid.isEmpty()) {
m_serialNumber = cid;
}
return true;
}
void DeviceStorage::getMapInfoFromHwinfo(const QString &info, QMap<QString, QString> &mapInfo, const QString &ch)
{
QStringList infoList = info.split("\n");
for (QStringList::iterator it = infoList.begin(); it != infoList.end(); ++it) {
QStringList words = (*it).split(ch);
if (words.size() != 2) {
continue;
}
QRegExp re(".*\"(.*)\".*");
if (re.exactMatch(words[1].trimmed())) {
QString key = words[0].trimmed();
QString value = re.cap(1);
//这里是为了防止 "usb-storage", "sr" -》 usb-storage", "sr
if (key == "Driver") {
value.replace("\"", "");
}
mapInfo[key] += value;
} else {
if (words[0].trimmed() == "Resolution") {
mapInfo[words[0].trimmed()] += words[1].trimmed();
} else {
mapInfo[words[0].trimmed()] = words[1].trimmed();
}
}
}
}
void DeviceStorage::getMapInfoFromInput(const QString &info, QMap<QString, QString> &mapInfo)
{
QStringList items = info.split("\n\n");
foreach (const QString &item, items) {
if (item.isEmpty()) {
continue;
}
getMapInfoFromHwinfo(item, mapInfo);
}
}
bool DeviceStorage::getDiskInfoFromLshw(const QString &devicePath)
{
QProcess proc;
proc.start("sudo lshw -C disk");
proc.waitForFinished(-1);
QString outPut = proc.readAllStandardOutput();
QStringList list = outPut.split("*-disk\n");
outPut.clear();
for (int i =0;i<list.count();i++) {
if(list.at(i).contains(devicePath)) {
outPut = list.at(i);
break;
}
}
if (outPut.isEmpty()) {
return false;
}
QMap<QString, QString> mapInfo;
getMapInfoFromLshw(outPut, mapInfo);
addInfoFromlshw(mapInfo);
return true;
}
void DeviceStorage::getMapInfoFromLshw(const QString &info, QMap<QString, QString> &mapInfo, const QString &ch)
{
QStringList infoList = info.split("\n");
for (QStringList::iterator it = infoList.begin(); it != infoList.end(); ++it) {
QStringList words = (*it).split(ch);
if (words.size() != 2) {
continue;
}
// && words[0].contains("configuration") == false && words[0].contains("resources") == false
// 将configuration的内容进行拆分
if (words[0].contains("configuration") == true) {
QStringList keyValues = words[1].split(" ");
for (QStringList::iterator it = keyValues.begin(); it != keyValues.end(); ++it) {
QStringList attr = (*it).split("=");
if (attr.size() != 2) {
continue;
}
mapInfo.insert(attr[0].trimmed(), attr[1].trimmed());
}
} else if (words[0].contains("resources") == true) {
QStringList keyValues = words[1].split(" ");
for (QStringList::iterator it = keyValues.begin(); it != keyValues.end(); ++it) {
QStringList attr = (*it).split(":");
if (attr.size() != 2) {
continue;
}
if (mapInfo.find(attr[0].trimmed()) != mapInfo.end()) {
mapInfo[attr[0].trimmed()] += QString(" ");
}
mapInfo[attr[0].trimmed()] += attr[1].trimmed();
}
} else {
mapInfo.insert(words[0].trimmed(), words[1].trimmed());
}
}
}
bool DeviceStorage::getDiskInfoFromLsblk(const QString &devicePath)
{
QString cmd = QString("lsblk -d -o name,rota %1").arg(devicePath);
QProcess proc;
proc.start(cmd);
proc.waitForFinished(-1);
QMap<QString, QString> mapInfo;
QString outPut = proc.readAllStandardOutput();
loadLsblkInfo(outPut, mapInfo);
if (mapInfo.size() == 1) {
setMediaType(mapInfo.firstKey(),mapInfo.value(mapInfo.firstKey()));
} else {
return false;
}
return true;
}
void DeviceStorage::loadLsblkInfo(const QString &info, QMap<QString, QString> &mapInfo)
{
QStringList lines = info.split("\n");
foreach (QString line, lines) {
QStringList words = line.replace(QRegExp("[\\s]+"), " ").split(" ");
if (words.size() != 2 || words[0] == "NAME") {
continue;
}
mapInfo.insert(words[0].trimmed(), words[1].trimmed());
}
}
bool DeviceStorage::getDiskInfoFromSmartCtl(const QString &devicePath)
{
QString cmd = QString("smartctl --all %1").arg(devicePath);
QProcess proc;
proc.start(cmd);
proc.waitForFinished(-1);
QString outPut = proc.readAllStandardOutput();
if (outPut.contains("Please specify device type with the -d option")) {
QString cmd = QString("smartctl --all -d sat %1").arg(devicePath);
QProcess proc;
proc.start(cmd);
proc.waitForFinished(-1);
outPut = proc.readAllStandardOutput();
}
QMap<QString, QString> mapInfo;
getMapInfoFromSmartctl(mapInfo, outPut);
addInfoFromSmartctl(mapInfo);
return true;
}
void DeviceStorage::getDiskInfoModel(const QString &devicePath, QString &model)
{
QProcess proc;
QString cmd = QString("smartctl --all %1").arg(devicePath);
proc.start(cmd);
proc.waitForFinished(-1);
QString outPut = proc.readAllStandardOutput();
if (outPut.contains("Please specify device type with the -d option")) {
cmd = QString("smartctl --all -d sat %1").arg(devicePath);
proc.start(cmd);
proc.waitForFinished(-1);
outPut = proc.readAllStandardOutput();
}
QStringList infoList = outPut.split("\n");
for (int i = 0; i < infoList.size(); i++) {
QString info = infoList[i];
if(info.startsWith("Device Model:") || info.startsWith("Product:") || info.startsWith("Model Number:")){
model = info.split(":").last().trimmed();
return;
}
}
cmd = "lshw -C disk";
proc.start(cmd);
proc.waitForFinished(-1);
outPut = proc.readAllStandardOutput();
infoList = outPut.split("*-disk\n");
for (int i =0; i < infoList.size(); i++) {
if(infoList[i].contains(devicePath)) {
QStringList tempList = infoList[i].split("\n");
for (int j = 0; j < tempList.size(); j++) {
if(tempList[j].contains("product:")){
model = tempList[j].split(":").last().trimmed();
return;
}
}
break;
}
}
cmd = "udevadm info " + devicePath + " | grep ID_MODEL=";
proc.start("bash", QStringList() << "-c" << cmd);
proc.waitForFinished(-1);
outPut = proc.readAllStandardOutput();
if (!outPut.isEmpty()) {
auto idModel = outPut.split("=", QString::SkipEmptyParts);
if (idModel.count() > 1)
model = idModel.at(1).trimmed();
if (!model.isEmpty())
return;
}
qWarning() << "tried a lot but got nothing about model for" << devicePath;
// 若未获取到型号名,返回未知
model = "UnKnow";
return;
}
QString DeviceStorage::getDiskInfoMediaType(const QString &devicePath)
{
QStringList deviceList = devicePath.split("/");
QString device = deviceList[deviceList.size()-1];
QString value;
QString cmd = QString("cat /sys/block/%1/queue/rotational").arg(device);
QProcess proc;
proc.start(cmd);
proc.waitForFinished(-1);
QString outPut = proc.readAllStandardOutput().trimmed();
value = outPut;
if ("1" == value) {
cmd = QString("smartctl -i %1").arg(devicePath);
proc.start(cmd);
proc.waitForFinished(-1);
outPut = proc.readAllStandardOutput();
if (outPut.contains("Solid State Device")) {
value = "0";
} else if (outPut.contains("Please specify device type with the -d option")) {
//FIXME: Hard type scsi for USB disk
cmd = QString("smartctl -i -d scsi %1").arg(devicePath);
proc.start(cmd);
proc.waitForFinished(-1);
outPut = proc.readAllStandardOutput();
if (!outPut.contains("Rotation Rate:")) {
value = "0";
}
}
}
if (QString("0") == value) {
return "SSD";
} else if (QString("1") == value) {
return "HDD";
} else {
return "UnKnow";
}
}
static bool isPGUX()
{
static int isPGUX = -1;
QString output, err;
if (isPGUX != -1)
return 1 == isPGUX;
Utils::executeCmdWithArtList("dmidecode", QStringList() << "-t" << "11", output, err);
QRegularExpression re("String 4: (.+?)\\s");
QRegularExpressionMatch match = re.match(output);
isPGUX = (match.hasMatch() && (match.captured(1) == "PGUX")) ? 1 : 0;
return 1 == isPGUX;
}
void DeviceStorage::getDiskInfoInterface(const QString &devicePath, QString &interface, QString &model)
{
QString bootDevicePath("/proc/bootdevice/product_name");
QFile file(bootDevicePath);
if (file.open(QIODevice::ReadOnly)) {
if (model == file.readLine().simplified()) {
QString spec_version = Utils::readContent("/sys/block/sdd/device/spec_version").trimmed();
if (!spec_version.isEmpty())
interface = (spec_version == "300") ? "UFS 3.0" : "UFS 3.1";
}
file.close();
}
if (interface.isEmpty()) {
QString cmd = QString("hwinfo --disk --only %1").arg(devicePath);
QProcess proc;
proc.start(cmd);
proc.waitForFinished(-1);
QString outPut = proc.readAllStandardOutput().trimmed();
QStringList outPutList = outPut.split("(");
interface = outPutList[outPutList.size() - 1].split(" ")[0];
}
return;
}
void DeviceStorage::updateForHWDevice(const QString &devicePath)
{
if (m_model != Utils::readContent("/proc/bootdevice/product_name").trimmed())
return;
// m_firmwareVersion
if (m_firmwareVersion.isEmpty()) {
if (isPGUX())
m_firmwareVersion = Utils::readContent("/proc/bootdevice/rev").trimmed();
}
// hide mode and vendor
m_model = "";
m_vendor = "";
}
void DeviceStorage::getMapInfoFromSmartctl(QMap<QString, QString> &mapInfo, const QString &info, const QString &ch)
{
QString indexName;
int startIndex = 0;
QRegExp reg("^[\\s\\S]*[\\d]:[\\d][\\s\\S]*$");//time 08:00
for (int i = 0; i < info.size(); ++i) {
if (info[i] != '\n' && i != info.size() - 1) {
continue;
}
QString line = info.mid(startIndex, i - startIndex);
startIndex = i + 1;
int index = line.indexOf(ch);
if (index > 0 && reg.exactMatch(line) == false && false == line.contains("Error") && false == line.contains("hh:mm:SS")) {
if (line.indexOf("(") < index && line.indexOf(")") > index) {
continue;
}
if (line.indexOf("[") < index && line.indexOf("]") > index) {
continue;
}
indexName = line.mid(0, index).trimmed().remove(" is");
if (mapInfo.contains(indexName)) {
mapInfo[indexName] += ", ";
mapInfo[indexName] += line.mid(index + 1).trimmed();
} else {
mapInfo[indexName] = line.mid(index + 1).trimmed();
}
continue;
}
if (indexName.isEmpty() == false && (line.startsWith("\t\t") || line.startsWith(" ")) && line.contains(":") == false) {
if (mapInfo.contains(indexName)) {
mapInfo[indexName] += ", ";
mapInfo[indexName] += line.trimmed();
} else {
mapInfo[indexName] = line.trimmed();
}
continue;
}
indexName = "";
QRegExp rx("^[ ]*[0-9]+[ ]+([\\w-_]+)[ ]+0x[0-9a-fA-F-]+[ ]+[0-9]+[ ]+[0-9]+[ ]+[0-9]+[ ]+[\\w-]+[ ]+[\\w-]+[ ]+[\\w-]+[ ]+([0-9\\/w-]+[ ]*[ 0-9\\/w-()]*)$");
if (rx.indexIn(line) > -1) {
mapInfo[rx.cap(1)] = rx.cap(2);
continue;
}
QStringList strList;
if (line.endsWith(")")) {
int leftBracket = line.indexOf("(");
if (leftBracket > 0) {
QString str = line.left(leftBracket).trimmed();
strList = str.trimmed().split(" ");
if (strList.size() > 2) {
strList.last() += line.mid(leftBracket);
}
}
} else if (strList.size() == 0) {
strList = line.trimmed().split(" ");
}
if (strList.size() < 5) {
continue;
}
if (line.contains("Power_On_Hours")) {
mapInfo["Power_On_Hours"] = strList.last();
continue;
}
if (line.contains("Power_Cycle_Count")) {
mapInfo["Power_Cycle_Count"] = strList.last();
continue;
}
if (line.contains("Raw_Read_Error_Rate")) {
mapInfo["Raw_Read_Error_Rate"] = strList.last();
continue;
}
if (line.contains("Spin_Up_Time")) {
mapInfo["Spin_Up_Time"] = strList.last();
continue;
}
if (line.contains("Start_Stop_Count")) {
mapInfo["Start_Stop_Count"] = strList.last();
continue;
}
if (line.contains("Reallocated_Sector_Ct")) {
mapInfo["Reallocated_Sector_Ct"] = strList.last();
continue;
}
if (line.contains("Seek_Error_Rate")) {
mapInfo["Seek_Error_Rate"] = strList.last();
continue;
}
if (line.contains("Spin_Retry_Count")) {
mapInfo["Spin_Retry_Count"] = strList.last();
continue;
}
if (line.contains("Calibration_Retry_Count")) {
mapInfo["Calibration_Retry_Count"] = strList.last();
continue;
}
if (line.contains("G-Sense_Error_Rate")) {
mapInfo["G-Sense_Error_Rate"] = strList.last();
continue;
}
if (line.contains("Power-Off_Retract_Count")) {
mapInfo["Power-Off_Retract_Count"] = strList.last();
continue;
}
if (line.contains("Load_Cycle_Count")) {
mapInfo["Load_Cycle_Count"] = strList.last();
continue;
}
if (line.contains("Temperature_Celsius")) {
mapInfo["Temperature_Celsius"] = strList.last();
continue;
}
if (line.contains("Reallocated_Event_Count")) {
mapInfo["Reallocated_Event_Count"] = strList.last();
continue;
}
if (line.contains("Current_Pending_Sector")) {
mapInfo["Current_Pending_Sector"] = strList.last();
continue;
}
if (line.contains("Offline_Uncorrectable")) {
mapInfo["Offline_Uncorrectable"] = strList.last();
continue;
}
if (line.contains("UDMA_CRC_Error_Count")) {
mapInfo["UDMA_CRC_Error_Count"] = strList.last();
continue;
}
if (line.contains("Multi_Zone_Error_Rate")) {
mapInfo["Multi_Zone_Error_Rate"] = strList.last();
continue;
}
}
}
}