@@ -29,15 +29,6 @@ import (
29
29
30
30
const losetupCMD = "losetup"
31
31
32
- func findFreeLoop (file string ) (string , error ) {
33
- exitcode , out , err := utils .RunCMD (losetupCMD , "-f" )
34
- if exitcode != 0 {
35
- return "" , fmt .Errorf ("failed to find an unused loop device, exitcode: %d, stdout: %s, err: %s" , exitcode , out , err )
36
- }
37
-
38
- return strings .TrimSpace (out ), nil
39
- }
40
-
41
32
// setupLoop allocates the free loop device for the backing store
42
33
func setupLoop (file string ) (string , error ) {
43
34
exitcode , out , err := utils .RunCMD (losetupCMD , "-f" , "--show" , file )
@@ -48,6 +39,14 @@ func setupLoop(file string) (string, error) {
48
39
return strings .TrimSpace (out ), nil
49
40
}
50
41
42
+ func removeLoop (loopPath string ) error {
43
+ exitcode , stdout , stderr := utils .RunCMD (losetupCMD , "-d" , loopPath )
44
+ if exitcode != 0 {
45
+ return fmt .Errorf ("failed to remove loop device: %s, exitcode: %d, stdout: %s, err: %s" , loopPath , exitcode , stdout , stderr )
46
+ }
47
+ return nil
48
+ }
49
+
51
50
func partprobe (device string ) error {
52
51
exitcode , out , err := utils .RunCMD ("partprobe" , device )
53
52
if exitcode != 0 {
0 commit comments