char *dirname;
struct kmod_config *config;
struct kmod_hash *modules_by_name;
+ struct index_mm *indexes[_KMOD_INDEX_LAST];
};
void kmod_log(const struct kmod_ctx *ctx,
if (--ctx->refcount > 0)
return ctx;
+
INFO(ctx, "context %p released\n", ctx);
+
+ kmod_unload_resources(ctx);
kmod_hash_free(ctx->modules_by_name);
free(ctx->dirname);
if (ctx->config)
kmod_config_free(ctx->config);
+
free(ctx);
return NULL;
}
*output = NULL;
return -ENOMEM;
}
+
+KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
+{
+ size_t i;
+
+ if (ctx == NULL)
+ return -ENOENT;
+
+ for (i = 0; i < ARRAY_SIZE(index_files); i++) {
+ if (ctx->indexes[i] == NULL) {
+ const char *fn = index_files[i];
+
+ ctx->indexes[i] = index_mm_open(ctx, fn, true);
+ if (ctx->indexes[i] == NULL)
+ goto fail;
+ }
+ }
+
+ return 0;
+
+fail:
+ kmod_unload_resources(ctx);
+ return -ENOMEM;
+}
+
+KMOD_EXPORT void kmod_unload_resources(struct kmod_ctx *ctx)
+{
+ size_t i;
+
+ if (ctx == NULL)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(index_files); i++) {
+ if (ctx->indexes[i] != NULL) {
+ index_mm_close(ctx->indexes[i]);
+ ctx->indexes[i] = NULL;
+ }
+ }
+}
void kmod_set_log_priority(struct kmod_ctx *ctx, int priority);
void *kmod_get_userdata(const struct kmod_ctx *ctx);
void kmod_set_userdata(struct kmod_ctx *ctx, const void *userdata);
+int kmod_load_resources(struct kmod_ctx *ctx);
+void kmod_unload_resources(struct kmod_ctx *ctx);
/*
* kmod_list
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_unref_list;
kmod_module_remove_module;
kmod_module_insert_module;
-
kmod_module_get_dependencies;
kmod_module_get_module;
kmod_module_section_free_list;
kmod_module_section_get_name;
kmod_module_section_get_address;
-
kmod_module_get_holders;
-
kmod_module_get_size;
local:
*;