Skip to content

Commit

Permalink
fixed build of non-linux OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Feb 3, 2021
1 parent ee9018c commit df60f8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 1 addition & 5 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions device/dev_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions device/dev_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit df60f8e

Please sign in to comment.