@@ -28,11 +28,11 @@ import (
28
28
)
29
29
30
30
var (
31
- statuslineRE = regexp .MustCompile (`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]` )
32
- raid0lineRE = regexp .MustCompile (`(\d+) blocks( super ([0-9\.])*)? \d+k chunks` )
33
- buildlineRE = regexp .MustCompile (`\((\d+)/\d+\)` )
34
- unknownPersonalityLine = regexp .MustCompile (`(\d+) blocks (.*)` )
35
- raidPersonalityRE = regexp .MustCompile (`raid[0-9]+` )
31
+ statuslineRE = regexp .MustCompile (`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]` )
32
+ raid0lineRE = regexp .MustCompile (`(\d+) blocks( super ([0-9\.])*)? \d+k chunks` )
33
+ buildlineRE = regexp .MustCompile (`\((\d+)/\d+\)` )
34
+ unknownPersonalityLineRE = regexp .MustCompile (`(\d+) blocks (.*)` )
35
+ raidPersonalityRE = regexp .MustCompile (`raid[0-9]+` )
36
36
)
37
37
38
38
type mdStatus struct {
@@ -94,8 +94,8 @@ func evalRaid0line(statusline string) (size int64, err error) {
94
94
return size , nil
95
95
}
96
96
97
- func evalUnknownPersonalityline (statusline string ) (size int64 , err error ) {
98
- matches := unknownPersonalityLine .FindStringSubmatch (statusline )
97
+ func evalUnknownPersonalitylineRE (statusline string ) (size int64 , err error ) {
98
+ matches := unknownPersonalityLineRE .FindStringSubmatch (statusline )
99
99
100
100
if len (matches ) != 2 + 1 {
101
101
return 0 , fmt .Errorf ("invalid unknown personality status line: %s" , statusline )
@@ -176,10 +176,10 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {
176
176
currentMD = mainLine [0 ] // The name of the md-device.
177
177
isActive := (mainLine [2 ] == "active" ) // The activity status of the md-device.
178
178
personality = ""
179
- for _ , possiblePersonality := range mainLine {
179
+ for _ , possiblePersonality := range mainLine [ 3 :] {
180
180
if raidPersonalityRE .MatchString (possiblePersonality ) {
181
181
personality = possiblePersonality
182
- // break
182
+ break
183
183
}
184
184
}
185
185
@@ -196,7 +196,7 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {
196
196
active , total , size , err = evalStatusline (lines [i + 1 ]) // Parse statusline, always present.
197
197
default :
198
198
log .Infof ("Personality unknown: %s\n " , mainLine )
199
- size , err = evalUnknownPersonalityline (lines [i + 1 ]) // Parse statusline, always present.
199
+ size , err = evalUnknownPersonalitylineRE (lines [i + 1 ]) // Parse statusline, always present.
200
200
}
201
201
202
202
if err != nil {
0 commit comments