@@ -21,7 +21,6 @@ import (
21
21
"fmt"
22
22
"os"
23
23
"os/exec"
24
- "path/filepath"
25
24
"strings"
26
25
27
26
"github.com/golang/glog"
@@ -49,21 +48,6 @@ type FileSystems struct {
49
48
Filsystem []ContainerFileSystem `json:"filesystems"`
50
49
}
51
50
52
- func locateCommandPath (commandName string ) string {
53
- // default to root
54
- binary := filepath .Join ("/" , commandName )
55
- for _ , path := range []string {"/bin" , "/usr/sbin" , "/usr/bin" } {
56
- binPath := filepath .Join (path , binary )
57
- if _ , err := os .Stat (binPath ); err != nil {
58
- continue
59
- }
60
-
61
- return binPath
62
- }
63
-
64
- return ""
65
- }
66
-
67
51
func getSourcePath (volumeHandle string ) string {
68
52
return fmt .Sprintf ("%s/%s" , dataRoot , volumeHandle )
69
53
}
@@ -100,7 +84,11 @@ func parseMountInfo(originalMountInfo []byte) ([]MountPointInfo, error) {
100
84
}
101
85
102
86
func checkMountPointExist (sourcePath string ) (bool , error ) {
103
- cmdPath := locateCommandPath ("findmnt" )
87
+ cmdPath , err := exec .LookPath ("findmnt" )
88
+ if err != nil {
89
+ return false , fmt .Errorf ("findmnt not found: %w" , err )
90
+ }
91
+
104
92
out , err := exec .Command (cmdPath , "--json" ).CombinedOutput ()
105
93
if err != nil {
106
94
glog .V (3 ).Infof ("failed to execute command: %+v" , cmdPath )
0 commit comments