Portability | portable |
---|---|
Stability | stable |
Maintainer | pxqr.sta@gmail.com |
Safe Haskell | None |
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.
- data Device
- data Devnum
- newFromSysPath :: UDev -> RawFilePath -> IO Device
- newFromDevnum :: UDev -> Char -> Devnum -> IO Device
- newFromSubsystemSysname :: UDev -> BS.ByteString -> BS.ByteString -> IO Device
- newFromDeviceId :: UDev -> BS.ByteString -> IO Device
- newFromEnvironment :: UDev -> IO Device
- getParent :: Device -> IO Device
- getParentWithSubsystemDevtype :: Device -> BS.ByteString -> BS.ByteString -> IO (Maybe Device)
- getDevpath :: Device -> RawFilePath
- getSubsystem :: Device -> Maybe BS.ByteString
- getDevtype :: Device -> Maybe BS.ByteString
- getSyspath :: Device -> RawFilePath
- getSysname :: Device -> BS.ByteString
- getSysnum :: Device -> Maybe BS.ByteString
- getDevnode :: Device -> Maybe BS.ByteString
- isInitialized :: Device -> IO Bool
- getDevlinksListEntry :: Device -> IO List
- getPropertiesListEntry :: Device -> IO List
- getTagsListEntry :: Device -> IO List
- getPropertyValue :: Device -> BS.ByteString -> IO (Maybe BS.ByteString)
- getDriver :: Device -> BS.ByteString
- getDevnum :: Device -> Devnum
- getAction :: Device -> Maybe Action
- getSysattrValue :: Device -> BS.ByteString -> IO BS.ByteString
- setSysattrValue :: Device -> BS.ByteString -> BS.ByteString -> IO ()
- getSysattrListEntry :: Device -> IO List
- getSeqnum :: Device -> IO (Maybe Int)
- getUsecSinceInitialized :: Device -> IO (Maybe Int)
- hasTag :: Device -> BS.ByteString -> IO Bool
Documentation
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.
getTagsListEntry :: Device -> IO ListSource
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.
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.
:: 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.