util

package
v0.0.0-...-fe00de2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 16 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DevPath        = "/dev"
	LonghornDevDir = "/longhorn"

	DefaultNVMeNamespaceID = 1
)
View Source
const (
	DockerdProcess        = "dockerd"
	ContainerdProcess     = "containerd"
	ContainerdShimProcess = "containerd-shim"
)
View Source
const (
	BlockdevBinary = "blockdev"
)

Variables

This section is empty.

Functions

func DmsetupCreate

func DmsetupCreate(dmDeviceName, table string, executor *commonNs.Executor) error

DmsetupCreate creates a device mapper device with the given name and table

func DmsetupDeps

func DmsetupDeps(dmDeviceName string, executor *commonNs.Executor) ([]string, error)

DmsetupDeps returns the dependent devices of the device mapper device with the given name

func DmsetupReload

func DmsetupReload(dmDeviceName, table string, executor *commonNs.Executor) error

DmsetupReload reloads the table of the device mapper device with the given name and table

func DmsetupRemove

func DmsetupRemove(dmDeviceName string, force, deferred bool, executor *commonNs.Executor) error

DmsetupRemove removes the device mapper device with the given name

func DmsetupResume

func DmsetupResume(dmDeviceName string, executor *commonNs.Executor) error

DmsetupResume removes the device mapper device with the given name

func DmsetupSuspend

func DmsetupSuspend(dmDeviceName string, noflush, nolockfs bool, executor *commonNs.Executor) error

DmsetupSuspend suspends the device mapper device with the given name

func DuplicateDevice

func DuplicateDevice(dev *KernelDevice, dest string) error

DuplicateDevice creates a device node for the given device

func GetDeviceNumbers

func GetDeviceNumbers(devPath string, executor *commonNs.Executor) (int, int, error)

GetDeviceNumbers returns the major and minor numbers of the given device

func GetDeviceSectorSize

func GetDeviceSectorSize(devPath string, executor *commonNs.Executor) (int64, error)

GetDeviceSectorSize returns the sector size of the given device

func GetHostNamespacePath

func GetHostNamespacePath(hostProcPath string) string

func GetKnownDevices

func GetKnownDevices(executor *commonNs.Executor) (map[string]*KernelDevice, error)

GetKnownDevices returns the path of the device with the given major and minor numbers

func GetLonghornDevicePath

func GetLonghornDevicePath(name string) string

func GetNvmeControllerNameFromNamespaceName

func GetNvmeControllerNameFromNamespaceName(nsName string) string

func GetNvmeDevicePath

func GetNvmeDevicePath(name string) string

func GetNvmeNamespaceNameFromControllerName

func GetNvmeNamespaceNameFromControllerName(controllerName string, nsID int) string

func IsBlockDevice

func IsBlockDevice(path string) (bool, error)

IsBlockDevice returns true if the given path is a block device

func NewExecutor

func NewExecutor(hostProc string) (*commonNs.Executor, error)

NewExecutor creates a new namespaced executor

func PrintObject

func PrintObject(v interface{}) error

func RemoveDevice

func RemoveDevice(dev string) error

RemoveDevice removes the given device

Types

type BlockDevice

type BlockDevice struct {
	Name   string `json:"name"`
	Major  int    `json:"maj"`
	Minor  int    `json:"min"`
	MajMin string `json:"maj:min"`
}

type BlockDevices

type BlockDevices struct {
	Devices []BlockDevice `json:"blockdevices"`
}

type KernelDevice

type KernelDevice struct {
	Nvme   BlockDevice
	Export BlockDevice
}

func DetectDevice

func DetectDevice(path string, executor *commonNs.Executor) (*KernelDevice, error)

DetectDevice detects the device with the given path

type ProcessFinder

type ProcessFinder struct {
	// contains filtered or unexported fields
}

func NewProcessFinder

func NewProcessFinder(procPath string) *ProcessFinder

func (*ProcessFinder) FindAncestorByName

func (p *ProcessFinder) FindAncestorByName(ancestorProcess string) (*linuxproc.ProcessStatus, error)

func (*ProcessFinder) FindPid

func (p *ProcessFinder) FindPid(pid int64) (*linuxproc.ProcessStatus, error)

func (*ProcessFinder) FindSelf

func (p *ProcessFinder) FindSelf() (*linuxproc.ProcessStatus, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL