Copyright | (c) Sam Truzjan 2013 |
---|---|
License | BSD3 |
Maintainer | pxqr.sta@gmail.com |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
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
- data Device
- data Devnum
- data Action
- newFromSysPath :: UDev -> RawFilePath -> IO Device
- newFromDevnum :: UDev -> Char -> Devnum -> IO Device
- newFromSubsystemSysname :: UDev -> ByteString -> ByteString -> IO Device
- newFromDeviceId :: UDev -> ByteString -> IO Device
- newFromEnvironment :: UDev -> IO Device
- getParent :: Device -> IO Device
- getParentWithSubsystemDevtype :: Device -> ByteString -> ByteString -> IO (Maybe Device)
- getDevpath :: Device -> RawFilePath
- getSubsystem :: Device -> Maybe ByteString
- getDevtype :: Device -> Maybe ByteString
- getSyspath :: Device -> RawFilePath
- getSysname :: Device -> ByteString
- getSysnum :: Device -> Maybe ByteString
- getDevnode :: Device -> Maybe ByteString
- isInitialized :: Device -> IO Bool
- getDevlinksListEntry :: Device -> IO List
- getPropertiesListEntry :: Device -> IO List
- getTagsListEntry :: Device -> IO List
- getPropertyValue :: Device -> ByteString -> IO (Maybe ByteString)
- getDriver :: Device -> ByteString
- getDevnum :: Device -> Devnum
- getAction :: Device -> Maybe Action
- getSysattrValue :: Device -> ByteString -> IO ByteString
- setSysattrValue :: Device -> ByteString -> ByteString -> IO ()
- getSysattrListEntry :: Device -> IO List
- getSeqnum :: Device -> IO (Maybe Int)
- getUsecSinceInitialized :: Device -> IO (Maybe Int)
- hasTag :: Device -> ByteString -> IO Bool
Documentation
Opaque object representing one kernel sys device.
Device number.
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.
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.
getPropertyValue :: Device -> ByteString -> IO (Maybe ByteString) Source #
Get the value of a given property.
getDriver :: Device -> ByteString Source #
Get the kernel driver name.
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.
:: 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.