* SECTION:libkmod-loaded
* @short_description: currently loaded modules
*
- * Information about currently loaded modules, as reported by Linux kernel
+ * 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.
*/
/**
- * kmod_loaded_get_list:
+ * kmod_module_new_from_loaded:
* @ctx: kmod library context
* @list: where to save the list of loaded modules
*
* Get a list of all modules currently loaded in kernel. It uses /proc/modules
- * to get a list of loaded modules and create kmod_module objects that are put
+ * to get the names of loaded modules and to create kmod_module objects by
+ * calling kmod_module_new_from_name() in each of them. They are put are put
* in @list in no particular order.
*
* All the returned modules get their refcount incremented (or are created if
*
* Returns: 0 on success or < 0 on error.
*/
-KMOD_EXPORT int kmod_loaded_get_list(struct kmod_ctx *ctx,
+KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx,
struct kmod_list **list)
{
struct kmod_list *l = NULL;
list_entry != NULL; \
list_entry = kmod_list_next(first_entry, list_entry))
-int kmod_loaded_get_list(struct kmod_ctx *ctx, struct kmod_list **list);
-
enum kmod_remove {
KMOD_REMOVE_FORCE = O_TRUNC,
KMOD_REMOVE_NOWAIT = O_NONBLOCK,
struct kmod_module **mod);
int kmod_module_new_from_lookup(struct kmod_ctx *ctx, const char *alias,
struct kmod_list **list);
+int kmod_module_new_from_loaded(struct kmod_ctx *ctx, struct kmod_list **list);
struct kmod_module *kmod_module_ref(struct kmod_module *mod);
struct kmod_module *kmod_module_unref(struct kmod_module *mod);
kmod_unref;
kmod_list_next;
kmod_list_prev;
- kmod_loaded_get_list;
kmod_load_resources;
kmod_unload_resources;
kmod_module_new_from_name;
kmod_module_new_from_path;
kmod_module_new_from_lookup;
+ kmod_module_new_from_loaded;
kmod_module_ref;
kmod_module_unref;
kmod_module_unref_list;
printf("libkmod version %s\n", VERSION);
- err = kmod_loaded_get_list(ctx, &list);
+ err = kmod_module_new_from_loaded(ctx, &list);
if (err < 0) {
fprintf(stderr, "%s\n", strerror(-err));
kmod_unref(ctx);
printf("libkmod version %s\n", VERSION);
- err = kmod_loaded_get_list(ctx, &list);
+ err = kmod_module_new_from_loaded(ctx, &list);
if (err < 0) {
fprintf(stderr, "%s\n", strerror(-err));
kmod_unref(ctx);
return EXIT_FAILURE;
}
- err = kmod_loaded_get_list(ctx, &list);
+ err = kmod_module_new_from_loaded(ctx, &list);
if (err < 0) {
fprintf(stderr, "Error: could not get list of modules: %s\n",
strerror(-err));