The kernel installs a modules.builtin file listing all builtin modules. Let depmod generate a modules.builtin.bin file and use this in modprobe: If a module is not found in modules.dep or modules.alias, check if the module is builtin and print "builtin <module>" instead of trying to load anything. It is done in this order to not slow down the common case. Signed-off-by: Michal Marek <mmarek@xxxxxxx> --- depmod.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- modprobe.c | 23 +++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletions(-) diff --git a/depmod.c b/depmod.c index 3ac5070..43ff28f 100644 --- a/depmod.c +++ b/depmod.c @@ -825,6 +825,49 @@ static int output_symbols_bin(struct module *unused, FILE *out, char *dirname) return 1; } +static int output_builtin_bin(struct module *unused, FILE *out, char *dirname) +{ + struct index_node *index; + char *textfile, *line; + unsigned int linenum; + FILE *f; + + nofail_asprintf(&textfile, "%s/modules.builtin", dirname); + if (!(f = fopen(textfile, "r"))) { + if (errno != ENOENT) + fatal("Could not open '%s': %s\n", + textfile, strerror(errno)); + free(textfile); + return 0; + } + free(textfile); + index = index_create(); + + while ((line = getline_wrapped(f, &linenum)) != NULL) { + char *module = strrchr(line, '/'); + + if (!*line || *line == '#') { + free(line); + continue; + } + module = strrchr(line, '/'); + if (module) + module++; + else + module = line; + if (ends_in(module, ".ko")) + module[strlen(module) - 3] = '\0'; + underscores(module); + index_insert(index, module, "", 0); + free(line); + } + fclose(f); + index_write(index, out); + index_destroy(index); + + return 1; +} + static int output_aliases(struct module *modules, FILE *out, char *dirname) { struct module *i; @@ -932,7 +975,8 @@ static struct depfile depfiles[] = { { "modules.alias", output_aliases, 0 }, { "modules.alias.bin", output_aliases_bin, 0 }, { "modules.symbols", output_symbols, 0 }, - { "modules.symbols.bin", output_symbols_bin, 0 } + { "modules.symbols.bin", output_symbols_bin, 0 }, + { "modules.builtin.bin", output_builtin_bin, 0 }, }; /* If we can't figure it out, it's safe to say "true". */ diff --git a/modprobe.c b/modprobe.c index 21a3111..a17cfca 100644 --- a/modprobe.c +++ b/modprobe.c @@ -537,6 +537,24 @@ static int read_attribute(const char *filename, char *buf, size_t buflen) return (s == NULL) ? -1 : 1; } +/* is this a built-in module? + * 0: no, 1: yes, -1: don't know + */ +static int module_builtin(const char *dirname, const char *modname) +{ + struct index_file *index; + char *filename, *value; + + nofail_asprintf(&filename, "%s/modules.builtin.bin", dirname); + index = index_file_open(filename); + free(filename); + if (!index) + return -1; + value = index_search(index, modname); + free(value); + return value ? 1 : 0; +} + /* Is module in /sys/module? If so, fill in usecount if not NULL. 0 means no, 1 means yes, -1 means unknown. */ @@ -1331,6 +1349,11 @@ int do_modprobe(char *modname, modname, 0, flags & mit_remove, &modoptions, &commands, &aliases, &blacklist); + /* builtin module? */ + if (!aliases && module_builtin(dirname, modname) == 1) { + info("builtin %s\n", modname); + return 0; + } } } -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html