(deviceFields []string)
| 326 | } |
| 327 | |
| 328 | func evalComponentDevices(deviceFields []string) ([]MDStatComponent, error) { |
| 329 | mdComponentDevices := make([]MDStatComponent, 0) |
| 330 | for _, field := range deviceFields { |
| 331 | match := componentDeviceRE.FindStringSubmatch(field) |
| 332 | if match == nil { |
| 333 | continue |
| 334 | } |
| 335 | descriptorIndex, err := strconv.ParseInt(match[2], 10, 32) |
| 336 | if err != nil { |
| 337 | return mdComponentDevices, fmt.Errorf("error parsing int from device %q: %w", match[2], err) |
| 338 | } |
| 339 | mdComponentDevices = append(mdComponentDevices, MDStatComponent{ |
| 340 | Name: match[1], |
| 341 | DescriptorIndex: int32(descriptorIndex), |
| 342 | // match may contain one or more of these |
| 343 | // https://github.com/torvalds/linux/blob/7ec462100ef9142344ddbf86f2c3008b97acddbe/drivers/md/md.c#L8376-L8392 |
| 344 | Faulty: strings.Contains(match[3], "(F)"), |
| 345 | Spare: strings.Contains(match[3], "(S)"), |
| 346 | Journal: strings.Contains(match[3], "(J)"), |
| 347 | Replacement: strings.Contains(match[3], "(R)"), |
| 348 | WriteMostly: strings.Contains(match[3], "(W)"), |
| 349 | }) |
| 350 | } |
| 351 | |
| 352 | return mdComponentDevices, nil |
| 353 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…