newFlakeyDevice creates flakey device. REF: https://docs.kernel.org/admin-guide/device-mapper/dm-flakey.html
(flakeyDevice, loopDevice string, interval time.Duration)
| 16 | // |
| 17 | // REF: https://docs.kernel.org/admin-guide/device-mapper/dm-flakey.html |
| 18 | func newFlakeyDevice(flakeyDevice, loopDevice string, interval time.Duration) error { |
| 19 | loopSize, err := getBlkSize(loopDevice) |
| 20 | if err != nil { |
| 21 | return fmt.Errorf("failed to get the size of the loop device %s: %w", loopDevice, err) |
| 22 | } |
| 23 | |
| 24 | // The flakey device will be available in interval.Seconds(). |
| 25 | table := fmt.Sprintf("0 %d flakey %s 0 %d 0", |
| 26 | loopSize, loopDevice, int(interval.Seconds())) |
| 27 | |
| 28 | args := []string{"create", flakeyDevice, "--table", table} |
| 29 | |
| 30 | output, err := exec.Command("dmsetup", args...).CombinedOutput() |
| 31 | if err != nil { |
| 32 | return fmt.Errorf("failed to create flakey device %s with table %s (out: %s): %w", |
| 33 | flakeyDevice, table, string(output), err) |
| 34 | } |
| 35 | return nil |
| 36 | } |
| 37 | |
| 38 | // reloadFlakeyDevice reloads the flakey device with feature table. |
| 39 | func reloadFlakeyDevice(flakeyDevice string, syncFS bool, table string) (retErr error) { |
no test coverage detected