linux-kmod-0.1.0.0: Linux kernel modules support

Safe HaskellNone

System.Linux.KMod

Contents

Description

High-level bindings to to the libkmod library for manipulating Linux kernel modules.

Synopsis

Context

data Context Source

Opaque object representing the library context.

newSource

Arguments

:: Maybe FilePath

Linux module's directory, or Nothing for the default (/lib/modules/`uname -r`)

-> Maybe [FilePath]

List of paths (directories or files) for configuration files, or Nothing for the default (/run/modprobe.d, /etc/modprobe.d and /lib/modprobe.d)

-> IO Context 

Create a kmod Context from configuration files.

loadResources :: Context -> IO ()Source

Load indexes and keep them open in Context.

unloadResources :: Context -> IO ()Source

Unload all the indexes.

data Resources Source

Represent the return values of validateResources.

Constructors

Ok 
MustReload 
MustRecreate 

validateResources :: Context -> IO ResourcesSource

Check if indexes and configuration files changed on disk and the current context is not valid anymore.

data Index Source

Represent an index file.

Instances

dumpIndex :: Context -> Index -> Fd -> IO ()Source

Dump Index to file descriptor.

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

type Key = StringSource

Represent the key in a (key,value) pair.

type Value = StringSource

Represent the value in a (key,value) pair.

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

data Module Source

Opaque object representing a module. The Show instance of Module is achieved using kmod_module_get_name.

Instances

moduleNewFromLookup :: Context -> String -> IO [Module]Source

Create a new list of Modules using an alias or module name and lookup libkmod's configuration files and indexes in order to find the module. Once it's found in one of the places, it stops searching and create the list of Modules.

data Filter Source

Constructors

Filter 

Instances

moduleNewFromLookupWithFilter :: Context -> String -> Filter -> IO [Module]Source

Same as moduleNewFromLookup but apply filter the output list.

moduleNewFromName :: Context -> String -> IO ModuleSource

Create a new Module 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.

moduleNewFromPath :: Context -> String -> IO ModuleSource

Create a new Module using the module path.

type Options = StringSource

Options for module loading to pass to Linux Kernel.

moduleInsertModule :: Module -> InsertFlags -> Options -> IO ()Source

Insert a module in Linux kernel.

data Blacklist Source

Blacklist filter for moduleProbeInsertModule specifies how blacklist configuration should be applied.

Constructors

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

Arguments

 = Module

Module being loaded

-> String

Command line of the install executable

-> IO () 

Function to run a module install commands.

type PrintActionSource

Arguments

 = 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.

moduleProbeInsertModuleSource

Arguments

:: 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 moduleGetInstallCommands). If Nothing then use system(3)

-> 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 Blacklist filter, moduleProbeInsertModule throws a BlacklistError exception.

moduleRemoveModule :: Module -> RemoveFlags -> IO ()Source

Remove a module from Linux kernel.

moduleGetInstallCommands :: Module -> IO (Maybe String)Source

Get install commands for this Module. 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.

moduleGetRemoveCommands :: Module -> IO (Maybe String)Source

Get remove commands for this Module. 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.

moduleGetOptions :: Module -> IO (Maybe String)Source

Get options of this Module. Options 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.

moduleGetPath :: Module -> IO (Maybe String)Source

Get the path of this Module. If this Module was not created by path, it can search the modules.dep index in order to find out the module under context's dirname.

moduleGetDependencies :: Module -> IO [Module]Source

Search the modules.dep index to find the dependencies of the given Module.

moduleGetSoftdeps :: Module -> IO ([Module], [Module])Source

Get soft dependencies for this Module.

type Symbol = StringSource

Name of a symbol.

data Bind Source

Symbol bind type.

Constructors

None 
Local 
Global 
Weak 
Undefined 

Instances

type CRC = Word64Source

Crc of a symbol.

moduleGetDependencySymbols :: Module -> IO [(Symbol, Bind, CRC)]Source

Get the list of entries in ELF section ".symtab" or "__ksymtab_strings".

type Name = StringSource

Name of a module section.

type Address = Word64Source

Address of a module section.

moduleGetSections :: Module -> IO [(Name, Address)]Source

Get a list of sections of this Module, as returned by Linux kernel (implemented natively in Haskell by reading /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 Modules currently loaded in kernel.

data Initstate Source

Possible values of initialization state of a Module.

Constructors

Builtin 
Live 
Coming 
Going 

moduleGetInitstate :: Module -> IO InitstateSource

Get the Initstate of the given Module, as returned by Linux Kernel, by reading /sys filesystem.

moduleGetSize :: Module -> IO IntSource

Get the size of the given Module as returned by Linux kernel.

moduleGetRefcnt :: Module -> IO IntSource

Get the ref count of the given Module, as returned by Linux kernel, by reading /sys filesystem.

moduleGetHolders :: Module -> IO [Module]Source

Get the list of Modules that are holding the given Module, as returned by Linux kernel.