udev

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// PropertyAction is the key for the ACTION property.
	PropertyAction = "ACTION"
	// PropertyDevpath is the key for the DEVPATH property.
	PropertyDevpath = "DEVPATH"
	// PropertySubsystem is the key for the SUBSYSTEM property.
	PropertySubsystem = "SUBSYSTEM"
	// PropertySeqnum is the key for the SEQNUM property.
	PropertySeqnum = "SEQNUM"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Header     string
	Subsystem  string
	Action     string
	Devpath    string
	Seqnum     string
	Properties map[string]string
}

Event represents a udev event.

type EventReader

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

EventReader reads udev events.

func NewEventReader

func NewEventReader() (*EventReader, error)

NewEventReader creates a new udev event reader.

func NewEventReaderFromReader

func NewEventReaderFromReader(r io.ReadCloser) *EventReader

NewEventReaderFromReader creates a new udev event reader from an existing io.ReadCloser. This can be used to generate synthetic events for testing.

func (*EventReader) Close

func (r *EventReader) Close() error

Close closes the reader.

func (*EventReader) Read

func (r *EventReader) Read() (*Event, error)

Read reads a udev event, blocking until one is available.

type Monitor

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

Monitor monitors udev events.

func NewMonitor

func NewMonitor(options ...MonitorOption) (*Monitor, error)

NewMonitor creates an udev monitor with the given options.

func (*Monitor) Start

func (m *Monitor) Start(events chan *Event)

Start starts event monitoring and delivery.

func (*Monitor) Stop

func (m *Monitor) Stop() error

Stop stops event monitoring.

type MonitorOption

type MonitorOption func(*Monitor)

MonitorOption is an opaque option which can be applied to a Monitor.

func WithFilters

func WithFilters(filters ...map[string]string) MonitorOption

WithFilters returns a MonitorOption for filtering events by properties. Properties within a map have AND semantics: the map matches an event if all key-value pairs match the event. Multiple maps have OR semantics: they match an event if at least one map matches the event. Events which are matched are passed through. Others are filtered out.

func WithGlobFilters

func WithGlobFilters(globbers ...map[string]string) MonitorOption

WithGlobFilters returns a MonitorOption for filtering events by properties. Semantics are similar to WithFilters, but properties are matched using glob patterns instead of verbatim comparison.

type Reader

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

Reader implements an io.ReadCloser for reading raw event data from the udev netlink socket.

func NewReader

func NewReader() (*Reader, error)

NewReader creates a new io.ReadCloser for reading raw udev event data.

func (*Reader) Close

func (r *Reader) Close() error

Close implements the io.Closer interface.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read implements the io.Reader interface.

Jump to

Keyboard shortcuts

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