block

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BLKIDCMD = "blkid"
)
View Source
const (
	LSBLKCMD = "lsblk"
)

Variables

This section is empty.

Functions

func GenerateDiskGUID

func GenerateDiskGUID(disk *Disk, nodeName string) string

GenerateDiskGUID generates a GUID for disks.

func GeneratePartitionGUID

func GeneratePartitionGUID(part *Partition, nodeName string) string

GeneratePartitionGUID generates a GUID for partitions.

func GetDevPathByPTUUID added in v0.4.1

func GetDevPathByPTUUID(ptUUID string) (string, error)

func GetDiskUUID

func GetDiskUUID(part string, uuidType string) string

func GetFileSystemLabel added in v0.2.0

func GetFileSystemLabel(devPath string) string

func GetFileSystemType

func GetFileSystemType(part string) string

func GetParentDevName

func GetParentDevName(devPath string) (string, error)

func GetPartType added in v0.3.1

func GetPartType(devPath string) string

func HasPartitions

func HasPartitions(disk *Disk) bool

Types

type Disk

type Disk struct {
	Name                   string                  `json:"name"`
	Label                  string                  `json:"label"`
	SizeBytes              uint64                  `json:"size_bytes"`
	PhysicalBlockSizeBytes uint64                  `json:"physical_block_size_bytes"`
	DriveType              block.DriveType         `json:"drive_type"`
	IsRemovable            bool                    `json:"removable"`
	StorageController      block.StorageController `json:"storage_controller"`
	UUID                   string                  `json:"uuid"`    // This would be volume UUID on macOS, UUID on linux, empty on Windows
	PtUUID                 string                  `json:"pt_uuid"` // This would be volume PtUUID on macOS, PartUUID on linux, empty on Windows
	BusPath                string                  `json:"bus_path"`
	FileSystemInfo         FileSystemInfo          `json:"file_system_info"`
	NUMANodeID             int                     `json:"numa_node_id"`
	Vendor                 string                  `json:"vendor"`
	Model                  string                  `json:"model"`
	SerialNumber           string                  `json:"serial_number"`
	WWN                    string                  `json:"wwn"`
	Partitions             []*Partition            `json:"partitions"`
}

Disk describes a single disk drive on the host system. Disk drives provide raw block storage resources.

type FileSystemInfo

type FileSystemInfo struct {
	Type       string `json:"type"`
	IsReadOnly bool   `json:"read_only"`
	MountPoint string `json:"mount_point"`
}

type Info

type Info interface {
	GetDisks() []*Disk
	GetPartitions() []*Partition
	GetDiskByDevPath(name string) *Disk
	GetPartitionByDevPath(disk, part string) *Partition
	GetFileSystemInfoByDevPath(dname string) *FileSystemInfo
}

Info describes all disk drives and partitions in the host system.

func New

func New() (Info, error)

New returns a pointer to an Info implementation that describes the block storage resources of the host system.

type Partition

type Partition struct {
	Disk              *Disk                   `json:"-"`
	Name              string                  `json:"name"`
	Label             string                  `json:"label"`
	SizeBytes         uint64                  `json:"size_bytes"`
	UUID              string                  `json:"uuid"`    // This would be volume UUID on macOS, PartUUID on linux, empty on Windows
	FsUUID            string                  `json:"fs_uuid"` // This would be filesystem UUID on macOS and linux, empty on Windows
	PartType          string                  `json:"part_type"`
	DriveType         block.DriveType         `json:"drive_type"`
	StorageController block.StorageController `json:"storage_controller"`
	FileSystemInfo    FileSystemInfo          `json:"file_system_info"`
}

Partition describes a logical division of a Disk.

type UUIDType

type UUIDType string
const (
	FsType = "TYPE"

	PartUUID UUIDType = "PARTUUID"
	PTUUID   UUIDType = "PTUUID"
	UUID     UUIDType = "UUID"
)

borrowed from https://github.com/jaypipes/ghw/blob/master/pkg/block/block_linux.go * two function are changed with introducing context * 1. partitionInfo() * 2. openProcMounts()

Jump to

Keyboard shortcuts

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