udev-0.1.0.0: libudev bindings

Portabilityportable
Stabilitystable
Maintainerpxqr.sta@gmail.com
Safe HaskellNone

System.UDev.Device

Contents

Description

Representation of kernel sys devices. Devices are uniquely identified by their syspath, every device has exactly one path in the kernel sys filesystem. Devices usually belong to a kernel subsystem, and have a unique name inside that subsystem.

Synopsis

Documentation

data Device Source

Opaque object representing one kernel sys device.

Instances

data Devnum Source

Device number.

Create

newFromSysPath :: UDev -> RawFilePath -> IO DeviceSource

Create new udev device, and fill in information from the sys device and the udev database entry. The syspath is the absolute path to the device, including the sys mount point.

newFromDevnum :: UDev -> Char -> Devnum -> IO DeviceSource

Create new udev device, and fill in information from the sys device and the udev database entry. The device is looked-up by its major/minor number and type. Character and block device numbers are not unique across the two types.

newFromSubsystemSysname :: UDev -> BS.ByteString -> BS.ByteString -> IO DeviceSource

The device is looked up by the subsystem and name string of the device, like "mem" / "zero", or "block" / "sda".

newFromDeviceId :: UDev -> BS.ByteString -> IO DeviceSource

The device is looked-up by a special string:

  • b8:2 - block device major:minor
  • c128:1 - char device major:minor
  • n3 - network device ifindex
  • +sound:card29 - kernel driver core subsystem:device name

newFromEnvironment :: UDev -> IO DeviceSource

Create new udev device, and fill in information from the current process environment. This only works reliable if the process is called from a udev rule. It is usually used for tools executed from IMPORT= rules.

getParent :: Device -> IO DeviceSource

Find the next parent device, and fill in information from the sys device and the udev database entry.

getParentWithSubsystemDevtype :: Device -> BS.ByteString -> BS.ByteString -> IO (Maybe Device)Source

Find the next parent device, with a matching subsystem and devtype value, and fill in information from the sys device and the udev database entry.

Query

getDevpath :: Device -> RawFilePathSource

Retrieve the kernel devpath value of the udev device. The path does not contain the sys mount point, and starts with a '/'.

getSubsystem :: Device -> Maybe BS.ByteStringSource

Retrieve the subsystem string of the udev device. The string does not contain any "/".

getDevtype :: Device -> Maybe BS.ByteStringSource

Retrieve the devtype string of the udev device.

getSyspath :: Device -> RawFilePathSource

Retrieve the sys path of the udev device. The path is an absolute path and starts with the sys mount point.

getSysname :: Device -> BS.ByteStringSource

Get the kernel device name in /sys.

getSysnum :: Device -> Maybe BS.ByteStringSource

Get the instance number of the device.

getDevnode :: Device -> Maybe BS.ByteStringSource

Retrieve the device node file name belonging to the udev device. The path is an absolute path, and starts with the device directory.

isInitialized :: Device -> IO BoolSource

Check if udev has already handled the device and has set up device node permissions and context, or has renamed a network device.

This is only implemented for devices with a device node or network interfaces. All other devices return 1 here.

getDevlinksListEntry :: Device -> IO ListSource

Retrieve the list of device links pointing to the device file of the udev device. The next list entry can be retrieved with getNext, which returns Nothing if no more entries exist. The devlink path can be retrieved from the list entry by getName. The path is an absolute path, and starts with the device directory.

getPropertiesListEntry :: Device -> IO ListSource

Retrieve the list of key/value device properties of the udev device. The next list entry can be retrieved with getNext, which returns Nothing if no more entries exist. The property name can be retrieved from the list entry by getName, the property value by getValue.

getTagsListEntry :: Device -> IO ListSource

Retrieve the list of tags attached to the udev device. The next list entry can be retrieved with getNext, which returns Nothing if no more entries exist. The tag string can be retrieved from the list entry by getName.

getPropertyValue :: Device -> BS.ByteString -> IO (Maybe BS.ByteString)Source

Get the value of a given property.

getDriver :: Device -> BS.ByteStringSource

Get the kernel driver name.

getDevnum :: Device -> DevnumSource

Get the device major/minor number.

getAction :: Device -> Maybe ActionSource

This is only valid if the device was received through a monitor. Devices read from sys do not have an action string.

Sysattrs

getSysattrValue :: Device -> BS.ByteString -> IO BS.ByteStringSource

The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again.

setSysattrValueSource

Arguments

:: Device 
-> BS.ByteString

attribute name

-> BS.ByteString

new value to be set

-> IO () 

Update the contents of the sys attribute and the cached value of the device.

getSysattrListEntry :: Device -> IO ListSource

Retrieve the list of available sysattrs, with value being empty; This just return all available sysfs attributes for a particular device without reading their values.

Misc

getSeqnum :: Device -> IO (Maybe Int)Source

This is only valid if the device was received through a monitor. Devices read from sys do not have a sequence number.

getUsecSinceInitialized :: Device -> IO (Maybe Int)Source

Return the number of microseconds passed since udev set up the device for the first time.

This is only implemented for devices with need to store properties in the udev database. All other devices return Nothing here.

hasTag :: Device -> BS.ByteString -> IO BoolSource

Check if a given device has a certain tag associated.