summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Milde <daniel@milde.cz>2021-02-03 14:53:22 +0100
committerDaniel Milde <daniel@milde.cz>2021-02-03 14:53:22 +0100
commitdf60f8e30fcb5fda1eb037c4a2c4d9a48723de76 (patch)
tree13ab2e882c2e56b1c6057f7278b6f4cf3e266987
parentee9018c84b516695c42715136077c9ffe96a914a (diff)
fixed build of non-linux OSesv4.4.0
-rw-r--r--cmd/run.go6
-rw-r--r--device/dev_linux.go3
-rw-r--r--device/dev_other.go3
3 files changed, 7 insertions, 5 deletions
diff --git a/cmd/run.go b/cmd/run.go
index 1924946..fa6648e 100644
--- a/cmd/run.go
+++ b/cmd/run.go
@@ -88,11 +88,7 @@ func Run(flags *RunFlags, args []string, istty bool, writer io.Writer, testing b
if flags.ShowDisks {
if runtime.GOOS == "linux" {
ui.SetIgnoreDirPaths(flags.IgnoreDirs)
- ui.ListDevices(
- device.LinuxDevicesInfoGetter{
- MountsPath: "/proc/mounts",
- },
- )
+ ui.ListDevices(device.Getter)
} else {
fmt.Fprint(writer, "Listing devices is not yet supported for this platform")
return
diff --git a/device/dev_linux.go b/device/dev_linux.go
index 7f20b9b..1c232fc 100644
--- a/device/dev_linux.go
+++ b/device/dev_linux.go
@@ -15,6 +15,9 @@ type LinuxDevicesInfoGetter struct {
MountsPath string
}
+// Getter is current instance of DevicesInfoGetter
+var Getter DevicesInfoGetter = LinuxDevicesInfoGetter{MountsPath: "/proc/mounts"}
+
// GetDevicesInfo returns usage info about mounted devices (by calling Statfs syscall)
func (t LinuxDevicesInfoGetter) GetDevicesInfo() ([]*Device, error) {
file, err := os.Open(t.MountsPath)
diff --git a/device/dev_other.go b/device/dev_other.go
index 5878ef4..301e03c 100644
--- a/device/dev_other.go
+++ b/device/dev_other.go
@@ -7,6 +7,9 @@ import "errors"
// OtherDevicesInfoGetter retruns info for other devices
type OtherDevicesInfoGetter struct{}
+// Getter is current instance of DevicesInfoGetter
+var Getter DevicesInfoGetter = OtherDevicesInfoGetter{}
+
// GetDevicesInfo returns usage info about mounted devices (by calling Statfs syscall)
func (t OtherDevicesInfoGetter) GetDevicesInfo() ([]*Device, error) {
return nil, errors.New("Only Linux platform is supported for listing devices")