Index: module-init-tools-3.5/Makefile.am =================================================================== --- module-init-tools-3.5.orig/Makefile.am +++ module-init-tools-3.5/Makefile.am @@ -1,10 +1,23 @@ +# Build a libtool library, libmodprobe.la for installation in libdir. +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status --recheck + +lib_LTLIBRARIES = libmodprobe.la +libmodprobe_la_SOURCES = libmodprobe.c logging.c index.c zlibsupport.c zlibsupport.h logging.h index.h +libmodprobe_la_LDFLAGS = -version-info 1:0:0 -lz + insmod_SOURCES = insmod.c testing.h lsmod_SOURCES = lsmod.c testing.h -modprobe_SOURCES = modprobe.c logging.c index.c zlibsupport.c logging.h index.h testing.h zlibsupport.h +modprobe_SOURCES = modprobe.c logging.h index.h testing.h zlibsupport.h +modprobe_LDFLAGS = -lmodprobe rmmod_SOURCES = rmmod.c testing.h -depmod_SOURCES = depmod.c logging.c index.c moduleops.c tables.c zlibsupport.c depmod.h logging.h index.h moduleops.h tables.h list.h testing.h zlibsupport.h -modinfo_SOURCES = modinfo.c zlibsupport.c testing.h zlibsupport.h -modindex_SOURCES = modindex.c logging.c index.c logging.h index.h +depmod_SOURCES = depmod.c moduleops.c tables.c depmod.h logging.h index.h moduleops.h tables.h list.h testing.h zlibsupport.h +depmod_LDFLAGS = -lmodprobe +modinfo_SOURCES = modinfo.c testing.h zlibsupport.h +modinfo_LDFLAGS = -lmodprobe +modindex_SOURCES = modindex.c logging.h index.h +modindex_LDFLAGS = -lmodprobe insmod_static_SOURCES = insmod.c insmod_static_LDFLAGS = -static Index: module-init-tools-3.5/configure.ac =================================================================== --- module-init-tools-3.5.orig/configure.ac +++ module-init-tools-3.5/configure.ac @@ -2,6 +2,9 @@ AC_INIT AC_CANONICAL_SYSTEM +AC_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) + AM_INIT_AUTOMAKE(module-init-tools, "3.5") # If zlib is required, libz must be linked static, modprobe is in Index: module-init-tools-3.5/libmodprobe.c =================================================================== --- /dev/null +++ module-init-tools-3.5/libmodprobe.c @@ -0,0 +1,422 @@ +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <dirent.h> +#include <errno.h> +#include <fnmatch.h> +#include <sys/types.h> + +#include "index.h" +#include "logging.h" +#include "modprobe.h" + +#define streq(a,b) (strcmp((a),(b)) == 0) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + + +int use_binary_indexes = 1; /* default to enabled. */ + +/* Find blacklist commands if any. */ +int +find_blacklist(const char *modname, const struct module_blacklist *blacklist) +{ + while (blacklist) { + if (strcmp(blacklist->modulename, modname) == 0) + return 1; + blacklist = blacklist->next; + } + return 0; +} + +/* Link in a new alias line from the config file. */ +struct module_alias * +add_alias(const char *modname, struct module_alias *aliases) +{ + struct module_alias *new; + + new = NOFAIL(malloc(sizeof(*new))); + new->module = NOFAIL(strdup(modname)); + new->next = aliases; + return new; +} + +/* return a new alias list, with backlisted elems filtered out */ +struct module_alias * +apply_blacklist(const struct module_alias *aliases, + const struct module_blacklist *blacklist) +{ + struct module_alias *result = NULL; + while (aliases) { + char *modname = aliases->module; + if (!find_blacklist(modname, blacklist)) + result = add_alias(modname, result); + aliases = aliases->next; + } + return result; +} + +static void grammar(const char *cmd, const char *filename, unsigned int line) +{ + warn("%s line %u: ignoring bad line starting with '%s'\n", + filename, line, cmd); +} + +/* Link in a new option line from the config file. */ +struct module_options * +add_options(const char *modname, + const char *option, + struct module_options *options) +{ + struct module_options *new; + char *tab; + + new = NOFAIL(malloc(sizeof(*new))); + new->modulename = NOFAIL(strdup(modname)); + new->options = NOFAIL(strdup(option)); + /* We can handle tabs, kernel can't. */ + for (tab = strchr(new->options, '\t'); tab; tab = strchr(tab, '\t')) + *tab = ' '; + new->next = options; + return new; +} + +/* Careful! Don't munge - in [ ] as per Debian Bug#350915 */ +char *underscores(char *string) +{ + if (string) { + unsigned int i; + int inbracket = 0; + for (i = 0; string[i]; i++) { + switch (string[i]) { + case '[': + inbracket++; + break; + case ']': + inbracket--; + break; + case '-': + if (!inbracket) + string[i] = '_'; + } + } + if (inbracket) + warn("Unmatched bracket in %s\n", string); + } + return string; +} + +/* Link in a new install line from the config file. */ +static struct module_command * +add_command(const char *modname, + const char *command, + struct module_command *commands) +{ + struct module_command *new; + + new = NOFAIL(malloc(sizeof(*new))); + new->modulename = NOFAIL(strdup(modname)); + new->command = NOFAIL(strdup(command)); + new->next = commands; + return new; +} + +char *getline_wrapped(FILE *file, unsigned int *linenum) +{ + int size = 256; + int i = 0; + char *buf = NOFAIL(malloc(size)); + for(;;) { + int ch = getc_unlocked(file); + + switch(ch) { + case EOF: + if (i == 0) { + free(buf); + return NULL; + } + /* else fall through */ + + case '\n': + if (linenum) + (*linenum)++; + if (i == size) + buf = NOFAIL(realloc(buf, size + 1)); + buf[i] = '\0'; + return buf; + + case '\\': + ch = getc_unlocked(file); + + if (ch == '\n') { + if (linenum) + (*linenum)++; + continue; + } + /* else fall through */ + + default: + buf[i++] = ch; + + if (i == size) { + size *= 2; + buf = NOFAIL(realloc(buf, size)); + } + } + } +} + +char *strsep_skipspace(char **string, char *delim) +{ + if (!*string) + return NULL; + *string += strspn(*string, delim); + return strsep(string, delim); +} + +/* Link in a new blacklist line from the config file. */ +static struct module_blacklist * +add_blacklist(const char *modname, struct module_blacklist *blacklist) +{ + struct module_blacklist *new; + + new = NOFAIL(malloc(sizeof(*new))); + new->modulename = NOFAIL(strdup(modname)); + new->next = blacklist; + return new; +} + +/* FIXME: Maybe should be extended to "alias a b [and|or c]...". --RR */ +int read_config_file(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist) +{ + char *line; + unsigned int linenum = 0; + FILE *cfile; + + cfile = fopen(filename, "r"); + if (!cfile) + return 0; + + while ((line = getline_wrapped(cfile, &linenum)) != NULL) { + char *ptr = line; + char *cmd, *modname; + + if (dump_only) + printf("%s\n", line); + + cmd = strsep_skipspace(&ptr, "\t "); + if (cmd == NULL || cmd[0] == '#' || cmd[0] == '\0') { + free(line); + continue; + } + + if (strcmp(cmd, "alias") == 0) { + char *wildcard + = underscores(strsep_skipspace(&ptr, "\t ")); + char *realname + = underscores(strsep_skipspace(&ptr, "\t ")); + + if (!wildcard || !realname) + grammar(cmd, filename, linenum); + else if (fnmatch(wildcard,name,0) == 0) + *aliases = add_alias(realname, *aliases); + } else if (strcmp(cmd, "include") == 0) { + struct module_alias *newalias = NULL; + char *newfilename; + + newfilename = strsep_skipspace(&ptr, "\t "); + if (!newfilename) + grammar(cmd, filename, linenum); + else { + if (!read_config(newfilename, name, + dump_only, removing, + options, commands, &newalias, + blacklist)) + warn("Failed to open included" + " config file %s: %s\n", + newfilename, strerror(errno)); + + /* Files included override aliases, + etc that was already set ... */ + if (newalias) + *aliases = newalias; + } + } else if (strcmp(cmd, "options") == 0) { + modname = strsep_skipspace(&ptr, "\t "); + if (!modname || !ptr) + grammar(cmd, filename, linenum); + else { + ptr += strspn(ptr, "\t "); + *options = add_options(underscores(modname), + ptr, *options); + } + } else if (strcmp(cmd, "install") == 0) { + modname = strsep_skipspace(&ptr, "\t "); + if (!modname || !ptr) + grammar(cmd, filename, linenum); + else if (!removing) { + ptr += strspn(ptr, "\t "); + *commands = add_command(underscores(modname), + ptr, *commands); + } + } else if (strcmp(cmd, "blacklist") == 0) { + modname = strsep_skipspace(&ptr, "\t "); + if (!modname) + grammar(cmd, filename, linenum); + else if (!removing) { + *blacklist = add_blacklist(underscores(modname), + *blacklist); + } + } else if (strcmp(cmd, "remove") == 0) { + modname = strsep_skipspace(&ptr, "\t "); + if (!modname || !ptr) + grammar(cmd, filename, linenum); + else if (removing) { + ptr += strspn(ptr, "\t "); + *commands = add_command(underscores(modname), + ptr, *commands); + } + } else if (strcmp(cmd, "config") == 0) { + char *tmp = strsep_skipspace(&ptr, "\t "); + if (strcmp(tmp, "binary_indexes") == 0) { + tmp = strsep_skipspace(&ptr, "\t "); + if (strcmp(tmp, "yes") == 0) + use_binary_indexes = 1; + if (strcmp(tmp, "no") == 0) + use_binary_indexes = 0; + } + } else + grammar(cmd, filename, linenum); + + free(line); + } + fclose(cfile); + return 1; +} + +/* Read binary index file containing aliases only */ +/* fallback to legacy aliases file as necessary */ +int read_config_file_bin(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist) +{ + struct index_value *realname; + char *binfile; + FILE *cfile; + + asprintf(&binfile, "%s.bin", filename); + cfile = fopen(binfile, "r"); + if (!cfile) { + free(binfile); + + return read_config_file(filename, name, dump_only, removing, + options, commands, aliases, blacklist); + } + + if (dump_only) { + index_dump(cfile, stdout, "alias "); + free(binfile); + fclose(cfile); + return 1; + } + + realname = index_searchwild(cfile, name); + while(realname) { + struct index_value *next = realname->next; + *aliases = add_alias(realname->value, *aliases); + + free(realname); + realname = next; + } + + free(binfile); + fclose(cfile); + return 1; +} + +/* Simple format, ignore lines starting with #, one command per line. + Returns true or false. */ +int read_config(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist) +{ + DIR *dir; + int ret = 0; + + /* Reiser4 has file/directory duality: treat it as both. */ + dir = opendir(filename); + if (dir) { + struct dirent *i; + while ((i = readdir(dir)) != NULL) { + if (!streq(i->d_name,".") && !streq(i->d_name,"..")) { + char sub[strlen(filename) + 1 + + strlen(i->d_name) + 1]; + + sprintf(sub, "%s/%s", filename, i->d_name); + if (!read_config(sub, name, + dump_only, removing, options, + commands, aliases, blacklist)) + warn("Failed to open" + " config file %s: %s\n", + sub, strerror(errno)); + } + } + closedir(dir); + ret = 1; + } + + if (read_config_file(filename, name, dump_only, removing, + options, commands, aliases, blacklist)) + ret = 1; + + return ret; +} + +static const char *default_configs[] = +{ + "/etc/modprobe.conf", + "/etc/modprobe.d", +}; + +void read_toplevel_config(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist) +{ + unsigned int i; + + if (filename) { + if (!read_config(filename, name, dump_only, removing, + options, commands, aliases, blacklist)) + fatal("Failed to open config file %s: %s\n", + filename, strerror(errno)); + return; + } + + /* Try defaults. */ + for (i = 0; i < ARRAY_SIZE(default_configs); i++) { + read_config(default_configs[i], name, dump_only, removing, + options, commands, aliases, blacklist); + } +} Index: module-init-tools-3.5/modprobe.c =================================================================== --- module-init-tools-3.5.orig/modprobe.c +++ module-init-tools-3.5/modprobe.c @@ -42,13 +42,14 @@ #define streq(a,b) (strcmp((a),(b)) == 0) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#include "modprobe.h" #include "zlibsupport.h" #include "logging.h" #include "index.h" #include "list.h" #include "backwards_compat.c" -int use_binary_indexes = 1; /* default to enabled. */ +extern int use_binary_indexes; extern long init_module(void *, unsigned long, const char *); extern long delete_module(const char *, unsigned int); @@ -59,18 +60,8 @@ struct module { char filename[0]; }; -#ifndef MODULE_DIR -#define MODULE_DIR "/lib/modules" -#endif - typedef void (*errfn_t)(const char *fmt, ...); -static void grammar(const char *cmd, const char *filename, unsigned int line) -{ - warn("%s line %u: ignoring bad line starting with '%s'\n", - filename, line, cmd); -} - static void print_usage(const char *progname) { fprintf(stderr, @@ -81,51 +72,6 @@ static void print_usage(const char *prog exit(1); } -static char *getline_wrapped(FILE *file, unsigned int *linenum) -{ - int size = 256; - int i = 0; - char *buf = NOFAIL(malloc(size)); - for(;;) { - int ch = getc_unlocked(file); - - switch(ch) { - case EOF: - if (i == 0) { - free(buf); - return NULL; - } - /* else fall through */ - - case '\n': - if (linenum) - (*linenum)++; - if (i == size) - buf = NOFAIL(realloc(buf, size + 1)); - buf[i] = '\0'; - return buf; - - case '\\': - ch = getc_unlocked(file); - - if (ch == '\n') { - if (linenum) - (*linenum)++; - continue; - } - /* else fall through */ - - default: - buf[i++] = ch; - - if (i == size) { - size *= 2; - buf = NOFAIL(realloc(buf, size)); - } - } - } -} - static struct module *find_module(const char *filename, struct list_head *list) { struct module *i; @@ -603,117 +549,6 @@ static void clear_magic(struct module *m } } -struct module_options -{ - struct module_options *next; - char *modulename; - char *options; -}; - -struct module_command -{ - struct module_command *next; - char *modulename; - char *command; -}; - -struct module_alias -{ - struct module_alias *next; - char *module; -}; - -struct module_blacklist -{ - struct module_blacklist *next; - char *modulename; -}; - -/* Link in a new option line from the config file. */ -static struct module_options * -add_options(const char *modname, - const char *option, - struct module_options *options) -{ - struct module_options *new; - char *tab; - - new = NOFAIL(malloc(sizeof(*new))); - new->modulename = NOFAIL(strdup(modname)); - new->options = NOFAIL(strdup(option)); - /* We can handle tabs, kernel can't. */ - for (tab = strchr(new->options, '\t'); tab; tab = strchr(tab, '\t')) - *tab = ' '; - new->next = options; - return new; -} - -/* Link in a new install line from the config file. */ -static struct module_command * -add_command(const char *modname, - const char *command, - struct module_command *commands) -{ - struct module_command *new; - - new = NOFAIL(malloc(sizeof(*new))); - new->modulename = NOFAIL(strdup(modname)); - new->command = NOFAIL(strdup(command)); - new->next = commands; - return new; -} - -/* Link in a new alias line from the config file. */ -static struct module_alias * -add_alias(const char *modname, struct module_alias *aliases) -{ - struct module_alias *new; - - new = NOFAIL(malloc(sizeof(*new))); - new->module = NOFAIL(strdup(modname)); - new->next = aliases; - return new; -} - -/* Link in a new blacklist line from the config file. */ -static struct module_blacklist * -add_blacklist(const char *modname, struct module_blacklist *blacklist) -{ - struct module_blacklist *new; - - new = NOFAIL(malloc(sizeof(*new))); - new->modulename = NOFAIL(strdup(modname)); - new->next = blacklist; - return new; -} - -/* Find blacklist commands if any. */ -static int -find_blacklist(const char *modname, const struct module_blacklist *blacklist) -{ - while (blacklist) { - if (strcmp(blacklist->modulename, modname) == 0) - return 1; - blacklist = blacklist->next; - } - return 0; -} - -/* return a new alias list, with backlisted elems filtered out */ -static struct module_alias * -apply_blacklist(const struct module_alias *aliases, - const struct module_blacklist *blacklist) -{ - struct module_alias *result = NULL; - while (aliases) { - char *modname = aliases->module; - if (!find_blacklist(modname, blacklist)) - result = add_alias(modname, result); - aliases = aliases->next; - } - return result; -} - /* Find install commands if any. */ static const char *find_command(const char *modname, const struct module_command *commands) @@ -1049,31 +884,6 @@ static int type_matches(const char *path return ret; } -/* Careful! Don't munge - in [ ] as per Debian Bug#350915 */ -static char *underscores(char *string) -{ - if (string) { - unsigned int i; - int inbracket = 0; - for (i = 0; string[i]; i++) { - switch (string[i]) { - case '[': - inbracket++; - break; - case ']': - inbracket--; - break; - case '-': - if (!inbracket) - string[i] = '_'; - } - } - if (inbracket) - warn("Unmatched bracket in %s\n", string); - } - return string; -} - static int do_wildcard(const char *dirname, const char *type, const char *wildcard) @@ -1117,259 +927,6 @@ static int do_wildcard(const char *dirna return 0; } -static char *strsep_skipspace(char **string, char *delim) -{ - if (!*string) - return NULL; - *string += strspn(*string, delim); - return strsep(string, delim); -} - -/* Recursion */ -static int read_config(const char *filename, - const char *name, - int dump_only, - int removing, - struct module_options **options, - struct module_command **commands, - struct module_alias **alias, - struct module_blacklist **blacklist); - -/* FIXME: Maybe should be extended to "alias a b [and|or c]...". --RR */ -static int read_config_file(const char *filename, - const char *name, - int dump_only, - int removing, - struct module_options **options, - struct module_command **commands, - struct module_alias **aliases, - struct module_blacklist **blacklist) -{ - char *line; - unsigned int linenum = 0; - FILE *cfile; - - cfile = fopen(filename, "r"); - if (!cfile) - return 0; - - while ((line = getline_wrapped(cfile, &linenum)) != NULL) { - char *ptr = line; - char *cmd, *modname; - - if (dump_only) - printf("%s\n", line); - - cmd = strsep_skipspace(&ptr, "\t "); - if (cmd == NULL || cmd[0] == '#' || cmd[0] == '\0') { - free(line); - continue; - } - - if (strcmp(cmd, "alias") == 0) { - char *wildcard - = underscores(strsep_skipspace(&ptr, "\t ")); - char *realname - = underscores(strsep_skipspace(&ptr, "\t ")); - - if (!wildcard || !realname) - grammar(cmd, filename, linenum); - else if (fnmatch(wildcard,name,0) == 0) - *aliases = add_alias(realname, *aliases); - } else if (strcmp(cmd, "include") == 0) { - struct module_alias *newalias = NULL; - char *newfilename; - - newfilename = strsep_skipspace(&ptr, "\t "); - if (!newfilename) - grammar(cmd, filename, linenum); - else { - if (!read_config(newfilename, name, - dump_only, removing, - options, commands, &newalias, - blacklist)) - warn("Failed to open included" - " config file %s: %s\n", - newfilename, strerror(errno)); - - /* Files included override aliases, - etc that was already set ... */ - if (newalias) - *aliases = newalias; - } - } else if (strcmp(cmd, "options") == 0) { - modname = strsep_skipspace(&ptr, "\t "); - if (!modname || !ptr) - grammar(cmd, filename, linenum); - else { - ptr += strspn(ptr, "\t "); - *options = add_options(underscores(modname), - ptr, *options); - } - } else if (strcmp(cmd, "install") == 0) { - modname = strsep_skipspace(&ptr, "\t "); - if (!modname || !ptr) - grammar(cmd, filename, linenum); - else if (!removing) { - ptr += strspn(ptr, "\t "); - *commands = add_command(underscores(modname), - ptr, *commands); - } - } else if (strcmp(cmd, "blacklist") == 0) { - modname = strsep_skipspace(&ptr, "\t "); - if (!modname) - grammar(cmd, filename, linenum); - else if (!removing) { - *blacklist = add_blacklist(underscores(modname), - *blacklist); - } - } else if (strcmp(cmd, "remove") == 0) { - modname = strsep_skipspace(&ptr, "\t "); - if (!modname || !ptr) - grammar(cmd, filename, linenum); - else if (removing) { - ptr += strspn(ptr, "\t "); - *commands = add_command(underscores(modname), - ptr, *commands); - } - } else if (strcmp(cmd, "config") == 0) { - char *tmp = strsep_skipspace(&ptr, "\t "); - if (strcmp(tmp, "binary_indexes") == 0) { - tmp = strsep_skipspace(&ptr, "\t "); - if (strcmp(tmp, "yes") == 0) - use_binary_indexes = 1; - if (strcmp(tmp, "no") == 0) - use_binary_indexes = 0; - } - } else - grammar(cmd, filename, linenum); - - free(line); - } - fclose(cfile); - return 1; -} - -/* Simple format, ignore lines starting with #, one command per line. - Returns true or false. */ -static int read_config(const char *filename, - const char *name, - int dump_only, - int removing, - struct module_options **options, - struct module_command **commands, - struct module_alias **aliases, - struct module_blacklist **blacklist) -{ - DIR *dir; - int ret = 0; - - /* Reiser4 has file/directory duality: treat it as both. */ - dir = opendir(filename); - if (dir) { - struct dirent *i; - while ((i = readdir(dir)) != NULL) { - if (!streq(i->d_name,".") && !streq(i->d_name,"..")) { - char sub[strlen(filename) + 1 - + strlen(i->d_name) + 1]; - - sprintf(sub, "%s/%s", filename, i->d_name); - if (!read_config(sub, name, - dump_only, removing, options, - commands, aliases, blacklist)) - warn("Failed to open" - " config file %s: %s\n", - sub, strerror(errno)); - } - } - closedir(dir); - ret = 1; - } - - if (read_config_file(filename, name, dump_only, removing, - options, commands, aliases, blacklist)) - ret = 1; - - return ret; -} - -/* Read binary index file containing aliases only */ -/* fallback to legacy aliases file as necessary */ -static int read_config_file_bin(const char *filename, - const char *name, - int dump_only, - int removing, - struct module_options **options, - struct module_command **commands, - struct module_alias **aliases, - struct module_blacklist **blacklist) -{ - struct index_value *realname; - char *binfile; - FILE *cfile; - - asprintf(&binfile, "%s.bin", filename); - cfile = fopen(binfile, "r"); - if (!cfile) { - free(binfile); - - return read_config_file(filename, name, dump_only, removing, - options, commands, aliases, blacklist); - } - - if (dump_only) { - index_dump(cfile, stdout, "alias "); - free(binfile); - fclose(cfile); - return 1; - } - - realname = index_searchwild(cfile, name); - while(realname) { - struct index_value *next = realname->next; - *aliases = add_alias(realname->value, *aliases); - - free(realname); - realname = next; - } - - free(binfile); - fclose(cfile); - return 1; -} - -static const char *default_configs[] = -{ - "/etc/modprobe.conf", - "/etc/modprobe.d", -}; - -static void read_toplevel_config(const char *filename, - const char *name, - int dump_only, - int removing, - struct module_options **options, - struct module_command **commands, - struct module_alias **aliases, - struct module_blacklist **blacklist) -{ - unsigned int i; - - if (filename) { - if (!read_config(filename, name, dump_only, removing, - options, commands, aliases, blacklist)) - fatal("Failed to open config file %s: %s\n", - filename, strerror(errno)); - return; - } - - /* Try defaults. */ - for (i = 0; i < ARRAY_SIZE(default_configs); i++) { - read_config(default_configs[i], name, dump_only, removing, - options, commands, aliases, blacklist); - } -} - /* Read possible module arguments from the kernel command line. */ static int read_kcmdline(int dump_only, struct module_options **options) { Index: module-init-tools-3.5/modprobe.h =================================================================== --- /dev/null +++ module-init-tools-3.5/modprobe.h @@ -0,0 +1,86 @@ +#ifndef __MODPROBE_H +#define __MODPROBE_H + +#ifndef MODULE_DIR +#define MODULE_DIR "/lib/modules" +#endif + +struct module_options +{ + struct module_options *next; + char *modulename; + char *options; +}; + +struct module_command +{ + struct module_command *next; + char *modulename; + char *command; +}; + +struct module_alias +{ + struct module_alias *next; + char *module; +}; + +struct module_blacklist +{ + struct module_blacklist *next; + char *modulename; +}; + +struct module_alias * +apply_blacklist(const struct module_alias *aliases, + const struct module_blacklist *blacklist); + +int read_config(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist); + +void read_toplevel_config(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist); + +int read_config_file(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist); + +int read_config_file_bin(const char *filename, + const char *name, + int dump_only, + int removing, + struct module_options **options, + struct module_command **commands, + struct module_alias **aliases, + struct module_blacklist **blacklist); +struct module_options * +add_options(const char *modname, + const char *option, + struct module_options *options); + +char *strsep_skipspace(char **string, char *delim); +char *underscores(char *string); +struct module_alias * +add_alias(const char *modname, struct module_alias *aliases); +char *getline_wrapped(FILE *file, unsigned int *linenum); +int +find_blacklist(const char *modname, const struct module_blacklist *blacklist); + +#endif /* __MODPROBE_H */