Documentation
¶
Index ¶
- Constants
- func GetLspciPath() (string, error)
- type Distribution
- type DistributionVersion
- type FsType
- type GetfsUsageRetval
- type IsMountedProvider
- type KernelVersion
- type LinuxProvider
- func (s LinuxProvider) Chmod(path string, mode os.FileMode) error
- func (s LinuxProvider) Chown(path string, uid, gid int) error
- func (s LinuxProvider) Getegid() int
- func (s LinuxProvider) Geteuid() int
- func (s LinuxProvider) Getfs(device string) (string, error)
- func (s LinuxProvider) GetfsType(path string) (*FsType, error)
- func (s LinuxProvider) GetfsUsage(target string) (uint64, uint64, error)
- func (s LinuxProvider) IsMounted(target string) (bool, error)
- func (s LinuxProvider) Mkdir(name string, perm os.FileMode) error
- func (s LinuxProvider) Mkfs(req MkfsReq) error
- func (s LinuxProvider) Mount(source, target, fstype string, flags uintptr, data string) error
- func (s LinuxProvider) ReadFile(path string) ([]byte, error)
- func (s LinuxProvider) RemoveAll(path string) error
- func (s LinuxProvider) Stat(path string) (os.FileInfo, error)
- func (s LinuxProvider) Unmount(target string, flags int) error
- type MkfsReq
- type MockSysConfig
- type MockSysProvider
- func (msp *MockSysProvider) Chmod(string, os.FileMode) error
- func (msp *MockSysProvider) Chown(string, int, int) error
- func (msp *MockSysProvider) GetMountOpts(target string) (string, error)
- func (msp *MockSysProvider) Getegid() int
- func (msp *MockSysProvider) Geteuid() int
- func (msp *MockSysProvider) Getfs(_ string) (string, error)
- func (msp *MockSysProvider) GetfsType(path string) (*FsType, error)
- func (msp *MockSysProvider) GetfsUsage(_ string) (uint64, uint64, error)
- func (msp *MockSysProvider) IsMounted(target string) (bool, error)
- func (msp *MockSysProvider) Mkdir(path string, flags os.FileMode) error
- func (msp *MockSysProvider) Mkfs(_ MkfsReq) error
- func (msp *MockSysProvider) Mount(_, target, _ string, _ uintptr, opts string) error
- func (msp *MockSysProvider) ReadFile(path string) ([]byte, error)
- func (msp *MockSysProvider) RemoveAll(path string) error
- func (msp *MockSysProvider) Stat(path string) (os.FileInfo, error)
- func (msp *MockSysProvider) Unmount(target string, _ int) error
- type MountMap
- type MountProvider
- type RunCmdError
- type UnmountProvider
Constants ¶
const ( FsTypeNone = "none" FsTypeExt4 = "ext4" FsTypeBtrfs = "btrfs" FsTypeXfs = "xfs" FsTypeZfs = "zfs" FsTypeNtfs = "ntfs" FsTypeTmpfs = "tmpfs" FsTypeNfs = "nfs" FsTypeUnknown = "unknown" // magic numbers harvested from statfs man page MagicTmpfs = 0x01021994 MagicExt4 = 0xEF53 MagicBtrfs = 0x9123683E MagicXfs = 0x58465342 MagicZfs = 0x2FC12FC1 MagicNtfs = 0x5346544e MagicNfs = 0x6969 )
Variables ¶
This section is empty.
Functions ¶
func GetLspciPath ¶
GetLspciPath returns binary path based on distribution.
Types ¶
type Distribution ¶
type Distribution struct { ID string `json:"id"` Name string `json:"name"` Version DistributionVersion `json:"version"` Kernel KernelVersion `json:"kernel"` }
Distribution represents a Linux distribution.
func GetDistribution ¶
func GetDistribution() Distribution
GetDistribution returns information about the current Linux distribution.
func (Distribution) String ¶
func (d Distribution) String() string
type DistributionVersion ¶
type DistributionVersion struct { StringVersion string `json:"string_version"` Major int `json:"major"` Minor int `json:"minor"` Patch int `json:"patch"` }
DistributionVersion represents a version of a Linux distribution.
func (DistributionVersion) String ¶
func (dv DistributionVersion) String() string
type GetfsUsageRetval ¶
GetfsUsageRetval encapsulates return values from a GetfsUsage call.
type IsMountedProvider ¶
IsMountedProvider is the interface that wraps the IsMounted method, which can be provided by a system-specific implementation or a mock.
type KernelVersion ¶
KernelVersion is the kernel version.
type LinuxProvider ¶
type LinuxProvider struct{}
LinuxProvider encapsulates Linux-specific implementations of system interfaces.
func DefaultProvider ¶
func DefaultProvider() *LinuxProvider
DefaultProvider returns the package-default provider implementation.
func (LinuxProvider) Chmod ¶
func (s LinuxProvider) Chmod(path string, mode os.FileMode) error
Chmod changes the mode of the specified path.
func (LinuxProvider) Chown ¶
func (s LinuxProvider) Chown(path string, uid, gid int) error
Chown changes the ownership of the specified path.
func (LinuxProvider) Getegid ¶
func (s LinuxProvider) Getegid() int
Getegid returns the numeric effective group id of the caller.
func (LinuxProvider) Geteuid ¶
func (s LinuxProvider) Geteuid() int
Geteuid returns the numeric effective user id of the caller.
func (LinuxProvider) Getfs ¶
func (s LinuxProvider) Getfs(device string) (string, error)
Getfs probes the specified device in an attempt to determine the formatted filesystem type, if any.
func (LinuxProvider) GetfsType ¶
func (s LinuxProvider) GetfsType(path string) (*FsType, error)
GetfsType retrieves the filesystem type for a path.
func (LinuxProvider) GetfsUsage ¶
func (s LinuxProvider) GetfsUsage(target string) (uint64, uint64, error)
GetfsUsage retrieves total and available byte counts for a mountpoint.
func (LinuxProvider) IsMounted ¶
func (s LinuxProvider) IsMounted(target string) (bool, error)
IsMounted checks the target device or directory for mountedness.
func (LinuxProvider) Mkdir ¶
func (s LinuxProvider) Mkdir(name string, perm os.FileMode) error
Mkdir creates a new directory with the specified name and permission bits (before umask).
func (LinuxProvider) Mkfs ¶
func (s LinuxProvider) Mkfs(req MkfsReq) error
Mkfs attempts to create a filesystem of the supplied type, on the supplied device.
func (LinuxProvider) Mount ¶
func (s LinuxProvider) Mount(source, target, fstype string, flags uintptr, data string) error
Mount provides an implementation of Mounter which calls the system implementation.
func (LinuxProvider) ReadFile ¶
func (s LinuxProvider) ReadFile(path string) ([]byte, error)
ReadFile reads the named file and returns the contents.
func (LinuxProvider) RemoveAll ¶
func (s LinuxProvider) RemoveAll(path string) error
RemoveAll removes path and any children it contains.
type MockSysConfig ¶
type MockSysConfig struct { IsMountedBool bool IsMountedErr error MountErr error UnmountErr error MkfsErr error ChmodErr error ChownErr error GetfsStr string GetfsErr error SourceToTarget map[string]string GetfsIndex int GetfsUsageResps []GetfsUsageRetval GetfsTypeRes *FsType GetfsTypeErr []error StatErrors map[string]error RealStat bool ReadFileResults map[string][]byte ReadFileErrors map[string]error RealReadFile bool GeteuidRes int GetegidRes int MkdirErr error RealMkdir bool RemoveAllErr error RealRemoveAll bool }
MockSysConfig alters mock SystemProvider behavior.
type MockSysProvider ¶
type MockSysProvider struct { sync.RWMutex IsMountedInputs []string GetfsTypeCount int // contains filtered or unexported fields }
MockSysProvider gives a mock SystemProvider implementation.
func DefaultMockSysProvider ¶
func DefaultMockSysProvider(log logging.Logger) *MockSysProvider
func NewMockSysProvider ¶
func NewMockSysProvider(log logging.Logger, cfg *MockSysConfig) *MockSysProvider
func (*MockSysProvider) GetMountOpts ¶
func (msp *MockSysProvider) GetMountOpts(target string) (string, error)
func (*MockSysProvider) Getegid ¶
func (msp *MockSysProvider) Getegid() int
Getegid returns the numeric effective group id of the caller.
func (*MockSysProvider) Geteuid ¶
func (msp *MockSysProvider) Geteuid() int
Geteuid returns the numeric effective user id of the caller.
func (*MockSysProvider) GetfsType ¶
func (msp *MockSysProvider) GetfsType(path string) (*FsType, error)
func (*MockSysProvider) GetfsUsage ¶
func (msp *MockSysProvider) GetfsUsage(_ string) (uint64, uint64, error)
func (*MockSysProvider) IsMounted ¶
func (msp *MockSysProvider) IsMounted(target string) (bool, error)
func (*MockSysProvider) Mkdir ¶
func (msp *MockSysProvider) Mkdir(path string, flags os.FileMode) error
Mkdir creates a new directory with the specified name and permission bits (before umask).
func (*MockSysProvider) Mkfs ¶
func (msp *MockSysProvider) Mkfs(_ MkfsReq) error
func (*MockSysProvider) Mount ¶
func (msp *MockSysProvider) Mount(_, target, _ string, _ uintptr, opts string) error
func (*MockSysProvider) ReadFile ¶
func (msp *MockSysProvider) ReadFile(path string) ([]byte, error)
func (*MockSysProvider) RemoveAll ¶
func (msp *MockSysProvider) RemoveAll(path string) error
RemoveAll removes path and any children it contains.
type MountProvider ¶
type MountProvider interface {
Mount(source, target, fstype string, flags uintptr, data string) error
}
MountProvider is the interface that wraps the Mount method, which can be provided by a system-specific implementation or a mock.
type RunCmdError ¶
type RunCmdError struct { Wrapped error // Error from the command run Stdout string // Standard output from the command }
RunCmdError documents the output of a command that has been run.
func (*RunCmdError) Error ¶
func (rce *RunCmdError) Error() string
type UnmountProvider ¶
UnmountProvider is the interface that wraps the Unmount method, which can be provided by a system-specific implementation or a mock.