Safe Haskell | None |
---|
High-level bindings to to the libkmod
library for manipulating
Linux kernel modules.
- data Context
- new :: Maybe FilePath -> Maybe [FilePath] -> IO Context
- loadResources :: Context -> IO ()
- unloadResources :: Context -> IO ()
- data Resources
- = Ok
- | MustReload
- | MustRecreate
- validateResources :: Context -> IO Resources
- data Index
- dumpIndex :: Context -> Index -> Fd -> IO ()
- setLogPriority :: Context -> Int -> IO ()
- getLogPriority :: Context -> IO Int
- type Key = String
- type Value = String
- configGetBlacklists :: Context -> IO [String]
- configGetInstallCommands :: Context -> IO [(Key, Value)]
- configGetRemoveCommands :: Context -> IO [(Key, Value)]
- configGetAliases :: Context -> IO [(Key, Value)]
- configGetOptions :: Context -> IO [(Key, Value)]
- configGetSoftdeps :: Context -> IO [(Key, Value)]
- data Module
- moduleNewFromLookup :: Context -> String -> IO [Module]
- data Filter = Filter {}
- moduleNewFromLookupWithFilter :: Context -> String -> Filter -> IO [Module]
- moduleNewFromName :: Context -> String -> IO Module
- moduleNewFromPath :: Context -> String -> IO Module
- type Options = String
- data InsertFlags = InsertFlags {}
- moduleInsertModule :: Module -> InsertFlags -> Options -> IO ()
- data ProbeFlags = ProbeFlags {}
- data Blacklist
- type RunInstall = Module -> String -> IO ()
- type PrintAction = Module -> Bool -> Options -> IO ()
- data BlacklistError = BlacklistError
- moduleProbeInsertModule :: Module -> ProbeFlags -> Blacklist -> Maybe Options -> Maybe RunInstall -> Maybe PrintAction -> IO ()
- data RemoveFlags = RemoveFlags {
- removeForce :: Bool
- removeNowait :: Bool
- moduleRemoveModule :: Module -> RemoveFlags -> IO ()
- moduleGetInstallCommands :: Module -> IO (Maybe String)
- moduleGetRemoveCommands :: Module -> IO (Maybe String)
- moduleGetOptions :: Module -> IO (Maybe String)
- moduleGetPath :: Module -> IO (Maybe String)
- moduleGetDependencies :: Module -> IO [Module]
- moduleGetSoftdeps :: Module -> IO ([Module], [Module])
- type Symbol = String
- data Bind
- type CRC = Word64
- moduleGetDependencySymbols :: Module -> IO [(Symbol, Bind, CRC)]
- type Name = String
- type Address = Word64
- moduleGetSections :: Module -> IO [(Name, Address)]
- moduleGetSymbols :: Module -> IO [(Symbol, CRC)]
- moduleGetVersions :: Module -> IO [(Symbol, CRC)]
- moduleGetInfo :: Module -> IO [(Key, Value)]
- moduleNewFromLoaded :: Context -> IO [Module]
- data Initstate
- moduleGetInitstate :: Module -> IO Initstate
- moduleGetSize :: Module -> IO Int
- moduleGetRefcnt :: Module -> IO Int
- moduleGetHolders :: Module -> IO [Module]
Context
:: Maybe FilePath | Linux module's directory, or |
-> Maybe [FilePath] | List of paths (directories or files) for
configuration files, or |
-> IO Context |
Create a kmod
from configuration files.
Context
loadResources :: Context -> IO ()Source
Load indexes and keep them open in
.
Context
unloadResources :: Context -> IO ()Source
Unload all the indexes.
Represent the return values of
.
validateResources
validateResources :: Context -> IO ResourcesSource
Check if indexes and configuration files changed on disk and the current context is not valid anymore.
Represent an index file.
setLogPriority :: Context -> Int -> IO ()Source
Set the current logging priority. The value controls which messages are logged.
getLogPriority :: Context -> IO IntSource
Get the current logging priority.
Get configuration
configGetBlacklists :: Context -> IO [String]Source
Get the list of blacklisted modules.
configGetInstallCommands :: Context -> IO [(Key, Value)]Source
Get the list of modules and corresponding install commands.
configGetRemoveCommands :: Context -> IO [(Key, Value)]Source
Get the list of modules and corresponding remove commands.
configGetAliases :: Context -> IO [(Key, Value)]Source
Get the list of modules and corresponding aliases.
configGetOptions :: Context -> IO [(Key, Value)]Source
Get the list of modules and corresponding options.
configGetSoftdeps :: Context -> IO [(Key, Value)]Source
Get the list of modules and corresponding soft dependencies.
Modules
Filter type for
.
moduleNewFromLookupWithFilter
moduleNewFromLookupWithFilter :: Context -> String -> Filter -> IO [Module]Source
Same as
but apply filter the output list.
moduleNewFromLookup
moduleNewFromName :: Context -> String -> IO ModuleSource
Create a new
using the module name, that can not be an
alias, file name or anything else; it must be a module
name. There's no check if the module exists in the system.
Module
data InsertFlags Source
Flags for
.
moduleInsertModule
moduleInsertModule :: Module -> InsertFlags -> Options -> IO ()Source
Insert a module in Linux kernel.
filter for Blacklist
specifies
how blacklist configuration should be applied.
moduleProbeInsertModule
BlacklistAll | Apply blacklist configuration to the module and its dependencies |
Blacklist | Apply blacklist configuration to the module alone |
BlacklistAliasOnly | Apply blacklist configuration to the module only if it is an alias |
NoBlacklist | Do not apply blacklist configuration |
type RunInstallSource
Function to run a module install commands.
type PrintActionSource
= Module | Module that is going to be loaded |
-> Bool | True if the module has install commands specified in its configuration |
-> Options | Options passed to the module |
-> IO () |
Function to print the actions being taken during the execution of
.
moduleProbeInsertModule
data BlacklistError Source
Exception
n by throw
if the
module cannot be inserted due to a moduleProbeInsertModule
setting.
Blacklist
:: Module | Module to be loaded |
-> ProbeFlags | Flags |
-> Blacklist | How to handle blacklisted modules |
-> Maybe Options | Options to be passed to the module |
-> Maybe RunInstall | Function to execute
module's install
commands, if specified
in is configuration
(see
|
-> Maybe PrintAction | Function to print the action being taken on module loading |
-> IO () |
Insert a module in Linux kernel resolving dependencies, soft
dependencies, install commands and applying blacklist. If the
module cannot be inserted due to the
filter, Blacklist
moduleProbeInsertModule
s a
throw
exception.
BlacklistError
data RemoveFlags Source
Flags for
.
moduleRemoveModule
moduleRemoveModule :: Module -> RemoveFlags -> IO ()Source
Remove a module from Linux kernel.
moduleGetInstallCommands :: Module -> IO (Maybe String)Source
Get install commands for this
. Install commands come
from the configuration file and are cached in Module
. The first
call to this function will search for this module in configuration
and subsequent calls return the cached string. The install commands
are returned as they were in the configuration, concatenated by
';'. No other processing is made in this string.
Module
moduleGetRemoveCommands :: Module -> IO (Maybe String)Source
Get remove commands for this
. Remove commands come
from the configuration file and are cached in Module
. The first
call to this function will search for this module in configuration
and subsequent calls return the cached string. The remove commands
are returned as they were in the configuration, concatenated by
';'. No other processing is made in this string.
Module
moduleGetDependencies :: Module -> IO [Module]Source
Search the modules.dep index to find the dependencies of the
given
.
Module
moduleGetDependencySymbols :: Module -> IO [(Symbol, Bind, CRC)]Source
Get the list of entries in ELF section ".symtab" or "__ksymtab_strings".
moduleGetSections :: Module -> IO [(Name, Address)]Source
Get a list of sections of this
, as returned by Linux
kernel (implemented natively in Haskell by reading Module
/sys/module/
).
moduleGetSymbols :: Module -> IO [(Symbol, CRC)]Source
Get the list of entries in ELF section ".symtab" or "__ksymtab_strings".
moduleGetVersions :: Module -> IO [(Symbol, CRC)]Source
Get the list of entries in ELF section "__versions".
moduleGetInfo :: Module -> IO [(Key, Value)]Source
Get the list of entries in ELF section ".modinfo", these contain alias, license, depends, vermagic and other keys with respective values.
Loaded modules
moduleNewFromLoaded :: Context -> IO [Module]Source
Get the list of
s currently loaded in kernel.
Module
Possible values of initialization state of a
.
Module
moduleGetSize :: Module -> IO IntSource
Get the size of the given
as returned by Linux kernel.
Module