udev-0.1.1.0: libudev bindings
Copyright(c) Sam Truzjan 2013
LicenseBSD3
Maintainerpxqr.sta@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

System.UDev.Device

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

Instances details
UDevChild Device Source # 
Instance details

Defined in System.UDev.Types

Methods

getUDev :: Device -> UDev Source #

data Devnum Source #

Device number.

Instances

Instances details
Eq Devnum Source # 
Instance details

Defined in System.UDev.Device

Methods

(==) :: Devnum -> Devnum -> Bool #

(/=) :: Devnum -> Devnum -> Bool #

Ord Devnum Source # 
Instance details

Defined in System.UDev.Device

Read Devnum Source # 
Instance details

Defined in System.UDev.Device

Show Devnum Source # 
Instance details

Defined in System.UDev.Device

data Action Source #

Instances

Instances details
Eq Action Source # 
Instance details

Defined in System.UDev.Device

Methods

(==) :: Action -> Action -> Bool #

(/=) :: Action -> Action -> Bool #

Ord Action Source # 
Instance details

Defined in System.UDev.Device

Read Action Source # 
Instance details

Defined in System.UDev.Device

Show Action Source # 
Instance details

Defined in System.UDev.Device

Create

newFromSysPath :: UDev -> RawFilePath -> IO Device Source #

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 Device Source #

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 -> ByteString -> ByteString -> IO Device Source #

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

newFromDeviceId :: UDev -> ByteString -> IO Device Source #

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 Device Source #

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 Device Source #

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

getParentWithSubsystemDevtype :: Device -> ByteString -> 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 -> RawFilePath Source #

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 ByteString Source #

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

getDevtype :: Device -> Maybe ByteString Source #

Retrieve the devtype string of the udev device.

getSyspath :: Device -> RawFilePath Source #

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

getSysname :: Device -> ByteString Source #

Get the kernel device name in /sys.

getSysnum :: Device -> Maybe ByteString Source #

Get the instance number of the device.

getDevnode :: Device -> Maybe ByteString Source #

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 Bool Source #

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 List Source #

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 List Source #

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 List Source #

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 -> ByteString -> IO (Maybe ByteString) Source #

Get the value of a given property.

getDriver :: Device -> ByteString Source #

Get the kernel driver name.

getDevnum :: Device -> Devnum Source #

Get the device major/minor number.

getAction :: Device -> Maybe Action Source #

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 -> ByteString -> IO ByteString Source #

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

setSysattrValue Source #

Arguments

:: Device 
-> ByteString

attribute name

-> ByteString

new value to be set

-> IO () 

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

getSysattrListEntry :: Device -> IO List Source #

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 -> ByteString -> IO Bool Source #

Check if a given device has a certain tag associated.