MCPcopy
hub / github.com/etcd-io/bbolt / newFlakeyDevice

Function newFlakeyDevice

tests/dmflakey/dmsetup.go:18–36  ·  view source on GitHub ↗

newFlakeyDevice creates flakey device. REF: https://docs.kernel.org/admin-guide/device-mapper/dm-flakey.html

(flakeyDevice, loopDevice string, interval time.Duration)

Source from the content-addressed store, hash-verified

16//
17// REF: https://docs.kernel.org/admin-guide/device-mapper/dm-flakey.html
18func 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.
39func reloadFlakeyDevice(flakeyDevice string, syncFS bool, table string) (retErr error) {

Callers 1

InitFlakeyFunction · 0.85

Calls 2

getBlkSizeFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected