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

Function detachLoopDevice

tests/dmflakey/loopback.go:66–74  ·  view source on GitHub ↗

detachLoopDevice disassociates the loop device from any backing file. REF: https://man7.org/linux/man-pages/man4/loop.4.html

(loopDevice string)

Source from the content-addressed store, hash-verified

64//
65// REF: https://man7.org/linux/man-pages/man4/loop.4.html
66func detachLoopDevice(loopDevice string) error {
67 loopFd, err := os.Open(loopDevice)
68 if err != nil {
69 return fmt.Errorf("failed to open loop %s: %w", loopDevice, err)
70 }
71 defer loopFd.Close()
72
73 return unix.IoctlSetInt(int(loopFd.Fd()), unix.LOOP_CLR_FD, 0)
74}
75
76// getFreeLoopDevice allocates or finds a free loop device for use.
77//

Callers 2

InitFlakeyFunction · 0.85
TeardownMethod · 0.85

Calls 2

ErrorfMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected