util

package
v0.0.0-...-eabe34a Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 16 Imported by: 1

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 *LonghornBlockDevice, 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]*LonghornBlockDevice, 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(devPath 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"`
}

func DetectDevice

func DetectDevice(path string, executor *commonns.Executor) (*BlockDevice, error)

DetectDevice detects the device with the given path

type BlockDevices

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

type DeviceInfo

type DeviceInfo struct {
	Name            string
	BlockDeviceName string
	TableLive       bool
	TableInactive   bool
	Suspended       bool
	ReadOnly        bool
	Major           uint32
	Minor           uint32
	OpenCount       uint32 // Open reference count
	TargetCount     uint32 // Number of targets in the live table
	EventNumber     uint32 // Last event sequence number (used by wait)
}

func DmsetupInfo

func DmsetupInfo(dmDeviceName string, executor *commonns.Executor) ([]*DeviceInfo, error)

DmsetupInfo returns the information of the device mapper device with the given name

type LonghornBlockDevice

type LonghornBlockDevice struct {
	Nvme   BlockDevice
	Export BlockDevice
}

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