detachLoopDevice disassociates the loop device from any backing file. REF: https://man7.org/linux/man-pages/man4/loop.4.html
(loopDevice string)
| 64 | // |
| 65 | // REF: https://man7.org/linux/man-pages/man4/loop.4.html |
| 66 | func 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 | // |
no test coverage detected