-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | libudev bindings
--
-- libudev bindings
@package udev
@version 0.1.1.0
-- | Libudev list operations.
module System.UDev.List
-- | Opaque object representing one entry in a list. An entry contains
-- contains a name, and optionally a value.
data List
-- | Get the next entry from the list.
getNext :: List -> IO (Maybe List)
-- | Lookup an entry in the list with a certain name.
getByName :: List -> IO (Maybe List)
-- | Get the name of a list entry.
getName :: List -> IO ByteString
-- | Get the value of list entry.
getValue :: List -> IO ByteString
-- | The context contains the default values read from the udev config
-- file, and is passed to all library operations.
module System.UDev.Context
-- | Opaque object representing the library context.
data UDev
-- | Family of udev resources.
class UDevChild a
-- | Get the context a resource belong to.
getUDev :: UDevChild a => a -> UDev
-- | Create udev library context. This reads the udev configuration file,
-- and fills in the default values.
newUDev :: IO UDev
freeUDev :: UDev -> IO ()
-- | Like newUDev but context will be released at exit.
withUDev :: (UDev -> IO a) -> IO a
-- | Log message priority.
data Priority
-- | error conditions
LogError :: Priority
-- | informational
LogInfo :: Priority
-- | debug-level messages
LogDebug :: Priority
-- | Logger function will called by udev on events.
type Logger = UDev -> Priority " message priority;" -> ByteString " position: file" -> Int " position: line" -> ByteString " position: function" -> ByteString " message body" -> IO ()
-- | The initial logging priority is read from the udev config file at
-- startup.
getLogPriority :: UDev -> IO Priority
-- | Set the current logging priority. The value controls which messages
-- are logged.
setLogPriority :: UDev -> Priority -> IO ()
-- | The built-in logging writes to stderr. It can be overridden by a
-- custom function, to plug log messages into the users' logging
-- functionality.
setLogger :: UDev -> Logger -> IO ()
-- | Default logger will just print %PRIO %FILE:%LINE:n%FN:
-- %FORMAT to stdout.
defaultLogger :: Logger
-- | Retrieve stored data pointer from library context. This might be
-- useful to access from callbacks like a custom logging function.
getUserdata :: UDev -> IO a
-- | Store custom userdata in the library context.
setUserdata :: UDev -> a -> IO ()
instance GHC.Enum.Bounded System.UDev.Context.Priority
instance GHC.Enum.Enum System.UDev.Context.Priority
instance GHC.Classes.Ord System.UDev.Context.Priority
instance GHC.Classes.Eq System.UDev.Context.Priority
instance GHC.Read.Read System.UDev.Context.Priority
instance GHC.Show.Show System.UDev.Context.Priority
-- | The udev daemon processes events asynchronously. All events which do
-- not have interdependencies run in parallel. This exports the current
-- state of the event processing queue, and the current event sequence
-- numbers from the kernel and the udev daemon.
module System.UDev.Queue
-- | Opaque object representing the current event queue in the udev daemon.
data Queue
-- | Sequence number of event.
type Seqnum = Int
-- | Create a new queue.
newQueue :: UDev -> IO Queue
-- | Check if udev is active on the system.
isActive :: Queue -> IO Bool
-- | Check if udev is currently processing any events.
isEmpty :: Queue -> IO Bool
-- | Check if udev is currently processing a given sequence number.
isFinished :: Queue -> Seqnum -> IO Bool
-- | Get the first entry of the list of queued events.
getPending :: Queue -> IO List
-- | Check if udev is currently processing any events in a given sequence
-- number range.
sequenceIsFinished :: Queue -> Seqnum -> Seqnum -> IO Bool
-- | Get the current kernel event sequence number.
getKernelSeqnum :: Queue -> IO Seqnum
-- | Get the last known udev event sequence number.
getUDevSeqnum :: Queue -> IO Seqnum
-- | Retrieve properties from the hardware database.
module System.UDev.HWDB
-- | Opaque object representing the hardware database.
data HWDB
-- | Create a hardware database context to query properties for devices.
newHWDB :: UDev -> IO HWDB
-- | Lookup a matching device in the hardware database. The lookup key is a
-- modalias string, whose formats are defined for the Linux kernel
-- modules. Examples are: pci:v00008086d00001C2D*, usb:v04F2pB221*. The
-- first entry of a list of retrieved properties is returned.
getPropertiesList :: HWDB -> ByteString -> IO List
-- | 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.
module System.UDev.Device
-- | Opaque object representing one kernel sys device.
data Device
-- | Device number.
data Devnum
data Action
Add :: Action
Remove :: Action
Change :: Action
Online :: Action
Offline :: Action
Other :: ByteString -> Action
-- | 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.
newFromSysPath :: UDev -> RawFilePath -> IO Device
-- | 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.
newFromDevnum :: UDev -> Char -> Devnum -> IO Device
-- | The device is looked up by the subsystem and name string of the
-- device, like "mem" / "zero", or "block" / "sda".
newFromSubsystemSysname :: UDev -> ByteString -> ByteString -> IO Device
-- | 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
--
newFromDeviceId :: UDev -> ByteString -> IO Device
-- | 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.
newFromEnvironment :: UDev -> IO Device
-- | Find the next parent device, and fill in information from the sys
-- device and the udev database entry.
getParent :: Device -> IO Device
-- | 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.
getParentWithSubsystemDevtype :: Device -> ByteString -> ByteString -> IO (Maybe Device)
-- | Retrieve the kernel devpath value of the udev device. The path does
-- not contain the sys mount point, and starts with a '/'.
getDevpath :: Device -> RawFilePath
-- | Retrieve the subsystem string of the udev device. The string does not
-- contain any "/".
getSubsystem :: Device -> Maybe ByteString
-- | Retrieve the devtype string of the udev device.
getDevtype :: Device -> Maybe ByteString
-- | Retrieve the sys path of the udev device. The path is an absolute path
-- and starts with the sys mount point.
getSyspath :: Device -> RawFilePath
-- | Get the kernel device name in /sys.
getSysname :: Device -> ByteString
-- | Get the instance number of the device.
getSysnum :: Device -> Maybe ByteString
-- | Retrieve the device node file name belonging to the udev device. The
-- path is an absolute path, and starts with the device directory.
getDevnode :: Device -> Maybe ByteString
-- | 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.
isInitialized :: Device -> IO Bool
-- | 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.
getDevlinksListEntry :: Device -> IO List
-- | 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.
getPropertiesListEntry :: Device -> IO List
-- | 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.
getTagsListEntry :: Device -> IO List
-- | Get the value of a given property.
getPropertyValue :: Device -> ByteString -> IO (Maybe ByteString)
-- | Get the kernel driver name.
getDriver :: Device -> ByteString
-- | Get the device major/minor number.
getDevnum :: Device -> Devnum
-- | This is only valid if the device was received through a monitor.
-- Devices read from sys do not have an action string.
getAction :: Device -> Maybe Action
-- | The retrieved value is cached in the device. Repeated calls will
-- return the same value and not open the attribute again.
getSysattrValue :: Device -> ByteString -> IO ByteString
-- | Update the contents of the sys attribute and the cached value of the
-- device.
setSysattrValue :: Device -> ByteString -> ByteString -> IO ()
-- | 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.
getSysattrListEntry :: Device -> IO List
-- | This is only valid if the device was received through a monitor.
-- Devices read from sys do not have a sequence number.
getSeqnum :: Device -> IO (Maybe Int)
-- | 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.
getUsecSinceInitialized :: Device -> IO (Maybe Int)
-- | Check if a given device has a certain tag associated.
hasTag :: Device -> ByteString -> IO Bool
instance GHC.Classes.Ord System.UDev.Device.Devnum
instance GHC.Classes.Eq System.UDev.Device.Devnum
instance GHC.Read.Read System.UDev.Device.Devnum
instance GHC.Show.Show System.UDev.Device.Devnum
instance GHC.Classes.Ord System.UDev.Device.Action
instance GHC.Classes.Eq System.UDev.Device.Action
instance GHC.Read.Read System.UDev.Device.Action
instance GHC.Show.Show System.UDev.Device.Action
-- | Connects to a device event source.
module System.UDev.Monitor
-- | Opaque object handling an event source.
data Monitor
-- | Event source identifier.
data SourceId
-- | Events are sent out just after kernel processes them.
--
-- Applications should usually not connect directly to the "kernel"
-- events, because the devices might not be useable at that time, before
-- udev has configured them, and created device nodes. Use UDevId
-- instead.
KernelId :: SourceId
-- | Events are sent out after udev has finished its event processing, all
-- rules have been processed, and needed device nodes are created.
UDevId :: SourceId
-- | For extensibility.
OtherId :: ByteString -> SourceId
-- | Create new udev monitor and connect to a specified event source.
newFromNetlink :: UDev -> SourceId -> IO Monitor
-- | Binds the Monitor socket to the event source.
enableReceiving :: Monitor -> IO ()
-- | Set the size of the kernel socket buffer.
setReceiveBufferSize :: Monitor -> Int -> IO ()
-- | Retrieve the socket file descriptor associated with the monitor.
getFd :: Monitor -> IO Fd
-- | Similar to getFd but retrieves the socket handle
-- associated with the monitor.
getHandle :: Monitor -> IO Handle
-- | Receive data from the udev monitor socket, allocate a new udev device,
-- fill in the received data, and return the device.
receiveDevice :: Monitor -> IO Device
-- | Filter events by subsystem and device type.
--
-- The filter must be installed before the monitor is switched to
-- listening mode.
filterAddMatchSubsystemDevtype :: Monitor -> ByteString -> Maybe ByteString -> IO ()
-- | The filter must be installed before the monitor is switched to
-- listening mode.
filterAddMatchTag :: Monitor -> ByteString -> IO ()
-- | Update the installed socket filter. This is only needed, if the filter
-- was removed or changed.
filterUpdate :: Monitor -> IO ()
-- | Remove all filters from monitor.
filterRemove :: Monitor -> IO ()
instance GHC.Classes.Ord System.UDev.Monitor.SourceId
instance GHC.Classes.Eq System.UDev.Monitor.SourceId
instance GHC.Read.Read System.UDev.Monitor.SourceId
instance GHC.Show.Show System.UDev.Monitor.SourceId
instance System.UDev.Types.UDevChild System.UDev.Monitor.Monitor
instance System.UDev.Types.Ref System.UDev.Monitor.Monitor
-- | Lookup devices in the sys filesystem, filter devices by properties,
-- and return a sorted list of devices.
module System.UDev.Enumerate
-- | Opaque object representing one device lookup/sort context.
data Enumerate
-- | Create an enumeration context to scan /sys.
newEnumerate :: UDev -> IO Enumerate
-- | Kernel subsystem string.
type Subsystem = ByteString
-- | Match only devices belonging to a certain kernel subsystem.
addMatchSubsystem :: Enumerate -> Subsystem -> IO ()
-- | Match only devices not belonging to a certain kernel subsystem.
addNoMatchSubsystem :: Enumerate -> Subsystem -> IO ()
-- | /sys attribute string.
type SysAttr = ByteString
-- | Attribute specific /sys value string. Can be an int or identifier
-- depending on attribute.
type SysValue = ByteString
-- | Match only devices with a certain /sys device attribute.
addMatchSysattr :: Enumerate -> SysAttr -> Maybe SysValue -> IO ()
-- | Match only devices not having a certain /sys device attribute.
addNoMatchSysattr :: Enumerate -> ByteString -> Maybe ByteString -> IO ()
-- | Match only devices with a certain property.
addMatchProperty :: Enumerate -> ByteString -> ByteString -> IO ()
-- | Match only devices with a certain tag.
addMatchTag :: Enumerate -> ByteString -> IO ()
-- | Return the devices on the subtree of one given device. The parent
-- itself is included in the list.
--
-- A reference for the device is held until the udev_enumerate context is
-- cleaned up.
addMatchParent :: Enumerate -> Device -> IO ()
-- | Match only devices which udev has set up already.
addMatchIsInitialized :: Enumerate -> IO ()
-- | Match only devices with a given /sys device name.
addMatchSysname :: Enumerate -> ByteString -> IO ()
-- | Add a device to the list of devices, to retrieve it back sorted in
-- dependency order.
addSyspath :: Enumerate -> RawFilePath -> IO ()
-- | Scan /sys for all devices which match the given filters.
scanDevices :: Enumerate -> IO ()
-- | Scan /sys for all devices which match the given filters.
scanSubsystems :: Enumerate -> IO ()
-- | Get the first entry of the sorted list of device paths.
getListEntry :: Enumerate -> IO (Maybe List)
-- | Utilities useful when dealing with devices and device node names.
module System.UDev.Util
-- | Encode all potentially unsafe characters of a string to the
-- corresponding 2 char hex value prefixed by 'x'.
encodeString :: CString -> CString -> CSize -> IO ()
module System.UDev