|  |  |  | libkmod Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
int kmod_module_new_from_loaded (struct kmod_ctx *ctx,struct kmod_list **list); int kmod_module_get_initstate (const struct kmod_module *mod); const char * kmod_module_initstate_str (enum kmod_module_initstate state); long kmod_module_get_size (const struct kmod_module *mod); int kmod_module_get_refcnt (const struct kmod_module *mod); struct kmod_list * kmod_module_get_holders (const struct kmod_module *mod);
Information about currently loaded modules, as reported by Linux kernel. These information are not cached by libkmod and are always read from /sys and /proc/modules.
int kmod_module_new_from_loaded (struct kmod_ctx *ctx,struct kmod_list **list);
Create a new list of kmod modules with all modules currently loaded in
kernel. It uses /proc/modules to get the names of loaded modules and to
create kmod modules by calling kmod_module_new_from_name() in each of them.
They are put in list in no particular order.
The initial refcount is 1, and needs to be decremented to release the
resources of the kmod_module. The returned list must be released by
calling kmod_module_unref_list(). Since libkmod keeps track of all
kmod_modules created, they are all released upon ctx destruction too. Do
not unref ctx before all the desired operations with the returned list are
completed.
| 
 | kmod library context | 
| 
 | where to save the list of loaded modules | 
| Returns : | 0 on success or < 0 on error. | 
int                 kmod_module_get_initstate           (const struct kmod_module *mod);
Get the initstate of this mod, as returned by Linux Kernel, by reading
/sys filesystem.
| 
 | kmod module | 
| Returns : | < 0 on error or module state if module is found in kernel, valid states are KMOD_MODULE_BUILTIN: module is builtin; KMOD_MODULE_LIVE: module is live in kernel; KMOD_MODULE_COMING: module is being loaded; KMOD_MODULE_GOING: module is being unloaded. | 
const char *        kmod_module_initstate_str           (enum kmod_module_initstate state);
Translate a initstate to a string.
| 
 | the state as returned by kmod_module_get_initstate() | 
| Returns : | the string associated to the state. This string is statically
allocated, do not free it. | 
long                kmod_module_get_size                (const struct kmod_module *mod);
Get the size of this kmod module as returned by Linux kernel. If supported, the size is read from the coresize attribute in /sys/module. For older kernels, this falls back on /proc/modules and searches for the specified module to get its size.
| 
 | kmod module | 
| Returns : | the size of this kmod module. | 
int                 kmod_module_get_refcnt              (const struct kmod_module *mod);
Get the ref count of this mod, as returned by Linux Kernel, by reading
/sys filesystem.
| 
 | kmod module | 
| Returns : | 0 on success or < 0 on failure. | 
struct kmod_list *  kmod_module_get_holders             (const struct kmod_module *mod);
Get a list of kmod modules that are holding this mod, as returned by Linux
Kernel. After use, free the list by calling kmod_module_unref_list().
| 
 | kmod module | 
| Returns : | a new list of kmod modules on success or NULL on failure. |