lsblk

package
v4.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DeviceTypeLoop is the device type for loop devices in lsblk output
	DeviceTypeLoop = "loop"

	// DeviceTypeROM is the device type for ROM devices in lsblk output
	DeviceTypeROM = "rom"

	// DeviceTypeLVM is the device type for lvm devices in lsblk output
	DeviceTypeLVM = "lvm"
)
View Source
const LSBLK_COLUMNS = "NAME,ROTA,TYPE,SIZE,MODEL,VENDOR,RO,STATE,KNAME,SERIAL,PARTLABEL,FSTYPE"

Variables

View Source
var (
	DefaultLosetup = "/usr/sbin/losetup"
	DefaultLsblk   = "/usr/bin/lsblk"
)

Functions

func FlattenedBlockDevices

func FlattenedBlockDevices(bs []BlockDevice) map[string]BlockDevice

Types

type BlockDevice

type BlockDevice struct {
	Name      string        `json:"name"`
	KName     string        `json:"kname"`
	Type      string        `json:"type"`
	Model     string        `json:"model,omitempty"`
	Vendor    string        `json:"vendor,omitempty"`
	State     string        `json:"state,omitempty"`
	FSType    string        `json:"fstype"`
	Size      string        `json:"size"`
	Children  []BlockDevice `json:"children,omitempty"`
	ReadOnly  bool          `json:"ro,omitempty"`
	Serial    string        `json:"serial,omitempty"`
	PartLabel string        `json:"partLabel,omitempty"`
}

BlockDevice is the block device as output by lsblk. All the fields are lsblk columns.

func (BlockDevice) HasChildren

func (b BlockDevice) HasChildren() bool

HasChildren checks if the disk has partitions

type BlockDeviceInfo

type BlockDeviceInfo struct {
	IsUsableLoopDev bool
}

type BlockDeviceInfos

type BlockDeviceInfos map[string]BlockDeviceInfo

type HostLSBLK

type HostLSBLK struct {
	exec.Executor
	// contains filtered or unexported fields
}

func NewDefaultHostLSBLK

func NewDefaultHostLSBLK() *HostLSBLK

func NewHostLSBLK

func NewHostLSBLK(executor exec.Executor, lsblk, losetup string) *HostLSBLK

func (*HostLSBLK) BlockDeviceInfos

func (lsblk *HostLSBLK) BlockDeviceInfos(ctx context.Context, bs []BlockDevice) (BlockDeviceInfos, error)

func (*HostLSBLK) IsUsableLoopDev

func (lsblk *HostLSBLK) IsUsableLoopDev(ctx context.Context, b BlockDevice) (bool, error)

IsUsableLoopDev returns true if the loop device isn't in use by Kubernetes by matching the back file path against a standard string used to mount devices from host into pods

func (*HostLSBLK) ListBlockDevices

func (lsblk *HostLSBLK) ListBlockDevices(ctx context.Context) ([]BlockDevice, error)

ListBlockDevices lists the block devices using the lsblk command

type LSBLK

type LSBLK interface {
	ListBlockDevices(ctx context.Context) ([]BlockDevice, error)
	IsUsableLoopDev(ctx context.Context, b BlockDevice) (bool, error)
	BlockDeviceInfos(ctx context.Context, bs []BlockDevice) (BlockDeviceInfos, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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