kmodloader: allow /etc/modules.d/ files to pass options
authorJohn Crispin <blogic@openwrt.org>
Wed, 22 Jan 2014 17:57:09 +0000 (17:57 +0000)
committerJohn Crispin <blogic@openwrt.org>
Wed, 22 Jan 2014 20:08:24 +0000 (20:08 +0000)
Signed-off-by: John Crispin <blogic@openwrt.org>
kmodloader.c

index f0985eeb5c9240b92aebe86cec553ed964deffdd..db4574e27d25005228baf740cc81db53c9351945 100644 (file)
@@ -55,6 +55,7 @@ struct module {
 
        char *name;
        char *depends;
+       char *opts;
 
        int size;
        int usage;
@@ -182,6 +183,7 @@ alloc_module(const char *name, const char *depends, int size)
                return NULL;
 
        m->avl.key = m->name = strcpy(_name, name);
+       m->opts = 0;
 
        if (depends) {
                m->depends = strcpy(_dep, depends);
@@ -467,7 +469,7 @@ static int load_modprobe(void)
                todo = 0;
                avl_for_each_element(&modules, m, avl) {
                        if ((m->state == PROBE) && (!deps_available(m, 0))) {
-                               if (!insert_module(get_module_path(m->name), "")) {
+                               if (!insert_module(get_module_path(m->name), (m->opts) ? (m->opts) : (""))) {
                                        m->state = LOADED;
                                        m->error = 0;
                                        loaded++;
@@ -726,6 +728,8 @@ static int main_loader(int argc, char **argv)
                        if (!m || (m->state == LOADED))
                                continue;
 
+                       if (opts)
+                               m->opts = strdup(opts);
                        m->state = PROBE;
                        if (basename(gl.gl_pathv[j])[0] - '0' <= 9)
                                load_modprobe();