Documentation ¶
Overview ¶
Package lsblk contains code for running and interpreting output of system util lsblk
Index ¶
Constants ¶
const (
// CmdTmpl adds device name, if add empty string - command will print info about all devices
CmdTmpl = "lsblk %s --paths --json --bytes --fs " +
"--output NAME,TYPE,SIZE,ROTA,SERIAL,WWN,VENDOR,MODEL,REV,MOUNTPOINT,FSTYPE,PARTUUID"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockDevice ¶
type BlockDevice struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Size CustomInt64 `json:"size,omitempty"` Rota CustomBool `json:"rota,omitempty"` Serial string `json:"serial,omitempty"` WWN string `json:"wwn,omitempty"` Vendor string `json:"vendor,omitempty"` Model string `json:"model,omitempty"` Rev string `json:"rev,omitempty"` MountPoint string `json:"mountpoint,omitempty"` FSType string `json:"fstype,omitempty"` PartUUID string `json:"partuuid,omitempty"` Children []BlockDevice `json:"children,omitempty"` }
BlockDevice is the struct that represents output of lsblk command for a device
type CustomBool ¶
type CustomBool struct {
Bool bool
}
CustomBool to handle Rota lsblk output - true/false or "1"/"0"
func (CustomBool) MarshalJSON ¶
func (cb CustomBool) MarshalJSON() ([]byte, error)
MarshalJSON customizes rota marshalling
func (*CustomBool) UnmarshalJSON ¶
func (cb *CustomBool) UnmarshalJSON(data []byte) error
UnmarshalJSON customizes string rota unmarshalling
type CustomInt64 ¶
type CustomInt64 struct {
Int64 int64
}
CustomInt64 to handle Size lsblk output - 8001563222016 or "8001563222016"
func (*CustomInt64) MarshalJSON ¶
func (ci *CustomInt64) MarshalJSON() ([]byte, error)
MarshalJSON customizes size marshalling
func (*CustomInt64) UnmarshalJSON ¶
func (ci *CustomInt64) UnmarshalJSON(data []byte) error
UnmarshalJSON customizes string size unmarshalling
type LSBLK ¶
type LSBLK struct {
// contains filtered or unexported fields
}
LSBLK is a wrap for system lsblk util
func (*LSBLK) GetBlockDevices ¶
func (l *LSBLK) GetBlockDevices(device string) ([]BlockDevice, error)
GetBlockDevices run os lsblk command for device and construct BlockDevice struct based on output Receives device path. If device is empty string, info about all devices will be collected Returns slice of BlockDevice structs or error if something went wrong
func (*LSBLK) SearchDrivePath ¶
SearchDrivePath if not defined returns drive path based on drive S/N, VID and PID. Receives an instance of drivecrd.Drive struct Returns drive's path based on provided drivecrd.Drive or error if something went wrong