Lines Matching +full:- +full:- +full:fail +full:- +full:env +full:- +full:changed

2  * libkmod - interface to kernel module operations
4 * Copyright (C) 2011-2013 ProFUSION embedded systems
38 #include "libkmod-internal.h"
39 #include "libkmod-index.h"
96 if (ctx->log_fn == NULL) in kmod_log()
100 ctx->log_fn(ctx->log_data, priority, file, line, fn, format, args); in kmod_log()
159 return ctx->dirname; in kmod_get_dirname()
175 return (void *)ctx->userdata; in kmod_get_userdata()
189 ctx->userdata = userdata; in kmod_set_userdata()
231 * defaults to /lib/modules/`uname -r`. If it's relative,
235 * to load from user-defined configuration parameters such as
252 const char *env; in kmod_new() local
260 ctx->refcount = 1; in kmod_new()
261 ctx->log_fn = log_filep; in kmod_new()
262 ctx->log_data = stderr; in kmod_new()
263 ctx->log_priority = LOG_ERR; in kmod_new()
265 ctx->dirname = get_kernel_release(dirname); in kmod_new()
268 env = secure_getenv("KMOD_LOG"); in kmod_new()
269 if (env != NULL) in kmod_new()
270 kmod_set_log_priority(ctx, log_priority(env)); in kmod_new()
274 err = kmod_config_new(ctx, &ctx->config, config_paths); in kmod_new()
277 goto fail; in kmod_new()
280 ctx->modules_by_name = hash_new(KMOD_HASH_SIZE, NULL); in kmod_new()
281 if (ctx->modules_by_name == NULL) { in kmod_new()
282 ERR(ctx, "could not create by-name hash\n"); in kmod_new()
283 goto fail; in kmod_new()
287 DBG(ctx, "log_priority=%d\n", ctx->log_priority); in kmod_new()
291 fail: in kmod_new()
292 free(ctx->modules_by_name); in kmod_new()
293 free(ctx->dirname); in kmod_new()
310 ctx->refcount++; in kmod_ref()
328 if (--ctx->refcount > 0) in kmod_unref()
334 hash_free(ctx->modules_by_name); in kmod_unref()
335 free(ctx->dirname); in kmod_unref()
336 if (ctx->config) in kmod_unref()
337 kmod_config_free(ctx->config); in kmod_unref()
349 * The built-in logging writes to stderr. It can be
362 ctx->log_fn = log_fn; in kmod_set_log_fn()
363 ctx->log_data = (void *)data; in kmod_set_log_fn()
376 return -1; in kmod_get_log_priority()
377 return ctx->log_priority; in kmod_get_log_priority()
392 ctx->log_priority = priority; in kmod_set_log_priority()
400 mod = hash_find(ctx->modules_by_name, key); in kmod_pool_get_module()
412 hash_add(ctx->modules_by_name, key, mod); in kmod_pool_add_module()
420 hash_del(ctx->modules_by_name, key); in kmod_pool_del_module()
432 if (ctx->indexes[index_number] != NULL) { in kmod_lookup_alias_from_alias_bin()
435 realnames = index_mm_searchwild(ctx->indexes[index_number], in kmod_lookup_alias_from_alias_bin()
440 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in kmod_lookup_alias_from_alias_bin()
447 return -ENOSYS; in kmod_lookup_alias_from_alias_bin()
453 for (realname = realnames; realname; realname = realname->next) { in kmod_lookup_alias_from_alias_bin()
456 err = kmod_module_new_from_alias(ctx, name, realname->value, &mod); in kmod_lookup_alias_from_alias_bin()
459 name, realname->value, strerror(-err)); in kmod_lookup_alias_from_alias_bin()
460 goto fail; in kmod_lookup_alias_from_alias_bin()
470 fail: in kmod_lookup_alias_from_alias_bin()
498 if (ctx->indexes[KMOD_INDEX_MODULES_BUILTIN]) { in lookup_builtin_file()
502 line = index_mm_search(ctx->indexes[KMOD_INDEX_MODULES_BUILTIN], in lookup_builtin_file()
508 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in lookup_builtin_file()
540 name, strerror(-err)); in kmod_lookup_alias_from_builtin_file()
549 err = -ENOMEM; in kmod_lookup_alias_from_builtin_file()
572 if (ctx->indexes[KMOD_INDEX_MODULES_DEP]) { in kmod_search_moddep()
575 return index_mm_search(ctx->indexes[KMOD_INDEX_MODULES_DEP], in kmod_search_moddep()
579 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in kmod_search_moddep()
616 name, strerror(-n)); in kmod_lookup_alias_from_moddep_file()
633 struct kmod_config *config = ctx->config; in kmod_lookup_alias_from_config()
637 kmod_list_foreach(l, config->aliases) { in kmod_lookup_alias_from_config()
648 name, modname, strerror(-err)); in kmod_lookup_alias_from_config()
649 goto fail; in kmod_lookup_alias_from_config()
659 fail: in kmod_lookup_alias_from_config()
667 struct kmod_config *config = ctx->config; in kmod_lookup_alias_from_commands()
671 kmod_list_foreach(l, config->install_commands) { in kmod_lookup_alias_from_commands()
681 modname, strerror(-err)); in kmod_lookup_alias_from_commands()
688 return -ENOMEM; in kmod_lookup_alias_from_commands()
698 * module-init-tools does in kmod_lookup_alias_from_commands()
707 kmod_list_foreach(l, config->remove_commands) { in kmod_lookup_alias_from_commands()
717 modname, strerror(-err)); in kmod_lookup_alias_from_commands()
724 return -ENOMEM; in kmod_lookup_alias_from_commands()
734 * module-init-tools does in kmod_lookup_alias_from_commands()
748 hash_iter_init(ctx->modules_by_name, &iter); in kmod_set_modules_visited()
758 hash_iter_init(ctx->modules_by_name, &iter); in kmod_set_modules_required()
780 * Check if indexes and configuration files changed on disk and the current
786 * KMOD_RESOURCES_MUST_RECREATE if @ctx must be re-created.
793 if (ctx == NULL || ctx->config == NULL) in kmod_validate_resources()
796 kmod_list_foreach(l, ctx->config->paths) { in kmod_validate_resources()
797 struct kmod_config_path *cf = l->data; in kmod_validate_resources()
799 if (is_cache_invalid(cf->path, cf->stamp)) in kmod_validate_resources()
806 if (ctx->indexes[i] == NULL) in kmod_validate_resources()
809 snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname, in kmod_validate_resources()
812 if (is_cache_invalid(path, ctx->indexes_stamp[i])) in kmod_validate_resources()
839 return -ENOENT; in kmod_load_resources()
844 if (ctx->indexes[i] != NULL) { in kmod_load_resources()
850 snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname, in kmod_load_resources()
852 ctx->indexes[i] = index_mm_open(ctx, path, in kmod_load_resources()
853 &ctx->indexes_stamp[i]); in kmod_load_resources()
854 if (ctx->indexes[i] == NULL) in kmod_load_resources()
855 goto fail; in kmod_load_resources()
860 fail: in kmod_load_resources()
862 return -ENOMEM; in kmod_load_resources()
888 if (ctx->indexes[i] != NULL) { in kmod_unload_resources()
889 index_mm_close(ctx->indexes[i]); in kmod_unload_resources()
890 ctx->indexes[i] = NULL; in kmod_unload_resources()
891 ctx->indexes_stamp[i] = 0; in kmod_unload_resources()
916 return -ENOSYS; in kmod_dump_index()
919 return -ENOENT; in kmod_dump_index()
921 if (ctx->indexes[type] != NULL) { in kmod_dump_index()
923 index_mm_dump(ctx->indexes[type], fd, in kmod_dump_index()
929 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in kmod_dump_index()
936 return -ENOSYS; in kmod_dump_index()
947 return ctx->config; in kmod_get_config()