utils

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 9 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// SlotTypePCI pci type slot
	SlotTypePCI = "pci"
	// SlotTypeUSB usb type slot
	SlotTypeUSB = "usb"
)

Variables

This section is empty.

Functions

func FilterBluetoothName

func FilterBluetoothName(name string) bool

FilterBluetoothName filter bluetooth device name

func FilterCameraName

func FilterCameraName(name string) bool

FilterCameraName filter camera device name

func FilterCardName

func FilterCardName(name string) bool

FilterCardName filter sound,graphic card name, such as 'card0'

func ProcGetByKey

func ProcGetByKey(filename, delim string, keySet map[string]string,
	fall bool) error

func ReadFileContent

func ReadFileContent(filename string) (string, error)

ReadFileContent get file content and trim the last newline

func SHA256Sum

func SHA256Sum(data []byte) string

SHA256Sum sum data by sha256

func ScanDir

func ScanDir(dir string, filter func(string) bool) ([]string, error)

ScanDir return needed sub directory

Types

type CardInfo

type CardInfo struct {
	Name    string
	Vendor  string
	Product string
	Slot    string
}

CardInfo store card info, such as: sound, graphic...

func NewCardInfo

func NewCardInfo(dir, name string) (*CardInfo, error)

NewCardInfo create card info from uevent

type IDInfo

type IDInfo struct {
	ID   string
	Name string
}

IDInfo store device vendor or device info

type PCIUEvent

type PCIUEvent struct {
	Driver  string
	Vendor  *IDInfo
	Device  *IDInfo
	SVendor *IDInfo // subsystem vendor
	SDevice *IDInfo // subsystem device
	// contains filtered or unexported fields
}

PCIUevent pci uevent data

type UEvent

type UEvent struct {
	Type UEventType
	Name string
	Data interface{}
}

UEvent store device uevent file

func NewUEvent

func NewUEvent(filename string) (*UEvent, error)

type UEventType

type UEventType int

UEventType device port r=type

const (
	// device with pci port
	UEventTypePCI UEventType = iota + 11
	// device with usb port
	UEventTypeUSB
)

type USBUEvent

type USBUEvent struct {
	Driver  string
	Vendor  string
	Product string
	// contains filtered or unexported fields
}

USBUEvent usb uevent data

Jump to

Keyboard shortcuts

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