block

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDiskGUID

func GenerateDiskGUID(disk *Disk) string

GenerateDiskGUID generates a GUID for disks.

func GeneratePartitionGUID

func GeneratePartitionGUID(part *Partition) string

GeneratePartitionGUID generates a GUID for partitions.

func GetDiskUUID

func GetDiskUUID(part string, uuidType string) string

func GetFileSystemType

func GetFileSystemType(part string) string

func GetParentDevName

func GetParentDevName(devPath string) (string, error)

func HasPartitions

func HasPartitions(disk *Disk) bool

Types

type Disk

type Disk struct {
	Name                   string                  `json:"name"`
	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
	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

Jump to

Keyboard shortcuts

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