• Home
  • Raw
  • Download

Lines Matching +full:builtin +full:- +full:modules

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"
57 [KMOD_INDEX_MODULES_DEP] = { .fn = "modules.dep", .prefix = "" },
58 [KMOD_INDEX_MODULES_ALIAS] = { .fn = "modules.alias", .prefix = "alias " },
59 [KMOD_INDEX_MODULES_SYMBOL] = { .fn = "modules.symbols", .prefix = "alias "},
60 [KMOD_INDEX_MODULES_BUILTIN_ALIAS] = { .fn = "modules.builtin.alias", .prefix = "" },
61 [KMOD_INDEX_MODULES_BUILTIN] = { .fn = "modules.builtin", .prefix = ""},
98 if (ctx->log_fn == NULL) in kmod_log()
102 ctx->log_fn(ctx->log_data, priority, file, line, fn, format, args); in kmod_log()
156 * Retrieve the absolute path used for linux modules in this context. The path
161 return ctx->dirname; in kmod_get_dirname()
177 return (void *)ctx->userdata; in kmod_get_userdata()
191 ctx->userdata = userdata; in kmod_set_userdata()
211 static const char *dirname_default_prefix = "/lib/modules";
233 * defaults to /lib/modules/`uname -r`. If it's relative,
237 * to load from user-defined configuration parameters such as
263 ctx->refcount = 1; in kmod_new()
264 ctx->log_fn = log_filep; in kmod_new()
265 ctx->log_data = stderr; in kmod_new()
266 ctx->log_priority = LOG_ERR; in kmod_new()
268 ctx->dirname = get_kernel_release(dirname); in kmod_new()
277 err = kmod_config_new(ctx, &ctx->config, config_paths); in kmod_new()
283 ctx->modules_by_name = hash_new(KMOD_HASH_SIZE, NULL); in kmod_new()
284 if (ctx->modules_by_name == NULL) { in kmod_new()
285 ERR(ctx, "could not create by-name hash\n"); in kmod_new()
290 DBG(ctx, "log_priority=%d\n", ctx->log_priority); in kmod_new()
295 free(ctx->modules_by_name); in kmod_new()
296 free(ctx->dirname); in kmod_new()
313 ctx->refcount++; in kmod_ref()
331 if (--ctx->refcount > 0) in kmod_unref()
337 hash_free(ctx->modules_by_name); in kmod_unref()
338 free(ctx->dirname); in kmod_unref()
339 if (ctx->config) in kmod_unref()
340 kmod_config_free(ctx->config); in kmod_unref()
352 * The built-in logging writes to stderr. It can be
365 ctx->log_fn = log_fn; in kmod_set_log_fn()
366 ctx->log_data = (void *)data; in kmod_set_log_fn()
379 return -1; in kmod_get_log_priority()
380 return ctx->log_priority; in kmod_get_log_priority()
395 ctx->log_priority = priority; in kmod_set_log_priority()
403 mod = hash_find(ctx->modules_by_name, key); in kmod_pool_get_module()
415 hash_add(ctx->modules_by_name, key, mod); in kmod_pool_add_module()
423 hash_del(ctx->modules_by_name, key); in kmod_pool_del_module()
435 if (ctx->indexes[index_number] != NULL) { in kmod_lookup_alias_from_alias_bin()
438 realnames = index_mm_searchwild(ctx->indexes[index_number], in kmod_lookup_alias_from_alias_bin()
443 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in kmod_lookup_alias_from_alias_bin()
450 return -ENOSYS; in kmod_lookup_alias_from_alias_bin()
456 for (realname = realnames; realname; realname = realname->next) { in kmod_lookup_alias_from_alias_bin()
459 err = kmod_module_new_from_alias(ctx, name, realname->value, &mod); in kmod_lookup_alias_from_alias_bin()
462 name, realname->value, strerror(-err)); in kmod_lookup_alias_from_alias_bin()
501 if (ctx->indexes[KMOD_INDEX_MODULES_BUILTIN]) { in lookup_builtin_file()
505 line = index_mm_search(ctx->indexes[KMOD_INDEX_MODULES_BUILTIN], in lookup_builtin_file()
511 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in lookup_builtin_file()
517 DBG(ctx, "could not open builtin file '%s'\n", fn); in lookup_builtin_file()
542 struct kmod_module *mod = l->data; in kmod_lookup_alias_from_kernel_builtin_file()
564 name, strerror(-err)); in kmod_lookup_alias_from_builtin_file()
568 /* already mark it as builtin since it's being created from in kmod_lookup_alias_from_builtin_file()
573 err = -ENOMEM; in kmod_lookup_alias_from_builtin_file()
596 if (ctx->indexes[KMOD_INDEX_MODULES_DEP]) { in kmod_search_moddep()
599 return index_mm_search(ctx->indexes[KMOD_INDEX_MODULES_DEP], in kmod_search_moddep()
603 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in kmod_search_moddep()
640 name, strerror(-n)); in kmod_lookup_alias_from_moddep_file()
657 struct kmod_config *config = ctx->config; in kmod_lookup_alias_from_config()
661 kmod_list_foreach(l, config->aliases) { in kmod_lookup_alias_from_config()
672 name, modname, strerror(-err)); in kmod_lookup_alias_from_config()
691 struct kmod_config *config = ctx->config; in kmod_lookup_alias_from_commands()
695 kmod_list_foreach(l, config->install_commands) { in kmod_lookup_alias_from_commands()
705 modname, strerror(-err)); in kmod_lookup_alias_from_commands()
712 return -ENOMEM; in kmod_lookup_alias_from_commands()
722 * module-init-tools does in kmod_lookup_alias_from_commands()
731 kmod_list_foreach(l, config->remove_commands) { in kmod_lookup_alias_from_commands()
741 modname, strerror(-err)); in kmod_lookup_alias_from_commands()
748 return -ENOMEM; in kmod_lookup_alias_from_commands()
758 * module-init-tools does in kmod_lookup_alias_from_commands()
772 hash_iter_init(ctx->modules_by_name, &iter); in kmod_set_modules_visited()
782 hash_iter_init(ctx->modules_by_name, &iter); in kmod_set_modules_required()
810 * KMOD_RESOURCES_MUST_RECREATE if @ctx must be re-created.
817 if (ctx == NULL || ctx->config == NULL) in kmod_validate_resources()
820 kmod_list_foreach(l, ctx->config->paths) { in kmod_validate_resources()
821 struct kmod_config_path *cf = l->data; in kmod_validate_resources()
823 if (is_cache_invalid(cf->path, cf->stamp)) in kmod_validate_resources()
830 if (ctx->indexes[i] == NULL) in kmod_validate_resources()
833 snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname, in kmod_validate_resources()
836 if (is_cache_invalid(path, ctx->indexes_stamp[i])) in kmod_validate_resources()
864 return -ENOENT; in kmod_load_resources()
869 if (ctx->indexes[i] != NULL) { in kmod_load_resources()
875 snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname, in kmod_load_resources()
877 ret = index_mm_open(ctx, path, &ctx->indexes_stamp[i], in kmod_load_resources()
878 &ctx->indexes[i]); in kmod_load_resources()
881 * modules.builtin.alias are considered optional since it's in kmod_load_resources()
907 * knows that when starting up it will lookup a lot of modules, it could call
921 if (ctx->indexes[i] != NULL) { in kmod_unload_resources()
922 index_mm_close(ctx->indexes[i]); in kmod_unload_resources()
923 ctx->indexes[i] = NULL; in kmod_unload_resources()
924 ctx->indexes_stamp[i] = 0; in kmod_unload_resources()
936 * KMOD_INDEX_MODULES_BUILTIN: index of builtin module.
949 return -ENOSYS; in kmod_dump_index()
952 return -ENOENT; in kmod_dump_index()
954 if (ctx->indexes[type] != NULL) { in kmod_dump_index()
956 index_mm_dump(ctx->indexes[type], fd, in kmod_dump_index()
962 snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname, in kmod_dump_index()
969 return -ENOSYS; in kmod_dump_index()
980 return ctx->config; in kmod_get_config()