hotplug

package
v0.0.0-...-f6d5d5b Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definer

type Definer interface {
	// HotplugDeviceDetected is called for all devices and should return nil slot for those that are irrelevant for the interface.
	// Error should only be returned in rare cases when device is relevant, but there is a problem with creating a proposed slot for it.
	HotplugDeviceDetected(di *HotplugDeviceInfo) (*ProposedSlot, error)
}

Definer can be implemented by interfaces that need to create slots in response to hotplug events.

type HandledByGadgetPredicate

type HandledByGadgetPredicate interface {
	HandledByGadget(di *HotplugDeviceInfo, slot *snap.SlotInfo) bool
}

HandledByGadgetPredicate can be implemented by hotplug interfaces to decide whether a device is already handled by given gadget slot.

type HotplugDeviceInfo

type HotplugDeviceInfo struct {
	// contains filtered or unexported fields
}

HotplugDeviceInfo carries information about added/removed device detected at runtime.

func EnumerateExistingDevices

func EnumerateExistingDevices() (devices []*HotplugDeviceInfo, parseErrors []error, fatalError error)

EnumerateExistingDevices enumerates all devices by parsing 'udevadm info -e' command output. Non-fatal parsing errors are reported via parseErrors and they don't stop the parser.

func NewHotplugDeviceInfo

func NewHotplugDeviceInfo(env map[string]string) (*HotplugDeviceInfo, error)

NewHotplugDeviceInfo creates HotplugDeviceInfo structure related to udev add or remove event.

func (*HotplugDeviceInfo) Attribute

func (h *HotplugDeviceInfo) Attribute(name string) (string, bool)

Generic method for getting arbitrary attribute from the uevent data.

func (*HotplugDeviceInfo) DeviceName

func (h *HotplugDeviceInfo) DeviceName() string

Returns the value of "DEVNAME" attribute of the udev event associated with the device, e.g. "/dev/ttyUSB0". The DeviceName value may be empty.

func (*HotplugDeviceInfo) DevicePath

func (h *HotplugDeviceInfo) DevicePath() string

Returns full device path under /sysfs, e.g /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2. The path is derived from DEVPATH attribute of the udev event.

func (*HotplugDeviceInfo) DeviceType

func (h *HotplugDeviceInfo) DeviceType() string

Returns the value of "DEVTYPE" attribute of the udev event associated with the device, e.g. "usb_device". The DeviceType value may be empty.

func (*HotplugDeviceInfo) Major

func (h *HotplugDeviceInfo) Major() string

Returns the value of "MAJOR" attribute of the udev event associated with the device. The Major value may be empty.

func (*HotplugDeviceInfo) Minor

func (h *HotplugDeviceInfo) Minor() string

Returns the value of "MINOR" attribute of the udev event associated with the device. The Minor value may be empty.

func (*HotplugDeviceInfo) ShortString

func (h *HotplugDeviceInfo) ShortString() string

ShortString returns a string representation of the device with more aggressive truncating of model/vendor name.

func (*HotplugDeviceInfo) String

func (h *HotplugDeviceInfo) String() string

func (*HotplugDeviceInfo) Subsystem

func (h *HotplugDeviceInfo) Subsystem() string

Returns the value of "SUBSYSTEM" attribute of the udev event associated with the device, e.g. "usb". Subsystem value is always present.

type HotplugKeyHandler

type HotplugKeyHandler interface {
	HotplugKey(di *HotplugDeviceInfo) (snap.HotplugKey, error)
}

HotplugKeyHandler can be implemented by interfaces that need to provide a non-standard key for hotplug devices.

type ProposedSlot

type ProposedSlot struct {
	// Name is how the interface wants to name the slot. When left empty,
	// one will be generated on demand. The hotplug machinery appends a
	// suffix to ensure uniqueness of the name.
	Name  string                 `json:"name"`
	Label string                 `json:"label"`
	Attrs map[string]interface{} `json:"attrs,omitempty"`
}

ProposedSlot is a definition of the slot to create in response to a hotplug event.

func (*ProposedSlot) Clean

func (slot *ProposedSlot) Clean() (*ProposedSlot, error)

Clean returns a copy of the input slot with normalized attributes and validated slot name (unless its empty).

Jump to

Keyboard shortcuts

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